当前位置: 首页>>代码示例>>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;未经允许,请勿转载。