コード例 #1
0
 /**
  * Checks witht the config service if the portal is in read only mode and if 
  * it is throws an exception unless the user is a GOCDB admin
  * 
  * @param \User $user user
  * @throws \Exception
  */
 protected function checkPortalIsNotReadOnlyOrUserIsAdmin(\User $user = NULL)
 {
     require_once __DIR__ . '/Config.php';
     //this block is required to deal with unregistered users (where $user is null)
     $userIsAdmin = false;
     if (!is_null($user)) {
         if ($user->isAdmin()) {
             //sub query required becauser ->isAdmin can't be called on null
             $userIsAdmin = true;
         }
     }
     $configServ = new \org\gocdb\services\Config();
     if ($configServ->IsPortalReadOnly() and !$userIsAdmin) {
         throw new \Exception("The portal is currently in read only mode, so this action is not permitted");
     }
 }
コード例 #2
0
ファイル: NGI.php プロジェクト: Tom-Byrne/gocdb
 private function checkNumberOfScopes($scopeIds)
 {
     require_once __DIR__ . '/Config.php';
     $configService = new \org\gocdb\services\Config();
     $minumNumberOfScopes = $configService->getMinimumScopesRequired('ngi');
     if (sizeof($scopeIds) < $minumNumberOfScopes) {
         $s = "s";
         if ($minumNumberOfScopes == 1) {
             $s = "";
         }
         throw new \Exception("A NGI must have at least " . $minumNumberOfScopes . " scope" . $s . " assigned to it.");
     }
 }
コード例 #3
0
ファイル: PI.php プロジェクト: Tom-Byrne/gocdb
 /**
  * If all the scopes specified should be matched it returns true, if any of 
  * the scopes specified  being matched to an object is suffecient for it to
  * be included in the results then it retuns false. This is first determined
  * by the scope_match parameter, if this has not been set, the default 
  * decision is used
  * 
  * @param array $parameters
  * @return boolean
  */
 private function allScopesMustMatch($parameters)
 {
     if (!isset($parameters['scope_match'])) {
         $configService = new \org\gocdb\services\Config();
         $scopeMatch = $configService->getDefaultScopeMatch();
     } else {
         $scopeMatch = strtolower($parameters['scope_match']);
     }
     if ($scopeMatch == 'all') {
         return true;
     } elseif ($scopeMatch == 'any') {
         return false;
     } else {
         echo '<error>Unsuported value: ' . $parameters['scope_match'] . " . scope_match accepts either 'any' or 'all'.</error>";
         die;
     }
 }
コード例 #4
0
ファイル: Scope.php プロジェクト: Tom-Byrne/gocdb
 /**
  * Creates a multidimensional array containing all those scopes currently 
  * available in the same format as getScopesSelectedArray, but witht the 
  * default scopes selected. Used to provide checkboxes for scope selection 
  * when adding new entities in the web portal
  * 
  * @return array array contains a seriese of arrays, each of which contains
  *               a scope and a boolean.
  * @throws Exception if a array collection of scopes is not the input
  */
 public function getDefaultScopesSelectedArray()
 {
     //create an array containing scopes that can be applied to an entity
     // and wheter or not they appear in the $entityScopes list
     $scopeArray = array();
     $scopes = $this->getScopes();
     require_once __DIR__ . '/Config.php';
     $configService = new \org\gocdb\services\Config();
     $defaultScopeName = $configService->getDefaultScopeName();
     foreach ($scopes as $scope) {
         $innerArray = array('scope' => $scope, 'applied' => false);
         if ($scope->getName() == $defaultScopeName) {
             $innerArray['applied'] = true;
         }
         $scopeArray[] = $innerArray;
     }
     return $scopeArray;
 }