Пример #1
0
	public function view() {
		if (Config::get('concrete.permissions.model') != 'simple') {
			$this->setViewObject(new View('/panels/details/page/permissions/advanced'));
			$this->set('editPermissions', false);
			if ($this->page->getCollectionInheritance() == 'OVERRIDE') { 
				$this->set('editPermissions', true);
			}

		} else {

			$editAccess = array();
			$viewAccess = array();
			$c = $this->page;
				
			$pk = PagePermissionKey::getByHandle('view_page');
			$pk->setPermissionObject($c);
			$assignments = $pk->getAccessListItems();
			foreach($assignments as $asi) {
				$ae = $asi->getAccessEntityObject();
				if ($ae->getAccessEntityTypeHandle() == 'group') {
					$group = $ae->getGroupObject();
					if (is_object($group)) {
						$viewAccess[] = $group->getGroupID();
					}
				}
			}

			$pk = PermissionKey::getByHandle('edit_page_contents');
			$pk->setPermissionObject($c);
			$assignments = $pk->getAccessListItems();
			foreach($assignments as $asi) {
				$ae = $asi->getAccessEntityObject();
				if ($ae->getAccessEntityTypeHandle() == 'group') {
					$group = $ae->getGroupObject();
					if (is_object($group)) {
						$editAccess[] = $group->getGroupID();
					}
				}
			}
			
			$gl = new GroupList();
			$gl->sortBy('gID', 'asc');
            $gl->includeAllGroups();
			$groups = $gl->getResults();

			$this->set('editAccess', $editAccess);
			$this->set('viewAccess', $viewAccess);
			$this->set('gArray', $groups);
		}
	}
