Beispiel #1
0
 public function getPublishButtonTitle(Page $c)
 {
     if ($c->isPageDraft()) {
         $publishTitle = t('Publish Page');
     } else {
         $publishTitle = t('Publish Changes');
     }
     $pk = Key::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) {
         $publishTitle = t('Submit to Workflow');
     }
     return $publishTitle;
 }
 public function assignPermissions($userOrGroup, $permissions = [], $accessType = Key::ACCESS_TYPE_INCLUDE, $cascadeToChildren = true)
 {
     if (!$cascadeToChildren) {
         $this->setChildPermissionsToOverride();
     }
     $this->setPermissionsToOverride();
     if (is_array($userOrGroup)) {
         $pe = GroupCombinationEntity::getOrCreate($userOrGroup);
         // group combination
     } elseif ($userOrGroup instanceof User || $userOrGroup instanceof \Concrete\Core\User\UserInfo || $userOrGroup instanceof \Concrete\Core\User\User) {
         $pe = UserEntity::getOrCreate($userOrGroup);
     } elseif ($userOrGroup instanceof Entity) {
         $pe = $userOrGroup;
     } else {
         // group;
         $pe = GroupEntity::getOrCreate($userOrGroup);
     }
     foreach ($permissions as $pkHandle) {
         $pk = Key::getByHandle($pkHandle);
         $pk->setPermissionObject($this);
         $pa = $pk->getPermissionAccessObject();
         if (!is_object($pa)) {
             $pa = Access::create($pk);
         } elseif ($pa->isPermissionAccessInUse()) {
             $pa = $pa->duplicate();
         }
         $pa->addListItem($pe, false, $accessType);
         $pt = $pk->getPermissionAssignmentObject();
         $pt->assignPermissionAccess($pa);
     }
 }
 public function getPermissionAccessObject()
 {
     $cache = Core::make('cache/request');
     $identifier = sprintf('permission/assignment/access/%s/%s', $this->pk->getPermissionKeyHandle(), $this->getPermissionObject()->getPermissionObjectIdentifier());
     $item = $cache->getItem($identifier);
     if (!$item->isMiss()) {
         return $item->get();
     }
     $db = Loader::db();
     $r = $db->GetOne('select paID from PagePermissionAssignments where cID = ? and pkID = ?', array($this->getPermissionObject()->getPermissionsCollectionID(), $this->pk->getPermissionKeyID()));
     $pa = $r ? Access::getByID($r, $this->pk, false) : null;
     if (is_object($pa)) {
         if ($this->getPermissionObject()->isPageDraft() && $this->getPermissionObject()->getCollectionInheritance() == 'PARENT' && is_object($pageType = $this->getPermissionObject()->getPageTypeObject()) && isset($this->inheritedPageTypeDraftPermissions[$this->pk->getPermissionKeyHandle()])) {
             $pk = Key::getByHandle($this->inheritedPageTypeDraftPermissions[$this->pk->getPermissionKeyHandle()]);
             $pk->setPermissionObject($pageType);
             $access = $pk->getPermissionAccessObject();
             if (is_object($access)) {
                 $list_items = $access->getAccessListItems();
                 $pa->setListItems($list_items);
             }
         }
     }
     $cache->save($item->set($pa));
     return $pa;
 }
