/[drupal]/contributions/modules/advuser/advuser.module
ViewVC logotype

Diff of /contributions/modules/advuser/advuser.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.14.2.6, Wed Feb 18 12:40:13 2009 UTC revision 1.14.2.7, Wed Mar 18 13:13:12 2009 UTC
# Line 5  Line 5 
5   * filtering and apply actions to block, unblock, delete or email the selected   * filtering and apply actions to block, unblock, delete or email the selected
6   * users.   * users.
7   *   *
8   * $Id: advuser.module,v 1.14.2.5 2009/02/18 12:27:46 earnie Exp $   * $Id: advuser.module,v 1.14.2.6 2009/02/18 12:40:13 earnie Exp $
9   **/   **/
10    
11  /**  /**
# Line 396  function advuser_multiple_email_confirm_ Line 396  function advuser_multiple_email_confirm_
396    if ($form_state['values']['confirm']) {    if ($form_state['values']['confirm']) {
397      foreach ($form_state['values']['accounts'] as $uid => $value) {      foreach ($form_state['values']['accounts'] as $uid => $value) {
398        $account = user_load(array('uid' => $uid));        $account = user_load(array('uid' => $uid));
399        $from = variable_get("site_mail", ini_get("sendmail_from"));        $from = variable_get("site_mail", "nobody@$_SERVER[SERVER_NAME]");
400        // these are invariant for all sent emails        // these are invariant for all sent emails
401        $variables = _advuser_get_variables($account);        $variables = _advuser_get_variables($account);
402        $mail_subject = strtr($form_state['values']['mailsubject'], $variables);        $mail_subject = strtr($form_state['values']['mailsubject'], $variables);
403        $mail_body = strtr($form_state['values']['mailbody'], $variables);        $mail_body = strtr($form_state['values']['mailbody'], $variables);
404        drupal_mail('advance-user-mail', $account->mail, $mail_subject, $mail_body, $from);        drupal_mail('advuser', 'advance-user-mail', $account->mail, user_preferred_language($account), array('subject' => $mail_subject, 'body' => $mail_body), $from, TRUE);
405      }      }
406      drupal_set_message(t('The users have been mailed.'));      drupal_set_message(t('The users have been mailed.'));
407    }    }
# Line 409  function advuser_multiple_email_confirm_ Line 409  function advuser_multiple_email_confirm_
409  }  }
410    
411  /**  /**
412     * Implementation of hook_mail
413     */
414    function advuser_mail($key, &$message, $params) {
415      $message = array_merge($message, $params);
416    }
417    
418    /**
419   * advuser settings page   * advuser settings page
420   */   */
421  function advuser_settings() {  function advuser_settings() {
# Line 555  function _advuser_get_variables($user) { Line 562  function _advuser_get_variables($user) {
562  function _advuser_dbquery_users_to_notify() {  function _advuser_dbquery_users_to_notify() {
563    $user_where = users_by_access('receive email advuser');    $user_where = users_by_access('receive email advuser');
564    $user_where = implode(',', $user_where);    $user_where = implode(',', $user_where);
565    return empty($user_where) ? FALSE : db_query('SELECT u.mail, u.name FROM {users} u WHERE uid IN (' . $user_where . ')');    return empty($user_where) ? FALSE : db_query('SELECT u.* FROM {users} u WHERE uid IN (' . $user_where . ')');
566  }  }
567    
568    
# Line 611  function users_by_access($perm) { Line 618  function users_by_access($perm) {
618   * @param string $from   * @param string $from
619   */   */
620  function _advuser_mail_roles ($user_subject, $user_body, $from) {  function _advuser_mail_roles ($user_subject, $user_body, $from) {
621    static $mail_list = array();    static $accounts = array();
622    if (empty($mail_list)) {    if (empty($mail_list)) {
623      $result = _advuser_dbquery_users_to_notify();      $result = _advuser_dbquery_users_to_notify();
624      while ($row = db_fetch_object($result)) {      while ($row = db_fetch_object($result)) {
625        $mail_list[] = $row->mail;        $accounts[] = $row;
626      }      }
627    }    }
628    foreach ($mail_list as $to) {    foreach ($accounts as $account) {
629      drupal_mail('advanced-user-mail', $to, $user_subject, $user_body, $from);      drupal_mail('advuser', 'advanced-user-mail', $account->mail, user_preferred_language($account), array('subject' => $user_subject, 'body' => $user_body), $from, TRUE);
630    }    }
631  }  }
632    

Legend:
Removed from v.1.14.2.6  
changed lines
  Added in v.1.14.2.7

  ViewVC Help
Powered by ViewVC 1.1.2