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


PHP Member::write方法代码示例

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


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

示例1: doApprove

 public function doApprove()
 {
     $exist = Member::get()->filter(array('Email' => $this->Email))->first();
     if ($exist) {
         return false;
     }
     $member = new Member();
     $data = $this->toMap();
     unset($data['ID']);
     unset($data['ClassName']);
     unset($data['UnapprovedMember']);
     $member->update($data);
     $member->write();
     if ($this->MemberType === 'Organization') {
         $member->addToGroupByCode('organization');
         $organization = new Organization();
         $organization->AccountID = $member->ID;
         $organization->company_name = $this->OrganizationName;
         $organizationID = $organization->write();
         $member->OrganizationID = $organizationID;
         $member->write();
     } else {
         $member->addToGroupByCode('personal');
     }
     $this->setField('Approved', true);
     $this->write();
     return true;
 }
开发者ID:jallen0927,项目名称:lytech,代码行数:28,代码来源:UnapprovedMember.php

示例2: Member

 function testDefaultPasswordEncryptionDoesntChangeExistingMembers()
 {
     $member = new Member();
     $member->Password = 'mypassword';
     $member->PasswordEncryption = 'sha1_v2.4';
     $member->write();
     $origAlgo = Security::get_password_encryption_algorithm();
     Security::set_password_encryption_algorithm('none');
     $member->Password = 'mynewpassword';
     $member->write();
     $this->assertEquals($member->PasswordEncryption, 'sha1_v2.4');
     $result = $member->checkPassword('mynewpassword');
     $this->assertTrue($result->valid());
     Security::set_password_encryption_algorithm($origAlgo);
 }
开发者ID:nomidi,项目名称:sapphire,代码行数:15,代码来源:MemberTest.php

示例3: 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

示例4: createAndLoginUser

 /**
  * creates and logs in a temporary user.
  *
  */
 private function createAndLoginUser()
 {
     $this->username = "TEMPLATEOVERVIEW_URLCHECKER___";
     $this->password = rand(1000000000, 9999999999);
     //Make temporary admin member
     $adminMember = Member::get()->filter(array("Email" => $this->username))->first();
     if ($adminMember != NULL) {
         $adminMember->delete();
     }
     $this->member = new Member();
     $this->member->Email = $this->username;
     $this->member->Password = $this->password;
     $this->member->write();
     $adminGroup = Group::get()->filter(array("code" => "administrators"))->first();
     if (!$adminGroup) {
         user_error("No admin group exists");
     }
     $this->member->Groups()->add($adminGroup);
     curl_setopt($this->ch, CURLOPT_USERPWD, $this->username . ":" . $this->password);
     $loginUrl = Director::absoluteURL('/Security/LoginForm');
     curl_setopt($this->ch, CURLOPT_CUSTOMREQUEST, "POST");
     curl_setopt($this->ch, CURLOPT_URL, $loginUrl);
     curl_setopt($this->ch, CURLOPT_POST, 1);
     curl_setopt($this->ch, CURLOPT_POSTFIELDS, 'Email=' . $this->username . '&Password=' . $this->password);
     //execute the request (the login)
     $loginContent = curl_exec($this->ch);
     $httpCode = curl_getinfo($this->ch, CURLINFO_HTTP_CODE);
     $err = curl_errno($this->ch);
     $errmsg = curl_error($this->ch);
     $header = curl_getinfo($this->ch);
     if ($httpCode != 200) {
         echo "<span style='color:red'>There was an error logging in!</span><br />";
     }
 }
开发者ID:helpfulrobot,项目名称:purplespider-mypswd-tweaks,代码行数:38,代码来源:CheckAllTemplates.php

示例5: authenticate

 /**
  * Performs the login, but will also create and sync the Member record on-the-fly, if not found.
  *
  * @param array $data
  * @param Form $form
  * @return bool|Member|void
  * @throws SS_HTTPResponse_Exception
  */
 public static function authenticate($data, Form $form = null)
 {
     $service = Injector::inst()->get('LDAPService');
     $result = $service->authenticate($data['Username'], $data['Password']);
     $success = $result['success'] === true;
     if (!$success) {
         if ($form) {
             $form->sessionMessage($result['message'], 'bad');
         }
         return;
     }
     $data = $service->getUserByUsername($result['identity']);
     if (!$data) {
         if ($form) {
             $form->sessionMessage(_t('LDAPAuthenticator.PROBLEMFINDINGDATA', 'There was a problem retrieving your user data'), 'bad');
         }
         return;
     }
     // LDAPMemberExtension::memberLoggedIn() will update any other AD attributes mapped to Member fields
     $member = Member::get()->filter('GUID', $data['objectguid'])->limit(1)->first();
     if (!($member && $member->exists())) {
         $member = new Member();
         $member->GUID = $data['objectguid'];
         $member->write();
     }
     Session::clear('BackURL');
     return $member;
 }
