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


PHP Member::get_unique_identifier_field方法代码示例

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


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

示例1: setUp

 function setUp()
 {
     // backup the project unique identifier field
     $this->member_unique_identifier_field = Member::get_unique_identifier_field();
     Member::set_unique_identifier_field('Email');
     parent::setUp();
 }
开发者ID:nomidi,项目名称:sapphire,代码行数:7,代码来源:RestfulServiceTest.php

示例2: 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;
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-traininglistingsandsignup,代码行数:34,代码来源:TrainingSignupForm.php

示例3: setUp

 public function setUp()
 {
     parent::setUp();
     // Fixtures assume Email is the field used to identify the log in identity
     self::$original_unique_identifier_field = Member::get_unique_identifier_field();
     Member::set_unique_identifier_field('Email');
 }
开发者ID:normann,项目名称:sapphire,代码行数:7,代码来源:BasicAuthTest.php

示例4: getRequiredFields

 public function getRequiredFields(Order $order)
 {
     if (Member::currentUserID() || !Checkout::membership_required()) {
         return array();
     }
     return array(Member::get_unique_identifier_field(), 'Password');
 }
开发者ID:NobrainerWeb,项目名称:silverstripe-shop,代码行数:7,代码来源:MembershipCheckoutComponent.php

示例5: setUp

 function setUp()
 {
     parent::setUp();
     $this->orig['Member_unique_identifier_field'] = Member::get_unique_identifier_field();
     Member::set_unique_identifier_field('Email');
     Member::set_password_validator(null);
 }
开发者ID:nomidi,项目名称:sapphire,代码行数:7,代码来源:MemberTest.php

示例6: testEcommerceRoleCreateOrMerge

 function testEcommerceRoleCreateOrMerge()
 {
     $member = $this->objFromFixture('Member', 'member1');
     $this->session()->inst_set('loggedInAs', $member->ID);
     $uniqueField = Member::get_unique_identifier_field();
     $this->assertEquals('bob@somewhere.com', $member->getField($uniqueField), 'The unique field is the email address');
     $this->assertEquals('US', $member->getField('Country'), 'The country is US');
     /* Change the email address to a new one (doesn't exist) */
     $member = EcommerceRole::createOrMerge(array('Country' => 'AU', $uniqueField => 'somewhere@someplace.com'));
     $this->assertType('object', $member, 'The member is an object, not FALSE');
     $this->assertEquals('somewhere@someplace.com', $member->getField($uniqueField), 'The unique field is changed (no member with that email)');
     $this->assertEquals('AU', $member->getField('Country'), 'The member country is now AU');
     /* Change the data (update existing record - logged in member owns this email) */
     $member = EcommerceRole::createOrMerge(array('Country' => 'NZ', $uniqueField => 'somewhere@someplace.com'));
     $this->assertType('object', $member, 'The member is an object, not FALSE');
     $this->assertEquals('somewhere@someplace.com', $member->getField($uniqueField), 'The unique field is the same (updated own record)');
     $this->assertEquals('NZ', $member->getField('Country'), 'The member country is now NZ');
     /* Change the email address to one exists (we should not get a member back when trying to merge!) */
     $member = EcommerceRole::createOrMerge(array('Country' => 'US', $uniqueField => 'test@example.com'));
     $this->assertFalse($member, 'No member returned because we tried to merge an email that already exists in the DB');
     /* Log the member out */
     $this->session()->inst_set('loggedInAs', null);
     /* Non-logged in site user creating a new member with email that doesn't exist */
     $member = EcommerceRole::createOrMerge(array('Country' => 'NZ', $uniqueField => 'someonenew@nowhereatall.com'));
     $this->assertType('object', $member, 'The member is an object, not FALSE');
     $this->assertEquals('someonenew@nowhereatall.com', $member->getField($uniqueField));
     $this->assertEquals('NZ', $member->getField('Country'), 'The member country is NZ');
     /* Non-logged in site user creating a member with email that DOES exist */
     $member = EcommerceRole::createOrMerge(array('Country' => 'AU', $uniqueField => 'test@example.com'));
     $this->assertFalse($member, 'The new user tried to create a member with an email that already exists, FALSE returned');
     $member = EcommerceRole::createOrMerge(array('Country' => 'AU', $uniqueField => 'TEST@eXamPLE.com'));
     $this->assertFalse($member, 'Even if the email has a different case, FALSE is still returned');
 }
