[ Index ]

PHP Cross Reference of phpBB-3.3.11-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 __construct($p_master)
  32      {
  33          $this->p_master = $p_master;
  34      }
  35  
  36  	function main($id, $mode)
  37      {
  38          global $user, $template, $request;
  39          global $phpbb_root_path, $phpEx;
  40  
  41          $action = $request->variable('action', array('' => ''));
  42  
  43          if (is_array($action))
  44          {
  45              $action = key($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 $config, $phpbb_log, $request, $phpbb_root_path, $phpEx;
  78          global $template, $db, $user, $auth, $phpbb_container;
  79  
  80          $user_id = $request->variable('u', 0);
  81          $username = $request->variable('username', '', true);
  82          $start = $request->variable('start', 0);
  83          $st    = $request->variable('st', 0);
  84          $sk    = $request->variable('sk', 'b');
  85          $sd    = $request->variable('sd', 'd');
  86  
  87          /* @var $pagination \phpbb\pagination */
  88          $pagination = $phpbb_container->get('pagination');
  89  
  90          add_form_key('mcp_notes');
  91  
  92          $sql_where = ($user_id) ? "user_id = $user_id" : "username_clean = '" . $db->sql_escape(utf8_clean_string($username)) . "'";
  93  
  94          $sql = 'SELECT *
  95              FROM ' . USERS_TABLE . "
  96              WHERE $sql_where";
  97          $result = $db->sql_query($sql);
  98          $userrow = $db->sql_fetchrow($result);
  99          $db->sql_freeresult($result);
 100  
 101          if (!$userrow || (int) $userrow['user_id'] === ANONYMOUS)
 102          {
 103              trigger_error('NO_USER');
 104          }
 105  
 106          $user_id = $userrow['user_id'];
 107  
 108          // Populate user id to the currently active module (this module)
 109          // The following method is another way of adjusting module urls. It is the easy variant if we want
 110          // to directly adjust the current module url based on data retrieved within the same module.
 111          if (strpos($this->u_action, "&amp;u=$user_id") === false)
 112          {
 113              $this->p_master->adjust_url('&amp;u=' . $user_id);
 114              $this->u_action .= "&amp;u=$user_id";
 115          }
 116  
 117          $deletemark = ($action == 'del_marked') ? true : false;
 118          $deleteall    = ($action == 'del_all') ? true : false;
 119          $marked        = $request->variable('marknote', array(0));
 120          $usernote    = $request->variable('usernote', '', true);
 121  
 122          // Handle any actions
 123          if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
 124          {
 125              $where_sql = '';
 126              if ($deletemark && $marked)
 127              {
 128                  $sql_in = array();
 129                  foreach ($marked as $mark)
 130                  {
 131                      $sql_in[] = $mark;
 132                  }
 133                  $where_sql = ' AND ' . $db->sql_in_set('log_id', $sql_in);
 134                  unset($sql_in);
 135              }
 136  
 137              if ($where_sql || $deleteall)
 138              {
 139                  if (check_form_key('mcp_notes'))
 140                  {
 141                      $sql = 'DELETE FROM ' . LOG_TABLE . '
 142                          WHERE log_type = ' . LOG_USERS . "
 143                              AND reportee_id = $user_id
 144                              $where_sql";
 145                      $db->sql_query($sql);
 146  
 147                      $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_CLEAR_USER', false, array($userrow['username']));
 148  
 149                      $msg = ($deletemark) ? 'MARKED_NOTES_DELETED' : 'ALL_NOTES_DELETED';
 150                  }
 151                  else
 152                  {
 153                      $msg = 'FORM_INVALID';
 154                  }
 155                  $redirect = $this->u_action . '&amp;u=' . $user_id;
 156                  meta_refresh(3, $redirect);
 157                  trigger_error($user->lang[$msg] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
 158              }
 159          }
 160  
 161          if ($usernote && $action == 'add_feedback')
 162          {
 163              if (check_form_key('mcp_notes'))
 164              {
 165                  $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_USER_FEEDBACK', false, [$userrow['username']]);
 166                  $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_USER_FEEDBACK', false, [
 167                      'forum_id' => 0,
 168                      'topic_id' => 0,
 169                      $userrow['username']
 170                  ]);
 171                  $phpbb_log->add('user', $user->data['user_id'], $user->ip, 'LOG_USER_GENERAL', false, [
 172                      'reportee_id' => $user_id,
 173                      utf8_encode_ucr($usernote)
 174                  ]);
 175  
 176                  $msg = $user->lang['USER_FEEDBACK_ADDED'];
 177              }
 178              else
 179              {
 180                  $msg = $user->lang['FORM_INVALID'];
 181              }
 182              $redirect = $this->u_action;
 183              meta_refresh(3, $redirect);
 184  
 185              trigger_error($msg .  '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
 186          }
 187  
 188          if (!function_exists('phpbb_get_user_rank'))
 189          {
 190              include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
 191          }
 192  
 193          // Generate the appropriate user information for the user we are looking at
 194          $rank_data = phpbb_get_user_rank($userrow, $userrow['user_posts']);
 195          $avatar_img = phpbb_get_user_avatar($userrow);
 196  
 197          $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']);
 198          $sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_IP'], 'd' => $user->lang['SORT_ACTION']);
 199          $sort_by_sql = array('a' => 'u.username_clean', 'b' => 'l.log_time', 'c' => 'l.log_ip', 'd' => 'l.log_operation');
 200  
 201          $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
 202          gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
 203  
 204          // Define where and sort sql for use in displaying logs
 205          $sql_where = ($st) ? (time() - ($st * 86400)) : 0;
 206          $sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC');
 207  
 208          $keywords = $request->variable('keywords', '', true);
 209          $keywords_param = !empty($keywords) ? '&amp;keywords=' . urlencode(html_entity_decode($keywords, ENT_COMPAT)) : '';
 210  
 211          $log_data = array();
 212          $log_count = 0;
 213          $start = view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort, $keywords);
 214  
 215          if ($log_count)
 216          {
 217              $template->assign_var('S_USER_NOTES', true);
 218  
 219              foreach ($log_data as $row)
 220              {
 221                  $template->assign_block_vars('usernotes', array(
 222                      'REPORT_BY'        => $row['username_full'],
 223                      'REPORT_AT'        => $user->format_date($row['time']),
 224                      'ACTION'        => $row['action'],
 225                      'IP'            => $row['ip'],
 226                      'ID'            => $row['id'])
 227                  );
 228              }
 229          }
 230  
 231          $base_url = $this->u_action . "&amp;$u_sort_param$keywords_param";
 232          $pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);
 233  
 234          $template->assign_vars(array(
 235              'U_POST_ACTION'            => $this->u_action,
 236              'S_CLEAR_ALLOWED'        => ($auth->acl_get('a_clearlogs')) ? true : false,
 237              'S_SELECT_SORT_DIR'        => $s_sort_dir,
 238              'S_SELECT_SORT_KEY'        => $s_sort_key,
 239              'S_SELECT_SORT_DAYS'    => $s_limit_days,
 240              'S_KEYWORDS'            => $keywords,
 241  
 242              'L_TITLE'            => $user->lang['MCP_NOTES_USER'],
 243  
 244              'TOTAL_REPORTS'        => $user->lang('LIST_REPORTS', (int) $log_count),
 245  
 246              'JOINED'            => $user->format_date($userrow['user_regdate']),
 247              'POSTS'                => ($userrow['user_posts']) ? $userrow['user_posts'] : 0,
 248              'WARNINGS'            => ($userrow['user_warnings']) ? $userrow['user_warnings'] : 0,
 249  
 250              'USERNAME_FULL'        => get_username_string('full', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
 251              'USERNAME_COLOUR'    => get_username_string('colour', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
 252              'USERNAME'            => get_username_string('username', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
 253              'U_PROFILE'            => get_username_string('profile', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
 254  
 255              'AVATAR_IMG'        => $avatar_img,
 256              'RANK_IMG'            => $rank_data['img'],
 257              'RANK_TITLE'        => $rank_data['title'],
 258          ));
 259      }
 260  
 261  }


Generated: Sat Nov 4 14:26:03 2023 Cross-referenced by PHPXref 0.7.1