当前位置: 首页>>代码示例>>PHP>>正文


PHP DataObjectSet::insertFirst方法代码示例

本文整理汇总了PHP中DataObjectSet::insertFirst方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObjectSet::insertFirst方法的具体用法?PHP DataObjectSet::insertFirst怎么用?PHP DataObjectSet::insertFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataObjectSet的用法示例。


在下文中一共展示了DataObjectSet::insertFirst方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: DataObjectSet

 /**
  * Return the subsites that the current user can access.
  * Look for one of the given permission codes on the site.
  *
  * Sites and Templates will only be included if they have a Title
  *
  * @param $permCode array|string Either a single permission code or an array of permission codes.
  * @param $includeMainSite If true, the main site will be included if appropriate.
  * @param $mainSiteTitle The label to give to the main site
  */
 function accessible_sites($permCode, $includeMainSite = false, $mainSiteTitle = "Main site", $member = null)
 {
     // Rationalise member arguments
     if (!$member) {
         $member = Member::currentUser();
     }
     if (!$member) {
         return new DataObjectSet();
     }
     if (!is_object($member)) {
         $member = DataObject::get_by_id('Member', $member);
     }
     if (is_array($permCode)) {
         $SQL_codes = "'" . implode("', '", Convert::raw2sql($permCode)) . "'";
     } else {
         $SQL_codes = "'" . Convert::raw2sql($permCode) . "'";
     }
     $templateClassList = "'" . implode("', '", ClassInfo::subclassesFor("Subsite_Template")) . "'";
     $subsites = DataObject::get('Subsite', "\"Subsite\".\"Title\" != ''", '', "LEFT JOIN \"Group_Subsites\" \n\t\t\t\tON \"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"\n\t\t\tINNER JOIN \"Group\" ON \"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\"\n\t\t\t\tOR \"Group\".\"AccessAllSubsites\" = 1\n\t\t\tINNER JOIN \"Group_Members\" \n\t\t\t\tON \"Group_Members\".\"GroupID\"=\"Group\".\"ID\"\n\t\t\t\tAND \"Group_Members\".\"MemberID\" = {$member->ID}\n\t\t\tINNER JOIN \"Permission\" \n\t\t\t\tON \"Group\".\"ID\"=\"Permission\".\"GroupID\"\n\t\t\t\tAND \"Permission\".\"Code\" IN ({$SQL_codes}, 'ADMIN')");
     $rolesSubsites = DataObject::get('Subsite', "\"Subsite\".\"Title\" != ''", '', "LEFT JOIN \"Group_Subsites\" \n\t\t\t\tON \"Group_Subsites\".\"SubsiteID\" = \"Subsite\".\"ID\"\n\t\t\tINNER JOIN \"Group\" ON \"Group\".\"ID\" = \"Group_Subsites\".\"GroupID\"\n\t\t\t\tOR \"Group\".\"AccessAllSubsites\" = 1\n\t\t\tINNER JOIN \"Group_Members\" \n\t\t\t\tON \"Group_Members\".\"GroupID\"=\"Group\".\"ID\"\n\t\t\t\tAND \"Group_Members\".\"MemberID\" = {$member->ID}\n\t\t\tINNER JOIN \"Group_Roles\"\n\t\t\t\tON \"Group_Roles\".\"GroupID\"=\"Group\".\"ID\"\n\t\t\tINNER JOIN \"PermissionRole\"\n\t\t\t\tON \"Group_Roles\".\"PermissionRoleID\"=\"PermissionRole\".\"ID\"\n\t\t\tINNER JOIN \"PermissionRoleCode\"\n\t\t\t\tON \"PermissionRole\".\"ID\"=\"PermissionRoleCode\".\"RoleID\"\n\t\t\t\tAND \"PermissionRoleCode\".\"Code\" IN ({$SQL_codes}, 'ADMIN')");
     if (!$subsites && $rolesSubsites) {
         return $rolesSubsites;
     }
     if ($rolesSubsites) {
         foreach ($rolesSubsites as $subsite) {
             if (!$subsites->containsIDs(array($subsite->ID))) {
                 $subsites->push($subsite);
             }
         }
     }
     // Include the main site
     if (!$subsites) {
         $subsites = new DataObjectSet();
     }
     if ($includeMainSite) {
         if (!is_array($permCode)) {
             $permCode = array($permCode);
         }
         if (self::hasMainSitePermission($member, $permCode)) {
             $mainSite = new Subsite();
             $mainSite->Title = $mainSiteTitle;
             $subsites->insertFirst($mainSite);
         }
     }
     return $subsites;
 }
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:56,代码来源:Subsite.php


注:本文中的DataObjectSet::insertFirst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。