You are here

function filedepot::checkPermission in filedepot 7

Same name and namespace in other branches
  1. 6 filedepot.class.php \filedepot::checkPermission()
8 calls to filedepot::checkPermission()
filedepot::approveFileSubmission in ./filedepot.class.php
filedepot::createFolder in ./filedepot.class.php
Call createFolderNode to create the folder which will trigger this method through filedepot_insert @global type $user
filedepot::deleteFile in ./filedepot.class.php
filedepot::deleteFolder in ./filedepot.class.php
filedepot::getAllowableCategories in ./filedepot.class.php
Return list of repository categories user has permission to access to be used in SQL statements

... See full list

File

./filedepot.class.php, line 344
filedepot.class.php Main class for the Filedepot module

Class

filedepot
@file filedepot.class.php Main class for the Filedepot module

Code

function checkPermission($cid, $rights, $uid = 0, $adminOverRide = TRUE) {
  global $user;
  if (intval($cid) < 1) {
    return FALSE;
  }

  // If user is an admin - they should have access to all rights on all categories
  if ($adminOverRide and $uid == 0 and user_access('administer filedepot', $user)) {
    return TRUE;
  }
  else {
    if ($uid == 0 and !empty($user->uid)) {
      $uid = $user->uid;
    }

    // This modification allows the caching of permission objects to save database queries
    $obj = $this
      ->getPermissionObject($cid, $uid);
    if (is_array($rights)) {
      foreach ($rights as $key) {
        if ($obj
          ->hasPermission($key)) {
          return TRUE;
        }
      }
    }
    else {
      return $obj
        ->hasPermission($rights);
    }
  }
  return FALSE;
}