Exemplo n.º 1
0
 function get_itemperms($fid, $sitewide = FALSE)
 {
     global $user;
     $perms = array('groups' => array(), 'roles' => array());
     $cid = db_query("SELECT cid FROM {filedepot_files} WHERE fid=:fid", array(':fid' => $fid))->fetchField();
     if ($cid > 0) {
         if (module_exists('og') and module_exists('og_access')) {
             $groups = filedepot_og_get_user_groups();
             if (!empty($groups)) {
                 $groupids = implode(',', array_values($groups));
                 if (!empty($groupids) or $sitewide === TRUE) {
                     $sql = "SELECT permid from {filedepot_access} WHERE catid=:cid AND permtype='group' AND view = 1 AND permid > 0 ";
                     $sql .= "AND permid in ({$groupids}) ";
                     $query = db_query($sql, array(':cid' => $cid));
                     if ($query) {
                         while ($A = $query->fetchAssoc()) {
                             $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=:cid AND permtype='role' AND view = 1 AND permid > 0 ";
             if (!$sitewide) {
                 $sql .= "AND permid in ({$roleids}) ";
             }
             $query = db_query($sql, array(':cid' => $cid));
             if ($query) {
                 while ($A = $query->fetchAssoc()) {
                     $perms['roles'][] = $A['permid'];
                 }
             }
         }
     }
     return $perms;
 }
Exemplo n.º 2
0
function filedepot_getGroupOptions()
{
    global $user;
    $retval = '';
    $groups = filedepot_og_get_user_groups();
    foreach ($groups as $grpid) {
        $entity = filedepot_og_get_group_entity($grpid);
        $retval .= '<option value="' . $grpid . '">' . $entity->title . '</option>';
    }
    return $retval;
}