function nexcloud::get_itemperms in filedepot 6
Same name and namespace in other branches
- 7 nexcloud.class.php \nexcloud::get_itemperms()
4 calls to nexcloud::get_itemperms()
File
- ./
nexcloud.class.php, line 59 - nexcloud.class.php Tag Cloud class for the fildepot module
Class
- nexcloud
- @file nexcloud.class.php Tag Cloud class for the fildepot module
Code
function get_itemperms($fid, $sitewide = FALSE) {
global $user;
$perms = array();
$cid = db_result(db_query("SELECT cid FROM {filedepot_files} WHERE fid=%d", $fid));
if ($cid > 0) {
if ($user->og_groups != NULL) {
$groupids = implode(',', array_keys($user->og_groups));
if (!empty($groupids) or $sitewide === TRUE) {
$sql = "SELECT permid from {filedepot_access} WHERE catid=%d AND permtype='group' AND view = 1 AND permid > 0 ";
$sql .= "AND permid in ({$groupids}) ";
$query = db_query($sql, $cid);
if ($query) {
while ($A = db_fetch_array($query)) {
$perms['groups'][] = $A['permid'];
}
}
}
}
// Determine all the roles the active user has and test for view permission.
$roleids = implode(',', array_keys($user->roles));
if (!empty($roleids) or $sitewide === TRUE) {
$sql = "SELECT permid from {filedepot_access} WHERE catid=%d AND permtype='role' AND view = 1 AND permid > 0 ";
if (!$sitewide) {
$sql .= "AND permid in ({$roleids}) ";
}
$query = db_query($sql, $cid);
if ($query) {
while ($A = db_fetch_array($query)) {
$perms['roles'][] = $A['permid'];
}
}
}
}
return $perms;
}