开发者ID:nicolaas,项目名称:silverstripe-ecommerce,代码行数:33,代码来源:EcommerceTest.php

示例7: getMembershipFields

 public function getMembershipFields()
 {
     $fields = $this->getContactFields();
     $idfield = Member::get_unique_identifier_field();
     if (!$fields->fieldByName($idfield)) {
         $fields->push(TextField::create($idfield, $idfield));
         //TODO: scaffold the correct id field
     }
     $fields->push($this->getPasswordField());
     return $fields;
 }
开发者ID:NobrainerWeb,项目名称:silverstripe-shop,代码行数:11,代码来源:CheckoutFieldFactory.php

示例8: Link

 public function Link($action = null)
 {
     $dashboard = $this->currentDashboard;
     if ($dashboard && $dashboard->URLSegment != 'main') {
         $identifier = Member::get_unique_identifier_field();
         $identifier = $dashboard->Owner()->{$identifier};
         $segment = $dashboard->URLSegment ? $dashboard->URLSegment : 'main';
         return Controller::join_links($this->data()->Link(true), 'board', $segment, $dashboard->Owner()->ID, $action);
     } else {
         return $this->data()->Link($action ? $action : true);
     }
 }
开发者ID:spekulatius,项目名称:silverstripe-frontend-dashboards,代码行数:12,代码来源:SiteDashboardPage.php

示例9: setUp

 function setUp()
 {
     // This test assumes that MemberAuthenticator is present and the default
     $this->priorAuthenticators = Authenticator::get_authenticators();
     $this->priorDefaultAuthenticator = Authenticator::get_default_authenticator();
     Authenticator::register('MemberAuthenticator');
     Authenticator::set_default_authenticator('MemberAuthenticator');
     // And that the unique identified field is 'Email'
     $this->priorUniqueIdentifierField = Member::get_unique_identifier_field();
     Member::set_unique_identifier_field('Email');
     parent::setUp();
 }
开发者ID:eLBirador,项目名称:AllAboutCity,代码行数:12,代码来源:SecurityTest.php

示例10: doProcess

 public function doProcess($data, $form, $request)
 {
     $order = new Order();
     $items = $order->Items();
     $member = Member::currentUserID() ? Member::currentUser() : new Member();
     $paymentClass = isset($data['PaymentMethod']) ? $data['PaymentMethod'] : null;
     $payment = class_exists($paymentClass) ? new $paymentClass() : null;
     $requirePayment = $order->Subtotal() > 0 ? true : false;
     if (!($items && $items->Count() > 0)) {
         $form->sessionMessage(_t('OrderForm.NOITEMS', 'Error placing order: You have no items in your cart.'), 'bad');
         return Director::redirectBack();
     }
     if ($requirePayment) {
         if (!($payment && $payment instanceof Payment)) {
             user_error("OrderForm::doProcess(): '{$paymentClass}' is not a valid payment class!", E_USER_ERROR);
         }
     }
     // Ensure existing members don't get their record hijacked (IMPORTANT!)
     if (!$member->checkUniqueFieldValue($data)) {
         $uniqueField = Member::get_unique_identifier_field();
         $uniqueValue = $data[$uniqueField];
         $uniqueError = "Error placing order: The %s \"%d\" is\n\t\t\t\talready taken by another member. If this belongs to you, please\n\t\t\t\tlog in first before placing your order.";
         $form->sessionMessage(_t('EcommerceMemberExtension.ALREADYEXISTS', printf($uniqueError, strtolower($uniqueField), $uniqueValue), PR_MEDIUM, 'Let the user know that member already exists (e.g. %s could be "Email", %d could be "joe@somewhere.com)'), 'bad');
         return Director::redirectBack();
     }
     $form->saveInto($member);
     if (!$member->Password) {
         $member->setField('Password', Member::create_new_password());
     }
     $member->write();
     $form->saveInto($order);
     try {
         $result = $order->process($member->ID);
     } catch (Exception $e) {
         $form->sessionMessage(_t('OrderForm.PROCESSERROR', "An error occurred while placing your order: {$e->getMessage()}.<br>\n\t\t\t\t\tPlease contact the website administrator."), 'bad');
         // Send an email to site admin with $e->getMessage() error
         return Director::redirectBack();
     }
     if ($requirePayment) {
         $form->saveInto($payment);
         $payment->write();
         $result = $payment->processPayment($data, $form);
         if ($result->isSuccess()) {
             $order->sendReceipt();
         }
         // Long payment process. e.g. user goes to external site to pay (PayPal, WorldPay)
         if ($result->isProcessing()) {
             return $result->getValue();
         }
     }
     Director::redirect($order->Link());
 }
