You are here

function advuser_user_update in Advanced User 5

Same name and namespace in other branches
  1. 5.2 advuser.module \advuser_user_update()
  2. 6.2 advuser.module \advuser_user_update()
  3. 7.3 advuser.module \advuser_user_update()

Handle user edit TODO: DRY (don't repeat yourself!)

1 call to advuser_user_update()
advuser_user in ./advuser.module
hook_user implementation

File

./advuser.module, line 861

Code

function advuser_user_update($edit, $user, $category) {

  // send mail
  if (variable_get('advuser_modify_notify', ADVUSER_DEFAULT_MODIFY_NOTIFY)) {
    $from = variable_get("site_mail", ini_get("sendmail_from"));
    $body = variable_get('advuser_modify_mail', ADVUSER_DEFAULT_MODIFY_MAIL);
    $subject = variable_get('advuser_modify_subject', ADVUSER_DEFAULT_MODIFY_SUBJECT);

    // these are invariant for all sent emails
    $variables = _advuser_get_variables($user);
    $user_subject = strtr($subject, $variables);
    $user_body = strtr($body, $variables);
    watchdog('advuser', "Sending user account mail: subj='{$user_subject}' body='{$user_body}'");
    $roles = variable_get('advuser_new_roles', ADVUSER_DEFAULT_NEW_ROLES);
    $result = _advuser_dbquery_users_to_notify($roles);
    while ($row = db_fetch_object($result)) {
      drupal_mail('advanced-user-mail', $row->mail, $user_subject, $user_body, $from);
    }
  }
}