public function copyFromDefaultsToPageType(\Concrete\Core\Permission\Key\Key $pk) { $db = Loader::db(); $paID = $pk->getPermissionAccessID(); if ($paID) { $db = Loader::db(); $db->Replace('PageTypePermissionAssignments', array('ptID' => $this->permissionObject->getPageTypeID(), 'paID' => $paID, 'pkID' => $this->getPermissionKeyID()), array('ptID', 'pkID'), true); } }
/** * 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 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; }
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; }
/** * Begin the runtime. */ public function run() { $app = $this->app; include DIR_APPLICATION . '/bootstrap/app.php'; if ($this->app->isInstalled()) { /* * ---------------------------------------------------------------------------- * Now that we have languages out of the way, we can run our package on_start * methods * ---------------------------------------------------------------------------- */ $app->setupPackages(); /* * ---------------------------------------------------------------------------- * Legacy Definitions. This has to come after packages because this * essentially loads the entity manager, and the entity manager loads classes * found in its config, which may be classes that haven't been autoloaded by initialPackages. It also * has to come after setupPackages() in case an autoloader is configured in on_start() * ---------------------------------------------------------------------------- */ $this->initializeLegacyURLDefinitions($app); /* * Handle automatic updating. Must come after setupPackages() because some things setup autoloaders in on_start() of their package * controller */ $app->handleAutomaticUpdates(); // This is a crappy place for this, but it has to come AFTER the packages because sometimes packages // want to replace legacy "tools" URLs with the new MVC, and the tools paths are so greedy they don't // work unless they come at the end. $this->registerLegacyRoutes(); /* ---------------------------------------------------------------------------- * Register legacy routes * ---------------------------------------------------------------------------- */ $this->registerLegacyRoutes(); /* ---------------------------------------------------------------------------- * Register legacy config values * ---------------------------------------------------------------------------- */ $this->registerLegacyConfigValues(); /* * ---------------------------------------------------------------------------- * Load all permission keys into our local cache. * ---------------------------------------------------------------------------- */ Key::loadAll(); } /* * ---------------------------------------------------------------------------- * Fire an event for intercepting the dispatch * ---------------------------------------------------------------------------- */ Events::dispatch('on_before_dispatch'); $request = Request::createFromGlobals(); return $this->server->handleRequest($request); }
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 setUp() { $this->tables = array_merge($this->tables, array('PermissionAccessList', 'PageTypeComposerFormLayoutSets', 'AttributeSetKeys', 'AttributeSets', 'AttributeKeyCategories', 'PermissionAccessEntityTypes', 'Packages', 'AttributeKeys', 'AttributeTypes', 'PageFeeds')); parent::setUp(); \Concrete\Core\Permission\Access\Entity\Type::add('page_owner', 'Page Owner'); \Concrete\Core\Permission\Category::add('page'); \Concrete\Core\Permission\Key\Key::add('page', 'view_page', 'View Page', '', 0, 0); PageTemplate::add('left_sidebar', 'Left Sidebar'); PageTemplate::add('right_sidebar', 'Right Sidebar'); PageType::add(array('handle' => 'alternate', 'name' => 'Alternate')); PageType::add(array('handle' => 'another', 'name' => 'Another')); foreach ($this->pageData as $data) { $c = call_user_func_array(array($this, 'createPage'), $data); $c->reindex(); } $this->list = new \Concrete\Core\Page\PageList(); $this->list->ignorePermissions(); }
public function execute(Batch $batch) { $keys = $batch->getObjectCollection('permission_key'); if (!$keys) { return; } foreach ($keys->getKeys() as $key) { if (!$key->getPublisherValidator()->skipItem()) { $pkg = null; if ($key->getPackage()) { $pkg = \Package::getByHandle($key->getPackage()); } $p = Key::add($key->getCategory(), $key->getHandle(), $key->getName(), $key->getDescription(), $key->getCanTriggerWorkflow(), $key->getHasCustomClass(), $pkg); foreach ($key->getAccessEntities() as $entity) { $publisher = $entity->getPublisher(); $publisher->publish($p, $entity); } } } }
public static function getByID($paID, PermissionKey $pk, $checkPA = true) { $cache = Core::make('cache/request'); $identifier = sprintf('permission/access/%s/%s', $pk->getPermissionKeyID(), $paID); $item = $cache->getItem($identifier); if (!$item->isMiss()) { return $item->get(); } $db = Database::connection(); $handle = $pk->getPermissionKeyCategoryHandle(); if ($pk->permissionKeyHasCustomClass()) { $handle = $pk->getPermissionKeyHandle() . '_' . $handle; } $class = '\\Core\\Permission\\Access\\' . Core::make('helper/text')->camelcase($handle) . 'Access'; $class = core_class($class, $pk->getPackageHandle()); $obj = null; if ($checkPA) { $row = $db->GetRow('select paID, paIsInUse from PermissionAccess where paID = ?', array($paID)); if ($row && $row['paID']) { $obj = Core::make($class); $obj->setPropertiesFromArray($row); } } else { // we got here from an assignment object so we already know its in use. $obj = Core::make($class); $obj->paID = $paID; $obj->paIsInUse = true; } if (isset($obj)) { $obj->setPermissionKey($pk); } $item->set($obj); return $obj; }
/** * @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); }
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 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 run() { $this->x = new SimpleXMLElement("<concrete5-cif></concrete5-cif>"); $this->x->addAttribute('version', '1.0'); // First, attribute categories AttributeKeyCategory::exportList($this->x); // Features Feature::exportList($this->x); FeatureCategory::exportList($this->x); ConversationEditor::exportList($this->x); ConversationRatingType::exportList($this->x); // composer PageTypePublishTargetType::exportList($this->x); PageTypeComposerControlType::exportList($this->x); PageType::exportList($this->x); // attribute types AttributeType::exportList($this->x); // then block types BlockTypeList::exportList($this->x); // now block type sets (including user) BlockTypeSet::exportList($this->x); // gathering GatheringDataSource::exportList($this->x); GatheringItemTemplate::exportList($this->x); // now attribute keys (including user) AttributeKey::exportList($this->x); // now attribute keys (including user) AttributeSet::exportList($this->x); PageTemplate::exportList($this->x); // now theme PageTheme::exportList($this->x); // now packages PackageList::export($this->x); // permission access entity types PermissionAccessEntityType::exportList($this->x); // now task permissions PermissionKey::exportList($this->x); // workflow types WorkflowType::exportList($this->x); // now jobs Job::exportList($this->x); // now single pages $singlepages = $this->x->addChild("singlepages"); $db = Loader::db(); $r = $db->Execute('select cID from Pages where cFilename is not null and cFilename <> "" and cID not in (select cID from Stacks) order by cID asc'); while ($row = $r->FetchRow()) { $pc = Page::getByID($row['cID'], 'RECENT'); $pc->export($singlepages); } // now stacks/global areas StackList::export($this->x); // now content pages $pages = $this->x->addChild("pages"); $db = Loader::db(); $r = $db->Execute('select Pages.cID from Pages where cIsTemplate = 0 and cFilename is null or cFilename = "" order by cID asc'); while ($row = $r->FetchRow()) { $pc = Page::getByID($row['cID'], 'RECENT'); if ($pc->getPageTypeHandle() == STACKS_PAGE_TYPE) { continue; } $pc->export($pages); } SystemCaptchaLibrary::exportList($this->x); \Concrete\Core\Sharing\SocialNetwork\Link::exportList($this->x); \Concrete\Core\Page\Feed::exportList($this->x); \Concrete\Core\File\Image\Thumbnail\Type\Type::exportList($this->x); Config::exportList($this->x); Tree::exportList($this->x); }
public function doOverrideAreaPermissions() { $db = Loader::db(); $c = $this->getBlockCollectionObject(); $v = array($c->getCollectionID(), $c->getVersionID(), $this->bID, $this->arHandle); $db->query("update CollectionVersionBlocks set cbOverrideAreaPermissions = 1 where cID = ? and (cvID = ? or cbIncludeAll = 1) and bID = ? and arHandle = ?", $v); $v = array($c->getCollectionID(), $c->getVersionID(), $this->bID); $db->query("delete from BlockPermissionAssignments where cID = ? and cvID = ? and bID = ?", $v); // copy permissions from the page to the area $permissions = PermissionKey::getList('block'); foreach ($permissions as $pk) { $pk->setPermissionObject($this); $pk->copyFromPageOrAreaToBlock(); } }
public function getPackageItems(Package $package) { return Key::getListByPackage($package); }
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); } }
/** + * 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(); }
/** * @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 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')); } }
public function skipItem() { $key = Key::getByHandle($this->object->getHandle()); return is_object($key); }
* Handle automatic updating */ $cms->handleAutomaticUpdates(); /** * ---------------------------------------------------------------------------- * Now that we have languages out of the way, we can run our package on_start * methods * ---------------------------------------------------------------------------- */ $cms->setupPackages(); /** * ---------------------------------------------------------------------------- * Load all permission keys into our local cache. * ---------------------------------------------------------------------------- */ PermissionKey::loadAll(); /** * ---------------------------------------------------------------------------- * Fire an event for intercepting the dispatch * ---------------------------------------------------------------------------- */ \Events::dispatch('on_before_dispatch'); /** * ---------------------------------------------------------------------------- * Get the response to the current request * ---------------------------------------------------------------------------- */ $response = $cms->dispatch($request); /** * ---------------------------------------------------------------------------- * Send it to the user
public function duplicate($ptHandle, $ptName) { $data = array('handle' => $ptHandle, 'name' => $ptName, 'defaultTemplate' => $this->getPageTypeDefaultPageTemplateObject(), 'allowedTemplates' => $this->getPageTypeAllowedPageTemplates(), 'templates' => $this->getPageTypeSelectedPageTemplateObjects(), 'ptLaunchInComposer' => $this->doesPageTypeLaunchInComposer(), 'ptIsFrequentlyAdded' => $this->isPageTypeFrequentlyAdded()); $new = static::add($data); // now copy the edit form $sets = FormLayoutSet::getList($this); foreach ($sets as $set) { $set->duplicate($new); } // now copy the master pages for defaults and attributes $db = \Database::get(); $r = $db->Execute('select cID from Pages where cIsTemplate = 1 and ptID = ?', array($this->getPageTypeID())); $home = Page::getByID(HOME_CID); while ($row = $r->FetchRow()) { $c = Page::getByID($row['cID']); if (is_object($c)) { $nc = $c->duplicate($home); $nc->setPageType($new); $db->update('Pages', array('cParentID' => 0, 'cIsTemplate' => 1), array('cID' => $nc->getCollectionID())); $db->insert('PageTypePageTemplateDefaultPages', array('pTemplateID' => $nc->getPageTemplateID(), 'ptID' => $new->getPageTypeID(), 'cID' => $nc->getCollectionID())); // clear out output control blocks because they will be pointing to the wrong thing $composerBlocksIDs = $db->GetAll('select cvb.bID, cvb.arHandle from btCorePageTypeComposerControlOutput o inner join CollectionVersionBlocks cvb on cvb.bID = o.bID inner join Pages p on cvb.cID = p.cID where p.cID = ?', array($nc->getCollectionID())); foreach ($composerBlocksIDs as $row) { $b = \Block::getByID($row['bID'], $nc, $row['arHandle']); $b->deleteBlock(); } } } // copy permissions from the defaults to the page type $list = Key::getList('page_type'); foreach ($list as $pk) { $pk->setPermissionObject($this); $rpa = $pk->getPermissionAccessObject(); if (is_object($rpa)) { $pk->setPermissionObject($new); $pt = $pk->getPermissionAssignmentObject(); if (is_object($pt)) { $pt->clearPermissionAssignment(); $pt->assignPermissionAccess($rpa); } } } // copy permissions from the default page to the page type $list = Key::getList('page'); foreach ($list as $pk) { $pk->setPermissionObject($this->getPageTypePageTemplateDefaultPageObject()); $rpa = $pk->getPermissionAccessObject(); if (is_object($rpa)) { $pk->setPermissionObject($new->getPageTypePageTemplateDefaultPageObject()); $pt = $pk->getPermissionAssignmentObject(); if (is_object($pt)) { $pt->clearPermissionAssignment(); $pt->assignPermissionAccess($rpa); } } } // duplicate the target object. $target = $this->getPageTypePublishTargetObject(); $new->setConfiguredPageTypePublishTargetObject($target); }