开发者ID:andrewandante,项目名称:silverstripe-activedirectory,代码行数:36,代码来源:LDAPAuthenticator.php

示例6: finish

 public function finish($data, $form)
 {
     parent::finish($data, $form);
     $steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID}");
     if ($steps) {
         foreach ($steps as $step) {
             if ($step->class == 'Page2PersonalDetailsFormStep') {
                 $member = new Member();
                 $data = $step->loadData();
                 if ($data) {
                     $member->update($data);
                     $member->write();
                 }
             }
             if ($step->class == 'Page2OrganisationDetailsFormStep') {
                 $organisation = new Organisation();
                 $data = $step->loadData();
                 if ($data) {
                     $organisation->update($data);
                     if ($member && $member->ID) {
                         $organisation->MemberID = $member->ID;
                     }
                     $organisation->write();
                 }
             }
             // Debug::show($step->loadData()); // Shows the step data (unserialized by loadData)
         }
     }
     $controller = $this->getController();
     $controller->redirect($controller->Link() . 'finished');
 }
开发者ID:normann,项目名称:silverstripe-frameworktest,代码行数:31,代码来源:Page2MultiForm.php

示例7: testAuthenticateByTempID

 /**
  * Test that a member can be authenticated via their temp id
  */
 public function testAuthenticateByTempID()
 {
     $member = new Member();
     $member->Email = 'test1@test.com';
     $member->PasswordEncryption = "sha1";
     $member->Password = "mypassword";
     $member->write();
     // Make form
     $controller = new Security();
     $form = new Form($controller, 'Form', new FieldList(), new FieldList());
     // If the user has never logged in, then the tempid should be empty
     $tempID = $member->TempIDHash;
     $this->assertEmpty($tempID);
     // If the user logs in then they have a temp id
     $member->logIn(true);
     $tempID = $member->TempIDHash;
     $this->assertNotEmpty($tempID);
     // Test correct login
     $result = MemberAuthenticator::authenticate(array('tempid' => $tempID, 'Password' => 'mypassword'), $form);
     $this->assertNotEmpty($result);
     $this->assertEquals($result->ID, $member->ID);
     $this->assertEmpty($form->Message());
     // Test incorrect login
     $form->clearMessage();
     $result = MemberAuthenticator::authenticate(array('tempid' => $tempID, 'Password' => 'notmypassword'), $form);
     $this->assertEmpty($result);
     $this->assertEquals('The provided details don&#039;t seem to be correct. Please try again.', $form->Message());
     $this->assertEquals('bad', $form->MessageType());
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:32,代码来源:MemberAuthenticatorTest.php

示例8: 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

示例9: createUser

 private function createUser()
 {
     // create user
     $u = new Member();
     $u->write();
     $s = new \Ntb\SocialIdentity(['UserID' => 'foo_user', 'AuthService' => 'facebook', 'MemberID' => $u->ID]);
     $s->write();
 }
开发者ID:markguinn,项目名称:silverstripe-rest-api-oauth,代码行数:8,代码来源:FacebookSocialSessionEndpointTest.php

示例10: acs

 /**
  * Assertion Consumer Service
  *
  * The user gets sent back here after authenticating with the IdP, off-site.
  * The earlier redirection to the IdP can be found in the SAMLAuthenticator::authenticate.
  *
  * After this handler completes, we end up with a rudimentary Member record (which will be created on-the-fly
  * if not existent), with the user already logged in. Login triggers memberLoggedIn hooks, which allows
  * LDAP side of this module to finish off loading Member data.
  *
  * @throws OneLogin_Saml2_Error
  */
 public function acs()
 {
     $auth = Injector::inst()->get('SAMLHelper')->getSAMLAuth();
     $auth->processResponse();
     $error = $auth->getLastErrorReason();
     if (!empty($error)) {
         SS_Log::log($error, SS_Log::ERR);
         Form::messageForForm("SAMLLoginForm_LoginForm", "Authentication error: '{$error}'", 'bad');
         Session::save();
         return $this->getRedirect();
     }
     if (!$auth->isAuthenticated()) {
         Form::messageForForm("SAMLLoginForm_LoginForm", _t('Member.ERRORWRONGCRED'), 'bad');
         Session::save();
         return $this->getRedirect();
     }
     $decodedNameId = base64_decode($auth->getNameId());
     // check that the NameID is a binary string (which signals that it is a guid
     if (ctype_print($decodedNameId)) {
         Form::messageForForm("SAMLLoginForm_LoginForm", "Name ID provided by IdP is not a binary GUID.", 'bad');
         Session::save();
         return $this->getRedirect();
     }
     // transform the NameId to guid
     $guid = LDAPUtil::bin_to_str_guid($decodedNameId);
     if (!LDAPUtil::validGuid($guid)) {
         $errorMessage = "Not a valid GUID '{$guid}' recieved from server.";
         SS_Log::log($errorMessage, SS_Log::ERR);
         Form::messageForForm("SAMLLoginForm_LoginForm", $errorMessage, 'bad');
         Session::save();
         return $this->getRedirect();
     }
     // Write a rudimentary member with basic fields on every login, so that we at least have something
     // if LDAP synchronisation fails.
     $member = Member::get()->filter('GUID', $guid)->limit(1)->first();
     if (!($member && $member->exists())) {
         $member = new Member();
         $member->GUID = $guid;
     }
     $attributes = $auth->getAttributes();
     foreach ($member->config()->claims_field_mappings as $claim => $field) {
         if (!isset($attributes[$claim][0])) {
             SS_Log::log(sprintf('Claim rule \'%s\' configured in LDAPMember.claims_field_mappings, but wasn\'t passed through. Please check IdP claim rules.', $claim), SS_Log::WARN);
             continue;
         }
         $member->{$field} = $attributes[$claim][0];
     }
     $member->SAMLSessionIndex = $auth->getSessionIndex();
     // This will throw an exception if there are two distinct GUIDs with the same email address.
     // We are happy with a raw 500 here at this stage.
     $member->write();
     // This will trigger LDAP update through LDAPMemberExtension::memberLoggedIn.
     // Both SAML and LDAP identify Members by the GUID field.
     $member->logIn();
     return $this->getRedirect();
 }
开发者ID:eLBirador,项目名称:silverstripe-activedirectory,代码行数:68,代码来源:SAMLController.php

示例11: testDeletesOpauthIdentityOnDelete

 public function testDeletesOpauthIdentityOnDelete()
 {
     $member = new Member(array('Email' => 'test@test.com'));
     $member->write();
     $identity = new OpauthIdentity();
     $identity->write();
     $member->OpauthIdentities()->add($identity);
     $member->delete();
     $this->assertEquals(0, $member->OpauthIdentities()->Count());
 }
开发者ID:helpfulrobot,项目名称:betterbrief-silverstripe-opauth,代码行数:10,代码来源:OpauthMemberExtensionTest.php

示例12: createMember

 protected function createMember()
 {
     $email = $this->getValidEmailInput();
     if ($email !== false) {
         $member = new Member(['Email' => $email, 'Password' => $this->getPasswordFromInputOrEmail($email), 'FirstName' => $this->getFirstNameFromInputOrEmail($email), 'Surname' => $this->getLastNameInput()]);
         $member->write();
         return $member;
     }
     return false;
 }
开发者ID:axyr,项目名称:silverstripe-console,代码行数:10,代码来源:CreateMemberCommand.php

示例13: requireDefaultRecords

 function requireDefaultRecords()
 {
     $hasTestMembers = DataObject::get('Member')->find('Email', 'hayley@test.com');
     if (!$hasTestMembers) {
         foreach ($this->data() as $name) {
             $member = new Member(array('FirstName' => $name, 'FirstName' => 'Smith', 'Email' => "{$name}@test.com"));
             $member->write();
         }
         DB::alteration_message("Added default records to Member table", "created");
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-frameworktest,代码行数:11,代码来源:FrameworkTestRole.php

示例14: testCMSAccess

 public function testCMSAccess()
 {
     $members = Member::get()->byIDs($this->allFixtureIDs('Member'));
     foreach ($members as $member) {
         $this->assertTrue(Permission::checkMember($member, 'CMS_ACCESS'));
     }
     $member = new Member();
     $member->update(array('FirstName' => 'No CMS', 'Surname' => 'Access', 'Email' => 'no-access@example.com'));
     $member->write();
     $this->assertFalse(Permission::checkMember($member, 'CMS_ACCESS'));
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:11,代码来源:PermissionTest.php

示例15: testFindOrCreateMemberOverwriteExistingFields

 public function testFindOrCreateMemberOverwriteExistingFields()
 {
     $member = new Member(array('Email' => 'existing@test.com', 'FirstName' => 'Existing', 'Surname' => 'Existing'));
     $member->write();
     $identity = OpauthIdentity::factory(array('auth' => array('provider' => 'Facebook', 'uid' => 999, 'info' => array('email' => 'existing@test.com', 'first_name' => 'New', 'last_name' => 'New'))));
     $member = $identity->findOrCreateMember(array('overwriteExistingFields' => false));
     $this->assertEquals('Existing', $member->FirstName, 'Does not overwrite unless requested');
     $identity = OpauthIdentity::factory(array('auth' => array('provider' => 'Facebook', 'uid' => 999, 'info' => array('email' => 'existing@test.com', 'first_name' => 'New', 'last_name' => 'New'))));
     $member = $identity->findOrCreateMember(array('overwriteExistingFields' => array('FirstName')));
     $this->assertEquals('New', $member->FirstName, 'Overwrites existing fields if requested');
     $this->assertEquals('Existing', $member->Surname, 'Does not overwrite fields if not present in whitelist');
 }
开发者ID:helpfulrobot,项目名称:betterbrief-silverstripe-opauth,代码行数:12,代码来源:OpauthIdentityTest.php


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