jmkreyche
|
Posted: 12/06/2003, 10:12 AM |
|
I have created security groups for various admin roles. Since these roles don't lend themselves to a hierarchical structure, I need to assign multiple groups to a single user. I'd like to stay away from changing the common.php file. Is there another way to accomplish this?
Jessica
|
|
|
RonB
|
Posted: 12/07/2003, 8:22 AM |
|
I don't think so. We are looking in to this as well but I think it would mean re-writing the whole security class. Now it just checks if the level field in the login table is the same(or higher) as the authority setting for a given page. The query that does this would have to be rewritten so it would do a: where level in(1,2,3 etc..) check.
There is something of a write around for this in the sense that you can assign multiple access levels to one page. You can set page acces to level 1, 8, 10 and 12 if you wanted to. So instead of assigning multiple gtoups to a single user you can set multiple groups to a single page.
Ron
|
|
|
Don Anderson
|
Posted: 12/08/2003, 2:48 PM |
|
Dear Jessica,
I had a similar issue. Here are the changes I made to common.php. You can probably use the same code, after of course you alter the SQL queries.
Regards,
Don
//CCUserInGroups @0-9F7F30EA
function CCUserInGroups($GroupID, $GroupsAccess)
{
$Result = "";
if(strlen($GroupsAccess))
{
if(strlen($GroupID)) $Groups = explode(",",$GroupID);
{
while(list($key,$Group) = each($Groups)){
$Result = (strpos(";" . $GroupsAccess . ";", ";" . $Group . ";") !== false);
if ($Result != "") Break;
}
}
}
else
{
$Result = true;
}
return $Result;
}
//End CCUserInGroups
//CCLoginUser @0-2D4D39C3
//This function is being edited to enable Group data to come from the dz_grp_ref lookup table
/* If MySQL version 4.1 was available, then I'd use the following SELECT:
$SQL = "SELECT dz_user.UID AS UID, Group_ConCat(GID) AS Group FROM dz_user
LEFT JOIN dz_grp_ref ON dz_user.UID = dz_grp_ref.UID
WHERE Username=" . $db->ToSQL($login, ccsText)
. " AND Password=" . $db->ToSQL($password, ccsText)
. " GROUPBY GID";
However, without the GROUP_CONCAT function we have to do it is two steps.
*/
function CCLoginUser($login, $password)
{
$db = new clsDBlinksdb();
$SQL = "SELECT UID FROM dz_user WHERE Username=" . $db->ToSQL($login, ccsText) . " AND Password=" . $db->ToSQL($password, ccsText);
$db->query($SQL);
$Result = $db->next_record();
if($Result)
{
CCSetSession("UserID", $db->f("UID"));
CCSetSession("UserLogin", $login);
$Groups = "";
$SQL = "SELECT DISTINCT(GID) FROM dz_grp_ref WHERE UID=" . $db->f("UID") . " ORDER BY GID";
$db->query($SQL);
if ($db->next_record())
{
do
{
$Groups .= $db->f("GID") .",";
} while ($db->next_record());
$Groups = substr($Groups, 0, -1);
}
CCSetSession("GroupID", $Groups);
}
$db->close();
return $Result;
}
//End CCLoginUser
PS. I also added another function for those times when you want to call a php global in the one line available in many of the CCS dialogs.
//CCGetGlobal
function CCGetGlobal($varname)
{
global $$varname;
return $$varname;
}
//End CCGetGlobal
|
|
|
|