开发者ID:halkyon,项目名称:silverstripe-ecommerce_experiment,代码行数:52,代码来源:OrderForm.php

示例11: php

 /**
  * Ensures member unique id stays unique.
  */
 public function php($data)
 {
     $valid = parent::php($data);
     $field = Member::get_unique_identifier_field();
     if (isset($data[$field])) {
         $uid = $data[Member::get_unique_identifier_field()];
         $currentmember = Member::currentUser();
         //can't be taken
         if (DataObject::get_one('Member', "{$field} = '{$uid}' AND ID != " . $currentmember->ID)) {
             $this->validationError($field, "\"{$uid}\" is already taken by another member. Try another.", "required");
             $valid = false;
         }
     }
     return $valid;
 }
开发者ID:8secs,项目名称:cocina,代码行数:18,代码来源:ChefAccountForm.php

示例12: changePassword

 /**
  * Change the password.
  *
  * @param string $username
  *   The username to find.
  * @param string $password
  *   The new password, plain text.
  */
 public function changePassword($username = null, $password = null)
 {
     // Validate the input.
     if (!$username || !$password) {
         return 'Unable to change password. Invalid username or password';
     }
     // Find the user.
     $member = Member::get_one('Member', sprintf('"%s" = \'%s\'', Member::get_unique_identifier_field(), Convert::raw2sql($username)));
     if (!$member) {
         return "Unable to find user '{$username}'.";
     }
     // Modify the user.
     $member->Password = $password;
     $member->write();
 }
开发者ID:helpfulrobot,项目名称:silverstripe-sakemore,代码行数:23,代码来源:UserPasswordRole.php

示例13: __construct

 function __construct($controller, $name = "MemberRegistrationForm", $fields = null)
 {
     if (!$fields) {
         $restrictfields = array(Member::get_unique_identifier_field(), 'FirstName', 'Surname');
         $fields = singleton('Member')->scaffoldFormFields(array('restrictFields' => $restrictfields, 'fieldClasses' => array('Email' => 'EmailField')));
     }
     $fields->push(new ConfirmedPasswordField("Password"));
     $actions = new FieldList($register = new FormAction('register', "Register"));
     $validator = new MemberRegistration_Validator(Member::get_unique_identifier_field(), 'FirstName', 'Surname');
     parent::__construct($controller, $name, $fields, $actions, $validator);
     if (class_exists('SpamProtectorManager')) {
         $this->enableSpamProtection();
     }
     $this->extend('updateMemberRegistrationForm');
 }
开发者ID:nimeso,项目名称:silverstripe-members,代码行数:15,代码来源:MemberRegistrationForm.php

