Link to home
Start Free TrialLog in
Avatar of Bruce Gust
Bruce GustFlag for United States of America

asked on

What is setUserData?

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?
Avatar of Bruce Gust
Bruce Gust
Flag of United States of America image

ASKER

Not sure if it makes any difference, but I'm working in Code Igniter.
SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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