CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Single User; Multiple Groups

Print topic Send  topic

Author Message
OIG_user
Posted: 06/24/2004, 12:10 PM

Is there a way to assign multiple groups to one person. For example I want the person to be admin in section 1, but just a user in section 2.

I have the basic user table with user | pass | group

Thanks
peterr


Posts: 5971
Posted: 06/24/2004, 2:08 PM

You can assign multiple user groups to a page.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
OIG_user
Posted: 06/29/2004, 7:04 AM

I understand that you can assign multiple groups to a page but that is not what I am after.

I need one user to be assigned to multiple groups.

For example, the user is an administrator in the IT section but only a user in the HR section. I dont want all HR users to have access to the IT admin page, and vice versa. I also dont want the user to have a different password for each section. I am trying to avoid creating 1000 different groups.

peterr


Posts: 5971
Posted: 06/29/2004, 3:02 PM

In this case You could implement role-based security. It should be fairly simple to implement your own security in the page's "After Initialize" event. I posted an ASP example in my last post at http://forums.codecharge.com/posts.php?post_id=43087. It can be done about the same way in PHP.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Don
Posted: 07/18/2004, 1:45 AM

"OIG_user" <OIG_user@forum.codecharge> wrote in message
news:540db2726cb851@news.codecharge.com...
> Is there a way to assign multiple groups to one person. For example I
want the
> person to be admin in section 1, but just a user in section 2.
>
> I have the basic user table with user | pass | group
>
> Thanks

Hi There OIG_user,

What I did was modify the group handling functions in common.php.

Below is an example of my mods. You will have to modify for your own set up
but this should be a useful guide.

Cheers,
Don Anderson


//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=" . CCGetPasswordHash($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



Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.