[ Index ]

PHP Cross Reference of phpBB-3.2.8-deutsch

title

Body

[close]

/includes/mcp/ -> mcp_front.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 Front Panel
  24  */
  25  function mcp_front_view($id, $mode, $action)
  26  {
  27      global $phpEx, $phpbb_root_path;
  28      global $template, $db, $user, $auth, $module;
  29      global $phpbb_dispatcher, $request;
  30  
  31      // Latest 5 unapproved
  32      if ($module->loaded('queue'))
  33      {
  34          $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_approve')));
  35          $post_list = array();
  36          $forum_names = array();
  37  
  38          $forum_id = $request->variable('f', 0);
  39  
  40          $template->assign_var('S_SHOW_UNAPPROVED', (!empty($forum_list)) ? true : false);
  41  
  42          if (!empty($forum_list))
  43          {
  44              $sql_ary = array(
  45                  'SELECT' => 'COUNT(post_id) AS total',
  46                  'FROM' => array(
  47                          POSTS_TABLE => 'p',
  48                      ),
  49                  'WHERE' => $db->sql_in_set('p.forum_id', $forum_list) . '
  50                      AND ' . $db->sql_in_set('p.post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE))
  51              );
  52  
  53              /**
  54              * Allow altering the query to get the number of unapproved posts
  55              *
  56              * @event core.mcp_front_queue_unapproved_total_before
  57              * @var    array    sql_ary            Query array to get the total number of unapproved posts
  58              * @var    array    forum_list        List of forums to look for unapproved posts
  59              * @since 3.1.5-RC1
  60              */
  61              $vars = array('sql_ary', 'forum_list');
  62              extract($phpbb_dispatcher->trigger_event('core.mcp_front_queue_unapproved_total_before', compact($vars)));
  63  
  64              $sql = $db->sql_build_query('SELECT', $sql_ary);
  65              $result = $db->sql_query($sql);
  66              $total = (int) $db->sql_fetchfield('total');
  67              $db->sql_freeresult($result);
  68  
  69              if ($total)
  70              {
  71                  $sql = 'SELECT forum_id, forum_name
  72                      FROM ' . FORUMS_TABLE . '
  73                      WHERE ' . $db->sql_in_set('forum_id', $forum_list);
  74                  $result = $db->sql_query($sql);
  75  
  76                  while ($row = $db->sql_fetchrow($result))
  77                  {
  78                      $forum_names[$row['forum_id']] = $row['forum_name'];
  79                  }
  80                  $db->sql_freeresult($result);
  81  
  82                  $sql = 'SELECT post_id
  83                      FROM ' . POSTS_TABLE . '
  84                      WHERE ' . $db->sql_in_set('forum_id', $forum_list) . '
  85                          AND ' . $db->sql_in_set('post_visibility', array(ITEM_UNAPPROVED, ITEM_REAPPROVE)) . '
  86                      ORDER BY post_time DESC, post_id DESC';
  87                  $result = $db->sql_query_limit($sql, 5);
  88  
  89                  while ($row = $db->sql_fetchrow($result))
  90                  {
  91                      $post_list[] = $row['post_id'];
  92                  }
  93                  $db->sql_freeresult($result);
  94  
  95                  if (empty($post_list))
  96                  {
  97                      $total = 0;
  98                  }
  99              }
 100  
 101              /**
 102              * Alter list of posts and total as required
 103              *
 104              * @event core.mcp_front_view_queue_postid_list_after
 105              * @var    int        total                        Number of unapproved posts
 106              * @var    array    post_list                    List of unapproved posts
 107              * @var    array    forum_list                    List of forums that contain the posts
 108              * @var    array    forum_names                    Associative array with forum_id as key and it's corresponding forum_name as value
 109              * @since 3.1.0-RC3
 110              */
 111              $vars = array('total', 'post_list', 'forum_list', 'forum_names');
 112              extract($phpbb_dispatcher->trigger_event('core.mcp_front_view_queue_postid_list_after', compact($vars)));
 113  
 114              if ($total)
 115              {
 116                  $sql = 'SELECT p.post_id, p.post_subject, p.post_time, p.post_attachment, p.poster_id, p.post_username, u.username, u.username_clean, u.user_colour, t.topic_id, t.topic_title, t.topic_first_post_id, p.forum_id
 117                      FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t, ' . USERS_TABLE . ' u
 118                      WHERE ' . $db->sql_in_set('p.post_id', $post_list) . '
 119                          AND t.topic_id = p.topic_id
 120                          AND p.poster_id = u.user_id
 121                      ORDER BY p.post_time DESC, p.post_id DESC';
 122                  $result = $db->sql_query($sql);
 123  
 124                  while ($row = $db->sql_fetchrow($result))
 125                  {
 126                      $template->assign_block_vars('unapproved', array(
 127                          'U_POST_DETAILS'    => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=approve_details&amp;f=' . $row['forum_id'] . '&amp;p=' . $row['post_id']),
 128                          'U_MCP_FORUM'        => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=forum_view&amp;f=' . $row['forum_id']),
 129                          'U_MCP_TOPIC'        => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=topic_view&amp;f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']),
 130                          'U_FORUM'            => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),
 131                          'U_TOPIC'            => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']),
 132  
 133                          'AUTHOR_FULL'        => get_username_string('full', $row['poster_id'], $row['username'], $row['user_colour']),
 134                          'AUTHOR'            => get_username_string('username', $row['poster_id'], $row['username'], $row['user_colour']),
 135                          'AUTHOR_COLOUR'        => get_username_string('colour', $row['poster_id'], $row['username'], $row['user_colour']),
 136                          'U_AUTHOR'            => get_username_string('profile', $row['poster_id'], $row['username'], $row['user_colour']),
 137  
 138                          'FORUM_NAME'    => $forum_names[$row['forum_id']],
 139                          'POST_ID'        => $row['post_id'],
 140                          'TOPIC_TITLE'    => $row['topic_title'],
 141                          'SUBJECT'        => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
 142                          'POST_TIME'        => $user->format_date($row['post_time']),
 143                          'ATTACH_ICON_IMG'    => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
 144                      ));
 145                  }
 146                  $db->sql_freeresult($result);
 147              }
 148  
 149              $s_hidden_fields = build_hidden_fields(array(
 150                  'redirect'        => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main' . (($forum_id) ? '&amp;f=' . $forum_id : ''))
 151              ));
 152  
 153              $template->assign_vars(array(
 154                  'S_HIDDEN_FIELDS'        => $s_hidden_fields,
 155                  'S_MCP_QUEUE_ACTION'    => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue"),
 156                  'L_UNAPPROVED_TOTAL'    => $user->lang('UNAPPROVED_POSTS_TOTAL', (int) $total),
 157                  'S_HAS_UNAPPROVED_POSTS'=> ($total != 0),
 158              ));
 159          }
 160      }
 161  
 162      // Latest 5 reported
 163      if ($module->loaded('reports'))
 164      {
 165          $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_report')));
 166  
 167          $template->assign_var('S_SHOW_REPORTS', (!empty($forum_list)) ? true : false);
 168  
 169          if (!empty($forum_list))
 170          {
 171              $sql = 'SELECT COUNT(r.report_id) AS total
 172                  FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p
 173                  WHERE r.post_id = p.post_id
 174                      AND r.pm_id = 0
 175                      AND r.report_closed = 0
 176                      AND ' . $db->sql_in_set('p.forum_id', $forum_list);
 177  
 178              /**
 179              * Alter sql query to count the number of reported posts
 180              *
 181              * @event core.mcp_front_reports_count_query_before
 182              * @var    string    sql                The query string used to get the number of reports that exist
 183              * @var    array    forum_list        List of forums that contain the posts
 184              * @since 3.1.5-RC1
 185              */
 186              $vars = array('sql', 'forum_list');
 187              extract($phpbb_dispatcher->trigger_event('core.mcp_front_reports_count_query_before', compact($vars)));
 188  
 189              $result = $db->sql_query($sql);
 190              $total = (int) $db->sql_fetchfield('total');
 191              $db->sql_freeresult($result);
 192  
 193              if ($total)
 194              {
 195                  $sql_ary = array(
 196                      'SELECT'    => 'r.report_time, p.post_id, p.post_subject, p.post_time, p.post_attachment, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id, t.topic_id, t.topic_title, f.forum_id, f.forum_name',
 197  
 198                      'FROM'        => array(
 199                          REPORTS_TABLE            => 'r',
 200                          REPORTS_REASONS_TABLE    => 'rr',
 201                          TOPICS_TABLE            => 't',
 202                          USERS_TABLE                => array('u', 'u2'),
 203                          POSTS_TABLE                => 'p',
 204                      ),
 205  
 206                      'LEFT_JOIN'    => array(
 207                          array(
 208                              'FROM'    => array(FORUMS_TABLE => 'f'),
 209                              'ON'    => 'f.forum_id = p.forum_id',
 210                          ),
 211                      ),
 212  
 213                      'WHERE'        => 'r.post_id = p.post_id
 214                          AND r.pm_id = 0
 215                          AND r.report_closed = 0
 216                          AND r.reason_id = rr.reason_id
 217                          AND p.topic_id = t.topic_id
 218                          AND r.user_id = u.user_id
 219                          AND p.poster_id = u2.user_id
 220                          AND ' . $db->sql_in_set('p.forum_id', $forum_list),
 221  
 222                      'ORDER_BY'    => 'p.post_time DESC, p.post_id DESC',
 223                  );
 224  
 225                  /**
 226                  * Alter sql query to get latest reported posts
 227                  *
 228                  * @event core.mcp_front_reports_listing_query_before
 229                  * @var    array    sql_ary            Associative array with the query to be executed
 230                  * @var    array    forum_list        List of forums that contain the posts
 231                  * @since 3.1.0-RC3
 232                  */
 233                  $vars = array('sql_ary', 'forum_list');
 234                  extract($phpbb_dispatcher->trigger_event('core.mcp_front_reports_listing_query_before', compact($vars)));
 235  
 236                  $sql = $db->sql_build_query('SELECT', $sql_ary);
 237                  $result = $db->sql_query_limit($sql, 5);
 238  
 239                  while ($row = $db->sql_fetchrow($result))
 240                  {
 241                      $template->assign_block_vars('report', array(
 242                          'U_POST_DETAILS'    => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&amp;p=' . $row['post_id'] . "&amp;i=reports&amp;mode=report_details"),
 243                          'U_MCP_FORUM'        => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . "&amp;i=$id&amp;mode=forum_view"),
 244                          'U_MCP_TOPIC'        => append_sid("{$phpbb_root_path}mcp.$phpEx", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id'] . "&amp;i=$id&amp;mode=topic_view"),
 245                          'U_FORUM'            => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $row['forum_id']),
 246                          'U_TOPIC'            => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&amp;t=' . $row['topic_id']),
 247  
 248                          'REPORTER_FULL'        => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
 249                          'REPORTER'            => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
 250                          'REPORTER_COLOUR'    => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
 251                          'U_REPORTER'        => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
 252  
 253                          'AUTHOR_FULL'        => get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']),
 254                          'AUTHOR'            => get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']),
 255                          'AUTHOR_COLOUR'        => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']),
 256                          'U_AUTHOR'            => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']),
 257  
 258                          'FORUM_NAME'    => $row['forum_name'],
 259                          'TOPIC_TITLE'    => $row['topic_title'],
 260                          'SUBJECT'        => ($row['post_subject']) ? $row['post_subject'] : $user->lang['NO_SUBJECT'],
 261                          'REPORT_TIME'    => $user->format_date($row['report_time']),
 262                          'POST_TIME'        => $user->format_date($row['post_time']),
 263                          'ATTACH_ICON_IMG'    => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['post_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
 264                      ));
 265                  }
 266                  $db->sql_freeresult($result);
 267              }
 268  
 269              $template->assign_vars(array(
 270                  'L_REPORTS_TOTAL'    => $user->lang('REPORTS_TOTAL', (int) $total),
 271                  'S_HAS_REPORTS'        => ($total != 0),
 272              ));
 273          }
 274      }
 275  
 276      // Latest 5 reported PMs
 277      if ($module->loaded('pm_reports') && $auth->acl_get('m_pm_report'))
 278      {
 279          $template->assign_var('S_SHOW_PM_REPORTS', true);
 280          $user->add_lang(array('ucp'));
 281  
 282          $sql = 'SELECT COUNT(r.report_id) AS total
 283              FROM ' . REPORTS_TABLE . ' r, ' . PRIVMSGS_TABLE . ' p
 284              WHERE r.post_id = 0
 285                  AND r.pm_id = p.msg_id
 286                  AND r.report_closed = 0';
 287          $result = $db->sql_query($sql);
 288          $total = (int) $db->sql_fetchfield('total');
 289          $db->sql_freeresult($result);
 290  
 291          if ($total)
 292          {
 293              if (!function_exists('get_recipient_strings'))
 294              {
 295                  include($phpbb_root_path . 'includes/functions_privmsgs.' . $phpEx);
 296              }
 297  
 298              $sql_ary = array(
 299                  'SELECT'    => 'r.report_id, r.report_time, p.msg_id, p.message_subject, p.message_time, p.to_address, p.bcc_address, p.message_attachment, u.username, u.username_clean, u.user_colour, u.user_id, u2.username as author_name, u2.username_clean as author_name_clean, u2.user_colour as author_colour, u2.user_id as author_id',
 300  
 301                  'FROM'        => array(
 302                      REPORTS_TABLE            => 'r',
 303                      REPORTS_REASONS_TABLE    => 'rr',
 304                      USERS_TABLE                => array('u', 'u2'),
 305                      PRIVMSGS_TABLE                => 'p',
 306                  ),
 307  
 308                  'WHERE'        => 'r.pm_id = p.msg_id
 309                      AND r.post_id = 0
 310                      AND r.report_closed = 0
 311                      AND r.reason_id = rr.reason_id
 312                      AND r.user_id = u.user_id
 313                      AND p.author_id = u2.user_id',
 314  
 315                  'ORDER_BY'    => 'p.message_time DESC',
 316              );
 317              $sql = $db->sql_build_query('SELECT', $sql_ary);
 318              $result = $db->sql_query_limit($sql, 5);
 319  
 320              $pm_by_id = $pm_list = array();
 321              while ($row = $db->sql_fetchrow($result))
 322              {
 323                  $pm_by_id[(int) $row['msg_id']] = $row;
 324                  $pm_list[] = (int) $row['msg_id'];
 325              }
 326              $db->sql_freeresult($result);
 327  
 328              $address_list = get_recipient_strings($pm_by_id);
 329  
 330              foreach ($pm_list as $message_id)
 331              {
 332                  $row = $pm_by_id[$message_id];
 333  
 334                  $template->assign_block_vars('pm_report', array(
 335                      'U_PM_DETAILS'    => append_sid("{$phpbb_root_path}mcp.$phpEx", 'r=' . $row['report_id'] . "&amp;i=pm_reports&amp;mode=pm_report_details"),
 336  
 337                      'REPORTER_FULL'        => get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']),
 338                      'REPORTER'            => get_username_string('username', $row['user_id'], $row['username'], $row['user_colour']),
 339                      'REPORTER_COLOUR'    => get_username_string('colour', $row['user_id'], $row['username'], $row['user_colour']),
 340                      'U_REPORTER'        => get_username_string('profile', $row['user_id'], $row['username'], $row['user_colour']),
 341  
 342                      'PM_AUTHOR_FULL'        => get_username_string('full', $row['author_id'], $row['author_name'], $row['author_colour']),
 343                      'PM_AUTHOR'            => get_username_string('username', $row['author_id'], $row['author_name'], $row['author_colour']),
 344                      'PM_AUTHOR_COLOUR'        => get_username_string('colour', $row['author_id'], $row['author_name'], $row['author_colour']),
 345                      'U_PM_AUTHOR'            => get_username_string('profile', $row['author_id'], $row['author_name'], $row['author_colour']),
 346  
 347                      'PM_SUBJECT'        => $row['message_subject'],
 348                      'REPORT_TIME'        => $user->format_date($row['report_time']),
 349                      'PM_TIME'            => $user->format_date($row['message_time']),
 350                      'RECIPIENTS'        => implode(', ', $address_list[$row['msg_id']]),
 351                      'ATTACH_ICON_IMG'    => ($auth->acl_get('u_download') && $row['message_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
 352                  ));
 353              }
 354          }
 355  
 356          $template->assign_vars(array(
 357              'L_PM_REPORTS_TOTAL'    => $user->lang('PM_REPORTS_TOTAL', (int) $total),
 358              'S_HAS_PM_REPORTS'        => ($total != 0),
 359          ));
 360      }
 361  
 362      // Latest 5 logs
 363      if ($module->loaded('logs'))
 364      {
 365          $forum_list = array_values(array_intersect(get_forum_list('f_read'), get_forum_list('m_')));
 366  
 367          if (!empty($forum_list))
 368          {
 369              $log_count = false;
 370              $log = array();
 371              view_log('mod', $log, $log_count, 5, 0, $forum_list);
 372  
 373              foreach ($log as $row)
 374              {
 375                  $template->assign_block_vars('log', array(
 376                      'USERNAME'        => $row['username_full'],
 377                      'IP'            => $row['ip'],
 378                      'TIME'            => $user->format_date($row['time']),
 379                      'ACTION'        => $row['action'],
 380                      'U_VIEW_TOPIC'    => (!empty($row['viewtopic'])) ? $row['viewtopic'] : '',
 381                      'U_VIEWLOGS'    => (!empty($row['viewlogs'])) ? $row['viewlogs'] : '')
 382                  );
 383              }
 384          }
 385  
 386          $template->assign_vars(array(
 387              'S_SHOW_LOGS'    => (!empty($forum_list)) ? true : false,
 388              'S_HAS_LOGS'    => (!empty($log)) ? true : false)
 389          );
 390      }
 391  
 392      $template->assign_var('S_MCP_ACTION', append_sid("{$phpbb_root_path}mcp.$phpEx"));
 393      make_jumpbox(append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=forum_view'), 0, false, 'm_', true);
 394  }


Generated: Tue Apr 7 19:42:26 2020 Cross-referenced by PHPXref 0.7.1