Esempio n. 1
0
 public static function checkDocumentForObject($act, $object_id, $doc_id, array $opt = array())
 {
     $opt = array_merge(array('method' => '', 'skip_methods' => array(), 'kind' => null), $opt);
     if (!in_array($opt['method'], $opt['skip_methods'])) {
         if ($act == 'add' || $act == 'list' && $object_id != '') {
             switch ($opt['kind']) {
                 case 'building':
                     R3Security::checkBuilding($object_id);
                     break;
                 case 'street_lighting':
                     R3Security::checkStreetlighting($object_id);
                     break;
                 case 'global_entry':
                     R3Security::checkGlobalEntry($object_id);
                     break;
                 case 'global_plain':
                     R3Security::checkGlobalPlain($object_id);
                     break;
                 default:
                     throw new Exception("Invalid kind \"{$opt['kind']}\" for document#{$doc_id}");
             }
         } else {
             R3Security::checkDocument($doc_id);
         }
     }
 }
 public function checkPerm()
 {
     $db = ezcDbInstance::get();
     $act = $this->act == 'list' ? 'SHOW' : strToUpper($this->act);
     $name = strToUpper($this->baseName);
     if (!$this->auth->hasPerm($act, $name)) {
         die(sprintf(_("PERMISSION DENIED [%s/%s]"), $act, $name));
     }
     if ($this->act == 'add') {
         R3Security::checkGlobalEntry($this->ge_id);
     } else {
         // Can edit/delete the given id
         if (!in_array($this->method, array('getEnergySource', 'getEnergyUDM'))) {
             R3Security::checkGlobalSubcategory($this->id);
         }
     }
 }