function ad_owners_permission in Advertisement 6.3
Same name and namespace in other branches
- 6.2 owners/ad_owners.module \ad_owners_permission()
- 7 owners/ad_owners.module \ad_owners_permission()
Determine whether the user has a given privilege.
1 call to ad_owners_permission()
- ad_permission in ./
ad.module - Determine whether the user has a given privilege.
1 string reference to 'ad_owners_permission'
- ad_permission in ./
ad.module - Determine whether the user has a given privilege.
File
- owners/
ad_owners.module, line 559 - Enhances the ad module to support ad owners.
Code
function ad_owners_permission($aid, $string, $account) {
static $permissions = array();
if (!isset($permissions[$aid]) || !isset($permissions[$aid][$account->uid])) {
$oid = db_result(db_query("SELECT oid FROM {ad_owners} WHERE aid = %d and uid = %d", $aid, $account->uid));
if ($oid) {
$permissions[$aid][$account->uid] = explode('|,|', db_result(db_query("SELECT permissions FROM {ad_permissions} WHERE oid = %d", $oid)));
}
else {
$account = user_load($account->uid);
if (user_access('grant default per ad type permissions')) {
$perms = ad_owners_default_permissions();
$permissions[$aid][$account->uid] = $perms['default'];
}
else {
$permissions[$aid][$account->uid] = array();
}
}
}
return in_array("{$string}", $permissions[$aid][$account->uid]);
}