/[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.16, Tue Jan 13 14:29:00 2009 UTC revision 1.17, Mon Apr 6 14:42:20 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.15 2009/01/13 13:52:09 earnie Exp $   * $Id: advuser.module,v 1.14.2.7 2009/03/18 13:13:12 earnie Exp $
9   **/   **/
10    
11  /**  /**
# Line 18  define('ADVUSER_SUBSTITUTION_TEXT', ' Line 18  define('ADVUSER_SUBSTITUTION_TEXT', '
18   */   */
19  function advuser_perm() {  function advuser_perm() {
20    return array(    return array(
21      t('administer advuser'),      'administer advuser',
22      t('access advuser'),      'access advuser',
23      t('send email advuser'),      'send email advuser',
24      t('receive email advuser'),      'receive email advuser',
25    );    );
26  }  }
27    
# Line 148  function advuser_admin_account() { Line 148  function advuser_admin_account() {
148      $form['roles'][$account->uid][0] = array('#value' => theme('item_list', $users_roles));      $form['roles'][$account->uid][0] = array('#value' => theme('item_list', $users_roles));
149      $form['member_for'][$account->uid] = array('#value' => format_interval(time() - $account->created));      $form['member_for'][$account->uid] = array('#value' => format_interval(time() - $account->created));
150      $form['last_access'][$account->uid] =  array('#value' => $account->access ? t('@time ago', array('@time' => format_interval(time() - $account->access))) : t('never'));      $form['last_access'][$account->uid] =  array('#value' => $account->access ? t('@time ago', array('@time' => format_interval(time() - $account->access))) : t('never'));
151      profile_load_profile($account);      module_invoke('profile', 'load_profile', $account);
152      foreach(advuser_profile_fields() as $field) {      foreach(advuser_profile_fields() as $field) {
153        $form[$field->name][$account->uid] = array('#value' => profile_view_field($account, $field));        $form[$field->name][$account->uid] = array('#value' => profile_view_field($account, $field));
154      }      }
155      $fv = l(t('edit'), "user/$account->uid/edit", array(), $destination);      $fv = l(t('edit'), "user/$account->uid/edit", array('query' => $destination));
156      if ($account->uid != 1) {      if ($account->uid != 1) {
157        $fv .= ' | ' . l(t('delete'), "user/$account->uid/delete", array(), $destination);        $fv .= ' | ' . l(t('delete'), "user/$account->uid/delete", array('query' => $destination));
158      }      }
159      $form['operations'][$account->uid] = array('#value' => $fv);      $form['operations'][$account->uid] = array('#value' => $fv);
160    }    }
# Line 265  function theme_advuser_admin_account($fo Line 265  function theme_advuser_admin_account($fo
265  /**  /**
266   * Submit the user administration update form.   * Submit the user administration update form.
267   */   */
268  function advuser_admin_account_submit($form, &$form_states) {  function advuser_admin_account_submit($form, &$form_state) {
269    $operations = module_invoke_all('user_operations');    $operations = module_invoke_all('user_operations');
270    $operations = array_merge($operations,module_invoke_all('advuser_operations'));    $operations = array_merge($operations,module_invoke_all('advuser_operations'));
271    $operation = $operations[$form_state['values']['operation']];    $operation = $operations[$form_state['values']['operation']];
# 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 533  function _advuser_get_variables($user) { Line 540  function _advuser_get_variables($user) {
540    return array(    return array(
541      '%user_name' => $user->name,      '%user_name' => $user->name,
542      '%site' => variable_get("site_name", "drupal"),      '%site' => variable_get("site_name", "drupal"),
543      '%uri' => url('user/'. $user->uid, NULL, NULL, TRUE),      '%uri' => url('user/'. $user->uid, array('absolute' => TRUE)),
544      '%user_email' => $user->mail,      '%user_email' => $user->mail,
545      '%user_status' => t($user->status ? 'Active' : 'Blocked'),      '%user_status' => t($user->status ? 'Active' : 'Blocked'),
546      '%user_theme' => empty($user->theme) ? t('DEFAULT') : $user->theme,      '%user_theme' => empty($user->theme) ? t('DEFAULT') : $user->theme,
# 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.16  
changed lines
  Added in v.1.17

  ViewVC Help
Powered by ViewVC 1.1.2