예제 #1
0
 public function checkPerm()
 {
     $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 (!in_array($this->act, array('list', 'add'))) {
         R3Security::checkBuilding($this->id);
     }
 }
예제 #2
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);
         }
     }
 }