Пример #2
0
 public function removePermissions($userOrGroup, $permissions = array())
 {
     if ($this->cInheritPermissionsFrom != 'OVERRIDE') {
         return;
     }
     if (is_array($userOrGroup)) {
         $pe = GroupCombinationPermissionAccessEntity::getOrCreate($userOrGroup);
         // group combination
     } elseif ($userOrGroup instanceof User || $userOrGroup instanceof UserInfo) {
         $pe = UserPermissionAccessEntity::getOrCreate($userOrGroup);
     } else {
         // group;
         $pe = GroupPermissionAccessEntity::getOrCreate($userOrGroup);
     }
     foreach ($permissions as $pkHandle) {
         $pk = PagePermissionKey::getByHandle($pkHandle);
         $pk->setPermissionObject($this);
         $pa = $pk->getPermissionAccessObject();
         if (is_object($pa)) {
             if ($pa->isPermissionAccessInUse()) {
                 $pa = $pa->duplicate();
             }
             $pa->removeListItem($pe);
             $pt = $pk->getPermissionAssignmentObject();
             $pt->assignPermissionAccess($pa);
         }
     }
 }
         </div>
         </div>
     <?php 
     }
     ?>
 <?php 
 }
 if (!$c->getCollectionPointerID() && (!is_array($workflowList) || count($workflowList) == 0)) {
     if (is_object($vo)) {
         if (!$vo->isApproved() && !$c->isEditMode()) {
             if ($c->isPageDraft()) {
                 print Core::make('helper/concrete/ui')->notify(array('title' => t('Page Draft.'), 'message' => t("This is an un-published draft."), 'type' => 'info', 'icon' => 'exclamation'));
             } else {
                 $buttons = array();
                 if ($canApprovePageVersions && !$c->isCheckedOut()) {
                     $pk = \Concrete\Core\Permission\Key\PageKey::getByHandle('approve_page_versions');
                     $pk->setPermissionObject($c);
                     $pa = $pk->getPermissionAccessObject();
                     $workflows = array();
                     $canApproveWorkflow = true;
                     if (is_object($pa)) {
                         $workflows = $pa->getWorkflows();
                     }
                     foreach ($workflows as $wf) {
                         if (!$wf->canApproveWorkflow()) {
                             $canApproveWorkflow = false;
                         }
                     }
                     if (count($workflows) > 0 && !$canApproveWorkflow) {
                         $appLabel = t('Submit to Workflow');
                     }
Пример #4
0
 public function getAllAssignmentsForPage()
 {
     $db = Loader::db();
     $assignments = array();
     $r = $db->Execute('select peID, pkID, pdID from PagePermissionAssignments ppa inner join PermissionAccessList pal on ppa.paID = pal.paID where cID = ?', array($this->object->getCollectionID()));
     while ($row = $r->FetchRow()) {
         $pk = PagePermissionKey::getByID($row['pkID']);
         $pae = PermissionAccessEntity::getByID($row['peID']);
         $pd = PermissionDuration::getByID($row['pdID']);
         $ppc = new PageContentPermissionTimedAssignment();
         $ppc->setDurationObject($pd);
         $ppc->setAccessEntityObject($pae);
         $ppc->setPermissionKeyObject($pk);
         $assignments[] = $ppc;
     }
     $r = $db->Execute('select arHandle from Areas where cID = ? and arOverrideCollectionPermissions = 1', array($this->object->getCollectionID()));
     while ($row = $r->FetchRow()) {
         $r2 = $db->Execute('select peID, pdID, pkID from AreaPermissionAssignments apa inner join PermissionAccessList pal on apa.paID = pal.paID where cID = ? and arHandle = ?', array($this->object->getCollectionID(), $row['arHandle']));
         while ($row2 = $r2->FetchRow()) {
             $pk = AreaPermissionKey::getByID($row2['pkID']);
             $pae = PermissionAccessEntity::getByID($row2['peID']);
             $area = Area::get($this->getPermissionObject(), $row['arHandle']);
             $pk->setPermissionObject($area);
             $pd = PermissionDuration::getByID($row2['pdID']);
             $ppc = new PageContentPermissionTimedAssignment();
             $ppc->setDurationObject($pd);
             $ppc->setAccessEntityObject($pae);
             $ppc->setPermissionKeyObject($pk);
             $assignments[] = $ppc;
         }
     }
     $r = $db->Execute('select peID, cvb.cvID, cvb.bID, pdID, pkID from BlockPermissionAssignments bpa
                 inner join PermissionAccessList pal on bpa.paID = pal.paID inner join CollectionVersionBlocks cvb on cvb.cID = bpa.cID and cvb.cvID = bpa.cvID and cvb.bID = bpa.bID
                 where cvb.cID = ? and cvb.cvID = ? and cvb.cbOverrideAreaPermissions = 1', array($this->object->getCollectionID(), $this->object->getVersionID()));
     while ($row = $r->FetchRow()) {
         $pk = BlockPermissionKey::getByID($row['pkID']);
         $pae = PermissionAccessEntity::getByID($row['peID']);
         $arHandle = $db->GetOne('select arHandle from CollectionVersionBlocks where bID = ? and cvID = ? and cID = ?', array($row['bID'], $row['cvID'], $this->object->getCollectionID()));
         $b = Block::getByID($row['bID'], $this->object, $arHandle);
         $pk->setPermissionObject($b);
         $pd = PermissionDuration::getByID($row['pdID']);
         $ppc = new PageContentPermissionTimedAssignment();
         $ppc->setDurationObject($pd);
         $ppc->setAccessEntityObject($pae);
         $ppc->setPermissionKeyObject($pk);
         $assignments[] = $ppc;
     }
     return $assignments;
 }
Пример #5
0
         $pk->setPermissionObject($c);
         $pa = PermissionAccess::getByID($_REQUEST['paID'], $pk);
         $pa->addListItem($pe, $pd, $_REQUEST['accessType']);
     }
 }
 if ($_REQUEST['task'] == 'remove_access_entity' && Loader::helper("validation/token")->validate('remove_access_entity')) {
     $pk = PagePermissionKey::getByID($_REQUEST['pkID']);
     $pe = PermissionAccessEntity::getByID($_REQUEST['peID']);
     foreach ($pages as $c) {
         $pk->setPermissionObject($c);
         $pa = PermissionAccess::getByID($_REQUEST['paID'], $pk);
         $pa->removeListItem($pe);
     }
 }
 if ($_REQUEST['task'] == 'save_permission' && Loader::helper("validation/token")->validate('save_permission')) {
     $pk = PagePermissionKey::getByID($_REQUEST['pkID']);
     foreach ($pages as $c) {
         $pa = PermissionAccess::getByID($_REQUEST['paID'], $pk);
         if (is_object($pa)) {
             $pa->save($_POST);
             $pa->clearWorkflows();
             if (is_array($_POST['wfID'])) {
                 foreach ($_POST['wfID'] as $wfID) {
                     $wf = Workflow::getByID($wfID);
                     if (is_object($wf)) {
                         $pa->attachWorkflow($wf);
                     }
                 }
             }
         }
     }
Пример #6
0
 public function assignPermissions($userOrGroup, $permissions = array(), $accessType = PagePermissionKey::ACCESS_TYPE_INCLUDE)
 {
     if ($this->cInheritPermissionsFrom != 'OVERRIDE') {
         $this->setPermissionsToManualOverride();
         $this->clearPagePermissions();
     }
     if (is_array($userOrGroup)) {
         $pe = GroupCombinationPermissionAccessEntity::getOrCreate($userOrGroup);
         // group combination
     } else {
         if ($userOrGroup instanceof User || $userOrGroup instanceof UserInfo) {
             $pe = UserPermissionAccessEntity::getOrCreate($userOrGroup);
         } else {
             // group;
             $pe = GroupPermissionAccessEntity::getOrCreate($userOrGroup);
         }
     }
     foreach ($permissions as $pkHandle) {
         $pk = PagePermissionKey::getByHandle($pkHandle);
         $pk->setPermissionObject($this);
         $pa = $pk->getPermissionAccessObject();
         if (!is_object($pa)) {
             $pa = PermissionAccess::create($pk);
         } else {
             if ($pa->isPermissionAccessInUse()) {
                 $pa = $pa->duplicate();
             }
         }
         $pa->addListItem($pe, false, $accessType);
         $pt = $pk->getPermissionAssignmentObject();
         $pt->assignPermissionAccess($pa);
     }
 }