[ Index ]

PHP Cross Reference of phpBB-3.3.0-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;
  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)
 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, array($userrow['username']));
 166                  $phpbb_log->add('mod', $user->data['user_id'], $user->ip, 'LOG_USER_FEEDBACK', false, array(
 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, array(
 172                      'reportee_id' => $user_id,
 173                      $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          // Generate the appropriate user information for the user we are looking at
 189  
 190          $rank_title = $rank_img = '';
 191          $avatar_img = phpbb_get_user_avatar($userrow);
 192  
 193          $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']);
 194          $sort_by_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_DATE'], 'c' => $user->lang['SORT_IP'], 'd' => $user->lang['SORT_ACTION']);
 195          $sort_by_sql = array('a' => 'u.username_clean', 'b' => 'l.log_time', 'c' => 'l.log_ip', 'd' => 'l.log_operation');
 196  
 197          $s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
 198          gen_sort_selects($limit_days, $sort_by_text, $st, $sk, $sd, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param);
 199  
 200          // Define where and sort sql for use in displaying logs
 201          $sql_where = ($st) ? (time() - ($st * 86400)) : 0;
 202          $sql_sort = $sort_by_sql[$sk] . ' ' . (($sd == 'd') ? 'DESC' : 'ASC');
 203  
 204          $keywords = $request->variable('keywords', '', true);
 205          $keywords_param = !empty($keywords) ? '&amp;keywords=' . urlencode(htmlspecialchars_decode($keywords)) : '';
 206  
 207          $log_data = array();
 208          $log_count = 0;
 209          $start = view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort, $keywords);
 210  
 211          if ($log_count)
 212          {
 213              $template->assign_var('S_USER_NOTES', true);
 214  
 215              foreach ($log_data as $row)
 216              {
 217                  $template->assign_block_vars('usernotes', array(
 218                      'REPORT_BY'        => $row['username_full'],
 219                      'REPORT_AT'        => $user->format_date($row['time']),
 220                      'ACTION'        => $row['action'],
 221                      'IP'            => $row['ip'],
 222                      'ID'            => $row['id'])
 223                  );
 224              }
 225          }
 226  
 227          $base_url = $this->u_action . "&amp;$u_sort_param$keywords_param";
 228          $pagination->generate_template_pagination($base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);
 229  
 230          $template->assign_vars(array(
 231              'U_POST_ACTION'            => $this->u_action,
 232              'S_CLEAR_ALLOWED'        => ($auth->acl_get('a_clearlogs')) ? true : false,
 233              'S_SELECT_SORT_DIR'        => $s_sort_dir,
 234              'S_SELECT_SORT_KEY'        => $s_sort_key,
 235              'S_SELECT_SORT_DAYS'    => $s_limit_days,
 236              'S_KEYWORDS'            => $keywords,
 237  
 238              'L_TITLE'            => $user->lang['MCP_NOTES_USER'],
 239  
 240              'TOTAL_REPORTS'        => $user->lang('LIST_REPORTS', (int) $log_count),
 241  
 242              'RANK_TITLE'        => $rank_title,
 243              'JOINED'            => $user->format_date($userrow['user_regdate']),
 244              'POSTS'                => ($userrow['user_posts']) ? $userrow['user_posts'] : 0,
 245              'WARNINGS'            => ($userrow['user_warnings']) ? $userrow['user_warnings'] : 0,
 246  
 247              'USERNAME_FULL'        => get_username_string('full', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
 248              'USERNAME_COLOUR'    => get_username_string('colour', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
 249              'USERNAME'            => get_username_string('username', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
 250              'U_PROFILE'            => get_username_string('profile', $userrow['user_id'], $userrow['username'], $userrow['user_colour']),
 251  
 252              'AVATAR_IMG'        => $avatar_img,
 253              'RANK_IMG'            => $rank_img,
 254              )
 255          );
 256      }
 257  
 258  }


Generated: Tue Apr 7 19:44:41 2020 Cross-referenced by PHPXref 0.7.1