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


PHP Permission::get_members_by_permission方法代码示例

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


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

示例1: PublisherMembers

 /**
  * Returns a DataObjectSet of all the members that can publish pages
  * on this site by default
  */
 public function PublisherMembers()
 {
     if ($this->owner->CanPublishType == 'OnlyTheseUsers') {
         $groups = $this->owner->PublisherGroups();
         $members = new DataObjectSet();
         if ($groups) {
             foreach ($groups as $group) {
                 $members->merge($group->Members());
             }
         }
         // Default to ADMINs, if something goes wrong
         if (!$members->Count()) {
             $group = Permission::get_groups_by_permission('ADMIN')->first();
             $members = $group->Members();
         }
         return $members;
     } else {
         if ($this->owner->CanPublishType == 'LoggedInUsers') {
             // We don't want to return every user in the CMS....
             return Permission::get_members_by_permission('CMS_ACCESS_CMSMain');
         } else {
             $group = Permission::get_groups_by_permission('ADMIN')->first();
             return $group->Members();
         }
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-cmsworkflow,代码行数:30,代码来源:SiteConfigTwoStepWorkflow.php

示例2: PublisherMembers

 /**
  * Returns a DataObjectSet of all the members that can publish this page
  */
 public function PublisherMembers()
 {
     if ($this->owner->CanPublishType == 'OnlyTheseUsers') {
         $groups = $this->owner->PublisherGroups();
         $members = new DataObjectSet();
         if ($groups) {
             foreach ($groups as $group) {
                 $members->merge($group->Members());
             }
         }
         // Default to ADMINs, if something goes wrong
         if (!$members->Count()) {
             $group = Permission::get_groups_by_permission('ADMIN')->first();
             $members = $group->Members();
         }
         return $members;
     } elseif ($this->owner->CanPublishType == 'Inherit') {
         if ($this->owner->Parent()->Exists()) {
             return $this->owner->Parent()->PublisherMembers();
         } else {
             return SiteConfig::current_site_config()->PublisherMembers();
         }
     } elseif ($this->owner->CanPublishType == 'LoggedInUsers') {
         return Permission::get_members_by_permission('CMS_ACCESS_CMSMain');
     } else {
         $group = Permission::get_groups_by_permission('ADMIN')->first();
         return $group->Members();
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-cmsworkflow,代码行数:32,代码来源:SiteTreeCMSTwoStepWorkflow.php

示例3: getUsersList

 /**
  * Gets a list of users in the database
  * @return {array} Returns a standard response array
  */
 public function getUsersList()
 {
     $response = CodeBank_ClientAPI::responseBase();
     $members = Permission::get_members_by_permission(array('ADMIN', 'CODE_BANK_ACCESS'));
     foreach ($members as $member) {
         $response['data'][] = array('id' => $member->ID, 'username' => $member->Email, 'lastLogin' => $member->LastVisited);
     }
     return $response;
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:13,代码来源:CodeBankAdministration.php

示例4: testGettingMembersByPermission

 /**
  * Ensure the the get_*_by_permission functions are permission role aware
  */
 public function testGettingMembersByPermission()
 {
     $accessMember = $this->objFromFixture('Member', 'access');
     $accessAuthor = $this->objFromFixture('Member', 'author');
     $result = Permission::get_members_by_permission(array('CMS_ACCESS_SecurityAdmin'));
     $resultIDs = $result ? $result->column() : array();
     $this->assertContains($accessMember->ID, $resultIDs, 'Member is found via a permission attached to a role');
     $this->assertNotContains($accessAuthor->ID, $resultIDs);
 }
开发者ID:normann,项目名称:sapphire,代码行数:12,代码来源:PermissionTest.php

示例5: testDefaultAdmin

 public function testDefaultAdmin()
 {
     $adminMembers = Permission::get_members_by_permission('ADMIN');
     $this->assertEquals(0, $adminMembers->count());
     $admin = Member::default_admin();
     $this->assertInstanceOf('Member', $admin);
     $this->assertTrue(Permission::checkMember($admin, 'ADMIN'));
     $this->assertEquals($admin->Email, Security::default_admin_username());
     $this->assertNull($admin->Password);
 }
开发者ID:nickbooties,项目名称:silverstripe-framework,代码行数:10,代码来源:SecurityDefaultAdminTest.php

示例6: runAsAdmin

 public function runAsAdmin($closure)
 {
     // TODO This is so horribly ugly - is there no better way to know that we're in dev/build for the first time?
     $admins = Permission::get_members_by_permission('ADMIN')->First();
     if (!$admins) {
         return;
     }
     $admin = Security::findAnAdministrator();
     return $this->run($closure, $admin);
 }
开发者ID:nyeholt,项目名称:silverstripe-restrictedobjects,代码行数:10,代码来源:TransactionManager.php

示例7: blogOwners

 /**
  * Get members who have BLOGMANAGEMENT and ADMIN permission
  */
 function blogOwners($sort = 'Name', $direction = "ASC")
 {
     $adminMembers = Permission::get_members_by_permission('ADMIN');
     $blogOwners = Permission::get_members_by_permission('BLOGMANAGEMENT');
     if (!$adminMembers) {
         $adminMembers = new DataObjectSet();
     }
     if (!$blogOwners) {
         $blogOwners = new DataObjectSet();
     }
     $blogOwners->merge($adminMembers);
     $blogOwners->sort($sort, $direction);
     $this->extend('extendBlogOwners', $blogOwners);
     return $blogOwners;
 }
开发者ID:nicmart,项目名称:comperio-site,代码行数:18,代码来源:BlogHolder.php

示例8: updateCMSFields

 /**
  *
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     $helpText = LiteralField::create("ContentReviewHelp", _t("ContentReview.DEFAULTSETTINGSHELP", "These content review settings will apply to all pages that does not have specific Content Review schedule."));
     $fields->addFieldToTab("Root.ContentReview", $helpText);
     $reviewFrequency = DropdownField::create("ReviewPeriodDays", _t("ContentReview.REVIEWFREQUENCY", "Review frequency"), SiteTreeContentReview::get_schedule())->setDescription(_t("ContentReview.REVIEWFREQUENCYDESCRIPTION", "The review date will be set to this far in the future whenever the page is published"));
     $fields->addFieldToTab("Root.ContentReview", $reviewFrequency);
     $users = Permission::get_members_by_permission(array("CMS_ACCESS_CMSMain", "ADMIN"));
     $usersMap = $users->map("ID", "Title")->toArray();
     asort($usersMap);
     $userField = ListboxField::create("OwnerUsers", _t("ContentReview.PAGEOWNERUSERS", "Users"), $usersMap)->setMultiple(true)->setAttribute("data-placeholder", _t("ContentReview.ADDUSERS", "Add users"))->setDescription(_t("ContentReview.OWNERUSERSDESCRIPTION", "Page owners that are responsible for reviews"));
     $fields->addFieldToTab("Root.ContentReview", $userField);
     $groupsMap = array();
     foreach (Group::get() as $group) {
         // Listboxfield values are escaped, use ASCII char instead of »
         $groupsMap[$group->ID] = $group->getBreadcrumbs(" > ");
     }
     asort($groupsMap);
     $groupField = ListboxField::create("OwnerGroups", _t("ContentReview.PAGEOWNERGROUPS", "Groups"), $groupsMap)->setMultiple(true)->setAttribute("data-placeholder", _t("ContentReview.ADDGROUP", "Add groups"))->setDescription(_t("ContentReview.OWNERGROUPSDESCRIPTION", "Page owners that are responsible for reviews"));
     $fields->addFieldToTab("Root.ContentReview", $groupField);
 }
开发者ID:helpfulrobot,项目名称:silverstripe-contentreview,代码行数:24,代码来源:ContentReviewDefaultSettings.php

示例9: requireDefaultRecords

 function requireDefaultRecords()
 {
     // Default groups should've been built by Group->requireDefaultRecords() already
     // Find or create ADMIN group
     $adminGroups = Permission::get_groups_by_permission('ADMIN');
     if (!$adminGroups) {
         singleton('Group')->requireDefaultRecords();
         $adminGroups = Permission::get_groups_by_permission('ADMIN');
     }
     $adminGroup = $adminGroups->First();
     // Add a default administrator to the first ADMIN group found (most likely the default
     // group created through Group->requireDefaultRecords()).
     $admins = Permission::get_members_by_permission('ADMIN');
     if (!$admins) {
         // Leave 'Email' and 'Password' are not set to avoid creating
         // persistent logins in the database. See Security::setDefaultAdmin().
         $admin = Object::create('Member');
         $admin->FirstName = _t('Member.DefaultAdminFirstname', 'Default Admin');
         $admin->write();
         $admin->Groups()->add($adminGroup);
     }
 }
开发者ID:Raiser,项目名称:Praktikum,代码行数:22,代码来源:Member.php

示例10: updateCMSFields

 /**
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     $helpText = LiteralField::create('ContentReviewHelp', _t('ContentReview.DEFAULTSETTINGSHELP', 'These content review settings will apply to all pages that does not have specific Content Review schedule.'));
     $fields->addFieldToTab('Root.ContentReview', $helpText);
     $reviewFrequency = DropdownField::create('ReviewPeriodDays', _t('ContentReview.REVIEWFREQUENCY', 'Review frequency'), SiteTreeContentReview::get_schedule())->setDescription(_t('ContentReview.REVIEWFREQUENCYDESCRIPTION', 'The review date will be set to this far in the future whenever the page is published'));
     $fields->addFieldToTab('Root.ContentReview', $reviewFrequency);
     $users = Permission::get_members_by_permission(array('CMS_ACCESS_CMSMain', 'ADMIN'));
     $usersMap = $users->map('ID', 'Title')->toArray();
     asort($usersMap);
     $userField = ListboxField::create('OwnerUsers', _t('ContentReview.PAGEOWNERUSERS', 'Users'), $usersMap)->setMultiple(true)->setAttribute('data-placeholder', _t('ContentReview.ADDUSERS', 'Add users'))->setDescription(_t('ContentReview.OWNERUSERSDESCRIPTION', 'Page owners that are responsible for reviews'));
     $fields->addFieldToTab('Root.ContentReview', $userField);
     $groupsMap = array();
     foreach (Group::get() as $group) {
         // Listboxfield values are escaped, use ASCII char instead of »
         $groupsMap[$group->ID] = $group->getBreadcrumbs(' > ');
     }
     asort($groupsMap);
     $groupField = ListboxField::create('OwnerGroups', _t('ContentReview.PAGEOWNERGROUPS', 'Groups'), $groupsMap)->setMultiple(true)->setAttribute('data-placeholder', _t('ContentReview.ADDGROUP', 'Add groups'))->setDescription(_t('ContentReview.OWNERGROUPSDESCRIPTION', 'Page owners that are responsible for reviews'));
     $fields->addFieldToTab('Root.ContentReview', $groupField);
     $FirstReviewDaysBefore = NumericField::create('FirstReviewDaysBefore', _t('ContentReview.FIRSTREVIEWDAYSBEFORE', 'First review reminder # days before final review'));
     $SecondReviewDaysBefore = NumericField::create('SecondReviewDaysBefore', _t('ContentReview.SECONDREVIEWDAYSBEFORE', 'Second review reminder # days before final review'));
     // Email content
     $fields->addFieldsToTab('Root.ContentReview', array(TextField::create('ReviewFrom', _t('ContentReview.EMAILFROM', 'From email address'))->setRightTitle(_t('Review.EMAILFROM_RIGHTTITLE', 'e.g: do-not-reply@site.com')), $FirstReviewDaysBefore, $SecondReviewDaysBefore, TextField::create('ReviewReminderEmail', 'Review reminder email address')->setRightTitle('e.g: review.reminders@site.com'), TextField::create('ReviewSubjectReminder', _t('ContentReview.EMAILSUBJECTREMINDER', 'Subject line - reminder')), TextField::create('ReviewSubject', _t('ContentReview.EMAILSUBJECT', 'Subject line - Review due')), TextAreaField::create('ReviewBodyFirstReminder', _t('ContentReview.EMAILTEMPLATEFIRSTREMINDER', 'Email body - First reminder')), TextAreaField::create('ReviewBodySecondReminder', _t('ContentReview.EMAILTEMPLATESECONDREMINDER', 'Email body - Second reminder')), TextAreaField::create('ReviewBody', _t('ContentReview.EMAILTEMPLATE', 'Email body - Review due')), LiteralField::create('TemplateHelp', $this->owner->renderWith('ContentReviewAdminHelp'))));
 }
开发者ID:GOVTNZ,项目名称:silverstripe-contentreview,代码行数:27,代码来源:ContentReviewDefaultSettings.php

示例11: find_admin_session_by_accesstoken

 /**
  * We create / get a valid session by a defined accesstoken
  */
 static function find_admin_session_by_accesstoken($token)
 {
     $session = self::find_by_accesstoken($token);
     if (!$session) {
         if (!(strlen(trim($token)) > 6)) {
             return user_error('admin authtoken must be at least 6 chars long');
         }
         $session = AuthSession::create(array("UID" => $token));
         $session->write();
     }
     if (!$session->Member() || !$session->Member()->inGroup('ADMIN')) {
         // we need to attach an admin user to session to fulfill a valid session datao object with admin privileges
         $admin = Permission::get_members_by_permission('ADMIN')->First();
         $session->Member = $admin;
         $session->MemberID = $admin->ID;
         $session->write();
     }
     if (!$session->isValid()) {
         // renew session
         $session->setValidInMinutesFromNow(302400);
         $session->write();
     }
     return $session;
 }
开发者ID:helpfulrobot,项目名称:pstaender-silverstripe-restful-api,代码行数:27,代码来源:AuthSession.php

示例12: getCandidateUsers

 /**
  * Gets the list of user candidates to be assigned to assist with this blog.
  *
  * @return SS_List
  */
 protected function getCandidateUsers()
 {
     if ($this->config()->grant_user_access) {
         $list = Member::get();
         $this->extend('updateCandidateUsers', $list);
         return $list;
     } else {
         return Permission::get_members_by_permission($this->config()->grant_user_permission);
     }
 }
开发者ID:micmania1,项目名称:silverstripe-blog,代码行数:15,代码来源:Blog.php

示例13: findAnAdministrator

 /**
  * Return an existing member with administrator privileges, or create one of necessary.
  *
  * Will create a default 'Administrators' group if no group is found
  * with an ADMIN permission. Will create a new 'Admin' member with administrative permissions
  * if no existing Member with these permissions is found.
  *
  * Important: Any newly created administrator accounts will NOT have valid
  * login credentials (Email/Password properties), which means they can't be used for login
  * purposes outside of any default credentials set through {@link Security::setDefaultAdmin()}.
  *
  * @return Member
  */
 public static function findAnAdministrator()
 {
     // coupling to subsites module
     $origSubsite = null;
     if (is_callable('Subsite::changeSubsite')) {
         $origSubsite = Subsite::currentSubsiteID();
         Subsite::changeSubsite(0);
     }
     $member = null;
     // find a group with ADMIN permission
     $adminGroup = DataObject::get('Group')->where(array('"Permission"."Code"' => 'ADMIN'))->sort('"Group"."ID"')->innerJoin("Permission", '"Group"."ID" = "Permission"."GroupID"')->First();
     if (is_callable('Subsite::changeSubsite')) {
         Subsite::changeSubsite($origSubsite);
     }
     if ($adminGroup) {
         $member = $adminGroup->Members()->First();
     }
     if (!$adminGroup) {
         singleton('Group')->requireDefaultRecords();
     }
     if (!$member) {
         singleton('Member')->requireDefaultRecords();
         $member = Permission::get_members_by_permission('ADMIN')->First();
     }
     return $member;
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:39,代码来源:Security.php

示例14: findAnAdministrator

 /**
  * Return an existing member with administrator privileges, or create one of necessary.
  *
  * Will create a default 'Administrators' group if no group is found
  * with an ADMIN permission. Will create a new 'Admin' member with administrative permissions
  * if no existing Member with these permissions is found.
  *
  * Important: Any newly created administrator accounts will NOT have valid
  * login credentials (Email/Password properties), which means they can't be used for login
  * purposes outside of any default credentials set through {@link Security::setDefaultAdmin()}.
  *
  * @return Member
  */
 public static function findAnAdministrator()
 {
     // coupling to subsites module
     $origSubsite = null;
     if (is_callable('Subsite::changeSubsite')) {
         $origSubsite = Subsite::currentSubsiteID();
         Subsite::changeSubsite(0);
     }
     $member = null;
     // find a group with ADMIN permission
     $adminGroup = Permission::get_groups_by_permission('ADMIN')->First();
     if (is_callable('Subsite::changeSubsite')) {
         Subsite::changeSubsite($origSubsite);
     }
     if ($adminGroup) {
         $member = $adminGroup->Members()->First();
     }
     if (!$adminGroup) {
         singleton('Group')->requireDefaultRecords();
         $adminGroup = Permission::get_groups_by_permission('ADMIN')->First();
     }
     if (!$member) {
         singleton('Member')->requireDefaultRecords();
         $member = Permission::get_members_by_permission('ADMIN')->First();
     }
     if (!$member) {
         $member = Member::default_admin();
     }
     if (!$member) {
         // Failover to a blank admin
         $member = Member::create();
         $member->FirstName = _t('Member.DefaultAdminFirstname', 'Default Admin');
         $member->write();
         // Add member to group instead of adding group to member
         // This bypasses the privilege escallation code in Member_GroupSet
         $adminGroup->DirectMembers()->add($member);
     }
     return $member;
 }
开发者ID:miamollie,项目名称:echoAerial,代码行数:52,代码来源:Security.php

示例15: getCandidateUsers

 /**
  * Gets the list of user candidates to be assigned to assist with this blog.
  *
  * @return SS_List
  */
 protected function getCandidateUsers()
 {
     if ($this->config()->grant_user_access) {
         return Member::get();
     } else {
         return Permission::get_members_by_permission($this->config()->grant_user_permission);
     }
 }
开发者ID:unculture,项目名称:silverstripe-blog,代码行数:13,代码来源:Blog.php


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