Beispiel #4
0
 /**
  * We take any permissions function run on the permissions class and send it into the category object.
  */
 public function __call($f, $a)
 {
     if (!is_object($this->response)) {
         // handles task permissions
         $permission = Loader::helper('text')->uncamelcase($f);
     }
     if (count($a) > 0) {
         if (is_object($this->response)) {
             $r = call_user_func_array(array($this->response, $f), $a);
         } else {
             $pk = PermissionKey::getByHandle($permission);
             $r = call_user_func_array(array($pk, $f), $a);
         }
     } elseif (is_object($this->response)) {
         $r = $this->response->{$f}();
     } else {
         $pk = PermissionKey::getByHandle($permission);
         if (is_object($pk)) {
             $r = $pk->validate();
         } else {
             throw new \Exception(t('Unable to get permission key for %s', $permission));
         }
     }
     if (is_array($r) || is_object($r)) {
         return $r;
     } elseif ($r) {
         return 1;
     } else {
         return 0;
     }
 }
 public function handlePageUpdate($event)
 {
     $page = $event->getPageObject();
     $pk = PermissionKey::getByHandle('view_page');
     $pk->setPermissionObject($page);
     $list = $pk->getAccessListItems();
     foreach ($list as $pa) {
         $pae = $pa->getAccessEntityObject();
         if ($pae->getAccessEntityTypeHandle() == 'group') {
             if ($pae->getGroupObject()->getGroupID() == GUEST_GROUP_ID) {
                 $pd = $pa->getPermissionDurationObject();
                 if (!is_object($pd)) {
                     $pd = new PermissionDuration();
                 }
                 $publicDate = strtotime($page->getCollectionDatePublic());
                 $pd->setStartDateAllDay(0);
                 $pd->setEndDateAllDay(0);
                 $pd->setStartDate($dateStart = date('Y-m-d H:i:s', $publicDate));
                 $pd->save();
                 $paa = PermissionAccess::getByID($pa->paID, $pk);
                 $paa->addListItem($pae, $pd, PermissionKey::ACCESS_TYPE_INCLUDE);
             }
         }
     }
 }
 public function getUsersToNotify(SubscriptionInterface $subscription, SubjectInterface $subject)
 {
     $key = Key::getByHandle('notify_in_notification_center');
     $users = array();
     if (is_object($key)) {
         $access = $key->getPermissionAssignmentObject()->getPermissionAccessObject();
         if (is_object($access)) {
             /**
              * @var $access Access
              */
             $items = $access->getAccessListItems(Key::ACCESS_TYPE_INCLUDE);
             /**
              * @var $item NotifyInNotificationCenterNotificationListItem
              */
             foreach ($items as $item) {
                 if ($item->getSubscriptionsAllowedPermission() == 'A' || $item->getSubscriptionsAllowedPermission() == 'C' && in_array($subscription, $item->getSubscriptionsAllowedArray())) {
                     /**
                      * @var $entity Entity
                      */
                     $entity = $item->getAccessEntityObject();
                     $users = array_merge($entity->getAccessEntityUsers($access), $users);
                 }
             }
             // Now we loop through the array and remove
             $items = $access->getAccessListItems(Key::ACCESS_TYPE_EXCLUDE);
             /**
              * @var $item NotifyInNotificationCenterNotificationListItem
              */
             $usersToRemove = array();
             foreach ($subject->getUsersToExcludeFromNotification() as $user) {
                 $usersToRemove[] = $user->getUserID();
             }
             foreach ($items as $item) {
                 if ($item->getSubscriptionsAllowedPermission() == 'N' || $item->getSubscriptionsAllowedPermission() == 'C' && in_array($subscription, $item->getSubscriptionsAllowedArray())) {
                     /**
                      * @var $entity Entity
                      */
                     $entity = $item->getAccessEntityObject();
                     foreach ($entity->getAccessEntityUsers($access) as $user) {
                         $usersToRemove[] = $user->getUserID();
                     }
                 }
             }
             $users = array_unique($users);
             $usersToRemove = array_unique($usersToRemove);
             $users = array_filter($users, function ($element) use($usersToRemove) {
                 if (in_array($element->getUserID(), $usersToRemove)) {
                     return false;
                 }
                 return true;
             });
         }
     }
     return $users;
 }
 public function apply($mixed)
 {
     $workflow = Workflow::getByName($this->workflowName);
     $key = Key::getByHandle($this->pkHandle);
     $key->setPermissionObject($mixed->getPermissionObject());
     $assignment = $key->getPermissionAssignmentObject();
     $access = $assignment->getPermissionAccessObject();
     if (is_object($access)) {
         $access->attachWorkflow($workflow);
     }
 }
 public function apply($mixed)
 {
     $key = Key::getByHandle($this->pkHandle);
     $entity = $mixed->getAccessEntity();
     $pa = $key->getPermissionAccessObject();
     if (!is_object($pa)) {
         $pa = Access::create($key);
     }
     $pa->addListItem($entity, false, $this->accessType);
     $pt = $key->getPermissionAssignmentObject();
     $pt->assignPermissionAccess($pa);
 }
 public function getPermissionAccessObject()
 {
     $db = Database::connection();
     if ($this->permissionObjectToCheck instanceof File) {
         $r = $db->GetOne('select paID from FilePermissionAssignments where fID = ? and pkID = ?', array($this->permissionObject->getFileID(), $this->pk->getPermissionKeyID()));
         if ($r) {
             return Access::getByID($r, $this->pk, false);
         }
     } else {
         if (isset($this->inheritedPermissions[$this->pk->getPermissionKeyHandle()])) {
             $pk = Key::getByHandle($this->inheritedPermissions[$this->pk->getPermissionKeyHandle()]);
             $pk->setPermissionObject($this->permissionObjectToCheck);
             $pae = $pk->getPermissionAccessObject();
             return $pae;
         }
     }
 }
 public function import(\SimpleXMLElement $sx)
 {
     if (isset($sx->permissionkeys)) {
         foreach ($sx->permissionkeys->permissionkey as $pk) {
             if (is_object(Key::getByHandle((string) $pk['handle']))) {
                 continue;
             }
             $pkc = Category::getByHandle((string) $pk['category']);
             $c1 = $pkc->getPermissionKeyClass();
             $pkx = call_user_func(array($c1, 'import'), $pk);
             $assignments = array();
             if (isset($pk->access)) {
                 foreach ($pk->access->children() as $ch) {
                     if ($ch->getName() == 'group') {
                         /*
                          * Legacy
                          */
                         $g = Group::getByName($ch['name']);
                         if (!is_object($g)) {
                             $g = Group::add($g['name'], $g['description']);
                         }
                         $pae = GroupEntity::getOrCreate($g);
                         $assignments[] = $pae;
                     }
                     if ($ch->getName() == 'entity') {
                         $type = Type::getByHandle((string) $ch['type']);
                         $class = $type->getAccessEntityTypeClass();
                         if (method_exists($class, 'configureFromImport')) {
                             $pae = $class::configureFromImport($ch);
                             $assignments[] = $pae;
                         }
                     }
                 }
             }
             if (count($assignments)) {
                 $pa = Access::create($pkx);
                 foreach ($assignments as $pae) {
                     $pa->addListItem($pae);
                 }
                 $pt = $pkx->getPermissionAssignmentObject();
                 $pt->assignPermissionAccess($pa);
             }
         }
     }
 }
 /**
  * @param UserList $list
  * @param $request
  */
 public function filterList(ItemList $list)
 {
     $gsID = $this->data['gsID'];
     $gs = GroupSet::getByID($gsID);
     $groupsetids = array(-1);
     if (is_object($gs)) {
         $groups = $gs->getGroups();
     }
     $list->addToQuery('left join UserGroups ugs on u.uID = ugs.uID');
     $pk = Key::getByHandle('search_users_in_group');
     foreach ($groups as $g) {
         if ($pk->validate($g) && !in_array($g->getGroupID(), $groupsetids)) {
             $groupsetids[] = $g->getGroupID();
         }
     }
     $instr = 'ugs.gID in (' . implode(',', $groupsetids) . ')';
     $list->filter(false, $instr);
 }
 public function installMaintenanceModePermission()
 {
     $pk = Key::getByHandle('view_in_maintenance_mode');
     if (!$pk instanceof Key) {
         $pk = Key::add('admin', 'view_in_maintenance_mode', 'View Site in Maintenance Mode', 'Controls whether a user can access the website when its under maintenance.', false, false);
         $pa = $pk->getPermissionAccessObject();
         if (!is_object($pa)) {
             $pa = Access::create($pk);
         }
         $adminGroup = Group::getByID(ADMIN_GROUP_ID);
         if ($adminGroup) {
             $adminGroupEntity = GroupEntity::getOrCreate($adminGroup);
             $pa->addListItem($adminGroupEntity);
             $pt = $pk->getPermissionAssignmentObject();
             $pt->assignPermissionAccess($pa);
         }
     }
 }
 public function addNotifications()
 {
     $this->output(t('Adding notifications...'));
     $adminGroupEntity = GroupEntity::getOrCreate(\Group::getByID(ADMIN_GROUP_ID));
     $adminUserEntity = UserEntity::getOrCreate(\UserInfo::getByID(USER_SUPER_ID));
     $pk = Key::getByHandle('notify_in_notification_center');
     $pa = Access::create($pk);
     $pa->addListItem($adminUserEntity);
     $pa->addListItem($adminGroupEntity);
     $pt = $pk->getPermissionAssignmentObject();
     $pt->assignPermissionAccess($pa);
 }
 public function up(Schema $schema)
 {
     $ft = FlagType::getByhandle('spam');
     if (!is_object($ft)) {
         FlagType::add('spam');
     }
     $bt = BlockType::getByHandle('image_slider');
     $bt->refresh();
     $types = array(Type::getByHandle('group'), Type::getByHandle('user'), Type::getByHandle('group_set'), Type::getByHandle('group_combination'));
     $categories = array(Category::getByHandle('conversation'), Category::getByHandle('conversation_message'));
     foreach ($categories as $category) {
         foreach ($types as $pe) {
             if (is_object($category) && is_object($pe)) {
                 $category->associateAccessEntityType($pe);
             }
         }
     }
     try {
         $gat = AuthenticationType::getByHandle('google');
     } catch (Exception $e) {
         $gat = AuthenticationType::add('google', 'Google');
         if (is_object($gat)) {
             $gat->disable();
         }
     }
     // fix register page permissions
     $g1 = \Group::getByID(GUEST_GROUP_ID);
     $register = \Page::getByPath('/register', "RECENT");
     $register->assignPermissions($g1, array('view_page'));
     // add new permissions, set it to the same value as edit page permissions on all pages.
     $epk = PermissionKey::getByHandle('edit_page_permissions');
     $msk = PermissionKey::getByHandle('edit_page_multilingual_settings');
     $ptk = PermissionKey::getByHandle('edit_page_page_type');
     if (!is_object($msk)) {
         $msk = PermissionKey::add('page', 'edit_page_multilingual_settings', 'Edit Multilingual Settings', 'Controls whether a user can see the multilingual settings menu, re-map a page or set a page as ignored in multilingual settings.', false, false);
     }
     if (!is_object($ptk)) {
         $ptk = PermissionKey::add('page', 'edit_page_page_type', 'Edit Page Type', 'Change the type of an existing page.', false, false);
     }
     $db = \Database::get();
     $r = $db->Execute('select cID from Pages where cInheritPermissionsFrom = "OVERRIDE" order by cID asc');
     while ($row = $r->FetchRow()) {
         $c = Page::getByID($row['cID']);
         if (is_object($c) && !$c->isError()) {
             $epk->setPermissionObject($c);
             $msk->setPermissionObject($c);
             $ptk->setPermissionObject($c);
             $rpa = $epk->getPermissionAccessObject();
             if (is_object($rpa)) {
                 $pt = $msk->getPermissionAssignmentObject();
                 if (is_object($pt)) {
                     $pt->clearPermissionAssignment();
                     $pt->assignPermissionAccess($rpa);
                 }
                 $pt = $ptk->getPermissionAssignmentObject();
                 if (is_object($pt)) {
                     $pt->clearPermissionAssignment();
                     $pt->assignPermissionAccess($rpa);
                 }
             }
         }
     }
     // add new page type permissions
     $epk = PermissionKey::getByHandle('edit_page_type_permissions');
     $msk = PermissionKey::getByHandle('edit_page_type');
     $dsk = PermissionKey::getByHandle('delete_page_type');
     if (!is_object($msk)) {
         $msk = PermissionKey::add('page_type', 'edit_page_type', 'Edit Page Type', '', false, false);
     }
     if (!is_object($dsk)) {
         $dsk = PermissionKey::add('page_type', 'delete_page_type', 'Delete Page Type', '', false, false);
     }
     $list = \Concrete\Core\Page\Type\Type::getList();
     foreach ($list as $pagetype) {
         $epk->setPermissionObject($pagetype);
         $msk->setPermissionObject($pagetype);
         $dsk->setPermissionObject($pagetype);
         $rpa = $epk->getPermissionAccessObject();
         if (is_object($rpa)) {
             $pt = $msk->getPermissionAssignmentObject();
             if (is_object($pt)) {
                 $pt->clearPermissionAssignment();
                 $pt->assignPermissionAccess($rpa);
             }
             $pt = $dsk->getPermissionAssignmentObject();
             if (is_object($pt)) {
                 $pt->clearPermissionAssignment();
                 $pt->assignPermissionAccess($rpa);
             }
         }
     }
     // add new multilingual tables.
     $sm = $db->getSchemaManager();
     $schemaTables = $sm->listTableNames();
     if (!in_array('MultilingualPageRelations', $schemaTables)) {
         $mpr = $schema->createTable('MultilingualPageRelations');
         $mpr->addColumn('mpRelationID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0));
         $mpr->addColumn('cID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0));
         $mpr->addColumn('mpLanguage', 'string', array('notnull' => true, 'default' => ''));
         $mpr->addColumn('mpLocale', 'string', array('notnull' => true));
         $mpr->setPrimaryKey(array('mpRelationID', 'cID', 'mpLocale'));
     }
     if (!in_array('MultilingualSections', $schemaTables)) {
         $mus = $schema->createTable('MultilingualSections');
         $mus->addColumn('cID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0));
         $mus->addColumn('msLanguage', 'string', array('notnull' => true, 'default' => ''));
         $mus->addColumn('msCountry', 'string', array('notnull' => true, 'default' => ''));
         $mus->setPrimaryKey(array('cID'));
     }
     if (!in_array('MultilingualTranslations', $schemaTables)) {
         $mts = $schema->createTable('MultilingualTranslations');
         $mts->addColumn('mtID', 'integer', array('autoincrement' => true, 'unsigned' => true));
         $mts->addColumn('mtSectionID', 'integer', array('unsigned' => true, 'notnull' => true, 'default' => 0));
         $mts->addColumn('msgid', 'text', array('notnull' => false));
         $mts->addColumn('msgstr', 'text', array('notnull' => false));
         $mts->addColumn('context', 'text', array('notnull' => false));
         $mts->addColumn('comments', 'text', array('notnull' => false));
         $mts->addColumn('reference', 'text', array('notnull' => false));
         $mts->addColumn('flags', 'text', array('notnull' => false));
         $mts->addColumn('updated', 'datetime', array('notnull' => false));
         $mts->setPrimaryKey(array('mtID'));
     }
     // block type
     $bt = BlockType::getByHandle('switch_language');
     if (!is_object($bt)) {
         $bt = BlockType::installBlockType('switch_language');
     }
     // single pages
     $sp = Page::getByPath('/dashboard/system/multilingual');
     if (!is_object($sp) || $sp->isError()) {
         $sp = SinglePage::add('/dashboard/system/multilingual');
         $sp->update(array('cName' => 'Multilingual'));
         $sp->setAttribute('meta_keywords', 'multilingual, localization, internationalization, i18n');
     }
     $sp = Page::getByPath('/dashboard/system/multilingual/setup');
     if (!is_object($sp) || $sp->isError()) {
         $sp = SinglePage::add('/dashboard/system/multilingual/setup');
         $sp->update(array('cName' => 'Multilingual Setup'));
     }
     $sp = Page::getByPath('/dashboard/system/multilingual/page_report');
     if (!is_object($sp) || $sp->isError()) {
         $sp = SinglePage::add('/dashboard/system/multilingual/page_report');
         $sp->update(array('cName' => 'Page Report'));
     }
     $sp = Page::getByPath('/dashboard/system/multilingual/translate_interface');
     if (!is_object($sp) || $sp->isError()) {
         $sp = SinglePage::add('/dashboard/system/multilingual/translate_interface');
         $sp->update(array('cName' => 'Translate Interface'));
     }
     $sp = Page::getByPath('/dashboard/pages/types/attributes');
     if (!is_object($sp) || $sp->isError()) {
         $sp = SinglePage::add('/dashboard/pages/types/attributes');
         $sp->update(array('cName' => 'Page Type Attributes'));
     }
 }
Beispiel #15
0
 public function apply_to_site($pThemeID)
 {
     $pk = PermissionKey::getByHandle('customize_themes');
     if ($this->validateAction() && $pk->can()) {
         $vl = $this->getValueListFromRequest($pThemeID);
         $pt = PageTheme::getByID($pThemeID);
         $vl->save();
         $sccRecord = null;
         if ($this->request->request->has('sccRecordID')) {
             $sccRecord = $this->app->make(CustomCssRecordService::class)->getByID($this->request->request->get('sccRecordID'));
         }
         $preset = false;
         if ($this->request->request->has('handle')) {
             $preset = $pt->getThemeCustomizablePreset($this->request->request->get('handle'));
         }
         // reset all custom styles on particular pages
         $pl = new PageList();
         $pl->filterByPagesWithCustomStyles();
         $results = $pl->getResults();
         foreach ($results as $csc) {
             $cscv = $csc->getVersionToModify();
             $cscv->resetCustomThemeStyles();
             $vo = $csc->getVersionObject();
             if ($vo->isApproved()) {
                 $vo = $cscv->getVersionObject();
                 $vo->approve();
             }
         }
         // set the global style object.
         $pt->setCustomStyleObject($vl, $preset, $sccRecord);
         $r = new PageEditResponse();
         $r->setPage($this->page);
         $r->setRedirectURL(URL::to($this->page));
         $r->outputJSON();
     }
 }
 public function skipItem()
 {
     $key = Key::getByHandle($this->object->getHandle());
     return is_object($key);
 }
Beispiel #17
0
 /**
  * @return \Concrete\Core\Page\PageList
  */
 public function getPageListObject()
 {
     $pl = new PageList();
     $pl->setItemsPerPage($this->itemsPerFeed);
     $pl->sortByPublicDateDescending();
     if (!$this->checkPagePermissions) {
         $pl->ignorePermissions();
     } else {
         $vp = \Concrete\Core\Permission\Key\Key::getByHandle('view_page');
         $guest = \Group::getByID(GUEST_GROUP_ID);
         $access = GroupEntity::getOrCreate($guest);
         // we set page permissions to be Guest group only, because
         // authentication won't work with RSS feeds
         $pl->setPermissionsChecker(function ($page) use($vp, $access) {
             $vp->setPermissionObject($page);
             $pa = $vp->getPermissionAccessObject($page);
             if (!is_object($pa)) {
                 return false;
             }
             return $pa->validateAccessEntities(array($access));
         });
     }
     if ($this->cParentID) {
         if ($this->pfIncludeAllDescendents) {
             $parent = \Page::getByID($this->cParentID);
             if (is_object($parent) && !$parent->isError()) {
                 $pl->filterByPath($parent->getCollectionPath());
             }
         } else {
             $pl->filterByParentID($this->cParentID);
         }
     }
     if ($this->pfDisplayAliases) {
         $pl->includeAliases();
     }
     if ($this->ptID) {
         $pl->filterByPageTypeID($this->ptID);
     }
     if ($this->pfDisplayFeaturedOnly) {
         $pl->filterByAttribute('is_featured', true);
     }
     return $pl;
 }
 public function up(Schema $schema)
 {
     /* refresh CollectionVersionBlocks, CollectionVersionBlocksCacheSettings tables */
     $cvb = $schema->getTable('CollectionVersionBlocks');
     $cvb->addColumn('cbOverrideBlockTypeCacheSettings', 'boolean', array('default' => 0));
     $cvbcs = $schema->createTable('CollectionVersionBlocksCacheSettings');
     $cvbcs->addColumn('cID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0));
     $cvbcs->addColumn('cvID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 1));
     $cvbcs->addColumn('bID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0));
     $cvbcs->addColumn('arHandle', 'string', array('notnull' => false));
     $cvbcs->addColumn('btCacheBlockOutput', 'boolean', array('default' => 0));
     $cvbcs->addColumn('btCacheBlockOutputOnPost', 'boolean', array('default' => 0));
     $cvbcs->addColumn('btCacheBlockOutputForRegisteredUsers', 'boolean', array('default' => 0));
     $cvbcs->addColumn('btCacheBlockOutputLifetime', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0));
     $cvbcs->setPrimaryKey(array('cID', 'cvID', 'bId', 'arHandle'));
     /* add permissions lines for edit_block_name and edit_block_cache_settings */
     $ebk = Key::getByHandle('edit_block_name');
     if (!is_object($ebk)) {
         Key::add('block', 'edit_block_name', 'Edit Name', "Controls whether users can change the block's name (rarely used.).", false, false);
     }
     $ebk = Key::getByHandle('edit_block_cache_settings');
     if (!is_object($ebk)) {
         Key::add('block', 'edit_block_cache_settings', 'Edit Cache Settings', "Controls whether users can change the block cache settings for this block instance.", false, false);
     }
     /* Add marketplace single pages */
     $sp = Page::getByPath('/dashboard/extend/connect');
     if (!is_object($sp) || $sp->isError()) {
         $sp = SinglePage::add('/dashboard/extend/connect');
         $sp->update(array('cName' => 'Connect to the Community'));
         $sp->setAttribute('meta_keywords', 'concrete5.org, my account, marketplace');
     }
     $sp = Page::getByPath('/dashboard/extend/themes');
     if (!is_object($sp) || $sp->isError()) {
         $sp = SinglePage::add('/dashboard/extend/themes');
         $sp->update(array('cName' => 'Get More Themes'));
         $sp->setAttribute('meta_keywords', 'buy theme, new theme, marketplace, template');
     }
     $sp = Page::getByPath('/dashboard/extend/addons');
     if (!is_object($sp) || $sp->isError()) {
         $sp = SinglePage::add('/dashboard/extend/addons');
         $sp->update(array('cName' => 'Get More Add-Ons'));
         $sp->setAttribute('meta_keywords', 'buy addon, buy add on, buy add-on, purchase addon, purchase add on, purchase add-on, find addon, new addon, marketplace');
     }
     /* Add auth types ("handle|name") "twitter|Twitter" and "community|concrete5.org" */
     try {
         $community = AuthenticationType::getByHandle('community');
     } catch (Exception $e) {
         $community = AuthenticationType::add('community', 'concrete5.org');
         if (is_object($community)) {
             $community->disable();
         }
     }
     try {
         $twitter = AuthenticationType::getByHandle('twitter');
     } catch (Exception $e) {
         $twitter = AuthenticationType::add('twitter', 'Twitter');
         if (is_object($twitter)) {
             $twitter->disable();
         }
     }
     /* delete customize page themes dashboard single page */
     $customize = Page::getByPath('/dashboard/pages/themes/customize');
     if (is_object($customize) && !$customize->isError()) {
         $customize->delete();
     }
     /* exclude nav from flat view in dashboard */
     $flat = Page::getByPath('/dashboard/sitemap/explore');
     if (is_object($customize) && !$customize->isError()) {
         $flat->setAttribute("exclude_nav", false);
     }
 }
 public function view()
 {
     $key = Key::getByHandle('notify_in_notification_center');
     $this->set('key', $key);
 }
Beispiel #20
0
 /**
     +	 * Returns true if the logged-in user can approve the current workflow
     +	 */
 public function canApproveWorkflow()
 {
     $pk = Key::getByHandle('approve_basic_workflow_action');
     $pk->setPermissionObject($this);
     return $pk->validate();
 }
 /**
  * @inheritdoc
  */
 public function collection(Collection $collection, $code = Response::HTTP_OK, $headers = array())
 {
     if (!$this->app) {
         throw new \RuntimeException('Cannot resolve collections without a reference to the application');
     }
     $request = $this->request;
     if ($collection->isError() && $collection->getError() == COLLECTION_NOT_FOUND) {
         if ($response = $this->collectionNotFound($collection, $request, $headers)) {
             return $response;
         }
     }
     if ($collection->getCollectionPath() != '/page_not_found') {
         if (!isset($collection->cPathFetchIsCanonical) || !$collection->cPathFetchIsCanonical) {
             // Handle redirect URL (additional page paths)
             /** @var Url $url */
             $url = $this->app->make('url/manager')->resolve([$collection]);
             $query = $url->getQuery();
             $query->modify($request->getQueryString());
             $url = $url->setQuery($query);
             return $this->redirect($url, Response::HTTP_MOVED_PERMANENTLY, $headers);
         }
     }
     // maintenance mode
     if ($collection->getCollectionPath() != '/login') {
         $smm = $this->config->get('concrete.maintenance_mode');
         if ($smm == 1 && !Key::getByHandle('view_in_maintenance_mode')->validate() && ($_SERVER['REQUEST_METHOD'] != 'POST' || Loader::helper('validation/token')->validate() == false)) {
             $v = new View('/frontend/maintenance_mode');
             $router = $this->app->make(RouterInterface::class);
             $tmpTheme = $router->getThemeByRoute('/frontend/maintenance_mode');
             $v->setViewTheme($tmpTheme[0]);
             $v->addScopeItems(['c' => $collection]);
             $request->setCurrentPage($collection);
             if (isset($tmpTheme[1])) {
                 $v->setViewTemplate($tmpTheme[1]);
             }
             return $this->view($v, $code, $headers);
         }
     }
     if ($collection->getCollectionPointerExternalLink() != '') {
         return $this->redirect($collection->getCollectionPointerExternalLink());
     }
     $cp = new Checker($collection);
     if ($cp->isError() && $cp->getError() == COLLECTION_FORBIDDEN) {
         return $this->forbidden($request->getUri(), Response::HTTP_FORBIDDEN, $headers);
     }
     if (!$collection->isActive() && !$cp->canViewPageVersions()) {
         return $this->notFound('', Response::HTTP_NOT_FOUND, $headers);
     }
     $scheduledVersion = Version::get($collection, "SCHEDULED");
     if ($publishDate = $scheduledVersion->cvPublishDate) {
         $datetime = $this->app->make('helper/date');
         $now = $datetime->date('Y-m-d G:i:s');
         if (strtotime($now) >= strtotime($publishDate)) {
             $scheduledVersion->approve();
             $collection->loadVersionObject('ACTIVE');
         }
     }
     if ($cp->canEditPageContents() || $cp->canEditPageProperties() || $cp->canViewPageVersions()) {
         $collection->loadVersionObject('RECENT');
     }
     $vp = new Checker($collection->getVersionObject());
     // returns the $vp object, which we then check
     if (is_object($vp) && $vp->isError()) {
         switch ($vp->getError()) {
             case COLLECTION_NOT_FOUND:
                 return $this->notFound('', Response::HTTP_NOT_FOUND, $headers);
                 break;
             case COLLECTION_FORBIDDEN:
                 return $this->forbidden($request->getUri(), Response::HTTP_FORBIDDEN, $headers);
                 break;
         }
     }
     // Now that we've passed all permissions checks, and we have a page, we check to see if we
     // ought to redirect based on base url or trailing slash settings
     $cms = $this->app;
     $site = $this->app['site']->getSite();
     $response = $cms->handleCanonicalURLRedirection($request, $site);
     if (!$response) {
         $response = $cms->handleURLSlashes($request, $site);
     }
     if (isset($response)) {
         return $response;
     }
     $dl = $cms->make('multilingual/detector');
     if ($dl->isEnabled()) {
         $dl->setupSiteInterfaceLocalization($collection);
     }
     if (!$request->getPath() && $request->isMethod('GET') && !$request->query->has('cID')) {
         // This is a request to the home page –http://www.mysite.com/
         // First, we check to see if we need to redirect to a default multilingual section.
         if ($dl->isEnabled() && $site->getConfigRepository()->get('multilingual.redirect_home_to_default_locale')) {
             // Let's retrieve the default language
             $ms = $dl->getPreferredSection();
             if (is_object($ms)) {
                 return $this->redirect(\URL::to($ms));
             }
         }
         // Otherwise, let's check to see if our home page, which we have loaded already, has a path (like /en)
         // If it does, we'll redirect to the path.
         if ($collection->getCollectionPath() != '') {
             return $this->redirect(\URL::to($collection));
         }
     }
     $request->setCurrentPage($collection);
     $c = $collection;
     // process.php needs this
     require DIR_BASE_CORE . '/bootstrap/process.php';
     $u = new User();
     // On page view event.
     $pe = new Event($collection);
     $pe->setUser($u);
     $pe->setRequest($request);
     $this->app['director']->dispatch('on_page_view', $pe);
     // Core menu items
     $item = new RelationListItem();
     $menu = $this->app->make('helper/concrete/ui/menu');
     $menu->addMenuItem($item);
     $controller = $collection->getPageController();
     // we update the current page with the one bound to this controller.
     $collection->setController($controller);
     return $this->controller($controller);
 }