當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Subsite::hasMainSitePermission方法代碼示例

本文整理匯總了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;
 }
開發者ID:hafriedlander,項目名稱:silverstripe-config-experiment,代碼行數:25,代碼來源:RelatedPageLink.php

示例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');
 }
開發者ID:helpfulrobot,項目名稱:mikenz-silverstripe-simplesubsites,代碼行數:15,代碼來源:SubsiteTest.php


注:本文中的Subsite::hasMainSitePermission方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。