本文整理汇总了PHP中Group::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::get方法的具体用法?PHP Group::get怎么用?PHP Group::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Group
的用法示例。
在下文中一共展示了Group::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save()
{
$form = Form::load('logbook.views.AddBlogEntry');
if($form->validate())
{
$auth = new Author();
$auth->clause('user_id',Application::current()->user()->id());
if($auth->id())
{
$item = new Entry();
$item->parse();
$item->set('author_id',$auth->id());
if(!Application::param('entry_date'))
$item->set('entry_date',date('Y-m-d H:i:s'));
$item->synch();
Entry::setTagsAndSave($item,Application::param('entry_tags'));
$group = new Group();
$group->noForeign();
$author_id = $item->get('author_id');
$entry_id = $item->get('entry_id');
if($groups = $group->fetch())
{
foreach($groups as $group)
{
if(file_exists(Application::MANAGED_CODE.'lbk_default_access_'.$group->get('access_id')))
{
$data = file_get_contents(Application::MANAGED_CODE.'lbk_default_access_'.$group->get('access_id'));
$perms = unserialize($data);
ManageGroupAccess::setPermissionsOnEntryForGroup($author_id,$entry_id,$group->id(),$perms);
}
}
}
Application::setUrlParam('author_id',Application::param('author_id'));
Application::setUrlParam('entry_id',Application::param('entry_id'));
LogbookAccess::publishLookupTables();
$this->redirectOnSave();
}
else
die('You are not an author!');
}
}
示例2: doAdd
public function doAdd(array $data)
{
if ($Member = Member::get()->filter(array("Email" => $data['Email']))->first()) {
$this->addErrorMessage('Email', 'Die Emailadresse ist bereits vergeben.', 'bad');
$this->controller->redirectBack();
return false;
}
$Member = new Member();
$this->saveInto($Member);
$Member->write();
// find a group with ADMIN permission
$adminGroup = Group::get()->where("Code='administrators'")->First();
// Member noch als Administrator festlegen
if (isset($data['Admin'])) {
$adminGroup->Members()->add($Member);
} else {
$adminGroup->Members()->remove($Member);
}
// find a group with ADMIN permission
$authorGroup = Group::get()->where("Code='content-authors'")->First();
// Member noch als Administrator festlegen
if (isset($data['Author'])) {
$authorGroup->Members()->add($Member);
} else {
$authorGroup->Members()->remove($Member);
}
$this->controller->redirect('administration/members');
}
示例3: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->removeFieldFromTab('Root', 'Pages');
$fields->removeFieldsFromTab('Root.Main', array('SortOrder', 'showBlockbyClass', 'shownInClass', 'MemberVisibility'));
$fields->addFieldToTab('Root.Main', LiteralField::create('Status', 'Published: ' . $this->Published()), 'Title');
$memberGroups = Group::get();
$sourcemap = $memberGroups->map('Code', 'Title');
$source = array('anonymous' => 'Anonymous visitors');
foreach ($sourcemap as $mapping => $key) {
$source[$mapping] = $key;
}
$memberVisibility = new CheckboxSetField($name = "MemberVisibility", $title = "Show block for specific groups", $source);
$memberVisibility->setDescription('Show this block only for the selected group(s). If you select no groups, the block will be visible to all members.');
$availabelClasses = $this->availableClasses();
$inClass = new CheckboxSetField($name = "shownInClass", $title = "Show block for specific content types", $availabelClasses);
$filterSelector = OptionsetField::create('showBlockbyClass', 'Choose filter set', array('0' => 'by page', '1' => 'by page/data type'))->setDescription('<p><br /><strong>by page</strong>: block will be displayed in the selected page(s)<br /><strong>by page/data type</strong>: block will be displayed on the pages created with the particular page/data type. e.g. is <strong>"InternalPage"</strong> is picked, the block will be displayed, and will ONLY be displayed on all <strong>Internal Pages</strong></p>');
$availablePages = Page::get()->exclude('ClassName', array('ErrorPage', 'RedirectorPage', 'VirtualPage'));
$pageSelector = new CheckboxSetField($name = "Pages", $title = "Show on Page(s)", $availablePages->map('ID', 'Title'));
if ($this->canConfigPageAndType(Member::currentUser())) {
$fields->addFieldsToTab('Root.VisibilitySettings', array($filterSelector, $pageSelector, $inClass));
}
if ($this->canConfigMemberVisibility(Member::currentUser())) {
$fields->addFieldToTab('Root.VisibilitySettings', $memberVisibility);
}
if (!$fields->fieldByName('Options')) {
$fields->insertBefore($right = RightSidebar::create('Options'), 'Root');
}
$fields->addFieldsToTab('Options', array(CheckboxField::create('addMarginTop', 'add "margin-top" class to block wrapper'), CheckboxField::create('addMarginBottom', 'add "margin-bottom" class to block wrapper')));
return $fields;
}
示例4: Register
public function Register($data, Form $form)
{
if (!Member::currentUser()) {
$member = new Member();
// Debug::show($form);
$form->saveInto($member);
if (Group::get()->filter('Title', 'Subscribed')->count() == 0) {
$group = Group::create();
$group->Title = 'Subscribed';
$group->write();
} else {
$group = Group::get()->filter('Title', 'Subscribed')->First();
}
if (Member::get()->filter('Email', $data['Email'])) {
$form->addErrorMessage('Email', 'That email address is already in use. <a href="Security/login">login</a>', 'bad', true, true);
//Controller::curr()->redirect('register');
} else {
//has to be called before setting group
$member->write();
if (!$member->inGroup($group)) {
$member->Groups()->add($group);
}
}
}
Controller::curr()->redirectBack();
}
示例5: requireDefaultRecords
public function requireDefaultRecords()
{
parent::requireDefaultRecords();
// Add default author group if no other group exists
$frontend_group = Group::get()->filter("Code", "users-frontend");
if (!$frontend_group->exists()) {
$frontend_group = new Group();
$frontend_group->Code = 'users-frontend';
$frontend_group->Title = "Frontend Users";
$frontend_group->Sort = 1;
$frontend_group->write();
Permission::grant($frontend_group->ID, 'USERS_MANAGE_ACCOUNT');
DB::alteration_message('Front end users group created', 'created');
}
// Add a verified users group (only used if we turn on
// verification)
$verify_group = Group::get()->filter("Code", "users-verified");
if (!$verify_group->exists()) {
$verify_group = new Group();
$verify_group->Code = 'users-verified';
$verify_group->Title = "Verified Users";
$verify_group->Sort = 1;
$verify_group->write();
Permission::grant($verify_group->ID, 'USERS_VERIFIED');
DB::alteration_message('Verified users group created', 'created');
}
}
示例6: getEditForm
public function getEditForm($id = null, $fields = null)
{
// TODO Duplicate record fetching (see parent implementation)
if (!$id) {
$id = $this->currentPageID();
}
$form = parent::getEditForm($id);
// TODO Duplicate record fetching (see parent implementation)
$record = $this->getRecord($id);
if ($record && !$record->canView()) {
return Security::permissionFailure($this);
}
$memberList = GridField::create('Members', false, Member::get(), $memberListConfig = GridFieldConfig_RecordEditor::create()->addComponent(new GridFieldButtonRow('after'))->addComponent(new GridFieldExportButton('buttons-after-left')))->addExtraClass("members_grid");
if ($record && method_exists($record, 'getValidator')) {
$validator = $record->getValidator();
} else {
$validator = Injector::inst()->get('Member')->getValidator();
}
$memberListConfig->getComponentByType('GridFieldDetailForm')->setValidator($validator);
$groupList = GridField::create('Groups', false, Group::get(), GridFieldConfig_RecordEditor::create());
$columns = $groupList->getConfig()->getComponentByType('GridFieldDataColumns');
$columns->setDisplayFields(array('Breadcrumbs' => singleton('Group')->fieldLabel('Title')));
$columns->setFieldFormatting(array('Breadcrumbs' => function ($val, $item) {
return Convert::raw2xml($item->getBreadcrumbs(' > '));
}));
$fields = new FieldList($root = new TabSet('Root', $usersTab = new Tab('Users', _t('SecurityAdmin.Users', 'Users'), $memberList, new LiteralField('MembersCautionText', sprintf('<p class="caution-remove"><strong>%s</strong></p>', _t('SecurityAdmin.MemberListCaution', 'Caution: Removing members from this list will remove them from all groups and the' . ' database')))), $groupsTab = new Tab('Groups', singleton('Group')->i18n_plural_name(), $groupList)), new HiddenField('ID', false, 0));
// Add import capabilities. Limit to admin since the import logic can affect assigned permissions
if (Permission::check('ADMIN')) {
$fields->addFieldsToTab('Root.Users', array(new HeaderField(_t('SecurityAdmin.IMPORTUSERS', 'Import users'), 3), new LiteralField('MemberImportFormIframe', sprintf('<iframe src="%s" id="MemberImportFormIframe" width="100%%" height="250px" frameBorder="0">' . '</iframe>', $this->Link('memberimport')))));
$fields->addFieldsToTab('Root.Groups', array(new HeaderField(_t('SecurityAdmin.IMPORTGROUPS', 'Import groups'), 3), new LiteralField('GroupImportFormIframe', sprintf('<iframe src="%s" id="GroupImportFormIframe" width="100%%" height="250px" frameBorder="0">' . '</iframe>', $this->Link('groupimport')))));
}
// Tab nav in CMS is rendered through separate template
$root->setTemplate('CMSTabSet');
// Add roles editing interface
if (Permission::check('APPLY_ROLES')) {
$rolesField = GridField::create('Roles', false, PermissionRole::get(), GridFieldConfig_RecordEditor::create());
$rolesTab = $fields->findOrMakeTab('Root.Roles', _t('SecurityAdmin.TABROLES', 'Roles'));
$rolesTab->push($rolesField);
}
$actionParam = $this->getRequest()->param('Action');
if ($actionParam == 'groups') {
$groupsTab->addExtraClass('ui-state-active');
} elseif ($actionParam == 'users') {
$usersTab->addExtraClass('ui-state-active');
} elseif ($actionParam == 'roles') {
$rolesTab->addExtraClass('ui-state-active');
}
$actions = new FieldList();
$form = Form::create($this, 'EditForm', $fields, $actions)->setHTMLID('Form_EditForm');
$form->addExtraClass('cms-edit-form');
$form->setTemplate($this->getTemplatesWithSuffix('_EditForm'));
// Tab nav in CMS is rendered through separate template
if ($form->Fields()->hasTabset()) {
$form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
}
$form->addExtraClass('center ss-tabset cms-tabset ' . $this->BaseCSSClasses());
$form->setAttribute('data-pjax-fragment', 'CurrentForm');
$this->extend('updateEditForm', $form);
return $form;
}
示例7: TechnicalCommitteeMembers
public function TechnicalCommitteeMembers()
{
//Group_Member
$group = Group::get()->filter('Code', 'technical-committee')->first();
$res = $group->getManyManyComponents("Members", '', 'Member.FirstName, Member.SurName');
return $res;
}
示例8: StartSurvey
function StartSurvey($data, $form)
{
//Check for existing member email address
if ($member = Member::get()->filter('Email', Convert::raw2sql($data['Email']))->first()) {
//Set error message
$form->AddErrorMessage('Email', "Sorry, that email address already exists. Please choose another or login with that email.", 'bad');
//Set form data from submitted values
Session::set("FormInfo.Form_DeploymentSurveyRegistrationForm.data", $data);
//Return back to form
return Controller::curr()->redirectBack();
}
//Otherwise create new member and log them in
$Member = new Member();
$form->saveInto($Member);
$Member->write();
//Find or create the 'user' group
if (!($userGroup = Group::get()->filter('Code', 'users')->first())) {
$userGroup = new Group();
$userGroup->Code = "users";
$userGroup->Title = "Users";
$userGroup->Write();
$Member->Groups()->add($userGroup);
}
//Add member to user group
$Member->Groups()->add($userGroup);
$BackURL = Controller::curr()->Link('AboutYou');
return OpenStackIdCommon::loginMember($Member, $BackURL);
}
示例9: SupportingCastMembers
public function SupportingCastMembers()
{
//Group_Member
$group = Group::get()->filter('Code', 'supporting-cast')->first();
$res = $group->getManyManyComponents("Members", '', 'Group_Members.SortOrder ASC');
return $res;
}
示例10: doEdit
public function doEdit(array $data)
{
if ($Member = Member::get()->byID($data['ID'])) {
$this->saveInto($Member);
$Member->changePassword($data['Password']['_Password']);
$Member->Changed = true;
$Member->write();
// find a group with ADMIN permission
$adminGroup = Group::get()->where("Code='administrators'")->First();
// Member noch als Administrator festlegen
if (isset($data['Admin'])) {
$adminGroup->Members()->add($Member);
} else {
$adminGroup->Members()->remove($Member);
}
// find a group with ADMIN permission
$authorGroup = Group::get()->where("Code='content-authors'")->First();
// Member noch als Administrator festlegen
if (isset($data['Author'])) {
$authorGroup->Members()->add($Member);
} else {
$authorGroup->Members()->remove($Member);
}
}
$this->controller->redirect('administration/members');
}
示例11: processRecord
public function processRecord($record, $columnMap, &$results, $preview = false)
{
$objID = parent::processRecord($record, $columnMap, $results, $preview);
$_cache_groupByCode = array();
// Add to predefined groups
$member = DataObject::get_by_id($this->objectClass, $objID);
foreach ($this->groups as $group) {
// TODO This isnt the most memory effective way to add members to a group
$member->Groups()->add($group);
}
// Add to groups defined in CSV
if (isset($record['Groups']) && $record['Groups']) {
$groupCodes = explode(',', $record['Groups']);
foreach ($groupCodes as $groupCode) {
$groupCode = Convert::raw2url($groupCode);
if (!isset($_cache_groupByCode[$groupCode])) {
$group = Group::get()->filter('Code', $groupCode)->first();
if (!$group) {
$group = new Group();
$group->Code = $groupCode;
$group->Title = $groupCode;
$group->write();
}
$member->Groups()->add($group);
$_cache_groupByCode[$groupCode] = $group;
}
}
}
$member->destroy();
unset($member);
return $objID;
}
示例12: iAmLoggedInWithPermissions
/**
* Creates a member in a group with the correct permissions.
* Example: Given I am logged in with "ADMIN" permissions
*
* @Given /^I am logged in with "([^"]*)" permissions$/
*/
function iAmLoggedInWithPermissions($permCode)
{
if (!isset($this->cache_generatedMembers[$permCode])) {
$group = \Group::get()->filter('Title', "{$permCode} group")->first();
if (!$group) {
$group = \Injector::inst()->create('Group');
}
$group->Title = "{$permCode} group";
$group->write();
$permission = \Injector::inst()->create('Permission');
$permission->Code = $permCode;
$permission->write();
$group->Permissions()->add($permission);
$member = \DataObject::get_one('Member', sprintf('"Email" = \'%s\'', "{$permCode}@example.org"));
if (!$member) {
$member = \Injector::inst()->create('Member');
}
// make sure any validation for password is skipped, since we're not testing complexity here
$validator = \Member::password_validator();
\Member::set_password_validator(null);
$member->FirstName = $permCode;
$member->Surname = "User";
$member->Email = "{$permCode}@example.org";
$member->PasswordEncryption = "none";
$member->changePassword('Secret!123');
$member->write();
$group->Members()->add($member);
\Member::set_password_validator($validator);
$this->cache_generatedMembers[$permCode] = $member;
}
return new Step\Given(sprintf('I log in with "%s" and "%s"', "{$permCode}@example.org", 'Secret!123'));
}
示例13: onAfterInit
/**
* If the REMOTE_USER is set and is in the Member table, log that member in. If
* not, and Config::inst()->get('AuthRemoteUserExtension', 'auto_create_user') is set, add that
* Member to the configured group, and log the new user in. Otherwise, do nothing.
*/
public function onAfterInit()
{
if (isset($_SERVER['REMOTE_USER'])) {
$unique_identifier = $_SERVER['REMOTE_USER'];
} elseif (isset($_SERVER['REDIRECT_REMOTE_USER'])) {
$unique_identifier = $_SERVER['REDIRECT_REMOTE_USER'];
}
if (isset($unique_identifier)) {
$unique_identifier_field = Member::config()->unique_identifier_field;
$member = Member::get()->filter($unique_identifier_field, $unique_identifier)->first();
if ($member) {
$member->logIn();
$this->owner->redirectBack();
} elseif (Config::inst()->get('AuthRemoteUserExtension', 'auto_create_user') && strlen(Config::inst()->get('AuthRemoteUserExtension', 'auto_user_group'))) {
$group = Group::get()->filter('Title', Config::inst()->get('AuthRemoteUserExtension', 'auto_user_group'))->first();
if ($group) {
$member = new Member();
$member->{$unique_identifier_field} = $unique_identifier;
$member->write();
$member->Groups()->add($group);
$member->logIn();
}
}
}
}
开发者ID:helpfulrobot,项目名称:quinninteractive-silverstripe-auth-remote-user,代码行数:30,代码来源:AuthRemoteUserExtension.php
示例14: getCMSFields
public function getCMSFields()
{
$summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : Summit::ActiveSummitID();
Requirements::javascript('summit/javascript/SummitPushNotification.js');
$f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main')));
$f->addFieldToTab('Root.Main', $txt = new TextareaField('Message', 'Message'));
$txt->setAttribute('required', 'true');
$f->addFieldToTab('Root.Main', $ddl_channel = new DropdownField('Channel', 'Channel', singleton('SummitPushNotification')->dbObject('Channel')->enumValues()));
$f->addFieldToTab('Root.Main', $ddl_events = new DropdownField('EventID', 'Event', SummitEvent::get()->filter(['Published' => 1, 'SummitID' => $summit_id])->sort('Title', 'ASC')->Map('ID', 'FormattedTitle')));
$f->addFieldToTab('Root.Main', $ddl_groups = new DropdownField('GroupID', 'Group', Group::get()->sort('Title', 'ASC')->Map('ID', 'Title')));
$f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID'));
$ddl_channel->setEmptyString('--SELECT A CHANNEL--');
$ddl_channel->setAttribute('required', 'true');
$ddl_events->setEmptyString('--SELECT AN EVENT--');
$ddl_events->addExtraClass('hidden');
$ddl_groups->setEmptyString('--SELECT A GROUP--');
$ddl_groups->addExtraClass('hidden');
$config = GridFieldConfig_RelationEditor::create(50);
$config->removeComponentsByType('GridFieldAddExistingAutocompleter');
$config->removeComponentsByType('GridFieldAddNewButton');
$config->addComponent($auto_completer = new CustomGridFieldAddExistingAutocompleter('buttons-before-right'));
$auto_completer->setResultsFormat('$Title ($Email)');
$recipients = new GridField('Recipients', 'Member Recipients', $this->Recipients(), $config);
$f->addFieldToTab('Root.Main', $recipients);
return $f;
}
示例15: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->replaceField("From", $from = new DateField("From", "Valid From - add any date and time"));
$fields->replaceField("Until", $until = new DateField("Until", "Valid Until - add any date and time"));
$fields->replaceField("NewPrice", new CurrencyField("NewPrice", "PRICE (OPTION 1 / 3) - only enter if there is a set new price independent of the 'standard' price."));
$fields->replaceField("Percentage", new NumericField("Percentage", "PERCENTAGE (OPTIONAL 2/ 3) discount from 0 (0% discount) to 100 (100% discount)."));
$fields->replaceField("Reduction", new CurrencyField("Reduction", "REDUCTION (OPTION 3 /3 ) - e.g. if you enter 2.00 then the new price will be the standard product price minus 2."));
if (!$this->ID) {
$fields->addFieldToTab("Root.Main", new LiteralField("SaveFirst", "<p>Please save first - and then select security groups / countries</p>"));
$fields->removeByName("NoLongerValid");
}
if ($groups = Group::get()->count()) {
$groups = Group::get();
$fields->replaceField("Groups", new CheckboxSetField("Groups", "Who", $groups->map()->toArray()));
} else {
$fields->removeByName("Groups");
}
if ($ecommerceCountries = EcommerceCountry::get()) {
$fields->replaceField("EcommerceCountries", new CheckboxSetField("EcommerceCountries", "Where", $ecommerceCountries->map()->toArray()));
} else {
$fields->removeByName("EcommerceCountries");
}
if (DiscountCouponOption::get()->count()) {
$fields->replaceField("DiscountCouponOptions", new CheckboxSetField("DiscountCouponOptions", "Discount Coupons", DiscountCouponOption::get()->map()->toArray()));
} else {
$fields->removeByName("DiscountCouponOptions");
}
$from->setConfig('showcalendar', true);
$until->setConfig('showcalendar', true);
return $fields;
}