TheAdminMarket
11-01-2014, 08:16 AM
Hello,
I've seen that with the code below I can check if the active user has permissions for a specific action:
if ($permissions["my_plugin"] & $vbulletin->bf_ugp["my_plugin"]["post"])
{
echo "He can post";
} else {
echo "No permissions to post";
}
But as I said before this works for the current active user. What if I want to check if the user with userid=77 has such permission?
Checking a relevant code I found how to get the online status of a specific user:
$userid = 77;
$userinfo = verify_id('user', $userid, 1, 1);
$online_status = fetch_online_status($userinfo, true);
So, is there any similar way to get as true/false if a specific user has a specific permission?
EDITED ----------------
Currently I'm using the follow way to do it:
1.- I'm setting a vBulltin option to hold the usegroupids that have this permission: eg 1,4,5
2.- With the help of a function I'm getting the result
function getPostPermission($userid)
{
global $db, $vbulletin, $vboptions, $permission;
if (!$userid || $userid <= 0)
{
$permission = 0;
} else {
$sql_user = $vbulletin->db->query_first("SELECT * FROM ".TABLE_PREFIX."user WHERE userid=$userid LIMIT 1");
$all_ids = array();
$all_ids = explode(',', $sql_user["membergroupids"]);
array_push($all_ids, $sql_user["usergroupid"]);
$allowed = array();
$allowed = explode(',', $vbulletin->options["post_usergroups"]);
$has_common = array_intersect($all_ids, $allowed);
if (count($has_common) == 0)
{
$permission = 0;
} else {
$permission = 1;
}
}
return $permission;
}
Thank you
I've seen that with the code below I can check if the active user has permissions for a specific action:
if ($permissions["my_plugin"] & $vbulletin->bf_ugp["my_plugin"]["post"])
{
echo "He can post";
} else {
echo "No permissions to post";
}
But as I said before this works for the current active user. What if I want to check if the user with userid=77 has such permission?
Checking a relevant code I found how to get the online status of a specific user:
$userid = 77;
$userinfo = verify_id('user', $userid, 1, 1);
$online_status = fetch_online_status($userinfo, true);
So, is there any similar way to get as true/false if a specific user has a specific permission?
EDITED ----------------
Currently I'm using the follow way to do it:
1.- I'm setting a vBulltin option to hold the usegroupids that have this permission: eg 1,4,5
2.- With the help of a function I'm getting the result
function getPostPermission($userid)
{
global $db, $vbulletin, $vboptions, $permission;
if (!$userid || $userid <= 0)
{
$permission = 0;
} else {
$sql_user = $vbulletin->db->query_first("SELECT * FROM ".TABLE_PREFIX."user WHERE userid=$userid LIMIT 1");
$all_ids = array();
$all_ids = explode(',', $sql_user["membergroupids"]);
array_push($all_ids, $sql_user["usergroupid"]);
$allowed = array();
$allowed = explode(',', $vbulletin->options["post_usergroups"]);
$has_common = array_intersect($all_ids, $allowed);
if (count($has_common) == 0)
{
$permission = 0;
} else {
$permission = 1;
}
}
return $permission;
}
Thank you