public function setPermissionObject(Area $a)
 {
     $ax = $a;
     if ($a->isGlobalArea()) {
         $cx = Stack::getByName($a->getAreaHandle());
         $a = Area::get($cx, STACKS_AREA_NAME);
     }
     if ($a instanceof SubArea && !$a->overrideCollectionPermissions()) {
         $a = $a->getSubAreaParentPermissionsObject();
     }
     $this->permissionObject = $a;
     // if the area overrides the collection permissions explicitly (with a one on the override column) we check
     if ($a->overrideCollectionPermissions()) {
         $this->permissionObjectToCheck = $a;
     } else {
         if ($a->getAreaCollectionInheritID() > 0) {
             // in theory we're supposed to be inheriting some permissions from an area with the same handle,
             // set on the collection id specified above (inheritid). however, if someone's come along and
             // reverted that area to the page's permissions, there won't be any permissions, and we
             // won't see anything. so we have to check
             $areac = Page::getByID($a->getAreaCollectionInheritID());
             $inheritArea = Area::get($areac, $a->getAreaHandle());
             if (is_object($inheritArea) && $inheritArea->overrideCollectionPermissions()) {
                 // okay, so that area is still around, still has set permissions on it. So we
                 // pass our current area to our grouplist, userinfolist objects, knowing that they will
                 // smartly inherit the correct items.
                 $this->permissionObjectToCheck = $inheritArea;
             }
         }
         if (!$this->permissionObjectToCheck) {
             $this->permissionObjectToCheck = $a->getAreaCollectionObject();
         }
     }
 }
예제 #2
1
파일: Area.php 프로젝트: ceko/concrete5-1
 /**
  * @param Page $c
  * @param string $arHandle
  *
  * @return Area
  */
 public static function getOrCreate($c, $arHandle)
 {
     $area = Area::get($c, $arHandle);
     if (!is_object($area)) {
         $a = new Area($arHandle);
         $area = $a->create($c, $arHandle);
     }
     return $area;
 }
예제 #3
0
 public function getTotalBlocksInAreaEditMode()
 {
     $stack = $this->getGlobalAreaStackObject();
     $ax = Area::get($stack, STACKS_AREA_NAME);
     $db = Loader::db();
     $r = $db->GetOne('select count(b.bID) from CollectionVersionBlocks cvb inner join Blocks b on cvb.bID = b.bID inner join BlockTypes bt on b.btID = bt.btID where cID = ? and cvID = ? and arHandle = ?', array($stack->getCollectionID(), $stack->getVersionID(), $ax->getAreaHandle()));
     return $r;
 }
예제 #4
0
 public function getSubAreaParentPermissionsObject()
 {
     $db = Loader::db();
     $arParentID = $this->arParentID;
     if ($arParentID == 0) {
         return false;
     }
     while ($arParentID > 0) {
         $row = $db->GetRow('select arID, arHandle, arParentID, arOverrideCollectionPermissions from Areas where arID = ?', array($arParentID));
         $arParentID = $row['arParentID'];
         if ($row['arOverrideCollectionPermissions']) {
             break;
         }
     }
     $a = Area::get($this->c, $row['arHandle']);
     return $a;
 }
예제 #5
0
 /**
  * @return bool|Area|mixed|null
  */
 public function getSubAreaParentPermissionsObject()
 {
     $cache = \Core::make('cache/request');
     $item = $cache->getItem(sprintf('subarea/parent/permissions/%s', $this->getAreaID()));
     if (!$item->isMiss()) {
         return $item->get();
     }
     $db = Loader::db();
     $arParentID = $this->arParentID;
     if ($arParentID == 0) {
         return false;
     }
     while ($arParentID > 0) {
         $row = $db->GetRow('select arID, arHandle, arParentID, arOverrideCollectionPermissions from Areas where arID = ?', array($arParentID));
         $arParentID = $row['arParentID'];
         if ($row['arOverrideCollectionPermissions']) {
             break;
         }
     }
     $a = Area::get($this->c, $row['arHandle']);
     $item->set($a);
     return $a;
 }