本文整理汇总了PHP中Subsite::hasMainSitePermission方法的典型用法代码示例。如果您正苦于以下问题:PHP Subsite::hasMainSitePermission方法的具体用法?PHP Subsite::hasMainSitePermission怎么用?PHP Subsite::hasMainSitePermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subsite
的用法示例。
在下文中一共展示了Subsite::hasMainSitePermission方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCMSFields
function getCMSFields()
{
$subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain");
if (!$subsites) {
$subsites = new DataObjectSet();
}
if (Subsite::hasMainSitePermission(null, array("CMS_ACCESS_CMSMain"))) {
$subsites->push(new ArrayData(array('Title' => 'Main site', "\"ID\"" => 0)));
}
if ($subsites->Count()) {
$subsiteSelectionField = new DropdownField("CopyContentFromID_SubsiteID", "Subsite", $subsites->toDropdownMap('ID', 'Title'), $this->CopyContentFromID ? $this->CopyContentFrom()->SubsiteID : Session::get('SubsiteID'));
}
// Setup the linking to the original page.
$pageSelectionField = new SubsitesTreeDropdownField("RelatedPageID", _t('VirtualPage.CHOOSE', "Choose a page to link to"), "SiteTree", "ID", "MenuTitle");
if (isset($_GET['RelatedPageID_SubsiteID'])) {
$pageSelectionField->setSubsiteID($_GET['RelatedPageID_SubsiteID']);
}
$pageSelectionField->setFilterFunction(create_function('$item', 'return $item->ClassName != "VirtualPage";'));
if ($subsites->Count()) {
$fields = new FieldSet($subsiteSelectionField, $pageSelectionField);
} else {
$fields = new FieldSet($pageSelectionField);
}
return $fields;
}
示例2: testhasMainSitePermission
function testhasMainSitePermission()
{
$admin = $this->objFromFixture('Member', 'admin');
$subsite1member = $this->objFromFixture('Member', 'subsite1member');
$subsite1admin = $this->objFromFixture('Member', 'subsite1admin');
$allsubsitesauthor = $this->objFromFixture('Member', 'allsubsitesauthor');
$this->assertTrue(Subsite::hasMainSitePermission($admin), 'Default permissions granted for super-admin');
$this->assertTrue(Subsite::hasMainSitePermission($admin, array("ADMIN")), 'ADMIN permissions granted for super-admin');
$this->assertFalse(Subsite::hasMainSitePermission($subsite1admin, array("ADMIN")), 'ADMIN permissions (on main site) denied for subsite1 admin');
$this->assertFalse(Subsite::hasMainSitePermission($subsite1admin, array("CMS_ACCESS_CMSMain")), 'CMS_ACCESS_CMSMain (on main site) denied for subsite1 admin');
$this->assertFalse(Subsite::hasMainSitePermission($allsubsitesauthor, array("ADMIN")), 'ADMIN permissions (on main site) denied for CMS author with edit rights on all subsites');
$this->assertTrue(Subsite::hasMainSitePermission($allsubsitesauthor, array("CMS_ACCESS_CMSMain")), 'CMS_ACCESS_CMSMain (on main site) granted for CMS author with edit rights on all subsites');
$this->assertFalse(Subsite::hasMainSitePermission($subsite1member, array("ADMIN")), 'ADMIN (on main site) denied for subsite1 subsite1 cms author');
$this->assertFalse(Subsite::hasMainSitePermission($subsite1member, array("CMS_ACCESS_CMSMain")), 'CMS_ACCESS_CMSMain (on main site) denied for subsite1 cms author');
}