Esempio n. 1
0
 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 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'));
     }
 }
Esempio n. 4
0
 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 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);
         }
     }
 }