示例14: __construct

 /**
  * Constructor
  *
  * @param Controller $controller The parent controller, necessary to
  *                               create the appropriate form action tag.
  * @param string $name The method on the controller that will return this
  *                     form object.
  * @param FieldList|FormField $fields All of the fields in the form - a
  *                                   {@link FieldList} of {@link FormField}
  *                                   objects.
  * @param FieldList|FormAction $actions All of the action buttons in the
  *                                     form - a {@link FieldList} of
  *                                     {@link FormAction} objects
  * @param bool $checkCurrentUser If set to TRUE, it will be checked if a
  *                               the user is currently logged in, and if
  *                               so, only a logout button will be rendered
  * @param string $authenticatorClassName Name of the authenticator class that this form uses.
  */
 function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true)
 {
     // This is now set on the class directly to make it easier to create subclasses
     // $this->authenticator_class = $authenticatorClassName;
     $customCSS = project() . '/css/member_login.css';
     if (Director::fileExists($customCSS)) {
         Requirements::css($customCSS);
     }
     if (isset($_REQUEST['BackURL'])) {
         $_REQUEST['BackURL'] = str_replace("/RegistrationForm", "", $_REQUEST['BackURL']);
         $backURL = $_REQUEST['BackURL'];
     } else {
         if (strpos(Session::get('BackURL'), "/RegistrationForm") > 0) {
             Session::set('BackURL', str_replace("/RegistrationForm", "", Session::get('BackURL')));
         }
         $backURL = str_replace("/RegistrationForm", "", Session::get('BackURL'));
     }
     if ($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
         $fields = new FieldList(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this));
         $actions = new FieldList(new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else")));
     } else {
         if (!$fields) {
             $label = singleton('Member')->fieldLabel(Member::get_unique_identifier_field());
             $fields = new FieldList(new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this), new TextField("Email", $label, Session::get('SessionForms.MemberLoginForm.Email'), null, $this), new PasswordField("Password", _t('Member.PASSWORD', 'Password')));
             if (Security::$autologin_enabled) {
                 $fields->push(new CheckboxField("Remember", _t('Member.REMEMBERME', "Remember me next time?")));
             }
         }
         if (!$actions) {
             $actions = new FieldList(new FormAction('dologin', _t('Member.BUTTONLOGIN', "Log in")), new LiteralField('forgotPassword', '<p id="ForgotPassword"><a href="Security/lostpassword">' . _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>'), new LiteralField('resendEmail', '<p id="ResendEmail"><a href="Security/verifyemail">' . _t('EmailVerifiedMember.BUTTONRESENDEMAIL', "I've lost my verification email") . '</a></p>'));
         }
     }
     if (isset($backURL)) {
         $fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
     }
     parent::__construct($controller, $name, $fields, $actions);
     // Focus on the email input when the page is loaded
     // Only include this if other form JS validation is enabled
     /*		if($this->getValidator()->getJavascriptValidationHandler() != 'none') {
     			Requirements::customScript(<<<JS
     				(function() {
     					var el = document.getElementById("MemberLoginForm_LoginForm_Email");
     					if(el && el.focus) el.focus();
     				})();
     JS
     			);
     		}*/
 }
开发者ID:helpfulrobot,项目名称:exadium-emailverifiedmember,代码行数:66,代码来源:EmailVerifiedMemberLoginForm.php

示例15: checkUniqueFieldValue

 /**
  * Check that no existing members have the same value
  * for their unique field. This is useful for checking
  * if a member already exists with a certain email address.
  * 
  * If the member is logged in, and the existing member found
  * has the same ID (it's them), return TRUE because this is
  * their own member account.
  * 
  * @param array $data Raw data to check from a form request
  * @return boolean TRUE is unique | FALSE not unique
  */
 public function checkUniqueFieldValue($data)
 {
     $field = Member::get_unique_identifier_field();
     $value = isset($data[$field]) ? $data[$field] : null;
     if (!$value) {
         return true;
     }
     $SQL_value = Convert::raw2sql($value);
     $existingMember = DataObject::get_one('Member', "{$field} = '{$SQL_value}'");
     if ($existingMember && $existingMember->exists()) {
         if ($this->owner->ID != $existingMember->ID) {
             return false;
         }
     }
     return true;
 }
开发者ID:halkyon,项目名称:silverstripe-ecommerce_experiment,代码行数:28,代码来源:EcommerceMemberExtension.php


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