[ Index ]

PHP Cross Reference of phpBB-3.1.12-deutsch

title

Body

[close]

/includes/mcp/ -> mcp_notes.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  /**
  23  * mcp_notes
  24  * Displays notes about a user
  25  */
  26  class mcp_notes
  27  {
  28      var $p_master;
  29      var $u_action;
  30  
  31  	function mcp_notes(&$p_master)
  32      {
  33          $this->p_master = &$p_master;
  34      }
  35  
  36  	function main($id, $mode)
  37      {
  38          global $auth, $db, $user, $template;
  39          global $config, $phpbb_root_path, $phpEx;
  40  
  41          $action = request_var('action', array('' => ''));
  42  
  43          if (is_array($action))
  44          {
  45              list($action, ) = each($action);
  46          }
  47  
  48          $this->page_title = 'MCP_NOTES';
  49  
  50          switch ($mode)
  51          {
  52              case 'front':
  53                  $template->assign_vars(array(
  54                      'U_FIND_USERNAME'    => append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=searchuser&amp;form=mcp&amp;field=username&amp;select_single=true'),
  55                      'U_POST_ACTION'        => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=notes&amp;mode=user_notes'),
  56  
  57                      'L_TITLE'            => $user->lang['MCP_NOTES'],
  58                  ));
  59  
  60                  $this->tpl_name = 'mcp_notes_front';
  61              break;
  62  
  63              case 'user_notes':
  64                  $user->add_lang('acp/common');
  65  
  66                  $this->mcp_notes_user_view($action);
  67                  $this->tpl_name = 'mcp_notes_user';
  68              break;
  69          }
  70      }
  71  
  72      /**
  73      * Display user notes
  74      */
  75  	function mcp_notes_user_view($action)
  76      {
  77          global $phpEx, $phpbb_root_path, $config;
  78          global $template, $db, $user, $auth, $phpbb_container;
  79  
  80          $user_id = request_var('u', 0);
  81          $username = request_var('username', '', true);
  82          $start = request_var('start', 0);
  83          $st    = request_var('st', 0);
  84          $sk    = request_var('sk', 'b');
  85          $sd    = request_var('sd', 'd');
  86          $pagination = $phpbb_container->get('pagination');
  87  
  88          add_form_key('mcp_notes');
  89  
  90          $sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
  91  
  92          $sql = 'SELECT *
  93              FROM ' . USERS_TABLE . "
  94              WHERE $sql_where";
  95          $result = $db->sql_query($sql);
  96          $userrow = $db->sql_fetchrow($result);
  97          $db->sql_freeresult($result);
  98  
  99          if (!$userrow)
 100          {
 101              trigger_error('NO_USER');
 102          }
 103  
 104          $user_id = $userrow['user_id'];
 105  
 106          // Populate user id to the currently active module (this module)
 107          // The following method is another way of adjusting module urls. It is the easy variant if we want
 108          // to directly adjust the current module url based on data retrieved within the same module.
 109          if (strpos($this->u_action, "&amp;u=$user_id") === false)
 110          {
 111              $this->p_master->adjust_url('&amp;u=' . $user_id);
 112              $this->u_action .= "&amp;u=$user_id";
 113          }
 114  
 115          $deletemark = ($action == 'del_marked') ? true : false;
 116          $deleteall    = ($action == 'del_all') ? true : false;
 117          $marked        = request_var('marknote', array(0));
 118          $usernote    = utf8_normalize_nfc(request_var('usernote', '', true));
 119  
 120          // Handle any actions
 121          if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
 122          {
 123              $where_sql = '';
 124              if ($deletemark && $marked)
 125              {
 126                  $sql_in = array();
 127                  foreach ($marked as $mark)
 128                  {
 129                      $sql_in[] = $mark;
 130                  }
 131                  $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in);
 132                  unset($sql_in);
 133              }
 134  
 135              if ($where_sql || $deleteall)
 136              {
 137                  if (check_form_key('mcp_notes'))
 138                  {
 139                      $sql = 'DELETE FROM ' . LOG_TABLE . '
 140                          WHERE log_type = ' . LOG_USERS . "
 141                              AND reportee_id = $user_id
 142                              $where_sql";
 143                      $db->sql_query($sql);
 144  
 145                      add_log('admin', 'LOG_CLEAR_USER', $userrow['username']);
 146  
 147                      $msg = ($deletemark) ? 'MARKED_NOTES_DELETED' : 'ALL_NOTES_DELETED';
 148                  }
 149                  else
 150                  {
 151                      $msg = 'FORM_INVALID';
 152                  }
 153                  $redirect = $this->u_action . '&amp;u=' . $user_id;
 154                  meta_refresh(3, $redirect);
 155                  trigger_error($user->lang[$msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
 156              }
 157          }
 158  
 159          if ($usernote && $action == 'add_feedback')
 160          {
 161              if (check_form_key('mcp_notes'))
 162              {
 163                  add_log('admin', 'LOG_USER_FEEDBACK', $userrow['username']);
 164                  add_log('mod', 0, 0, 'LOG_USER_FEEDBACK', $userrow['username']);
 165  
 166                  add_log('user', $user_id, 'LOG_USER_GENERAL', $usernote);
 167                  $msg = $user->lang['USER_FEEDBACK_ADDED'];
 168              }
 169              else
 170              {
 171                  $msg = $user->lang['FORM_INVALID'];
 172              }
 173              $redirect = $this->u_action;
 174              meta_refresh(3, $redirect);
 175  
 176              trigger_error($msg .  '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
 177          }
 178  
 179          // Generate the appropriate user information for the user we are looking at
 180  
 181          $rank_title = $rank_img = '';
 182          $avatar_img = phpbb_get_user_avatar($userrow);
 183  
 184          $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']);
 185          $sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_IP'], 'd' => $user->lang['SORT_ACTION']);
 186          $sort_by_sql = array('a' => 'u.username_clean', 'b' => 'l.log_time', 'c' => 'l.log_ip', 'd' => 'l.log_operation');
 187  
 188          $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
 189          gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
 190  
 191          // Define where and sort sql for use in displaying logs
 192          $sql_where = ($st) ? (time() - ($st * 86400)) : 0;
 193          $sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC');
 194  
 195          $keywords = utf8_normalize_nfc(request_var('keywords', '', true));
 196          $keywords_param = !empty($keywords) ? '&amp;keywords=' . urlencode(htmlspecialchars_decode($keywords)) : '';
 197  
 198          $log_data = array();
 199          $log_count = 0;
 200          $start = view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort, $keywords);
 201  
 202          if ($log_count)
 203          {
 204              $template->assign_var('S_USER_NOTES', true);
 205  
 206              foreach ($log_data as $row)
 207              {
 208                  $template->assign_block_vars('usernotes', array(
 209                      'REPORT_BY'        => $row['username_full'],
 210                      'REPORT_AT'        => $user->format_date($row['time']),
 211                      'ACTION'        => $row['action'],
 212                      'IP'            => $row['ip'],
 213                      'ID'            => $row['id'])
 214                  );
 215              }
 216          }
 217  
 218          $base_url = $this->u_action . "&amp;$u_sort_param$keywords_param";
 219          $pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);
 220  
 221          $template->assign_vars(array(
 222              'U_POST_ACTION'            => $this->u_action,
 223              'S_CLEAR_ALLOWED'        => ($auth->acl_get('a_clearlogs')) ? true : false,
 224              'S_SELECT_SORT_DIR'        => $s_sort_dir,
 225              'S_SELECT_SORT_KEY'        => $s_sort_key,
 226              'S_SELECT_SORT_DAYS'    => $s_limit_days,
 227              'S_KEYWORDS'            => $keywords,
 228  
 229              'L_TITLE'            => $user->lang['MCP_NOTES_USER'],
 230  
 231              'TOTAL_REPORTS'        => $user->lang('LIST_REPORTS', (int) $log_count),
 232  
 233              'RANK_TITLE'        => $rank_title,
 234              'JOINED'            => $user->format_date($userrow['user_regdate']),
 235              'POSTS'                => ($userrow['user_posts']) ? $userrow['user_posts'] : 0,
 236              'WARNINGS'            => ($userrow['user_warnings']) ? $userrow['user_warnings'] : 0,
 237  
 238              'USERNAME_FULL'        => get_username_string('full', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
 239              'USERNAME_COLOUR'    => get_username_string('colour', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
 240              'USERNAME'            => get_username_string('username', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
 241              'U_PROFILE'            => get_username_string('profile', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
 242  
 243              'AVATAR_IMG'        => $avatar_img,
 244              'RANK_IMG'            => $rank_img,
 245              )
 246          );
 247      }
 248  
 249  }


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