本文整理汇总了PHP中Member::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Member::get方法的具体用法?PHP Member::get怎么用?PHP Member::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Member
的用法示例。
在下文中一共展示了Member::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: 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);
}
示例3: getMembers
private function getMembers()
{
$filterString = '';
$members = Member::get('Member', $filterString);
$search = $this->getRequest()->getVar('search');
if ($search) {
$members = $members->filterAny(array('Surname:PartialMatch' => $search, 'Firstname:PartialMatch' => $search, 'Email:PartialMatch' => $search));
//('SearchFields:fulltext', $search);
}
$sort = Convert::raw2sql($this->getRequest()->getVar('sort'));
if ($sort) {
if (strlen($sort) > 2) {
$dir = substr($sort, 0, 1);
$field = substr($sort, 1);
if ($field == 'FirstName' || $field == 'LastVisited' || $field == 'Surname' || $field == 'Email') {
if ($dir == 'a') {
$members = $members->sort(Convert::raw2sql($field) . " ASC");
} else {
$members = $members->sort(Convert::raw2sql($field) . " DESC");
}
} else {
die("Undefined field for sorting");
}
}
}
return new PaginatedList($members, $this->request);
}
示例4: addmembertocartform_add
function addmembertocartform_add($data, $form)
{
$member = Member::currentUser();
if ($member && $member->IsShopAdmin()) {
$order = ShoppingCart::current_order();
$member = Member::get()->byID(intval($data["MemberID"]));
if ($member) {
if ($member->ID != $order->MemberID) {
$order->MemberID = $member->ID;
$order->BillingAddressID = 0;
$order->ShippingAddressID = 0;
$order->write();
$response = $member->getTitle() . " " . _t("AddToCartPage.ADDED", "customer has been added to order.");
$status = "good";
} else {
$response = _t("AddToCartPage.NOCHANGE", "The order has not been changed.");
$status = "good";
}
} else {
$response = _t("AddToCartPage.CUSTOMERNOTADDED", "Customer could not be added.");
$status = "bad";
}
if (Director::is_ajax()) {
return $response;
} else {
$form->setMessage($response, $status);
$this->redirectBack();
}
}
}
示例5: TeamMembers
/**
* Template accessors
* ----------------------------------*/
public function TeamMembers()
{
$team = Member::get()->filterByCallback(function ($item) {
return $item->inGroup('team-member');
});
return $team->count() ? $team : false;
}
示例6: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->removeByName('ProviderClass');
$fields->removeByName('ProviderSettings');
$fields->removeByName('Sent');
$fields->removeByName('SentAt');
$fields->removeByName('RecipientMembers');
$fields->removeByName('RecipientGroups');
$fields->removeByName('SendJobID');
if ($this->Sent) {
$fields->insertBefore(new LiteralField('SentAsMessage', sprintf('<p class="message">%s</p>', _t('Push.SENTAT', 'This notification was sent at {at}', array('at' => $this->obj('SentAt')->Nice())))), 'Title');
}
if ($this->Sent || !interface_exists('QueuedJob')) {
$fields->removeByName('ScheduledAt');
} else {
$fields->dataFieldByName('ScheduledAt')->getDateField()->setConfig('showcalendar', true);
}
$fields->dataFieldByName('Content')->setDescription(_t('Push.USEDMAINBODY', '(Used as the main body of the notification)'));
if ($this->ID) {
$fields->addFieldsToTab('Root.Main', array(new CheckboxSetField('RecipientMembers', _t('Push.RECIPIENTMEMBERS', 'Recipient Members'), Member::get()->map()), new TreeMultiselectField('RecipientGroups', _t('Push.RECIPIENTGROUPS', 'Recipient Groups'), 'Group')));
}
$fields->addFieldsToTab('Root.Main', array(PushProviderField::create('Provider', _t('Push.PROVIDER', 'Provider'))));
return $fields;
}
示例7: doSave
function doSave($data, $form)
{
if (isset($data['Password']) && is_array($data['Password'])) {
$data['Password'] = $data['Password']['_Password'];
}
// We need to ensure that the unique field is never overwritten
$uniqueField = Member::get_unique_identifier_field();
if (isset($data[$uniqueField])) {
$SQL_unique = Convert::raw2sql($data[$uniqueField]);
$existingUniqueMember = Member::get()->filter(array($uniqueField => $SQL_unique))->first();
if ($existingUniqueMember && $existingUniqueMember->exists()) {
if (Member::currentUserID() != $existingUniqueMember->ID) {
die("current member does not match enrolled member.");
return false;
}
}
}
$member = Member::currentUser();
if (!$member) {
$member = new Member();
}
$member->update($data);
$member->write();
$arrayExtraFields = array();
if (isset($data["SelectedOption"])) {
$arrayExtraFields["SelectedOption"] = $data["SelectedOption"];
}
if (isset($data["BookingCode"])) {
$arrayExtraFields["BookingCode"] = $data["BookingCode"];
}
$this->controller->addAttendee($member, $arrayExtraFields);
$this->redirect($this->getController()->Link("thankyou"));
return;
}
示例8: 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');
}
示例9: 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');
}
示例10: getCMSFields
public function getCMSFields()
{
$fields = new FieldList(new TabSet('Root'));
$fields->addFieldToTab('Root.Main', new TextField('Title', $this->fieldLabel('Title')));
$filter = '';
$reqParent = isset($_REQUEST['ParentID']) ? (int) $_REQUEST['ParentID'] : 0;
$attachTo = $this->ActionID ? $this->ActionID : $reqParent;
if ($attachTo) {
$action = DataObject::get_by_id('WorkflowAction', $attachTo);
if ($action && $action->ID) {
$filter = '"WorkflowDefID" = ' . (int) $action->WorkflowDefID;
}
}
$actions = DataObject::get('WorkflowAction', $filter);
$options = array();
if ($actions) {
$options = $actions->map();
}
$defaultAction = $action ? $action->ID : "";
$typeOptions = array('Active' => _t('WorkflowTransition.Active', 'Active'), 'Passive' => _t('WorkflowTransition.Passive', 'Passive'));
$fields->addFieldToTab('Root.Main', new DropdownField('ActionID', $this->fieldLabel('ActionID'), $options, $defaultAction));
$fields->addFieldToTab('Root.Main', $nextActionDropdownField = new DropdownField('NextActionID', $this->fieldLabel('NextActionID'), $options));
$nextActionDropdownField->setEmptyString(_t('WorkflowTransition.SELECTONE', '(Select one)'));
$fields->addFieldToTab('Root.Main', new DropdownField('Type', _t('WorkflowTransition.TYPE', 'Type'), $typeOptions));
$members = Member::get();
$fields->findOrMakeTab('Root.RestrictToUsers', _t('WorkflowTransition.TabTitle', 'Restrict to users'));
$fields->addFieldToTab('Root.RestrictToUsers', new CheckboxSetField('Users', _t('WorkflowDefinition.USERS', 'Restrict to Users'), $members));
$fields->addFieldToTab('Root.RestrictToUsers', new TreeMultiselectField('Groups', _t('WorkflowDefinition.GROUPS', 'Restrict to Groups'), 'Group'));
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例11: getCMSFields
public function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->insertBefore(new DropdownField('MemberID', 'Member', Member::get()->map('ID', "FirstName")), 'AttendingWholeEvent');
$siteConfig = SiteConfig::current_site_config();
$current = $siteConfig->getCurrentEventID();
if ($this->ParentID < 1) {
$event = Event::get()->byID($current);
} else {
$event = Event::get()->byID($this->ParentID);
}
$fields->insertAfter(HiddenField::create('ParentID', 'Event', $event->ID), 'ExtraDetail');
$fields->removeByName('PublicFieldsRaw');
$fields->removeByName('Sort');
if ($this->PlayerGames()->Count() > 0) {
$gridField = new GridField('PlayerGames', 'Games', $this->PlayerGames(), $config = GridFieldConfig_RelationEditor::create());
$gridField->setModelClass('PlayerGame');
$config->addComponent(new GridFieldOrderableRows());
$config->removeComponentsByType('GridFieldPaginator');
$config->removeComponentsByType('GridFieldPageCount');
$config->addComponent(new GridFieldDeleteAction(false));
$config->addComponent($export = new GridFieldExportButton('before'));
$export->setExportColumns(singleton("PlayerGame")->getExportFields());
$fields->addFieldToTab('Root.PlayerGames', $gridField);
}
return $fields;
}
示例12: getCMSFields
public function getCMSFields()
{
$fields = new FieldList(new TabSet('Root'));
$fields->addFieldToTab('Root.Main', new TextField('Title', _t('WorkflowAction.TITLE', 'Title')));
$filter = '';
$reqParent = isset($_REQUEST['ParentID']) ? (int) $_REQUEST['ParentID'] : 0;
$attachTo = $this->ActionID ? $this->ActionID : $reqParent;
if ($attachTo) {
$action = DataObject::get_by_id('WorkflowAction', $attachTo);
if ($action && $action->ID) {
$filter = '"WorkflowDefID" = ' . (int) $action->WorkflowDefID;
}
}
$actions = DataObject::get('WorkflowAction', $filter);
$options = array();
if ($actions) {
$options = $actions->map();
}
$typeOptions = $this->dbObject('Type')->enumValues();
$fields->addFieldToTab('Root.Main', new DropdownField('ActionID', _t('WorkflowTransition.ACTION', 'Action'), $options));
$fields->addFieldToTab('Root.Main', new DropdownField('NextActionID', _t('WorkflowTransition.NEXT_ACTION', 'Next Action'), $options, null, null, _t('WorkflowTransition.SELECTONE', '(Select one)')));
$fields->addFieldToTab('Root.Main', new DropdownField('Type', _t('WorkflowTransition.TYPE', 'Type'), $typeOptions));
$members = Member::get();
$fields->addFieldToTab('Root.RestrictToUsers', new CheckboxSetField('Users', _t('WorkflowDefinition.USERS', 'Restrict to Users'), $members));
$fields->addFieldToTab('Root.RestrictToUsers', new TreeMultiselectField('Groups', _t('WorkflowDefinition.GROUPS', 'Restrict to Groups'), 'Group'));
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例13: 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();
}
示例14: validatePullRequest
/**
* @param array $pull_request_data
* @throws NonFoundationMemberException
* @throws NotFoundEntityException
* @throws NonSignedCLAFoundationMemberException
*/
public function validatePullRequest(array $pull_request_data)
{
//get sender user
if (isset($pull_request_data['user']) && ($sender = $pull_request_data['user'])) {
$user_name = $sender['login'];
//get user email from api
// https://api.github.com/users/:user_name
$client = new \Github\Client();
$user = $client->api('user')->show($user_name);
if ($user != null && isset($user['email']) && ($user_email = $user['email'])) {
//check if exist on db
$member = Member::get()->filter('Email', $user_email)->first();
if (!$member) {
$this->rejectPullRequest($pull_request_data, self::NON_MEMBER_REJECT_REASON);
throw new NotFoundEntityException('Member', sprintf('user email %s does not exists!', $user_email));
}
if (!$member->isFoundationMember()) {
//reject pull request
$this->rejectPullRequest($pull_request_data, self::NON_FOUNDATION_MEMBER_REJECT_REASON);
throw new NonFoundationMemberException($user_email);
}
if (!$member->hasSignedCLA()) {
//reject pull request
$this->rejectPullRequest($pull_request_data, self::NON_SIGNED_CLA_REJECT_REASON);
throw new NonSignedCLAFoundationMemberException($user_email);
}
}
}
}
示例15: memberEdit
/**
* Show the member edit page
*
* @return string Returns the member edit page as HTML code.
*/
public function memberEdit()
{
if ($Member = Member::get()->byID($this->request->param('ID'))) {
$GLOBALS['MemberID'] = $Member->ID;
}
return $this->customise(new ArrayData(array("Title" => _t('AdminMemberEdit.TITLE', 'AdminMemberEdit.TITLE'), "Form" => $this->MemberEditForm(), "Member" => $Member)))->renderWith(array('Administration_memberedit', 'Administration', $this->stat('template_main'), $this->stat('template')));
}