public function testCanEditPages() { $config = $this->objFromFixture('SiteConfig', 'default'); // Log in without pages admin access $this->logInWithPermission('CMS_ACCESS_AssetAdmin'); $this->assertFalse($config->canEditPages()); // Login with necessary edit permission $perms = SiteConfig::config()->required_permission; $this->logInWithPermission(reset($perms)); $this->assertTrue($config->canEditPages()); }
public function testAvailableThemes() { $config = SiteConfig::current_site_config(); $ds = DIRECTORY_SEPARATOR; $testThemeBaseDir = TEMP_FOLDER . $ds . 'test-themes'; if (file_exists($testThemeBaseDir)) { Filesystem::removeFolder($testThemeBaseDir); } mkdir($testThemeBaseDir); mkdir($testThemeBaseDir . $ds . 'blackcandy'); mkdir($testThemeBaseDir . $ds . 'blackcandy_blog'); mkdir($testThemeBaseDir . $ds . 'darkshades'); mkdir($testThemeBaseDir . $ds . 'darkshades_blog'); $themes = $config->getAvailableThemes($testThemeBaseDir); $this->assertContains('blackcandy', $themes, 'Test themes contain blackcandy theme'); $this->assertContains('darkshades', $themes, 'Test themes contain darkshades theme'); SiteConfig::config()->disabled_themes = array('darkshades'); $themes = $config->getAvailableThemes($testThemeBaseDir); $this->assertFalse(in_array('darkshades', $themes), 'Darkshades was disabled - it is no longer available'); Filesystem::removeFolder($testThemeBaseDir); }
public function updateCMSFields(FieldList $fields) { $services = SiteConfig::config()->available_services; if (!$services) { $services = array_keys(self::listAvailableMediaServices()); } if (in_array('twitter', $services)) { $fields->addFieldToTab('Root.Social', new TextField('TwitterUsername', _t('Socialstream.TwitterUsername', 'Twitter Username'))); } if (in_array('twitter_hashtag', $services)) { $fields->addFieldToTab('Root.Social', new TextField('TwitterHashtag', _t('Socialstream.TwitterHashtag', 'Twitter Hashtag'))); } if (in_array('facebook_page', $services)) { $fields->addFieldToTab('Root.Social', new TextField('FacebookPage', _t('Socialstream.FacebookPage', 'Facebook Page'))); } if (in_array('vimeo', $services)) { $fields->addFieldToTab('Root.Social', new TextField('VimeoUsername', _t('Socialstream.VimeoUsername', 'Vimeo Username'))); } if (in_array('youtube', $services)) { $fields->addFieldToTab('Root.Social', new TextField('YoutubeUsername', _t('Socialstream.YoutubeUsername', 'Youtube Username'))); } if (in_array('dailymotion', $services)) { $fields->addFieldToTab('Root.Social', new TextField('DailymotionUsername', _t('Socialstream.DailymotionUsername', 'Dailymotion Username'))); } if (in_array('rss', $services)) { $fields->addFieldToTab('Root.Social', new TextField('RssFeed', _t('Socialstream.RssFeed', 'Rss Feed'))); } if (in_array('flickr', $services)) { $fields->addFieldToTab('Root.Social', new TextField('FlickrUsername', _t('Socialstream.FlickrUsername', 'Flickr Username'))); } if (in_array('github', $services)) { $fields->addFieldToTab('Root.Social', new TextField('GithubUsername', _t('Socialstream.GithubUsername', 'Github Username'))); } $fields->addFieldToTab('Root.Social', $wl = new ListboxField('LifestreamWhitelist', _t('Socialstream.LifestreamWhitelist', 'Lifestream Whitelist'), array_combine($services, $services))); $wl->setMultiple(true); $wl->setDescription('A list of services to display on the Lifestream. If left blank, all configured streams will be used.'); $fields->addFieldToTab('Root.Social', new NumericField('LifestreamItems', _t('Socialstream.LifestreamItems', 'Lifestream Items'))); return $fields; }
public function testCreatePermissions() { // Test logged out users cannot create $this->logOut(); $this->assertFalse(singleton('SiteTree')->canCreate()); // Login with another permission $this->logInWithPermission('DUMMY'); $this->assertFalse(singleton('SiteTree')->canCreate()); // Login with basic CMS permission $perms = SiteConfig::config()->required_permission; $this->logInWithPermission(reset($perms)); $this->assertTrue(singleton('SiteTree')->canCreate()); // Test creation underneath a parent which this user doesn't have access to $parent = $this->objFromFixture('Page', 'about'); $this->assertFalse(singleton('SiteTree')->canCreate(null, array('Parent' => $parent))); // Test creation underneath a parent which doesn't allow a certain child $parentB = new SiteTreeTest_ClassB(); $parentB->Title = 'Only Allows SiteTreeTest_ClassC'; $parentB->write(); $this->assertTrue(singleton('SiteTreeTest_ClassA')->canCreate(null)); $this->assertFalse(singleton('SiteTreeTest_ClassA')->canCreate(null, array('Parent' => $parentB))); $this->assertTrue(singleton('SiteTreeTest_ClassC')->canCreate(null, array('Parent' => $parentB))); }