public function import(\SimpleXMLElement $sx)
 {
     if (isset($sx->permissioncategories)) {
         foreach ($sx->permissioncategories->category as $pkc) {
             $pkg = static::getPackageObject($pkc['package']);
             $category = Category::getByHandle((string) $pkc['handle']);
             if (!is_object($category)) {
                 Category::add((string) $pkc['handle'], $pkg);
             }
         }
     }
 }
 public function execute(Batch $batch)
 {
     $categories = $batch->getObjectCollection('permission_key_category');
     if (!$categories) {
         return;
     }
     foreach ($categories->getCategories() as $category) {
         if (!$category->getPublisherValidator()->skipItem()) {
             $pkg = null;
             if ($category->getPackage()) {
                 $pkg = \Package::getByHandle($category->getPackage());
             }
             Category::add($category->getHandle(), $pkg);
         }
     }
 }
 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 up(Schema $schema)
 {
     \Concrete\Core\Database\Schema\Schema::refreshCoreXMLSchema(array('ConversationPermissionAddMessageAccessList', 'ConversationSubscriptions', 'Conversations'));
     // Subscribe admin to conversations by default, if we have no subscriptions
     $users = \Conversation::getDefaultSubscribedUsers();
     if (count($users) == 0) {
         $admin = \UserInfo::getByID(USER_SUPER_ID);
         if (is_object($admin)) {
             $users = array($admin);
             \Conversation::setDefaultSubscribedUsers($users);
         }
     }
     $db = \Database::get();
     $db->Execute('DROP TABLE IF EXISTS PageStatistics');
     $pp = $schema->getTable('PagePaths');
     if (!$pp->hasColumn('ppGeneratedFromURLSlugs')) {
         $db->Execute('alter table PagePaths add column ppGeneratedFromURLSlugs tinyint(1) unsigned not null default 0');
         // we have to do this directly because the page path calls below will die otherwise.
     }
     $bt = BlockType::getByHandle('page_list');
     if (is_object($bt)) {
         $bt->refresh();
     }
     $bt = BlockType::getByHandle('page_title');
     if (is_object($bt)) {
         $bt->refresh();
     }
     $bt = BlockType::getByHandle('form');
     if (is_object($bt)) {
         $bt->refresh();
     }
     $c = \Page::getByPath('/dashboard/system/seo/urls');
     if (is_object($c) && !$c->isError()) {
         $c->update(array('cName' => 'URLs and Redirection'));
     }
     $sp = \Page::getByPath('/dashboard/system/environment/entities');
     if (!is_object($sp) || $sp->isError()) {
         $sp = \SinglePage::add('/dashboard/system/environment/entities');
         $sp->update(array('cName' => 'Database Entities'));
         $sp->setAttribute('meta_keywords', 'database, entities, doctrine, orm');
     }
     $pkx = Category::getByHandle('multilingual_section');
     if (!is_object($pkx)) {
         $pkx = Category::add('multilingual_section');
     }
     $pkx->associateAccessEntityType(Type::getByHandle('group'));
     $pkx->associateAccessEntityType(Type::getByHandle('user'));
     $pkx->associateAccessEntityType(Type::getByHandle('group_combination'));
     $db->Execute("alter table QueueMessages modify column body longtext not null");
     $ms = $schema->getTable('MultilingualSections');
     if (!$ms->hasColumn('msNumPlurals')) {
         $ms->addColumn('msNumPlurals', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 2));
         $this->updateSectionPlurals = true;
     }
     if (!$ms->hasColumn('msPluralRule')) {
         $ms->addColumn('msPluralRule', 'string', array('notnull' => true, 'length' => 400, 'default' => '(n != 1)'));
         $this->updateSectionPlurals = true;
     }
     if (!$ms->hasColumn('msPluralCases')) {
         $ms->addColumn('msPluralCases', 'string', array('notnull' => true, 'length' => 1000, 'default' => "one@1\nother@0, 2~16, 100, 1000, 10000, 100000, 1000000, …"));
         $this->updateSectionPlurals = true;
     }
     $mt = $schema->getTable('MultilingualTranslations');
     if (!$mt->hasColumn('msgidPlural')) {
         $mt->addColumn('msgidPlural', 'text', array('notnull' => false));
         $this->updateMultilingualTranslations = true;
     }
     if (!$mt->hasColumn('msgstrPlurals')) {
         $mt->addColumn('msgstrPlurals', 'text', array('notnull' => false));
         $this->updateMultilingualTranslations = true;
     }
     $cms = $schema->getTable('ConversationMessages');
     if (!$cms->hasColumn('cnvMessageAuthorName')) {
         $cms->addColumn('cnvMessageAuthorName', 'string', array('notnull' => false, 'length' => 255));
     }
     if (!$cms->hasColumn('cnvMessageAuthorEmail')) {
         $cms->addColumn('cnvMessageAuthorEmail', 'string', array('notnull' => false, 'length' => 255));
     }
     if (!$cms->hasColumn('cnvMessageAuthorWebsite')) {
         $cms->addColumn('cnvMessageAuthorWebsite', 'string', array('notnull' => false, 'length' => 255));
     }
     $this->updatePermissionDurationObjects();
     $key = Key::getByHandle('add_conversation_message');
     if (is_object($key) && !$key->permissionKeyHasCustomClass()) {
         $key->setPermissionKeyHasCustomClass(true);
     }
     $this->installMaintenanceModePermission();
 }