Verzeichnisstruktur phpBB-3.0.0


Veröffentlicht
12.12.2007

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

mcp_forum.php

Zuletzt modifiziert: 09.10.2024, 12:51 - Dateigröße: 16.26 KiB


 001  <?php
 002  /**
 003  *
 004  * @package mcp
 005  * @version $Id$
 006  * @copyright (c) 2005 phpBB Group
 007  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
 008  *
 009  */
 010   
 011  /**
 012  * @ignore
 013  */
 014  if (!defined('IN_PHPBB'))
 015  {
 016      exit;
 017  }
 018   
 019  /**
 020  * MCP Forum View
 021  */
 022  function mcp_forum_view($id, $mode, $action, $forum_info)
 023  {
 024      global $template, $db, $user, $auth, $cache, $module;
 025      global $phpEx, $phpbb_root_path, $config;
 026   
 027      $user->add_lang(array('viewtopic', 'viewforum'));
 028   
 029      include_once($phpbb_root_path . 'includes/functions_display.' . $phpEx);
 030   
 031      // merge_topic is the quickmod action, merge_topics is the mcp_forum action, and merge_select is the mcp_topic action
 032      $merge_select = ($action == 'merge_select' || $action == 'merge_topic' || $action == 'merge_topics') ? true : false;
 033   
 034      if ($merge_select)
 035      {
 036          // Fixes a "bug" that makes forum_view use the same ordering as topic_view
 037          unset($_POST['sk'], $_POST['sd'], $_REQUEST['sk'], $_REQUEST['sd']);
 038      }
 039   
 040      $forum_id            = $forum_info['forum_id'];
 041      $start                = request_var('start', 0);
 042      $topic_id_list        = request_var('topic_id_list', array(0));
 043      $post_id_list        = request_var('post_id_list', array(0));
 044      $source_topic_ids    = array(request_var('t', 0));
 045      $to_topic_id        = request_var('to_topic_id', 0);
 046   
 047      $url_extra = '';
 048      $url_extra .= ($forum_id) ? "&amp;f=$forum_id" : '';
 049      $url_extra .= ($GLOBALS['topic_id']) ? '&amp;t=' . $GLOBALS['topic_id'] : '';
 050      $url_extra .= ($GLOBALS['post_id']) ? '&amp;p=' . $GLOBALS['post_id'] : '';
 051      $url_extra .= ($GLOBALS['user_id']) ? '&amp;u=' . $GLOBALS['user_id'] : '';
 052   
 053      $url = append_sid("{$phpbb_root_path}mcp.$phpEx?$url_extra");
 054   
 055      // Resync Topics
 056      switch ($action)
 057      {
 058          case 'resync':
 059              $topic_ids = request_var('topic_id_list', array(0));
 060              mcp_resync_topics($topic_ids);
 061          break;
 062   
 063          case 'merge_topics':
 064              $source_topic_ids = $topic_id_list;
 065          case 'merge_topic':
 066              if ($to_topic_id)
 067              {
 068                  merge_topics($forum_id, $source_topic_ids, $to_topic_id);
 069              }
 070          break;
 071      }
 072   
 073      $selected_ids = '';
 074      if (sizeof($post_id_list) && $action != 'merge_topics')
 075      {
 076          foreach ($post_id_list as $num => $post_id)
 077          {
 078              $selected_ids .= '&amp;post_id_list[' . $num . ']=' . $post_id;
 079          }
 080      }
 081      else if (sizeof($topic_id_list) && $action == 'merge_topics')
 082      {
 083          foreach ($topic_id_list as $num => $topic_id)
 084          {
 085              $selected_ids .= '&amp;topic_id_list[' . $num . ']=' . $topic_id;
 086          }
 087      }
 088   
 089      make_jumpbox($url . "&amp;i=$id&amp;action=$action&amp;mode=$mode" . (($merge_select) ? $selected_ids : ''), $forum_id, false, 'm_', true);
 090   
 091      $topics_per_page = ($forum_info['forum_topics_per_page']) ? $forum_info['forum_topics_per_page'] : $config['topics_per_page'];
 092   
 093      $sort_days = $total = 0;
 094      $sort_key = $sort_dir = '';
 095      $sort_by_sql = $sort_order_sql = array();
 096      mcp_sorting('viewforum', $sort_days, $sort_key, $sort_dir, $sort_by_sql, $sort_order_sql, $total, $forum_id);
 097   
 098      $forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total;
 099      $limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';
 100   
 101      $template->assign_vars(array(
 102          'ACTION'                => $action,
 103          'FORUM_NAME'            => $forum_info['forum_name'],
 104          'FORUM_DESCRIPTION'        => generate_text_for_display($forum_info['forum_desc'], $forum_info['forum_desc_uid'], $forum_info['forum_desc_bitfield'], $forum_info['forum_desc_options']),
 105   
 106          'REPORTED_IMG'            => $user->img('icon_topic_reported', 'TOPIC_REPORTED'),
 107          'UNAPPROVED_IMG'        => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'),
 108          'LAST_POST_IMG'            => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
 109          'NEWEST_POST_IMG'        => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
 110   
 111          'S_CAN_REPORT'            => $auth->acl_get('m_report', $forum_id),
 112          'S_CAN_DELETE'            => $auth->acl_get('m_delete', $forum_id),
 113          'S_CAN_MERGE'            => $auth->acl_get('m_merge', $forum_id),
 114          'S_CAN_MOVE'            => $auth->acl_get('m_move', $forum_id),
 115          'S_CAN_FORK'            => $auth->acl_get('m_', $forum_id),
 116          'S_CAN_LOCK'            => $auth->acl_get('m_lock', $forum_id),
 117          'S_CAN_SYNC'            => $auth->acl_get('m_', $forum_id),
 118          'S_CAN_APPROVE'            => $auth->acl_get('m_approve', $forum_id),
 119          'S_MERGE_SELECT'        => ($merge_select) ? true : false,
 120          'S_CAN_MAKE_NORMAL'        => $auth->acl_gets('f_sticky', 'f_announce', $forum_id),
 121          'S_CAN_MAKE_STICKY'        => $auth->acl_get('f_sticky', $forum_id),
 122          'S_CAN_MAKE_ANNOUNCE'    => $auth->acl_get('f_announce', $forum_id),
 123   
 124          'U_VIEW_FORUM'            => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
 125          'U_VIEW_FORUM_LOGS'        => ($auth->acl_gets('a_', 'm_', $forum_id) && $module->loaded('logs')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=logs&amp;mode=forum_logs&amp;f=' . $forum_id) : '',
 126   
 127          'S_MCP_ACTION'            => $url . "&amp;i=$id&amp;forum_action=$action&amp;mode=$mode&amp;start=$start" . (($merge_select) ? $selected_ids : ''),
 128   
 129          'PAGINATION'            => generate_pagination($url . "&amp;i=$id&amp;action=$action&amp;mode=$mode&amp;sd=$sort_dir&amp;sk=$sort_key&amp;st=$sort_days" . (($merge_select) ? $selected_ids : ''), $forum_topics, $topics_per_page, $start),
 130          'PAGE_NUMBER'            => on_page($forum_topics, $topics_per_page, $start),
 131          'TOTAL_TOPICS'            => ($forum_topics == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $forum_topics),
 132      ));
 133   
 134      // Grab icons
 135      $icons = $cache->obtain_icons();
 136   
 137      $topic_rows = array();
 138   
 139      if ($config['load_db_lastread'])
 140      {
 141          $read_tracking_join = ' LEFT JOIN ' . TOPICS_TRACK_TABLE . ' tt ON (tt.topic_id = t.topic_id AND tt.user_id = ' . $user->data['user_id'] . ')';
 142          $read_tracking_select = ', tt.mark_time';
 143      }
 144      else
 145      {
 146          $read_tracking_join = $read_tracking_select = '';
 147      }
 148   
 149      $sql = "SELECT t.*$read_tracking_select
 150          FROM " . TOPICS_TABLE . " t $read_tracking_join
 151          WHERE t.forum_id IN($forum_id, 0)
 152              " . (($auth->acl_get('m_approve', $forum_id)) ? '' : 'AND t.topic_approved = 1') . "
 153              $limit_time_sql
 154          ORDER BY t.topic_type DESC, $sort_order_sql";
 155      $result = $db->sql_query_limit($sql, $topics_per_page, $start);
 156   
 157      $topic_list = $topic_tracking_info = array();
 158      while ($row = $db->sql_fetchrow($result))
 159      {
 160          $topic_rows[$row['topic_id']] = $row;
 161          $topic_list[] = $row['topic_id'];
 162      }
 163      $db->sql_freeresult($result);
 164   
 165      // If there is more than one page, but we have no topic list, then the start parameter is... erm... out of sync
 166      if (!sizeof($topic_list) && $forum_topics && $start > 0)
 167      {
 168          redirect($url . "&amp;i=$id&amp;action=$action&amp;mode=$mode");
 169      }
 170   
 171      // Get topic tracking info
 172      if (sizeof($topic_list))
 173      {
 174          if ($config['load_db_lastread'])
 175          {
 176              $topic_tracking_info = get_topic_tracking($forum_id, $topic_list, $topic_rows, array($forum_id => $forum_info['mark_time']), array());
 177          }
 178          else
 179          {
 180              $topic_tracking_info = get_complete_topic_tracking($forum_id, $topic_list, array());
 181          }
 182      }
 183   
 184      foreach ($topic_rows as $topic_id => $row)
 185      {
 186          $topic_title = '';
 187   
 188          $replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies'];
 189   
 190          if ($row['topic_status'] == ITEM_MOVED)
 191          {
 192              $unread_topic = false;
 193          }
 194          else
 195          {
 196              $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
 197          }
 198   
 199          // Get folder img, topic status/type related information
 200          $folder_img = $folder_alt = $topic_type = '';
 201          topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type);
 202   
 203          $topic_title = censor_text($row['topic_title']);
 204   
 205          $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
 206          $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $row['forum_id'])) ? true : false;
 207          $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? $url . '&amp;i=queue&amp;mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . '&amp;t=' . $row['topic_id'] : '';
 208   
 209          $topic_row = array(
 210              'ATTACH_ICON_IMG'        => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
 211              'TOPIC_FOLDER_IMG'        => $user->img($folder_img, $folder_alt),
 212              'TOPIC_FOLDER_IMG_SRC'    => $user->img($folder_img, $folder_alt, false, '', 'src'),
 213              'TOPIC_ICON_IMG'        => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '',
 214              'TOPIC_ICON_IMG_WIDTH'    => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '',
 215              'TOPIC_ICON_IMG_HEIGHT'    => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '',
 216              'UNAPPROVED_IMG'        => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '',
 217   
 218              'TOPIC_AUTHOR'                => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
 219              'TOPIC_AUTHOR_COLOUR'        => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
 220              'TOPIC_AUTHOR_FULL'            => get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
 221              'U_TOPIC_AUTHOR'            => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
 222   
 223              'LAST_POST_AUTHOR'            => get_username_string('username', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
 224              'LAST_POST_AUTHOR_COLOUR'    => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
 225              'LAST_POST_AUTHOR_FULL'        => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
 226              'U_LAST_POST_AUTHOR'        => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
 227   
 228              'TOPIC_TYPE'        => $topic_type,
 229              'TOPIC_TITLE'        => $topic_title,
 230              'REPLIES'            => ($auth->acl_get('m_approve', $row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies'],
 231              'LAST_POST_TIME'    => $user->format_date($row['topic_last_post_time']),
 232              'FIRST_POST_TIME'    => $user->format_date($row['topic_time']),
 233              'LAST_POST_SUBJECT'    => $row['topic_last_post_subject'],
 234              'LAST_VIEW_TIME'    => $user->format_date($row['topic_last_view_time']),
 235   
 236              'S_TOPIC_REPORTED'        => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $row['forum_id'])) ? true : false,
 237              'S_TOPIC_UNAPPROVED'    => $topic_unapproved,
 238              'S_POSTS_UNAPPROVED'    => $posts_unapproved,
 239              'S_UNREAD_TOPIC'        => $unread_topic,
 240          );
 241   
 242          if ($row['topic_status'] == ITEM_MOVED)
 243          {
 244              $topic_row = array_merge($topic_row, array(
 245                  'U_VIEW_TOPIC'        => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "t={$row['topic_moved_id']}"),
 246                  'U_DELETE_TOPIC'    => ($auth->acl_get('m_delete', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&amp;f=$forum_id&amp;topic_id_list[]={$row['topic_id']}&amp;mode=forum_view&amp;action=delete_topic") : '',
 247                  'S_MOVED_TOPIC'        => true,
 248                  'TOPIC_ID'            => $row['topic_moved_id'],
 249              ));
 250          }
 251          else
 252          {
 253              if ($action == 'merge_topic' || $action == 'merge_topics')
 254              {
 255                  $u_select_topic = $url . "&amp;i=$id&amp;mode=forum_view&amp;action=$action&amp;to_topic_id=" . $row['topic_id'] . $selected_ids;
 256              }
 257              else
 258              {
 259                  $u_select_topic = $url . "&amp;i=$id&amp;mode=topic_view&amp;action=merge&amp;to_topic_id=" . $row['topic_id'] . $selected_ids;
 260              }
 261              $topic_row = array_merge($topic_row, array(
 262                  'U_VIEW_TOPIC'        => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&amp;f=$forum_id&amp;t={$row['topic_id']}&amp;mode=topic_view"),
 263   
 264                  'S_SELECT_TOPIC'    => ($merge_select && !in_array($row['topic_id'], $source_topic_ids)) ? true : false,
 265                  'U_SELECT_TOPIC'    => $u_select_topic,
 266                  'U_MCP_QUEUE'        => $u_mcp_queue,
 267                  'U_MCP_REPORT'        => ($auth->acl_get('m_report', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=topic_view&amp;t=' . $row['topic_id'] . '&amp;action=reports') : '',
 268                  'TOPIC_ID'            => $row['topic_id'],
 269                  'S_TOPIC_CHECKED'    => ($topic_id_list && in_array($row['topic_id'], $topic_id_list)) ? true : false,
 270              ));
 271          }
 272   
 273          $template->assign_block_vars('topicrow', $topic_row);
 274      }
 275      unset($topic_rows);
 276  }
 277   
 278  /**
 279  * Resync topics
 280  */
 281  function mcp_resync_topics($topic_ids)
 282  {
 283      global $auth, $db, $template, $phpEx, $user, $phpbb_root_path;
 284   
 285      if (!sizeof($topic_ids))
 286      {
 287          trigger_error('NO_TOPIC_SELECTED');
 288      }
 289   
 290      if (!check_ids($topic_ids, TOPICS_TABLE, 'topic_id', array('m_')))
 291      {
 292          return;
 293      }
 294   
 295      // Sync everything and perform extra checks separately
 296      sync('topic_reported', 'topic_id', $topic_ids, false, true);
 297      sync('topic_attachment', 'topic_id', $topic_ids, false, true);
 298      sync('topic', 'topic_id', $topic_ids, true, false);
 299   
 300      $sql = 'SELECT topic_id, forum_id, topic_title
 301          FROM ' . TOPICS_TABLE . '
 302          WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
 303      $result = $db->sql_query($sql);
 304   
 305      // Log this action
 306      while ($row = $db->sql_fetchrow($result))
 307      {
 308          add_log('mod', $row['forum_id'], $row['topic_id'], 'LOG_TOPIC_RESYNC', $row['topic_title']);
 309      }
 310      $db->sql_freeresult($result);
 311   
 312      $msg = (sizeof($topic_ids) == 1) ? $user->lang['TOPIC_RESYNC_SUCCESS'] : $user->lang['TOPICS_RESYNC_SUCCESS'];
 313   
 314      $redirect = request_var('redirect', $user->data['session_page']);
 315   
 316      meta_refresh(3, $redirect);
 317      trigger_error($msg . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
 318   
 319      return;
 320  }
 321   
 322  /**
 323  * Merge selected topics into selected topic
 324  */
 325  function merge_topics($forum_id, $topic_ids, $to_topic_id)
 326  {
 327      global $db, $template, $user, $phpEx, $phpbb_root_path, $auth;
 328   
 329      if (!sizeof($topic_ids))
 330      {
 331          $template->assign_var('MESSAGE', $user->lang['NO_TOPIC_SELECTED']);
 332          return;
 333      }
 334      if (!$to_topic_id)
 335      {
 336          $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
 337          return;
 338      }
 339   
 340      $topic_data = get_topic_data(array($to_topic_id), 'm_merge');
 341   
 342      if (!sizeof($topic_data))
 343      {
 344          $template->assign_var('MESSAGE', $user->lang['NO_FINAL_TOPIC_SELECTED']);
 345          return;
 346      }
 347   
 348      $topic_data = $topic_data[$to_topic_id];
 349   
 350      $post_id_list    = request_var('post_id_list', array(0));
 351      $start            = request_var('start', 0);
 352   
 353      if (!sizeof($post_id_list) && sizeof($topic_ids))
 354      {
 355          $sql = 'SELECT post_id
 356              FROM ' . POSTS_TABLE . '
 357              WHERE ' . $db->sql_in_set('topic_id', $topic_ids);
 358          $result = $db->sql_query($sql);
 359   
 360          $post_id_list = array();
 361          while ($row = $db->sql_fetchrow($result))
 362          {
 363              $post_id_list[] = $row['post_id'];
 364          }
 365          $db->sql_freeresult($result);
 366      }
 367   
 368      if (!sizeof($post_id_list))
 369      {
 370          $template->assign_var('MESSAGE', $user->lang['NO_POST_SELECTED']);
 371          return;
 372      }
 373   
 374      if (!check_ids($post_id_list, POSTS_TABLE, 'post_id', array('m_merge')))
 375      {
 376          return;
 377      }
 378   
 379      $redirect = request_var('redirect', build_url(array('_f_', 'quickmod')));
 380   
 381      $s_hidden_fields = build_hidden_fields(array(
 382          'i'                => 'main',
 383          'f'                => $forum_id,
 384          'post_id_list'    => $post_id_list,
 385          'to_topic_id'    => $to_topic_id,
 386          'mode'            => 'forum_view',
 387          'action'        => 'merge_topics',
 388          'start'            => $start,
 389          'redirect'        => $redirect,
 390          'topic_id_list'    => $topic_ids)
 391      );
 392      $success_msg = $return_link = '';
 393   
 394      if (confirm_box(true))
 395      {
 396          $to_forum_id = $topic_data['forum_id'];
 397   
 398          move_posts($post_id_list, $to_topic_id);
 399          add_log('mod', $to_forum_id, $to_topic_id, 'LOG_MERGE', $topic_data['topic_title']);
 400   
 401          // Message and return links
 402          $success_msg = 'POSTS_MERGED_SUCCESS';
 403   
 404          // If the topic no longer exist, we will update the topic watch table.
 405          // To not let it error out on users watching both topics, we just return on an error...
 406          $db->sql_return_on_error(true);
 407          $db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids));
 408          $db->sql_return_on_error(false);
 409   
 410          $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids));
 411   
 412          // Link to the new topic
 413          $return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&amp;t=' . $to_topic_id) . '">', '</a>');
 414      }
 415      else
 416      {
 417          confirm_box(false, 'MERGE_TOPICS', $s_hidden_fields);
 418      }
 419   
 420      $redirect = request_var('redirect', "index.$phpEx");
 421      $redirect = reapply_sid($redirect);
 422   
 423      if (!$success_msg)
 424      {
 425          return;
 426      }
 427      else
 428      {
 429          meta_refresh(3, append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$to_forum_id&amp;t=$to_topic_id"));
 430          trigger_error($user->lang[$success_msg] . '<br /><br />' . $return_link);
 431      }
 432  }
 433   
 434  ?>