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


PHP _user_mail_notify函数代码示例

本文整理汇总了PHP中_user_mail_notify函数的典型用法代码示例。如果您正苦于以下问题:PHP _user_mail_notify函数的具体用法?PHP _user_mail_notify怎么用?PHP _user_mail_notify使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: testUserMailsNotSent

 /**
  * Tests mails are not sent when notify.$op is FALSE.
  *
  * @param string $op
  *   The operation being performed on the account.
  * @param array $mail_keys
  *   The mail keys to test for. Ignored by this test because we assert that no
  *   mails at all are sent.
  *
  * @dataProvider userMailsProvider
  */
 public function testUserMailsNotSent($op, array $mail_keys)
 {
     $this->config('user.settings')->set('notify.' . $op, FALSE)->save();
     $return = _user_mail_notify($op, $this->createUser());
     $this->assertFalse($return, '_user_mail_notify() returns FALSE.');
     $this->assertEmpty($this->getMails(), 'No emails sent by _user_mail_notify().');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:18,代码来源:UserMailNotifyTest.php

示例2: testActionExecution

 /**
  * Tests the action execution.
  *
  * @covers ::execute
  */
 public function testActionExecution()
 {
     $account = $this->prophesizeEntity(UserInterface::class);
     $mail_type = 'test_mail_type';
     $this->action->setContextValue('user', $account->reveal())->setContextValue('email_type', $mail_type);
     $this->action->execute();
     // To ge the notifications that were sent, we call the _user_mail_notify()
     // with no parameters.
     $notifications = _user_mail_notify();
     $this->assertSame([$mail_type => 1], $notifications);
 }
开发者ID:Progressable,项目名称:openway8,代码行数:16,代码来源:SendAccountEmailTest.php

示例3: hook_redhen_contact_user_update

/**
 * Act on the contact when the link to a drupal user account is modified
 *
 * @param string $op ( insert | update | delete )
 * @param $contact
 *  The RedhenContact object with the new user drupal user info
 * @param $old_contact
 *  The RedhenContact object with the old user info
 *
 * @return void
 */
function hook_redhen_contact_user_update($op, RedhenContact $contact, $old_contact = NULL)
{
    // Send "Welcome (no approval required)" email to new user.
    if ($op == 'insert') {
        $wrapper = entity_metadata_wrapper('redhen_contact', $contact);
        // Set _user_mail_notify specific operation.
        $op = 'register_no_approval_required';
        // Send an email.
        _user_mail_notify($op, $wrapper->user->value());
    }
}
开发者ID:petergiesin,项目名称:asfitness,代码行数:22,代码来源:redhen.api.php

示例4: processItem

 /**
  * {@inheritdoc}
  */
 public function processItem($data)
 {
     try {
         $user_data = ['mail' => $data->attendee->email, 'name' => $data->attendee->email, 'status' => 1, 'field_first_name' => ['value' => $data->attendee->first_name], 'field_last_name' => ['value' => $data->attendee->last_name]];
         $user = entity_create('user', $user_data);
         $user->save();
         _user_mail_notify('register_admin_created', $user);
         if ($data->attendee->amount_paid == $this->personalSponsorshipPrice) {
             $this->createUserProfile($user, TRUE);
         } else {
             $this->createUserProfile($user);
         }
     } catch (\Exception $e) {
         \Drupal::logger('eventbrite cron')->log(RfcLogLevel::ERROR, 'User {mail} hasn\'t been created.', ['mail' => $data->attendee->email]);
     }
 }
开发者ID:slovak-drupal-association,项目名称:dccs,代码行数:19,代码来源:EventbriteAttendeesSync.php

示例5: processItem

 /**
  * {@inheritdoc}
  */
 public function processItem($data)
 {
     if (FALSE === user_load_by_mail($data->attendee->email)) {
         try {
             // build array of user data
             $user_data = ['mail' => $data->attendee->email, 'name' => $data->attendee->email, 'status' => 1, 'field_first_name' => ['value' => $data->attendee->first_name], 'field_last_name' => ['value' => $data->attendee->last_name]];
             // create User entity
             $user = entity_create('user', $user_data);
             $user->save();
             // notify user about new account
             _user_mail_notify('register_admin_created', $user);
             // create user profile
             $this->createUserProfile($user);
         } catch (\Exception $e) {
             \Drupal::logger('eventbrite')->log(RfcLogLevel::ERROR, 'User {mail} hasn\'t been created.', ['mail' => $data->attendee->email]);
         }
     }
 }
开发者ID:slovak-drupal-association,项目名称:dccs,代码行数:21,代码来源:EventbriteSync.php

示例6: processItem

 /**
  * {@inheritdoc}
  */
 public function processItem($data)
 {
     if (is_array($data)) {
         $name = explode(' ', $data[0]);
         $email = $data[1];
         $username = explode('@', $email);
         try {
             // build array of user data
             $user_data = ['mail' => $email, 'name' => $username[0], 'status' => 1, 'field_first_name' => ['value' => $name[0]], 'field_last_name' => ['value' => $name[1]]];
             // create User entity
             $user = entity_create('user', $user_data);
             $user->save();
             // notify user about new account
             _user_mail_notify('register_admin_created', $user);
             // create user profile
             $this->createUserProfile($user);
         } catch (\Exception $e) {
             \Drupal::logger('eventninja queue')->log(RfcLogLevel::ERROR, 'User {mail} hasn\'t been created.', ['mail' => $email]);
         }
     }
 }
开发者ID:slovak-drupal-association,项目名称:dccs,代码行数:24,代码来源:EventninjaSync.php

示例7: save

 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     $account = $this->entity;
     $pass = $account->getPassword();
     $admin = $form_state->getValue('administer_users');
     $notify = !$form_state->isValueEmpty('notify');
     // Save has no return value so this cannot be tested.
     // Assume save has gone through correctly.
     $account->save();
     $form_state->set('user', $account);
     $form_state->setValue('uid', $account->id());
     $this->logger('user')->notice('New user: %name %email.', array('%name' => $form_state->getValue('name'), '%email' => '<' . $form_state->getValue('mail') . '>', 'type' => $account->link($this->t('Edit'), 'edit-form')));
     // Add plain text password into user account to generate mail tokens.
     $account->password = $pass;
     // New administrative account without notification.
     if ($admin && !$notify) {
         drupal_set_message($this->t('Created a new user account for <a href="@url">%name</a>. No email has been sent.', array('@url' => $account->url(), '%name' => $account->getUsername())));
     } elseif (!$admin && !\Drupal::config('user.settings')->get('verify_mail') && $account->isActive()) {
         _user_mail_notify('register_no_approval_required', $account);
         user_login_finalize($account);
         drupal_set_message($this->t('Registration successful. You are now logged in.'));
         $form_state->setRedirect('<front>');
     } elseif ($account->isActive() || $notify) {
         if (!$account->getEmail() && $notify) {
             drupal_set_message($this->t('The new user <a href="@url">%name</a> was created without an email address, so no welcome message was sent.', array('@url' => $account->url(), '%name' => $account->getUsername())));
         } else {
             $op = $notify ? 'register_admin_created' : 'register_no_approval_required';
             if (_user_mail_notify($op, $account)) {
                 if ($notify) {
                     drupal_set_message($this->t('A welcome message with further instructions has been emailed to the new user <a href="@url">%name</a>.', array('@url' => $account->url(), '%name' => $account->getUsername())));
                 } else {
                     drupal_set_message($this->t('A welcome message with further instructions has been sent to your email address.'));
                     $form_state->setRedirect('<front>');
                 }
             }
         }
     } else {
         _user_mail_notify('register_pending_approval', $account);
         drupal_set_message($this->t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, a welcome message with further instructions has been sent to your email address.'));
         $form_state->setRedirect('<front>');
     }
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:45,代码来源:RegisterForm.php

示例8: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $langcode = $this->languageManager->getCurrentLanguage()->getId();
     $account = $form_state->getValue('account');
     // Mail one time login URL and instructions using current language.
     $mail = _user_mail_notify('password_reset', $account, $langcode);
     if (!empty($mail)) {
         $this->logger('user')->notice('Password reset instructions mailed to %name at %email.', array('%name' => $account->getUsername(), '%email' => $account->getEmail()));
         drupal_set_message($this->t('Further instructions have been sent to your email address.'));
     }
     $form_state->setRedirect('user.page');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:15,代码来源:UserPasswordForm.php

示例9: createUser

 /**
  * @inheritDoc
  */
 public function createUser(&$params, $mail)
 {
     $user = \Drupal::currentUser();
     $user_register_conf = \Drupal::config('user.settings')->get('register');
     $verify_mail_conf = \Drupal::config('user.settings')->get('verify_mail');
     // Don't create user if we don't have permission to.
     if (!$user->hasPermission('administer users') && $user_register_conf == 'admin_only') {
         return FALSE;
     }
     $account = entity_create('user');
     $account->setUsername($params['cms_name'])->setEmail($params[$mail]);
     // Allow user to set password only if they are an admin or if
     // the site settings don't require email verification.
     if (!$verify_mail_conf || $user->hasPermission('administer users')) {
         // @Todo: do we need to check that passwords match or assume this has already been done for us?
         $account->setPassword($params['cms_pass']);
     }
     // Only activate account if we're admin or if anonymous users don't require
     // approval to create accounts.
     if ($user_register_conf != 'visitors' && !$user->hasPermission('administer users')) {
         $account->block();
     }
     // Validate the user object
     $violations = $account->validate();
     if (count($violations)) {
         return FALSE;
     }
     try {
         $account->save();
     } catch (\Drupal\Core\Entity\EntityStorageException $e) {
         return FALSE;
     }
     // Send off any emails as required.
     // Possible values for $op:
     //    - 'register_admin_created': Welcome message for user created by the admin.
     //    - 'register_no_approval_required': Welcome message when user
     //      self-registers.
     //    - 'register_pending_approval': Welcome message, user pending admin
     //      approval.
     // @Todo: Should we only send off emails if $params['notify'] is set?
     switch (TRUE) {
         case $user_register_conf == 'admin_only' || $user->isAuthenticated():
             _user_mail_notify('register_admin_created', $account);
             break;
         case $user_register_conf == 'visitors':
             _user_mail_notify('register_no_approval_required', $account);
             break;
         case 'visitors_admin_approval':
             _user_mail_notify('register_pending_approval', $account);
             break;
     }
     return $account->id();
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:56,代码来源:Drupal8.php

示例10: submit

 /**
  * {@inheritdoc}
  */
 public function submit(array $form, FormStateInterface $form_state)
 {
     // Cancel account immediately, if the current user has administrative
     // privileges, no confirmation mail shall be sent, and the user does not
     // attempt to cancel the own account.
     if ($this->currentUser()->hasPermission('administer users') && empty($form_state['values']['user_cancel_confirm']) && $this->entity->id() != $this->currentUser()->id()) {
         user_cancel($form_state['values'], $this->entity->id(), $form_state['values']['user_cancel_method']);
         $form_state->setRedirect('user.admin_account');
     } else {
         // Store cancelling method and whether to notify the user in
         // $this->entity for user_cancel_confirm().
         $this->entity->user_cancel_method = $form_state['values']['user_cancel_method'];
         $this->entity->user_cancel_notify = $form_state['values']['user_cancel_notify'];
         $this->entity->save();
         _user_mail_notify('cancel_confirm', $this->entity);
         drupal_set_message($this->t('A confirmation request to cancel your account has been sent to your email address.'));
         $this->logger('user')->notice('Sent account cancellation request to %name %email.', array('%name' => $this->entity->label(), '%email' => '<' . $this->entity->getEmail() . '>'));
         $form_state->setRedirect('user.view', array('user' => $this->entity->id()));
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:23,代码来源:UserCancelForm.php

示例11: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $langcode = $this->languageManager->getCurrentLanguage()->id;
     $account = $form_state['values']['account'];
     // Mail one time login URL and instructions using current language.
     $mail = _user_mail_notify('password_reset', $account, $langcode);
     if (!empty($mail)) {
         watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' => $account->getUsername(), '%email' => $account->getEmail()));
         drupal_set_message($this->t('Further instructions have been sent to your email address.'));
     }
     $form_state['redirect_route']['route_name'] = 'user.page';
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:15,代码来源:UserPasswordForm.php

示例12: resetPassword

 public function resetPassword($email)
 {
     $users = \user_load_multiple(array(), array('mail' => $email, 'status' => '1'));
     $account = \reset($users);
     if (isset($account->uid)) {
         $mail = \_user_mail_notify('password_reset', $account, null);
         if (!empty($mail)) {
             return true;
         }
     }
     return false;
 }
开发者ID:nayanseth,项目名称:meetups,代码行数:12,代码来源:User.php

示例13: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     // Cancel account immediately, if the current user has administrative
     // privileges, no confirmation mail shall be sent, and the user does not
     // attempt to cancel the own account.
     if (!$form_state->isValueEmpty('access') && $form_state->isValueEmpty('user_cancel_confirm') && $this->entity->id() != $this->currentUser()->id()) {
         user_cancel($form_state->getValues(), $this->entity->id(), $form_state->getValue('user_cancel_method'));
         $form_state->setRedirectUrl($this->entity->urlInfo('collection'));
     } else {
         // Store cancelling method and whether to notify the user in
         // $this->entity for
         // \Drupal\user\Controller\UserController::confirmCancel().
         $this->entity->user_cancel_method = $form_state->getValue('user_cancel_method');
         $this->entity->user_cancel_notify = $form_state->getValue('user_cancel_notify');
         $this->entity->save();
         _user_mail_notify('cancel_confirm', $this->entity);
         drupal_set_message($this->t('A confirmation request to cancel your account has been sent to your email address.'));
         $this->logger('user')->notice('Sent account cancellation request to %name %email.', array('%name' => $this->entity->label(), '%email' => '<' . $this->entity->getEmail() . '>'));
         $form_state->setRedirect('entity.user.canonical', array('user' => $this->entity->id()));
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:24,代码来源:UserCancelForm.php

示例14: execute

 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $account = $this->getContextValue('user');
     $mail_type = $this->getContextValue('email_type');
     _user_mail_notify($mail_type, $account);
 }
开发者ID:shahinam,项目名称:drupal8devel,代码行数:9,代码来源:SendAccountEmail.php

示例15: callback_handler


//.........这里部分代码省略.........
									$user_roles = array();  // real user accounts get the authenticated user role.
									// Make sure at least one module implements our hook.
									if (count(\Drupal::moduleHandler()->getImplementations('social_login_default_user_roles')) > 0) {
										// Call modules that implements the hook.
										$user_roles = \Drupal::moduleHandler()->invokeAll('social_login_default_user_roles', $user_roles);
									}

									// Setup the user fields.
									$user_fields = array(
											'name' => $user_login,
											'mail' => $user_email,
											'pass' => $user_password,
											'status' => $user_status,
											'init' => $user_email,
											'roles' => $user_roles,
									);

									// Create a new user.
									$account = User::create($user_fields);
									$account->save();

									// The new account has been created correctly.
									if ($account !== FALSE) {

										// Disable Drupal legacy registration.
										$registration_method = 'auto';

										// Log the new user in.
										if (($uid = \Drupal::service("user.auth")->authenticate($user_login, $user_password)) !== FALSE) {

											// Loads a user object.
											$user = User::load($uid);

											user_login_finalize($user);

											// Send email if it's not a random email.
											if ($user_email_is_random !== TRUE) {
												// No approval required.
												if ($user_status == 1) {
													_user_mail_notify('register_no_approval_required', $user);
													drupal_set_message(t('You have succesfully created an account and linked it with your @social_network account.', array(
															'@social_network' => $provider_name,
													)), 'status');
												}
												// Approval required.
												else {
													$a = _user_mail_notify('register_pending_approval', $user);
													drupal_set_message(t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />You will receive an email once your account has been approved and you can then login with your @social_network account.', array(
															'@social_network' => $provider_name,
													)), 'status');
												}
											}
											// Random email used.
											else {
												drupal_set_message(t('You have succesfully created an account and linked it with your @social_network account.', array(
														'@social_network' => $provider_name,
												)), 'status');
											}
										}
										// For some reason we could not log the user in.
										else {
											// Redirect to login page (login manually).
											drupal_set_message(t('Error while logging you in, please try to login manually.'), 'error');
											\Drupal::logger('social_login')->error('- '. __FUNCTION__ .'@'. __LINE__ .' auto login, redirecting to '. \Drupal::url('user.login'));
											return new RedirectResponse(\Drupal::url('user.login'));
										}
									}
									// An error occured during user->save().
									else {
										// Redirect to registration page (register manually).
										drupal_set_message(t('Error while creating your user account, please try to register manually.'), 'error');
										\Drupal::logger('social_login')->error('- '. __FUNCTION__ .'@'. __LINE__ .' auto register, redirecting to '. \Drupal::url('user.register'));
										return new RedirectResponse(\Drupal::url('user.register'));
									}
								}

								// Use the legacy registration form?
								if ($registration_method == 'manual') {
									// Redirect to the registration page (+ prepopulate form with SESSION data).
									\Drupal::logger('social_login')->notice('- '. __FUNCTION__ .'@'. __LINE__ .' manual register, redirecting to '. \Drupal::url('user.register'));
									return new RedirectResponse(\Drupal::url('user.register'));
								}
							}
							// Registration disabled.
							else {
								drupal_set_message(t('Only site administrators can create new user accounts.'), 'error');
								return new RedirectResponse(\Drupal::url('<front>'));
							}
						}
					}
				}
				else {
					\Drupal::logger('social_login')->error('- '. __FUNCTION__ .'@'. __LINE__ .' invalid JSON received from resource');
				}
			}
		}

		// Return to the front page.
		return new RedirectResponse(\Drupal::url('<front>'));
	}
开发者ID:Greg-Boggs,项目名称:electric-dev,代码行数:101,代码来源:SocialLoginCore.php


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