本文整理汇总了PHP中Member::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Member::create方法的具体用法?PHP Member::create怎么用?PHP Member::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Member
的用法示例。
在下文中一共展示了Member::create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: php
public function php($data)
{
$member = $this->member;
$valid = true;
foreach ($this->unique as $field) {
$other = DataObject::get_one('Member', sprintf('"%s" = \'%s\'', Convert::raw2sql($field), Convert::raw2sql($data[$field])));
if ($other && (!$this->member || !$this->member->exists() || $other->ID != $this->member->ID)) {
$fieldInstance = $this->form->Fields()->dataFieldByName($field);
if ($fieldInstance->getCustomValidationMessage()) {
$message = $fieldInstance->getCustomValidationMessage();
} else {
$message = sprintf(_t('MemberProfiles.MEMBERWITHSAME', 'There is already a member with the same %s.'), $field);
}
$valid = false;
$this->validationError($field, $message, 'required');
}
}
// Create a dummy member as this is required for custom password validators
if (isset($data['Password']) && $data['Password'] !== "") {
if (is_null($member)) {
$member = Member::create();
}
if ($validator = $member::password_validator()) {
$results = $validator->validate($data['Password'], $member);
if (!$results->valid()) {
$valid = false;
foreach ($results->messageList() as $key => $value) {
$this->validationError('Password', $value, 'required');
}
}
}
}
return $valid && parent::php($data);
}
示例2: postCreate
/**
* This function create member
* when data posted from
* /admin/member/create
*/
public function postCreate()
{
// Check validation
$validator = Validator::make(Input::all(), Member::$rulesForCreate, Member::$messages);
// If failed then redirect to member-create-get route with
// validation error and input old
if ($validator->fails()) {
return Redirect::route('member-create-get')->withErrors($validator)->withInput();
}
// If validation is not failed then create member
$member = Member::create(array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'age' => Input::get('age'), 'gender' => Input::get('gender'), 'DOB' => DateFormat::store(Input::get('DOB')), 'present_address' => Input::get('present_address'), 'permanent_address' => Input::get('permanent_address'), 'city' => Input::get('city'), 'state' => Input::get('state'), 'country' => Input::get('country'), 'mobile_no' => Input::get('mobile_no'), 'email' => Input::get('email'), 'created_by' => Session::get('username')));
// Also create user account for the member
$user = User::create(array('details_id' => $member->id, 'username' => Input::get('username'), 'email' => $member->email, 'user_level' => 'member', 'active' => 0));
// generate random code and password
$password = str_random(10);
$code = str_random(60);
$newHashPassword = Hash::make($password);
// Save new password and code
$user->password_tmp = $newHashPassword;
$user->activation_code = $code;
if ($user->save()) {
// Send email to the member.
// This email contains username,password,activation link
Mail::send('emails.auth.activation', array('first_name' => $member->first_name, 'last_name' => $member->last_name, 'username' => $user->username, 'password' => $password, 'activation_link' => URL::route('activation-get', $code)), function ($message) use($user) {
$message->to($user->email, $user->username)->subject('Confirm Activation');
});
}
return View::make('adminArea.member.create')->with('success', 'Activation link has been sent successfully');
}
示例3: validateData
public function validateData(Order $order, array $data)
{
if (Member::currentUserID()) {
return;
}
$result = ValidationResult::create();
if (Checkout::membership_required() || !empty($data['Password'])) {
$member = Member::create($data);
$idfield = Member::config()->unique_identifier_field;
$idval = $data[$idfield];
if (ShopMember::get_by_identifier($idval)) {
// get localized field labels
$fieldLabels = $member->fieldLabels(false);
// if a localized value exists, use this for our error-message
$fieldLabel = isset($fieldLabels[$idfield]) ? $fieldLabels[$idfield] : $idfield;
$result->error(sprintf(_t("Checkout.MEMBEREXISTS", "A member already exists with the %s %s"), $fieldLabel, $idval), $idval);
}
$passwordresult = $this->passwordvalidator->validate($data['Password'], $member);
if (!$passwordresult->valid()) {
$result->error($passwordresult->message(), "Password");
}
}
if (!$result->valid()) {
throw new ValidationException($result);
}
}
示例4: parseOrderCustomer
public function parseOrderCustomer($orders, $transaction)
{
foreach ($orders->transactions->transaction as $order) {
// if not a guest transaction in FoxyCart
if (isset($order->customer_email) && $order->is_anonymous == 0) {
// if Customer is existing member, associate with current order
if (Member::get()->filter('Email', $order->customer_email)->First()) {
$customer = Member::get()->filter('Email', $order->customer_email)->First();
} else {
// set PasswordEncryption to 'none' so imported, encrypted password is not encrypted again
Config::inst()->update('Security', 'password_encryption_algorithm', 'none');
// create new Member, set password info from FoxyCart
$customer = Member::create();
$customer->Customer_ID = (int) $order->customer_id;
$customer->FirstName = (string) $order->customer_first_name;
$customer->Surname = (string) $order->customer_last_name;
$customer->Email = (string) $order->customer_email;
$customer->Password = (string) $order->customer_password;
$customer->Salt = (string) $order->customer_password_salt;
$customer->PasswordEncryption = 'none';
// record member record
$customer->write();
}
// set Order MemberID
$transaction->MemberID = $customer->ID;
}
}
}
示例5: run
public function run()
{
$faker = Faker\Factory::create();
//
for ($i = 0; $i < 50; $i++) {
$user = Member::create(array('first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'slug' => $faker->slug, 'image' => $faker->imageUrl($width = 125, $height = 150), 'pob' => $faker->city, 'dob' => $faker->date('Y-m-d', 'now'), 'gender' => $faker->numberBetween(1, 2), 'email' => $faker->email, 'address' => $faker->address, 'city' => $faker->city, 'province' => $faker->state, 'phone_home' => $faker->phoneNumber, 'phone_mobile' => $faker->phoneNumber));
}
}
示例6: setUpOnce
public function setUpOnce()
{
parent::setUpOnce();
Member::create(array('Email' => 'admin@api.com', 'Password' => 'admin'))->write();
$member = Member::get()->filter(array('Email' => 'admin@api.com'))->first();
$member->addToGroupByCode('restfulapi-administrators');
Member::create(array('Email' => 'stranger@api.com', 'Password' => 'stranger'))->write();
}
开发者ID:helpfulrobot,项目名称:colymba-silverstripe-restfulapi,代码行数:8,代码来源:RESTfulAPI_DefaultPermissionManager_Test.php
示例7: doSignup
public function doSignup(array $data)
{
$o_Member = Member::create();
$this->saveInto($o_Member);
$o_Member->Locale = i18n::get_locale();
$o_Member->write();
// We use Email Verified Member
$this->controller->redirect('Security/emailsent/' . $data['Email']);
}
示例8: authenticate
public static function authenticate($RAW_data, Form $form = null)
{
$member = Member::get()->first();
if (!$member || !$member->exists()) {
$member = Member::create();
$member->FirstName = _t('Member.DefaultAdminFirstname', 'Default Admin');
$member->write();
}
return $member;
}
示例9: buildReduced
/**
* @param array $data
* @return Member
*/
public function buildReduced(array $data)
{
$member = Member::create();
$member->FirstName = trim($data['FirstName']);
$member->Surname = trim($data['Surname']);
$member->Email = trim($data['Email']);
$member->Country = trim($data['Country']);
$member->Password = trim($data['Password']['_Password']);
return $member;
}
示例10: createMember
public function createMember()
{
$member = Member::create(array('first_name' => 'Iftekher', 'last_name' => 'Sunny', 'age' => 23, 'gender' => 'Male', 'DOB' => Carbon::today(), 'present_address' => 'Present address .....', 'permanent_address' => 'Permanent address ...', 'city' => 'Chittagong', 'state' => 'state ....', 'country' => 'Bangladesh', 'mobile_no' => '+8801800000000', 'email' => 'member@gmail.com', 'created_by' => 'Developer'));
$user = User::create(array('username' => 'member', 'password' => Hash::make('member'), 'user_level' => 'member123', 'email' => 'member@gmail.com', 'password_tmp' => '', 'activation_code' => '', 'active' => 1, 'remember_token' => '', 'details_id' => $member->id));
// generate random code and password
$password = str_random(10);
$code = str_random(60);
$newHashPassword = Hash::make($password);
// Save new password and code
$user->password_tmp = $newHashPassword;
$user->activation_code = $code;
$user->save();
}
示例11: testUnchangedFieldsDoesNotTriggerStatusChange
public function testUnchangedFieldsDoesNotTriggerStatusChange()
{
$spammer = Member::create();
$spammer->Nickname = 'loveguru69';
$spammer->FirstName = 'LoveGuru';
$spammer->Occupation = 'Astrology';
$spammer->Company = 'vashikaran specialist mantra';
$spammer->Email = 'loveguru69@gmail.com';
$spammer->write();
$user = Member::get()->filter('Nickname', 'loveguru69')->first();
$this->assertEquals($user->ForumStatus, 'Ghost');
$this->assertEmailSent('someone@somewhere.com', 'no-reply@somewhere.com', 'Suspected spammer: Please review');
$user->ForumStatus = 'Normal';
$user->write();
$this->assertEquals($user->ForumStatus, 'Normal');
}
示例12: parameterFields
public function parameterFields()
{
$member = Member::currentUserID() ? Member::currentUser() : Member::create();
$dateformat = $member->getDateFormat();
$fields = FieldList::create($start = DateField::create("StartPeriod", "Start Date"), $end = DateField::create("EndPeriod", "End Date"));
if ($this->grouping) {
$fields->push(DropdownField::create("Grouping", "Group By", array("Year" => "Year", "Month" => "Month", "Day" => "Day"), 'Month'));
if (self::config()->display_uncategorised_data) {
$fields->push(CheckboxField::create("IncludeUncategorised", "Include Uncategorised Data")->setDescription("Display data that doesn't have a date."));
}
}
$start->setConfig("dateformat", $dateformat);
$end->setConfig("dateformat", $dateformat);
$start->setConfig("showcalendar", true);
$end->setConfig("showcalendar", true);
return $fields;
}
示例13: testUserFollowing
public function testUserFollowing()
{
Restrictable::set_enabled(false);
$memberOne = Member::create();
$memberOne->Email = 'one@one.com';
$memberOne->Password = '1234';
$memberOne->write();
$memberTwo = Member::create();
$memberTwo->Email = 'two@two.com';
$memberTwo->Password = '1234';
$memberTwo->write();
$svc = singleton('MicroBlogService');
/* @var $svc MicroBlogService */
singleton('SecurityContext')->setMember($memberOne);
$svc->addFriendship($memberOne, $memberTwo);
// gah - ss3's testing setup needs to be better sorted to be able to do this bit...
}
示例14: Register
/**
* @param $data
* @param $form
* @return bool|SS_HTTPResponse
*/
public function Register($data, $form)
{
/** @var Form $form */
$data = $form->getData();
/** Set session array individually as setting the password breaks the form. */
$sessionArray = array('Email' => $data['Email']);
/** Check for existing member email address */
if ($existingUser = DataObject::get_one('Member', "Email = '" . Convert::raw2sql($data['Email']) . "'")) {
$form->AddErrorMessage('Email', 'Sorry, that email address already exists. Please choose another.', 'validation');
Session::set('FormInfo.Form_' . $this->name . '.data', $sessionArray);
return $this->controller->redirectBack();
}
/** Otherwise create new member and log them in
*
* @var Member $member
*/
$member = Member::create();
$form->saveInto($member);
$member->write();
$member->login();
/** Find or create the 'user' group
*
* @var Group $userGroup
*/
if (!($userGroup = DataObject::get_one('Group', "Code = 'users'"))) {
$userGroup = Group::create();
$userGroup->Code = 'users';
$userGroup->Title = 'Users';
$userGroup->Write();
$userGroup->Members()->add($member);
}
/** Add member to user group */
$userGroup->Members()->add($member);
/** Get profile page otherwise display warning. */
if ($ProfilePage = DataObject::get_one('EditProfilePage')) {
$this->controller->setFlash('Welcome ' . $data['Email'] . ', your account has been created!', 'success');
return $this->controller->redirect($ProfilePage->Link());
} else {
$this->controller->setFlash('Please add a "Edit Profile Page" in your SiteTree to enable profile editing', 'warning');
return $this->controller->redirect(Director::absoluteBaseURL());
}
}
示例15: register
public function register($data, $form)
{
//log out existing user
if ($member = Member::currentUser()) {
$member->logOut();
}
$member = Member::create();
$form->saveInto($member);
$member->write();
$this->extend('onRegister', $member);
$member->logIn();
if ($back = Session::get("BackURL")) {
Session::clear("BackURL");
return $this->Controller()->redirect($back);
}
if ($link = $member->getProfileLink()) {
return $this->controller->redirect($link);
}
return $this->controller->redirect($this->controller->Link());
}