Cleopatra
Posts: 73
|
| Posted: 06/10/2010, 9:35 AM |
|
Hey guys,
How can you retrieve values in a grid based on the logged in user, without using the user_id.
My users have another value company_id, so if a user is from 1 company he will be able to view all the records created by him or any other employee of his company.
What function should I use to put for the where clause parameters in order to retrieve the company_id?
_________________
php newbie |
 |
 |
mamboBROWN
Posts: 1713
|
| Posted: 06/10/2010, 9:45 PM |
|
Cleopatra,
You could have the system obtain the user's company_id when they first log into the system and save it as a session variable. This way you can use it throughout the session of the user.
|
 |
 |
magus
Posts: 98
|
| Posted: 06/11/2010, 9:33 PM |
|
Cleopatra,
To do what mambo is suggesting you may want to modify function
CCLoginUser()
in common.php
The way I modify common.php functions is to take a copy of the function and either put it at the end of common.php or in an included file.
Then I comment out the orginal unaltered function like so:.
/*
//CCLoginUser @0-779D489A
function CCLoginUser($login, $password)
{
CCLogoutUser();
$db = new clsDBvtiger();
$SQL = "SELECT id, user_hash, user_password FROM vtiger_users WHERE user_name=" . $db->ToSQL($login, ccsText) . " AND user_password=" . $db->ToSQL($password, ccsText);
$db->query($SQL);
$Result = $db->next_record();
if ($Result) {
CCSetSession("UserID", $db->f("id"));
CCSetSession("UserLogin", $login);
CCSetSession("GroupID", $db->f("user_hash"));
}
return $Result;
}
//End CCLoginUser
*/
This way Codecharge see the function as unaltered and will perform any updates to it it without complaining of breaking anything.
Regards,
Don A
|
 |
 |
Cleopatra
Posts: 73
|
| Posted: 06/12/2010, 8:39 PM |
|
Thank you Mambo and Don,
I'll try ot out
_________________
php newbie |
 |
 |
|