Solved

What is setUserData?

Posted on 2016-08-02
4
42 Views
Last Modified: 2016-08-02
Here's the function:

protected function generateSearchSql(array $fields,array $searchterms, array $select = null, $where = null, $orderby = 'hits desc', $strict = true){
	  
	$ud = setUserData();
	$the_client_code=$ud['filter']['clientcode'];
    
    if($select === null){
        $select = $fields;
    }

    $selectsql = pfsql::getSelect($select);

    $sql = "
    select a.* from
    (
        $selectsql

        , (";

    $firstterm = true;
    foreach($searchterms as $term){
        if($firstterm) $firstterm = false;
        else if($strict) $sql .= ") * (";
        else $sql .= ") + (";


        $first = true;
        //Search each field for each term
        foreach($fields as $field) {
            //Prepend plus
            if($first) $first = false;
            else $sql .= " + ";

            $sql .= " (case when $field like ('%$term%') then 1 else 0 end) ";

        }
    }

    if($where){
        $wheresql = $where;
    }

    $sql .= ") as hits from 
        account (nolock)
            join patient (nolock) on patient.accountid = account.accountid
            join practice (nolock) on account.practiceid = practice.PracticeID
            join client (nolock) on practice.clientid = client.clientid
			LEFT JOIN (SELECT TOP 1 ChargeGroup.AccountID, ChargeGroup.encountercode FROM ChargeGroup (nolock) 
			where 
			ChargeGroup.encountercode='$term'
			AND
			ChargeGroup.clientcode=$the_client_code) b 
			ON Account.AccountID=b.AccountID
        $wheresql
        ) a
    where hits > 0
    order by ". ($orderby ? "$orderby" :" hits desc "). "
    ";
	//echo $sql;
    return $sql;

  }

Open in new window


At the very top is setUserData. What is that? There's no function called that anywhere in the code. I'm missing something...

What is it?
0
Comment
Question by:brucegust
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Author Comment

by:brucegust
ID: 41739180
Not sure if it makes any difference, but I'm working in Code Igniter.
0
 
LVL 58

Assisted Solution

by:Julian Hansen
Julian Hansen earned 250 total points
ID: 41739195
That is a custom function it must be defined somewhere in the code base.
0
 
LVL 31

Accepted Solution

by:
Marco Gasi earned 250 total points
ID: 41739199
In CodeIgniter, userdata() ia method to access values stored in the $_SESSION array, but it doesn't exist a method setUserData(). So I think setUserData() is a custom function created by the author of the code to manage some common session related actions. You should go through included scripts in current page to find it.
0
 

Author Comment

by:brucegust
ID: 41739205
Found it!

It was in the helpers directory.

Thanks!

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/***********************
setUserData returns the appropriate userdata object based on whether the
current logged in user is spoofing another user or not.

Usage
$userdata = setUserData();


@PMT


**********************/
if ( ! function_exists('setUserData'))
{
    function &setUserData(){    
     if(isset($_SESSION['userdata'])){
      if(isset($_SESSION['spoof']['userdata'])){
        return $_SESSION['spoof']['userdata'];
      }else{
        return $_SESSION['userdata'];
      }
    }else{
      $_SESSION['userdata'] = false;
      return $_SESSION['userdata'];
    }
    
    
    }
    
    }

Open in new window

0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question