[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/includes/acp/ -> acp_inactive.php (source)

   1  <?php
   2  /**
   3  *
   4  * This file is part of the phpBB Forum Software package.
   5  *
   6  * @copyright (c) phpBB Limited <https://www.phpbb.com>
   7  * @license GNU General Public License, version 2 (GPL-2.0)
   8  *
   9  * For full copyright and license information, please see
  10  * the docs/CREDITS.txt file.
  11  *
  12  */
  13  
  14  /**
  15  * @ignore
  16  */
  17  if (!defined('IN_PHPBB'))
  18  {
  19      exit;
  20  }
  21  
  22  class acp_inactive
  23  {
  24      var $u_action;
  25      var $p_master;
  26  
  27  	function acp_inactive(&$p_master)
  28      {
  29          $this->p_master = &$p_master;
  30      }
  31  
  32  	function main($id, $mode)
  33      {
  34          global $config, $db, $user, $auth, $template, $phpbb_container;
  35          global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix;
  36  
  37          if (!function_exists('user_active_flip'))
  38          {
  39              include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
  40          }
  41  
  42          $user->add_lang('memberlist');
  43  
  44          $action = request_var('action', '');
  45          $mark    = (isset($_REQUEST['mark'])) ? request_var('mark', array(0)) : array();
  46          $start    = request_var('start', 0);
  47          $submit = isset($_POST['submit']);
  48  
  49          // Sort keys
  50          $sort_days    = request_var('st', 0);
  51          $sort_key    = request_var('sk', 'i');
  52          $sort_dir    = request_var('sd', 'd');
  53  
  54          $form_key = 'acp_inactive';
  55          add_form_key($form_key);
  56          $pagination = $phpbb_container->get('pagination');
  57  
  58          // We build the sort key and per page settings here, because they may be needed later
  59  
  60          // Number of entries to display
  61          $per_page = request_var('users_per_page', (int) $config['topics_per_page']);
  62  
  63          // Sorting
  64          $limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 365 => $user->lang['1_YEAR']);
  65          $sort_by_text = array('i' => $user->lang['SORT_INACTIVE'], 'j' => $user->lang['SORT_REG_DATE'], 'l' => $user->lang['SORT_LAST_VISIT'], 'd' => $user->lang['SORT_LAST_REMINDER'], 'r' => $user->lang['SORT_REASON'], 'u' => $user->lang['SORT_USERNAME'], 'p' => $user->lang['SORT_POSTS'], 'e' => $user->lang['SORT_REMINDER']);
  66          $sort_by_sql = array('i' => 'user_inactive_time', 'j' => 'user_regdate', 'l' => 'user_lastvisit', 'd' => 'user_reminded_time', 'r' => 'user_inactive_reason', 'u' => 'username_clean', 'p' => 'user_posts', 'e' => 'user_reminded');
  67  
  68          $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
  69          gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
  70  
  71          if ($submit && sizeof($mark))
  72          {
  73              if ($action !== 'delete' && !check_form_key($form_key))
  74              {
  75                  trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action), E_USER_WARNING);
  76              }
  77  
  78              switch ($action)
  79              {
  80                  case 'activate':
  81                  case 'delete':
  82  
  83                      $sql = 'SELECT user_id, username
  84                          FROM ' . USERS_TABLE . '
  85                          WHERE ' . $db->sql_in_set('user_id', $mark);
  86                      $result = $db->sql_query($sql);
  87  
  88                      $user_affected = array();
  89                      while ($row = $db->sql_fetchrow($result))
  90                      {
  91                          $user_affected[$row['user_id']] = $row['username'];
  92                      }
  93                      $db->sql_freeresult($result);
  94  
  95                      if ($action == 'activate')
  96                      {
  97                          // Get those 'being activated'...
  98                          $sql = 'SELECT user_id, username' . (($config['require_activation'] == USER_ACTIVATION_ADMIN) ? ', user_email, user_lang' : '') . '
  99                              FROM ' . USERS_TABLE . '
 100                              WHERE ' . $db->sql_in_set('user_id', $mark) . '
 101                                  AND user_type = ' . USER_INACTIVE;
 102                          $result = $db->sql_query($sql);
 103  
 104                          $inactive_users = array();
 105                          while ($row = $db->sql_fetchrow($result))
 106                          {
 107                              $inactive_users[] = $row;
 108                          }
 109                          $db->sql_freeresult($result);
 110  
 111                          user_active_flip('activate', $mark);
 112  
 113                          if ($config['require_activation'] == USER_ACTIVATION_ADMIN && !empty($inactive_users))
 114                          {
 115                              if (!class_exists('messenger'))
 116                              {
 117                                  include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
 118                              }
 119  
 120                              $messenger = new messenger(false);
 121  
 122                              foreach ($inactive_users as $row)
 123                              {
 124                                  $messenger->template('admin_welcome_activated', $row['user_lang']);
 125  
 126                                  $messenger->set_addresses($row);
 127  
 128                                  $messenger->anti_abuse_headers($config, $user);
 129  
 130                                  $messenger->assign_vars(array(
 131                                      'USERNAME'    => htmlspecialchars_decode($row['username']))
 132                                  );
 133  
 134                                  $messenger->send(NOTIFY_EMAIL);
 135                              }
 136  
 137                              $messenger->save_queue();
 138                          }
 139  
 140                          if (!empty($inactive_users))
 141                          {
 142                              foreach ($inactive_users as $row)
 143                              {
 144                                  add_log('admin', 'LOG_USER_ACTIVE', $row['username']);
 145                                  add_log('user', $row['user_id'], 'LOG_USER_ACTIVE_USER');
 146                              }
 147  
 148                              trigger_error(sprintf($user->lang['LOG_INACTIVE_ACTIVATE'], implode($user->lang['COMMA_SEPARATOR'], $user_affected) . ' ' . adm_back_link($this->u_action)));
 149                          }
 150  
 151                          // For activate we really need to redirect, else a refresh can result in users being deactivated again
 152                          $u_action = $this->u_action . "&amp;$u_sort_param&amp;start=$start";
 153                          $u_action .= ($per_page != $config['topics_per_page']) ? "&amp;users_per_page=$per_page" : '';
 154  
 155                          redirect($u_action);
 156                      }
 157                      else if ($action == 'delete')
 158                      {
 159                          if (confirm_box(true))
 160                          {
 161                              if (!$auth->acl_get('a_userdel'))
 162                              {
 163                                  trigger_error($user->lang['NO_AUTH_OPERATION'] . adm_back_link($this->u_action), E_USER_WARNING);
 164                              }
 165  
 166                              user_delete('retain', $mark, true);
 167  
 168                              add_log('admin', 'LOG_INACTIVE_' . strtoupper($action), implode(', ', $user_affected));
 169  
 170                              trigger_error(sprintf($user->lang['LOG_INACTIVE_DELETE'], implode($user->lang['COMMA_SEPARATOR'], $user_affected) . ' ' . adm_back_link($this->u_action)));
 171                          }
 172                          else
 173                          {
 174                              $s_hidden_fields = array(
 175                                  'mode'            => $mode,
 176                                  'action'        => $action,
 177                                  'mark'            => $mark,
 178                                  'submit'        => 1,
 179                                  'start'            => $start,
 180                              );
 181                              confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields($s_hidden_fields));
 182                          }
 183                      }
 184  
 185                  break;
 186  
 187                  case 'remind':
 188                      if (empty($config['email_enable']))
 189                      {
 190                          trigger_error($user->lang['EMAIL_DISABLED'] . adm_back_link($this->u_action), E_USER_WARNING);
 191                      }
 192  
 193                      $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey
 194                          FROM ' . USERS_TABLE . '
 195                          WHERE ' . $db->sql_in_set('user_id', $mark) . '
 196                              AND user_inactive_reason';
 197  
 198                      $sql .= ($config['require_activation'] == USER_ACTIVATION_ADMIN) ? ' = ' . INACTIVE_REMIND : ' <> ' . INACTIVE_MANUAL;
 199  
 200                      $result = $db->sql_query($sql);
 201  
 202                      if ($row = $db->sql_fetchrow($result))
 203                      {
 204                          // Send the messages
 205                          if (!class_exists('messenger'))
 206                          {
 207                              include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
 208                          }
 209  
 210                          $messenger = new messenger();
 211                          $usernames = $user_ids = array();
 212  
 213                          do
 214                          {
 215                              $messenger->template('user_remind_inactive', $row['user_lang']);
 216  
 217                              $messenger->set_addresses($row);
 218  
 219                              $messenger->anti_abuse_headers($config, $user);
 220  
 221                              $messenger->assign_vars(array(
 222                                  'USERNAME'        => htmlspecialchars_decode($row['username']),
 223                                  'REGISTER_DATE'    => $user->format_date($row['user_regdate'], false, true),
 224                                  'U_ACTIVATE'    => generate_board_url() . "/ucp.$phpEx?mode=activate&u=" . $row['user_id'] . '&k=' . $row['user_actkey'])
 225                              );
 226  
 227                              $messenger->send($row['user_notify_type']);
 228  
 229                              $usernames[] = $row['username'];
 230                              $user_ids[] = (int) $row['user_id'];
 231                          }
 232                          while ($row = $db->sql_fetchrow($result));
 233  
 234                          $messenger->save_queue();
 235  
 236                          // Add the remind state to the database
 237                          $sql = 'UPDATE ' . USERS_TABLE . '
 238                              SET user_reminded = user_reminded + 1,
 239                                  user_reminded_time = ' . time() . '
 240                              WHERE ' . $db->sql_in_set('user_id', $user_ids);
 241                          $db->sql_query($sql);
 242  
 243                          add_log('admin', 'LOG_INACTIVE_REMIND', implode(', ', $usernames));
 244  
 245                          trigger_error(sprintf($user->lang['LOG_INACTIVE_REMIND'], implode($user->lang['COMMA_SEPARATOR'], $usernames) . ' ' . adm_back_link($this->u_action)));
 246                      }
 247                      $db->sql_freeresult($result);
 248  
 249                      // For remind we really need to redirect, else a refresh can result in more than one reminder
 250                      $u_action = $this->u_action . "&amp;$u_sort_param&amp;start=$start";
 251                      $u_action .= ($per_page != $config['topics_per_page']) ? "&amp;users_per_page=$per_page" : '';
 252  
 253                      redirect($u_action);
 254  
 255                  break;
 256              }
 257          }
 258  
 259          // Define where and sort sql for use in displaying logs
 260          $sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
 261          $sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
 262  
 263          $inactive = array();
 264          $inactive_count = 0;
 265  
 266          $start = view_inactive_users($inactive, $inactive_count, $per_page, $start, $sql_where, $sql_sort);
 267  
 268          foreach ($inactive as $row)
 269          {
 270              $template->assign_block_vars('inactive', array(
 271                  'INACTIVE_DATE'    => $user->format_date($row['user_inactive_time']),
 272                  'REMINDED_DATE'    => $user->format_date($row['user_reminded_time']),
 273                  'JOINED'        => $user->format_date($row['user_regdate']),
 274                  'LAST_VISIT'    => (!$row['user_lastvisit']) ? ' - ' : $user->format_date($row['user_lastvisit']),
 275  
 276                  'REASON'        => $row['inactive_reason'],
 277                  'USER_ID'        => $row['user_id'],
 278                  'POSTS'            => ($row['user_posts']) ? $row['user_posts'] : 0,
 279                  'REMINDED'        => $row['user_reminded'],
 280  
 281                  'REMINDED_EXPLAIN'    => $user->lang('USER_LAST_REMINDED', (int) $row['user_reminded'], $user->format_date($row['user_reminded_time'])),
 282  
 283                  'USERNAME_FULL'        => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour'], false, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=users&amp;mode=overview&amp;redirect=acp_inactive')),
 284                  'USERNAME'            => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
 285                  'USER_COLOR'        => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
 286                  'USER_EMAIL'        => $row['user_email'],
 287  
 288                  'U_USER_ADMIN'    => append_sid("{$phpbb_admin_path}index.$phpEx", "i=users&amp;mode=overview&amp;u={$row['user_id']}"),
 289                  'U_SEARCH_USER'    => ($auth->acl_get('u_search')) ? append_sid("{$phpbb_root_path}search.$phpEx", "author_id={$row['user_id']}&amp;sr=posts") : '',
 290              ));
 291          }
 292  
 293          $option_ary = array('activate' => 'ACTIVATE', 'delete' => 'DELETE');
 294          if ($config['email_enable'])
 295          {
 296              $option_ary += array('remind' => 'REMIND');
 297          }
 298  
 299          $base_url = $this->u_action . "&amp;$u_sort_param&amp;users_per_page=$per_page";
 300          $pagination->generate_template_pagination($base_url, 'pagination', 'start', $inactive_count, $per_page, $start);
 301  
 302          $template->assign_vars(array(
 303              'S_INACTIVE_USERS'        => true,
 304              'S_INACTIVE_OPTIONS'    => build_select($option_ary),
 305  
 306              'S_LIMIT_DAYS'    => $s_limit_days,
 307              'S_SORT_KEY'    => $s_sort_key,
 308              'S_SORT_DIR'    => $s_sort_dir,
 309              'USERS_PER_PAGE'    => $per_page,
 310  
 311              'U_ACTION'        => $this->u_action . "&amp;$u_sort_param&amp;users_per_page=$per_page&amp;start=$start",
 312          ));
 313  
 314          $this->tpl_name = 'acp_inactive';
 315          $this->page_title = 'ACP_INACTIVE_USERS';
 316      }
 317  }


Generated: Thu Jan 11 00:25:41 2018 Cross-referenced by PHPXref 0.7.1