[ Index ]

PHP Cross Reference of phpBB-3.2.11-deutsch

title

Body

[close]

/includes/acp/ -> acp_forums.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  class acp_forums
  23  {
  24      var $u_action;
  25      var $parent_id = 0;
  26  
  27  	function main($id, $mode)
  28      {
  29          global $db, $user, $auth, $template, $cache, $request, $phpbb_dispatcher;
  30          global $phpbb_admin_path, $phpbb_root_path, $phpEx, $phpbb_log;
  31  
  32          $user->add_lang('acp/forums');
  33          $this->tpl_name = 'acp_forums';
  34          $this->page_title = 'ACP_MANAGE_FORUMS';
  35  
  36          $form_key = 'acp_forums';
  37          add_form_key($form_key);
  38  
  39          $action        = $request->variable('action', '');
  40          $update        = (isset($_POST['update'])) ? true : false;
  41          $forum_id    = $request->variable('f', 0);
  42  
  43          $this->parent_id    = $request->variable('parent_id', 0);
  44          $forum_data = $errors = array();
  45          if ($update && !check_form_key($form_key))
  46          {
  47              $update = false;
  48              $errors[] = $user->lang['FORM_INVALID'];
  49          }
  50  
  51          // Check additional permissions
  52          switch ($action)
  53          {
  54              case 'progress_bar':
  55                  $start = $request->variable('start', 0);
  56                  $total = $request->variable('total', 0);
  57  
  58                  $this->display_progress_bar($start, $total);
  59              break;
  60  
  61              case 'delete':
  62  
  63                  if (!$auth->acl_get('a_forumdel'))
  64                  {
  65                      trigger_error($user->lang['NO_PERMISSION_FORUM_DELETE'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
  66                  }
  67  
  68              break;
  69  
  70              case 'add':
  71  
  72                  if (!$auth->acl_get('a_forumadd'))
  73                  {
  74                      trigger_error($user->lang['NO_PERMISSION_FORUM_ADD'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
  75                  }
  76  
  77              break;
  78          }
  79  
  80          // Major routines
  81          if ($update)
  82          {
  83              switch ($action)
  84              {
  85                  case 'delete':
  86                      $action_subforums    = $request->variable('action_subforums', '');
  87                      $subforums_to_id    = $request->variable('subforums_to_id', 0);
  88                      $action_posts        = $request->variable('action_posts', '');
  89                      $posts_to_id        = $request->variable('posts_to_id', 0);
  90  
  91                      $errors = $this->delete_forum($forum_id, $action_posts, $action_subforums, $posts_to_id, $subforums_to_id);
  92  
  93                      if (count($errors))
  94                      {
  95                          break;
  96                      }
  97  
  98                      $auth->acl_clear_prefetch();
  99                      $cache->destroy('sql', FORUMS_TABLE);
 100  
 101                      trigger_error($user->lang['FORUM_DELETED'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id));
 102  
 103                  break;
 104  
 105                  case 'edit':
 106                      $forum_data = array(
 107                          'forum_id'        =>    $forum_id
 108                      );
 109  
 110                  // No break here
 111  
 112                  case 'add':
 113  
 114                      $forum_data += array(
 115                          'parent_id'                => $request->variable('forum_parent_id', $this->parent_id),
 116                          'forum_type'            => $request->variable('forum_type', FORUM_POST),
 117                          'type_action'            => $request->variable('type_action', ''),
 118                          'forum_status'            => $request->variable('forum_status', ITEM_UNLOCKED),
 119                          'forum_parents'            => '',
 120                          'forum_name'            => $request->variable('forum_name', '', true),
 121                          'forum_link'            => $request->variable('forum_link', ''),
 122                          'forum_link_track'        => $request->variable('forum_link_track', false),
 123                          'forum_desc'            => $request->variable('forum_desc', '', true),
 124                          'forum_desc_uid'        => '',
 125                          'forum_desc_options'    => 7,
 126                          'forum_desc_bitfield'    => '',
 127                          'forum_rules'            => $request->variable('forum_rules', '', true),
 128                          'forum_rules_uid'        => '',
 129                          'forum_rules_options'    => 7,
 130                          'forum_rules_bitfield'    => '',
 131                          'forum_rules_link'        => $request->variable('forum_rules_link', ''),
 132                          'forum_image'            => $request->variable('forum_image', ''),
 133                          'forum_style'            => $request->variable('forum_style', 0),
 134                          'display_subforum_list'    => $request->variable('display_subforum_list', false),
 135                          'display_on_index'        => $request->variable('display_on_index', false),
 136                          'forum_topics_per_page'    => $request->variable('topics_per_page', 0),
 137                          'enable_indexing'        => $request->variable('enable_indexing', true),
 138                          'enable_icons'            => $request->variable('enable_icons', false),
 139                          'enable_prune'            => $request->variable('enable_prune', false),
 140                          'enable_post_review'    => $request->variable('enable_post_review', true),
 141                          'enable_quick_reply'    => $request->variable('enable_quick_reply', false),
 142                          'enable_shadow_prune'    => $request->variable('enable_shadow_prune', false),
 143                          'prune_days'            => $request->variable('prune_days', 7),
 144                          'prune_viewed'            => $request->variable('prune_viewed', 7),
 145                          'prune_freq'            => $request->variable('prune_freq', 1),
 146                          'prune_old_polls'        => $request->variable('prune_old_polls', false),
 147                          'prune_announce'        => $request->variable('prune_announce', false),
 148                          'prune_sticky'            => $request->variable('prune_sticky', false),
 149                          'prune_shadow_days'        => $request->variable('prune_shadow_days', 7),
 150                          'prune_shadow_freq'        => $request->variable('prune_shadow_freq', 1),
 151                          'forum_password'        => $request->variable('forum_password', '', true),
 152                          'forum_password_confirm'=> $request->variable('forum_password_confirm', '', true),
 153                          'forum_password_unset'    => $request->variable('forum_password_unset', false),
 154                      );
 155  
 156                      /**
 157                      * Request forum data and operate on it (parse texts, etc.)
 158                      *
 159                      * @event core.acp_manage_forums_request_data
 160                      * @var    string    action        Type of the action: add|edit
 161                      * @var    array    forum_data    Array with new forum data
 162                      * @since 3.1.0-a1
 163                      */
 164                      $vars = array('action', 'forum_data');
 165                      extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_request_data', compact($vars)));
 166  
 167                      // On add, add empty forum_options... else do not consider it (not updating it)
 168                      if ($action == 'add')
 169                      {
 170                          $forum_data['forum_options'] = 0;
 171                      }
 172  
 173                      // Use link_display_on_index setting if forum type is link
 174                      if ($forum_data['forum_type'] == FORUM_LINK)
 175                      {
 176                          $forum_data['display_on_index'] = $request->variable('link_display_on_index', false);
 177                      }
 178  
 179                      // Linked forums and categories are not able to be locked...
 180                      if ($forum_data['forum_type'] == FORUM_LINK || $forum_data['forum_type'] == FORUM_CAT)
 181                      {
 182                          $forum_data['forum_status'] = ITEM_UNLOCKED;
 183                      }
 184  
 185                      $forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? $request->variable('display_recent', true) : $request->variable('display_active', false);
 186  
 187                      // Get data for forum rules if specified...
 188                      if ($forum_data['forum_rules'])
 189                      {
 190                          generate_text_for_storage($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options'], $request->variable('rules_parse_bbcode', false), $request->variable('rules_parse_urls', false), $request->variable('rules_parse_smilies', false));
 191                      }
 192  
 193                      // Get data for forum description if specified
 194                      if ($forum_data['forum_desc'])
 195                      {
 196                          generate_text_for_storage($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'], $request->variable('desc_parse_bbcode', false), $request->variable('desc_parse_urls', false), $request->variable('desc_parse_smilies', false));
 197                      }
 198  
 199                      $errors = $this->update_forum_data($forum_data);
 200  
 201                      if (!count($errors))
 202                      {
 203                          $forum_perm_from = $request->variable('forum_perm_from', 0);
 204                          $cache->destroy('sql', FORUMS_TABLE);
 205  
 206                          $copied_permissions = false;
 207                          // Copy permissions?
 208                          if ($forum_perm_from && $forum_perm_from != $forum_data['forum_id'] &&
 209                              ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))))
 210                          {
 211                              copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false);
 212                              phpbb_cache_moderators($db, $cache, $auth);
 213                              $copied_permissions = true;
 214                          }
 215  /* Commented out because of questionable UI workflow - re-visit for 3.0.7
 216                          else if (!$this->parent_id && $action != 'edit' && $auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))
 217                          {
 218                              $this->copy_permission_page($forum_data);
 219                              return;
 220                          }
 221  */
 222                          $auth->acl_clear_prefetch();
 223  
 224                          $acl_url = '&amp;mode=setting_forum_local&amp;forum_id[]=' . $forum_data['forum_id'];
 225  
 226                          $message = ($action == 'add') ? $user->lang['FORUM_CREATED'] : $user->lang['FORUM_UPDATED'];
 227  
 228                          // redirect directly to permission settings screen if authed
 229                          if ($action == 'add' && !$copied_permissions && $auth->acl_get('a_fauth'))
 230                          {
 231                              $message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>');
 232  
 233                              meta_refresh(4, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url));
 234                          }
 235  
 236                          trigger_error($message . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id));
 237                      }
 238  
 239                  break;
 240              }
 241          }
 242  
 243          switch ($action)
 244          {
 245              case 'move_up':
 246              case 'move_down':
 247  
 248                  if (!$forum_id)
 249                  {
 250                      trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
 251                  }
 252  
 253                  $sql = 'SELECT *
 254                      FROM ' . FORUMS_TABLE . "
 255                      WHERE forum_id = $forum_id";
 256                  $result = $db->sql_query($sql);
 257                  $row = $db->sql_fetchrow($result);
 258                  $db->sql_freeresult($result);
 259  
 260                  if (!$row)
 261                  {
 262                      trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
 263                  }
 264  
 265                  $move_forum_name = $this->move_forum_by($row, $action, 1);
 266  
 267                  if ($move_forum_name !== false)
 268                  {
 269                      $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_' . strtoupper($action), false, array($row['forum_name'], $move_forum_name));
 270                      $cache->destroy('sql', FORUMS_TABLE);
 271                  }
 272  
 273                  if ($request->is_ajax())
 274                  {
 275                      $json_response = new \phpbb\json_response;
 276                      $json_response->send(array('success' => ($move_forum_name !== false)));
 277                  }
 278  
 279              break;
 280  
 281              case 'sync':
 282                  if (!$forum_id)
 283                  {
 284                      trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
 285                  }
 286  
 287                  @set_time_limit(0);
 288  
 289                  $sql = 'SELECT forum_name, (forum_topics_approved + forum_topics_unapproved + forum_topics_softdeleted) AS total_topics
 290                      FROM ' . FORUMS_TABLE . "
 291                      WHERE forum_id = $forum_id";
 292                  $result = $db->sql_query($sql);
 293                  $row = $db->sql_fetchrow($result);
 294                  $db->sql_freeresult($result);
 295  
 296                  if (!$row)
 297                  {
 298                      trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
 299                  }
 300  
 301                  if ($row['total_topics'])
 302                  {
 303                      $sql = 'SELECT MIN(topic_id) as min_topic_id, MAX(topic_id) as max_topic_id
 304                          FROM ' . TOPICS_TABLE . '
 305                          WHERE forum_id = ' . $forum_id;
 306                      $result = $db->sql_query($sql);
 307                      $row2 = $db->sql_fetchrow($result);
 308                      $db->sql_freeresult($result);
 309  
 310                      // Typecast to int if there is no data available
 311                      $row2['min_topic_id'] = (int) $row2['min_topic_id'];
 312                      $row2['max_topic_id'] = (int) $row2['max_topic_id'];
 313  
 314                      $start = $request->variable('start', $row2['min_topic_id']);
 315  
 316                      $batch_size = 2000;
 317                      $end = $start + $batch_size;
 318  
 319                      // Sync all topics in batch mode...
 320                      sync('topic', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, true);
 321  
 322                      if ($end < $row2['max_topic_id'])
 323                      {
 324                          // We really need to find a way of showing statistics... no progress here
 325                          $sql = 'SELECT COUNT(topic_id) as num_topics
 326                              FROM ' . TOPICS_TABLE . '
 327                              WHERE forum_id = ' . $forum_id . '
 328                                  AND topic_id BETWEEN ' . $start . ' AND ' . $end;
 329                          $result = $db->sql_query($sql);
 330                          $topics_done = $request->variable('topics_done', 0) + (int) $db->sql_fetchfield('num_topics');
 331                          $db->sql_freeresult($result);
 332  
 333                          $start += $batch_size;
 334  
 335                          $url = $this->u_action . "&amp;parent_id={$this->parent_id}&amp;f=$forum_id&amp;action=sync&amp;start=$start&amp;topics_done=$topics_done&amp;total={$row['total_topics']}";
 336  
 337                          meta_refresh(0, $url);
 338  
 339                          $template->assign_vars(array(
 340                              'U_PROGRESS_BAR'        => $this->u_action . "&amp;action=progress_bar&amp;start=$topics_done&amp;total={$row['total_topics']}",
 341                              'UA_PROGRESS_BAR'        => addslashes($this->u_action . "&amp;action=progress_bar&amp;start=$topics_done&amp;total={$row['total_topics']}"),
 342                              'S_CONTINUE_SYNC'        => true,
 343                              'L_PROGRESS_EXPLAIN'    => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $topics_done, $row['total_topics']))
 344                          );
 345  
 346                          return;
 347                      }
 348                  }
 349  
 350                  $url = $this->u_action . "&amp;parent_id={$this->parent_id}&amp;f=$forum_id&amp;action=sync_forum";
 351                  meta_refresh(0, $url);
 352  
 353                  $template->assign_vars(array(
 354                      'U_PROGRESS_BAR'        => $this->u_action . '&amp;action=progress_bar',
 355                      'UA_PROGRESS_BAR'        => addslashes($this->u_action . '&amp;action=progress_bar'),
 356                      'S_CONTINUE_SYNC'        => true,
 357                      'L_PROGRESS_EXPLAIN'    => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], 0, $row['total_topics']))
 358                  );
 359  
 360                  return;
 361  
 362              break;
 363  
 364              case 'sync_forum':
 365  
 366                  $sql = 'SELECT forum_name, forum_type
 367                      FROM ' . FORUMS_TABLE . "
 368                      WHERE forum_id = $forum_id";
 369                  $result = $db->sql_query($sql);
 370                  $row = $db->sql_fetchrow($result);
 371                  $db->sql_freeresult($result);
 372  
 373                  if (!$row)
 374                  {
 375                      trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
 376                  }
 377  
 378                  sync('forum', 'forum_id', $forum_id, false, true);
 379  
 380                  $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_SYNC', false, array($row['forum_name']));
 381  
 382                  $cache->destroy('sql', FORUMS_TABLE);
 383  
 384                  $template->assign_var('L_FORUM_RESYNCED', sprintf($user->lang['FORUM_RESYNCED'], $row['forum_name']));
 385  
 386              break;
 387  
 388              case 'add':
 389              case 'edit':
 390  
 391                  if ($update)
 392                  {
 393                      $forum_data['forum_flags'] = 0;
 394                      $forum_data['forum_flags'] += ($request->variable('forum_link_track', false)) ? FORUM_FLAG_LINK_TRACK : 0;
 395                      $forum_data['forum_flags'] += ($request->variable('prune_old_polls', false)) ? FORUM_FLAG_PRUNE_POLL : 0;
 396                      $forum_data['forum_flags'] += ($request->variable('prune_announce', false)) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0;
 397                      $forum_data['forum_flags'] += ($request->variable('prune_sticky', false)) ? FORUM_FLAG_PRUNE_STICKY : 0;
 398                      $forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0;
 399                      $forum_data['forum_flags'] += ($request->variable('enable_post_review', true)) ? FORUM_FLAG_POST_REVIEW : 0;
 400                      $forum_data['forum_flags'] += ($request->variable('enable_quick_reply', false)) ? FORUM_FLAG_QUICK_REPLY : 0;
 401                  }
 402  
 403                  // Initialise $row, so we always have it in the event
 404                  $row = array();
 405  
 406                  // Show form to create/modify a forum
 407                  if ($action == 'edit')
 408                  {
 409                      $this->page_title = 'EDIT_FORUM';
 410                      $row = $this->get_forum_info($forum_id);
 411                      $old_forum_type = $row['forum_type'];
 412  
 413                      if (!$update)
 414                      {
 415                          $forum_data = $row;
 416                      }
 417                      else
 418                      {
 419                          $forum_data['left_id'] = $row['left_id'];
 420                          $forum_data['right_id'] = $row['right_id'];
 421                      }
 422  
 423                      // Make sure no direct child forums are able to be selected as parents.
 424                      $exclude_forums = array();
 425                      foreach (get_forum_branch($forum_id, 'children') as $row)
 426                      {
 427                          $exclude_forums[] = $row['forum_id'];
 428                      }
 429  
 430                      $parents_list = make_forum_select($forum_data['parent_id'], $exclude_forums, false, false, false);
 431  
 432                      $forum_data['forum_password_confirm'] = $forum_data['forum_password'];
 433                  }
 434                  else
 435                  {
 436                      $this->page_title = 'CREATE_FORUM';
 437  
 438                      $forum_id = $this->parent_id;
 439                      $parents_list = make_forum_select($this->parent_id, false, false, false, false);
 440  
 441                      // Fill forum data with default values
 442                      if (!$update)
 443                      {
 444                          $forum_data = array(
 445                              'parent_id'                => $this->parent_id,
 446                              'forum_type'            => FORUM_POST,
 447                              'forum_status'            => ITEM_UNLOCKED,
 448                              'forum_name'            => $request->variable('forum_name', '', true),
 449                              'forum_link'            => '',
 450                              'forum_link_track'        => false,
 451                              'forum_desc'            => '',
 452                              'forum_rules'            => '',
 453                              'forum_rules_link'        => '',
 454                              'forum_image'            => '',
 455                              'forum_style'            => 0,
 456                              'display_subforum_list'    => true,
 457                              'display_on_index'        => false,
 458                              'forum_topics_per_page'    => 0,
 459                              'enable_indexing'        => true,
 460                              'enable_icons'            => false,
 461                              'enable_prune'            => false,
 462                              'prune_days'            => 7,
 463                              'prune_viewed'            => 7,
 464                              'prune_freq'            => 1,
 465                              'enable_shadow_prune'        => false,
 466                              'prune_shadow_days'        => 7,
 467                              'prune_shadow_freq'        => 1,
 468                              'forum_flags'            => FORUM_FLAG_POST_REVIEW + FORUM_FLAG_ACTIVE_TOPICS,
 469                              'forum_options'            => 0,
 470                              'forum_password'        => '',
 471                              'forum_password_confirm'=> '',
 472                          );
 473                      }
 474                  }
 475  
 476                  /**
 477                  * Initialise data before we display the add/edit form
 478                  *
 479                  * @event core.acp_manage_forums_initialise_data
 480                  * @var    string    action        Type of the action: add|edit
 481                  * @var    bool    update        Do we display the form only
 482                  *                            or did the user press submit
 483                  * @var    int        forum_id    When editing: the forum id,
 484                  *                            when creating: the parent forum id
 485                  * @var    array    row            Array with current forum data
 486                  *                            empty when creating new forum
 487                  * @var    array    forum_data    Array with new forum data
 488                  * @var    string    parents_list    List of parent options
 489                  * @since 3.1.0-a1
 490                  */
 491                  $vars = array('action', 'update', 'forum_id', 'row', 'forum_data', 'parents_list');
 492                  extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_initialise_data', compact($vars)));
 493  
 494                  $forum_rules_data = array(
 495                      'text'            => $forum_data['forum_rules'],
 496                      'allow_bbcode'    => true,
 497                      'allow_smilies'    => true,
 498                      'allow_urls'    => true
 499                  );
 500  
 501                  $forum_desc_data = array(
 502                      'text'            => $forum_data['forum_desc'],
 503                      'allow_bbcode'    => true,
 504                      'allow_smilies'    => true,
 505                      'allow_urls'    => true
 506                  );
 507  
 508                  $forum_rules_preview = '';
 509  
 510                  // Parse rules if specified
 511                  if ($forum_data['forum_rules'])
 512                  {
 513                      if (!isset($forum_data['forum_rules_uid']))
 514                      {
 515                          // Before we are able to display the preview and plane text, we need to parse our $request->variable()'d value...
 516                          $forum_data['forum_rules_uid'] = '';
 517                          $forum_data['forum_rules_bitfield'] = '';
 518                          $forum_data['forum_rules_options'] = 0;
 519  
 520                          generate_text_for_storage($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options'], $request->variable('rules_allow_bbcode', false), $request->variable('rules_allow_urls', false), $request->variable('rules_allow_smilies', false));
 521                      }
 522  
 523                      // Generate preview content
 524                      $forum_rules_preview = generate_text_for_display($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options']);
 525  
 526                      // decode...
 527                      $forum_rules_data = generate_text_for_edit($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_options']);
 528                  }
 529  
 530                  // Parse desciption if specified
 531                  if ($forum_data['forum_desc'])
 532                  {
 533                      if (!isset($forum_data['forum_desc_uid']))
 534                      {
 535                          // Before we are able to display the preview and plane text, we need to parse our $request->variable()'d value...
 536                          $forum_data['forum_desc_uid'] = '';
 537                          $forum_data['forum_desc_bitfield'] = '';
 538                          $forum_data['forum_desc_options'] = 0;
 539  
 540                          generate_text_for_storage($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'], $request->variable('desc_allow_bbcode', false), $request->variable('desc_allow_urls', false), $request->variable('desc_allow_smilies', false));
 541                      }
 542  
 543                      // decode...
 544                      $forum_desc_data = generate_text_for_edit($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_options']);
 545                  }
 546  
 547                  $forum_type_options = '';
 548                  $forum_type_ary = array(FORUM_CAT => 'CAT', FORUM_POST => 'FORUM', FORUM_LINK => 'LINK');
 549  
 550                  foreach ($forum_type_ary as $value => $lang)
 551                  {
 552                      $forum_type_options .= '<option value="' . $value . '"' . (($value == $forum_data['forum_type']) ? ' selected="selected"' : '') . '>' . $user->lang['TYPE_' . $lang] . '</option>';
 553                  }
 554  
 555                  $styles_list = style_select($forum_data['forum_style'], true);
 556  
 557                  $statuslist = '<option value="' . ITEM_UNLOCKED . '"' . (($forum_data['forum_status'] == ITEM_UNLOCKED) ? ' selected="selected"' : '') . '>' . $user->lang['UNLOCKED'] . '</option><option value="' . ITEM_LOCKED . '"' . (($forum_data['forum_status'] == ITEM_LOCKED) ? ' selected="selected"' : '') . '>' . $user->lang['LOCKED'] . '</option>';
 558  
 559                  $sql = 'SELECT forum_id
 560                      FROM ' . FORUMS_TABLE . '
 561                      WHERE forum_type = ' . FORUM_POST . "
 562                          AND forum_id <> $forum_id";
 563                  $result = $db->sql_query_limit($sql, 1);
 564  
 565                  $postable_forum_exists = false;
 566                  if ($db->sql_fetchrow($result))
 567                  {
 568                      $postable_forum_exists = true;
 569                  }
 570                  $db->sql_freeresult($result);
 571  
 572                  // Subforum move options
 573                  if ($action == 'edit' && $forum_data['forum_type'] == FORUM_CAT)
 574                  {
 575                      $subforums_id = array();
 576                      $subforums = get_forum_branch($forum_id, 'children');
 577  
 578                      foreach ($subforums as $row)
 579                      {
 580                          $subforums_id[] = $row['forum_id'];
 581                      }
 582  
 583                      $forums_list = make_forum_select($forum_data['parent_id'], $subforums_id);
 584  
 585                      if ($postable_forum_exists)
 586                      {
 587                          $template->assign_vars(array(
 588                              'S_MOVE_FORUM_OPTIONS'        => make_forum_select($forum_data['parent_id'], $subforums_id)) // , false, true, false???
 589                          );
 590                      }
 591  
 592                      $template->assign_vars(array(
 593                          'S_HAS_SUBFORUMS'        => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false,
 594                          'S_FORUMS_LIST'            => $forums_list)
 595                      );
 596                  }
 597                  else if ($postable_forum_exists)
 598                  {
 599                      $template->assign_vars(array(
 600                          'S_MOVE_FORUM_OPTIONS'        => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false))
 601                      );
 602                  }
 603  
 604                  $s_show_display_on_index = false;
 605  
 606                  if ($forum_data['parent_id'] > 0)
 607                  {
 608                      // if this forum is a subforum put the "display on index" checkbox
 609                      if ($parent_info = $this->get_forum_info($forum_data['parent_id']))
 610                      {
 611                          if ($parent_info['parent_id'] > 0 || $parent_info['forum_type'] == FORUM_CAT)
 612                          {
 613                              $s_show_display_on_index = true;
 614                          }
 615                      }
 616                  }
 617  
 618                  if (strlen($forum_data['forum_password']) == 32)
 619                  {
 620                      $errors[] = $user->lang['FORUM_PASSWORD_OLD'];
 621                  }
 622  
 623                  $template_data = array(
 624                      'S_EDIT_FORUM'        => true,
 625                      'S_ERROR'            => (count($errors)) ? true : false,
 626                      'S_PARENT_ID'        => $this->parent_id,
 627                      'S_FORUM_PARENT_ID'    => $forum_data['parent_id'],
 628                      'S_ADD_ACTION'        => ($action == 'add') ? true : false,
 629  
 630                      'U_BACK'        => $this->u_action . '&amp;parent_id=' . $this->parent_id,
 631                      'U_EDIT_ACTION'    => $this->u_action . "&amp;parent_id={$this->parent_id}&amp;action=$action&amp;f=$forum_id",
 632  
 633                      'L_COPY_PERMISSIONS_EXPLAIN'    => $user->lang['COPY_PERMISSIONS_' . strtoupper($action) . '_EXPLAIN'],
 634                      'L_TITLE'                        => $user->lang[$this->page_title],
 635                      'ERROR_MSG'                        => (count($errors)) ? implode('<br />', $errors) : '',
 636  
 637                      'FORUM_NAME'                => $forum_data['forum_name'],
 638                      'FORUM_DATA_LINK'            => $forum_data['forum_link'],
 639                      'FORUM_IMAGE'                => $forum_data['forum_image'],
 640                      'FORUM_IMAGE_SRC'            => ($forum_data['forum_image']) ? $phpbb_root_path . $forum_data['forum_image'] : '',
 641                      'FORUM_POST'                => FORUM_POST,
 642                      'FORUM_LINK'                => FORUM_LINK,
 643                      'FORUM_CAT'                    => FORUM_CAT,
 644                      'PRUNE_FREQ'                => $forum_data['prune_freq'],
 645                      'PRUNE_DAYS'                => $forum_data['prune_days'],
 646                      'PRUNE_VIEWED'                => $forum_data['prune_viewed'],
 647                      'PRUNE_SHADOW_FREQ'            => $forum_data['prune_shadow_freq'],
 648                      'PRUNE_SHADOW_DAYS'            => $forum_data['prune_shadow_days'],
 649                      'TOPICS_PER_PAGE'            => $forum_data['forum_topics_per_page'],
 650                      'FORUM_RULES_LINK'            => $forum_data['forum_rules_link'],
 651                      'FORUM_RULES'                => $forum_data['forum_rules'],
 652                      'FORUM_RULES_PREVIEW'        => $forum_rules_preview,
 653                      'FORUM_RULES_PLAIN'            => $forum_rules_data['text'],
 654                      'S_BBCODE_CHECKED'            => ($forum_rules_data['allow_bbcode']) ? true : false,
 655                      'S_SMILIES_CHECKED'            => ($forum_rules_data['allow_smilies']) ? true : false,
 656                      'S_URLS_CHECKED'            => ($forum_rules_data['allow_urls']) ? true : false,
 657                      'S_FORUM_PASSWORD_SET'        => (empty($forum_data['forum_password'])) ? false : true,
 658  
 659                      'FORUM_DESC'                => $forum_desc_data['text'],
 660                      'S_DESC_BBCODE_CHECKED'        => ($forum_desc_data['allow_bbcode']) ? true : false,
 661                      'S_DESC_SMILIES_CHECKED'    => ($forum_desc_data['allow_smilies']) ? true : false,
 662                      'S_DESC_URLS_CHECKED'        => ($forum_desc_data['allow_urls']) ? true : false,
 663  
 664                      'S_FORUM_TYPE_OPTIONS'        => $forum_type_options,
 665                      'S_STATUS_OPTIONS'            => $statuslist,
 666                      'S_PARENT_OPTIONS'            => $parents_list,
 667                      'S_STYLES_OPTIONS'            => $styles_list,
 668                      'S_FORUM_OPTIONS'            => make_forum_select(($action == 'add') ? $forum_data['parent_id'] : false, ($action == 'edit') ? $forum_data['forum_id'] : false, false, false, false),
 669                      'S_SHOW_DISPLAY_ON_INDEX'    => $s_show_display_on_index,
 670                      'S_FORUM_POST'                => ($forum_data['forum_type'] == FORUM_POST) ? true : false,
 671                      'S_FORUM_ORIG_POST'            => (isset($old_forum_type) && $old_forum_type == FORUM_POST) ? true : false,
 672                      'S_FORUM_ORIG_CAT'            => (isset($old_forum_type) && $old_forum_type == FORUM_CAT) ? true : false,
 673                      'S_FORUM_ORIG_LINK'            => (isset($old_forum_type) && $old_forum_type == FORUM_LINK) ? true : false,
 674                      'S_FORUM_LINK'                => ($forum_data['forum_type'] == FORUM_LINK) ? true : false,
 675                      'S_FORUM_CAT'                => ($forum_data['forum_type'] == FORUM_CAT) ? true : false,
 676                      'S_ENABLE_INDEXING'            => ($forum_data['enable_indexing']) ? true : false,
 677                      'S_TOPIC_ICONS'                => ($forum_data['enable_icons']) ? true : false,
 678                      'S_DISPLAY_SUBFORUM_LIST'    => ($forum_data['display_subforum_list']) ? true : false,
 679                      'S_DISPLAY_ON_INDEX'        => ($forum_data['display_on_index']) ? true : false,
 680                      'S_PRUNE_ENABLE'            => ($forum_data['enable_prune']) ? true : false,
 681                      'S_PRUNE_SHADOW_ENABLE'            => ($forum_data['enable_shadow_prune']) ? true : false,
 682                      'S_FORUM_LINK_TRACK'        => ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? true : false,
 683                      'S_PRUNE_OLD_POLLS'            => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_POLL) ? true : false,
 684                      'S_PRUNE_ANNOUNCE'            => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_ANNOUNCE) ? true : false,
 685                      'S_PRUNE_STICKY'            => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_STICKY) ? true : false,
 686                      'S_DISPLAY_ACTIVE_TOPICS'    => ($forum_data['forum_type'] == FORUM_POST) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : true,
 687                      'S_ENABLE_ACTIVE_TOPICS'    => ($forum_data['forum_type'] == FORUM_CAT) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : false,
 688                      'S_ENABLE_POST_REVIEW'        => ($forum_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) ? true : false,
 689                      'S_ENABLE_QUICK_REPLY'        => ($forum_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) ? true : false,
 690                      'S_CAN_COPY_PERMISSIONS'    => ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))) ? true : false,
 691                  );
 692  
 693                  /**
 694                  * Modify forum template data before we display the form
 695                  *
 696                  * @event core.acp_manage_forums_display_form
 697                  * @var    string    action        Type of the action: add|edit
 698                  * @var    bool    update        Do we display the form only
 699                  *                            or did the user press submit
 700                  * @var    int        forum_id    When editing: the forum id,
 701                  *                            when creating: the parent forum id
 702                  * @var    array    row            Array with current forum data
 703                  *                            empty when creating new forum
 704                  * @var    array    forum_data    Array with new forum data
 705                  * @var    string    parents_list    List of parent options
 706                  * @var    array    errors        Array of errors, if you add errors
 707                  *                    ensure to update the template variables
 708                  *                    S_ERROR and ERROR_MSG to display it
 709                  * @var    array    template_data    Array with new forum data
 710                  * @since 3.1.0-a1
 711                  */
 712                  $vars = array(
 713                      'action',
 714                      'update',
 715                      'forum_id',
 716                      'row',
 717                      'forum_data',
 718                      'parents_list',
 719                      'errors',
 720                      'template_data',
 721                  );
 722                  extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_display_form', compact($vars)));
 723  
 724                  $template->assign_vars($template_data);
 725  
 726                  return;
 727  
 728              break;
 729  
 730              case 'delete':
 731  
 732                  if (!$forum_id)
 733                  {
 734                      trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
 735                  }
 736  
 737                  $forum_data = $this->get_forum_info($forum_id);
 738  
 739                  $subforums_id = array();
 740                  $subforums = get_forum_branch($forum_id, 'children');
 741  
 742                  foreach ($subforums as $row)
 743                  {
 744                      $subforums_id[] = $row['forum_id'];
 745                  }
 746  
 747                  $forums_list = make_forum_select($forum_data['parent_id'], $subforums_id);
 748  
 749                  $sql = 'SELECT forum_id
 750                      FROM ' . FORUMS_TABLE . '
 751                      WHERE forum_type = ' . FORUM_POST . "
 752                          AND forum_id <> $forum_id";
 753                  $result = $db->sql_query_limit($sql, 1);
 754  
 755                  if ($db->sql_fetchrow($result))
 756                  {
 757                      $template->assign_vars(array(
 758                          'S_MOVE_FORUM_OPTIONS'        => make_forum_select($forum_data['parent_id'], $subforums_id, false, true)) // , false, true, false???
 759                      );
 760                  }
 761                  $db->sql_freeresult($result);
 762  
 763                  $parent_id = ($this->parent_id == $forum_id) ? 0 : $this->parent_id;
 764  
 765                  $template->assign_vars(array(
 766                      'S_DELETE_FORUM'        => true,
 767                      'U_ACTION'                => $this->u_action . "&amp;parent_id={$parent_id}&amp;action=delete&amp;f=$forum_id",
 768                      'U_BACK'                => $this->u_action . '&amp;parent_id=' . $this->parent_id,
 769  
 770                      'FORUM_NAME'            => $forum_data['forum_name'],
 771                      'S_FORUM_POST'            => ($forum_data['forum_type'] == FORUM_POST) ? true : false,
 772                      'S_FORUM_LINK'            => ($forum_data['forum_type'] == FORUM_LINK) ? true : false,
 773                      'S_HAS_SUBFORUMS'        => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false,
 774                      'S_FORUMS_LIST'            => $forums_list,
 775                      'S_ERROR'                => (count($errors)) ? true : false,
 776                      'ERROR_MSG'                => (count($errors)) ? implode('<br />', $errors) : '')
 777                  );
 778  
 779                  return;
 780              break;
 781  
 782              case 'copy_perm':
 783                  $forum_perm_from = $request->variable('forum_perm_from', 0);
 784  
 785                  // Copy permissions?
 786                  if (!empty($forum_perm_from) && $forum_perm_from != $forum_id)
 787                  {
 788                      copy_forum_permissions($forum_perm_from, $forum_id, true);
 789                      phpbb_cache_moderators($db, $cache, $auth);
 790                      $auth->acl_clear_prefetch();
 791                      $cache->destroy('sql', FORUMS_TABLE);
 792  
 793                      $acl_url = '&amp;mode=setting_forum_local&amp;forum_id[]=' . $forum_id;
 794  
 795                      $message = $user->lang['FORUM_UPDATED'];
 796  
 797                      // Redirect to permissions
 798                      if ($auth->acl_get('a_fauth'))
 799                      {
 800                          $message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>');
 801                      }
 802  
 803                      trigger_error($message . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id));
 804                  }
 805  
 806              break;
 807          }
 808  
 809          // Default management page
 810          if (!$this->parent_id)
 811          {
 812              $navigation = $user->lang['FORUM_INDEX'];
 813          }
 814          else
 815          {
 816              $navigation = '<a href="' . $this->u_action . '">' . $user->lang['FORUM_INDEX'] . '</a>';
 817  
 818              $forums_nav = get_forum_branch($this->parent_id, 'parents', 'descending');
 819              foreach ($forums_nav as $row)
 820              {
 821                  if ($row['forum_id'] == $this->parent_id)
 822                  {
 823                      $navigation .= ' -&gt; ' . $row['forum_name'];
 824                  }
 825                  else
 826                  {
 827                      $navigation .= ' -&gt; <a href="' . $this->u_action . '&amp;parent_id=' . $row['forum_id'] . '">' . $row['forum_name'] . '</a>';
 828                  }
 829              }
 830          }
 831  
 832          // Jumpbox
 833          $forum_box = make_forum_select($this->parent_id, false, false, false, false); //make_forum_select($this->parent_id);
 834  
 835          if ($action == 'sync' || $action == 'sync_forum')
 836          {
 837              $template->assign_var('S_RESYNCED', true);
 838          }
 839  
 840          $sql = 'SELECT *
 841              FROM ' . FORUMS_TABLE . "
 842              WHERE parent_id = $this->parent_id
 843              ORDER BY left_id";
 844          $result = $db->sql_query($sql);
 845  
 846          $rowset = array();
 847          while ($row = $db->sql_fetchrow($result))
 848          {
 849              $rowset[(int) $row['forum_id']] = $row;
 850          }
 851          $db->sql_freeresult($result);
 852  
 853          /**
 854          * Modify the forum list data
 855          *
 856          * @event core.acp_manage_forums_modify_forum_list
 857          * @var    array    rowset    Array with the forums list data
 858          * @since 3.1.10-RC1
 859          */
 860          $vars = array('rowset');
 861          extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_modify_forum_list', compact($vars)));
 862  
 863          if (!empty($rowset))
 864          {
 865              foreach ($rowset as $row)
 866              {
 867                  $forum_type = $row['forum_type'];
 868  
 869                  if ($row['forum_status'] == ITEM_LOCKED)
 870                  {
 871                      $folder_image = '<img src="images/icon_folder_lock.gif" alt="' . $user->lang['LOCKED'] . '" />';
 872                  }
 873                  else
 874                  {
 875                      switch ($forum_type)
 876                      {
 877                          case FORUM_LINK:
 878                              $folder_image = '<img src="images/icon_folder_link.gif" alt="' . $user->lang['LINK'] . '" />';
 879                          break;
 880  
 881                          default:
 882                              $folder_image = ($row['left_id'] + 1 != $row['right_id']) ? '<img src="images/icon_subfolder.gif" alt="' . $user->lang['SUBFORUM'] . '" />' : '<img src="images/icon_folder.gif" alt="' . $user->lang['FOLDER'] . '" />';
 883                          break;
 884                      }
 885                  }
 886  
 887                  $url = $this->u_action . "&amp;parent_id=$this->parent_id&amp;f={$row['forum_id']}";
 888  
 889                  $template->assign_block_vars('forums', array(
 890                      'FOLDER_IMAGE'        => $folder_image,
 891                      'FORUM_IMAGE'        => ($row['forum_image']) ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="" />' : '',
 892                      'FORUM_IMAGE_SRC'    => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '',
 893                      'FORUM_NAME'        => $row['forum_name'],
 894                      'FORUM_DESCRIPTION'    => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']),
 895                      'FORUM_TOPICS'        => $row['forum_topics_approved'],
 896                      'FORUM_POSTS'        => $row['forum_posts_approved'],
 897  
 898                      'S_FORUM_LINK'        => ($forum_type == FORUM_LINK) ? true : false,
 899                      'S_FORUM_POST'        => ($forum_type == FORUM_POST) ? true : false,
 900  
 901                      'U_FORUM'            => $this->u_action . '&amp;parent_id=' . $row['forum_id'],
 902                      'U_MOVE_UP'            => $url . '&amp;action=move_up',
 903                      'U_MOVE_DOWN'        => $url . '&amp;action=move_down',
 904                      'U_EDIT'            => $url . '&amp;action=edit',
 905                      'U_DELETE'            => $url . '&amp;action=delete',
 906                      'U_SYNC'            => $url . '&amp;action=sync')
 907                  );
 908              }
 909          }
 910          else if ($this->parent_id)
 911          {
 912              $row = $this->get_forum_info($this->parent_id);
 913  
 914              $url = $this->u_action . '&amp;parent_id=' . $this->parent_id . '&amp;f=' . $row['forum_id'];
 915  
 916              $template->assign_vars(array(
 917                  'S_NO_FORUMS'        => true,
 918  
 919                  'U_EDIT'            => $url . '&amp;action=edit',
 920                  'U_DELETE'            => $url . '&amp;action=delete',
 921                  'U_SYNC'            => $url . '&amp;action=sync')
 922              );
 923          }
 924          unset($rowset);
 925  
 926          $template->assign_vars(array(
 927              'ERROR_MSG'        => (count($errors)) ? implode('<br />', $errors) : '',
 928              'NAVIGATION'    => $navigation,
 929              'FORUM_BOX'        => $forum_box,
 930              'U_SEL_ACTION'    => $this->u_action,
 931              'U_ACTION'        => $this->u_action . '&amp;parent_id=' . $this->parent_id,
 932  
 933              'U_PROGRESS_BAR'    => $this->u_action . '&amp;action=progress_bar',
 934              'UA_PROGRESS_BAR'    => addslashes($this->u_action . '&amp;action=progress_bar'),
 935          ));
 936      }
 937  
 938      /**
 939      * Get forum details
 940      */
 941  	function get_forum_info($forum_id)
 942      {
 943          global $db;
 944  
 945          $sql = 'SELECT *
 946              FROM ' . FORUMS_TABLE . "
 947              WHERE forum_id = $forum_id";
 948          $result = $db->sql_query($sql);
 949          $row = $db->sql_fetchrow($result);
 950          $db->sql_freeresult($result);
 951  
 952          if (!$row)
 953          {
 954              trigger_error("Forum #$forum_id does not exist", E_USER_ERROR);
 955          }
 956  
 957          return $row;
 958      }
 959  
 960      /**
 961      * Update forum data
 962      */
 963  	function update_forum_data(&$forum_data_ary)
 964      {
 965          global $db, $user, $cache, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log, $request;
 966  
 967          $errors = array();
 968  
 969          $forum_data = $forum_data_ary;
 970          /**
 971          * Validate the forum data before we create/update the forum
 972          *
 973          * @event core.acp_manage_forums_validate_data
 974          * @var    array    forum_data    Array with new forum data
 975          * @var    array    errors        Array of errors, should be strings and not
 976          *                            language key.
 977          * @since 3.1.0-a1
 978          */
 979          $vars = array('forum_data', 'errors');
 980          extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_validate_data', compact($vars)));
 981          $forum_data_ary = $forum_data;
 982          unset($forum_data);
 983  
 984          if ($forum_data_ary['forum_name'] == '')
 985          {
 986              $errors[] = $user->lang['FORUM_NAME_EMPTY'];
 987          }
 988  
 989          /**
 990           * Replace Emojis and other 4bit UTF-8 chars not allowed by MySql to UCR / NCR.
 991           * Using their Numeric Character Reference's Hexadecimal notation.
 992           */
 993          $forum_data_ary['forum_name'] = utf8_encode_ucr($forum_data_ary['forum_name']);
 994  
 995          /**
 996           * This should never happen again.
 997           * Leaving the fallback here just in case there will be the need of it.
 998           */
 999          if (preg_match_all('/[\x{10000}-\x{10FFFF}]/u', $forum_data_ary['forum_name'], $matches))
1000          {
1001              $character_list = implode('<br>', $matches[0]);
1002  
1003              $errors[] = $user->lang('FORUM_NAME_EMOJI', $character_list);
1004          }
1005  
1006          if (utf8_strlen($forum_data_ary['forum_desc']) > 4000)
1007          {
1008              $errors[] = $user->lang['FORUM_DESC_TOO_LONG'];
1009          }
1010  
1011          if (utf8_strlen($forum_data_ary['forum_rules']) > 4000)
1012          {
1013              $errors[] = $user->lang['FORUM_RULES_TOO_LONG'];
1014          }
1015  
1016          if ($forum_data_ary['forum_password'] || $forum_data_ary['forum_password_confirm'])
1017          {
1018              if ($forum_data_ary['forum_password'] != $forum_data_ary['forum_password_confirm'])
1019              {
1020                  $forum_data_ary['forum_password'] = $forum_data_ary['forum_password_confirm'] = '';
1021                  $errors[] = $user->lang['FORUM_PASSWORD_MISMATCH'];
1022              }
1023          }
1024  
1025          if ($forum_data_ary['prune_days'] < 0 || $forum_data_ary['prune_viewed'] < 0 || $forum_data_ary['prune_freq'] < 0)
1026          {
1027              $forum_data_ary['prune_days'] = $forum_data_ary['prune_viewed'] = $forum_data_ary['prune_freq'] = 0;
1028              $errors[] = $user->lang['FORUM_DATA_NEGATIVE'];
1029          }
1030  
1031          $range_test_ary = array(
1032              array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data_ary['forum_topics_per_page'], 'column_type' => 'USINT:0'),
1033          );
1034  
1035          if (!empty($forum_data_ary['forum_image']) && !file_exists($phpbb_root_path . $forum_data_ary['forum_image']))
1036          {
1037              $errors[] = $user->lang['FORUM_IMAGE_NO_EXIST'];
1038          }
1039  
1040          validate_range($range_test_ary, $errors);
1041  
1042          // Set forum flags
1043          // 1 = link tracking
1044          // 2 = prune old polls
1045          // 4 = prune announcements
1046          // 8 = prune stickies
1047          // 16 = show active topics
1048          // 32 = enable post review
1049          $forum_data_ary['forum_flags'] = 0;
1050          $forum_data_ary['forum_flags'] += ($forum_data_ary['forum_link_track']) ? FORUM_FLAG_LINK_TRACK : 0;
1051          $forum_data_ary['forum_flags'] += ($forum_data_ary['prune_old_polls']) ? FORUM_FLAG_PRUNE_POLL : 0;
1052          $forum_data_ary['forum_flags'] += ($forum_data_ary['prune_announce']) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0;
1053          $forum_data_ary['forum_flags'] += ($forum_data_ary['prune_sticky']) ? FORUM_FLAG_PRUNE_STICKY : 0;
1054          $forum_data_ary['forum_flags'] += ($forum_data_ary['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0;
1055          $forum_data_ary['forum_flags'] += ($forum_data_ary['enable_post_review']) ? FORUM_FLAG_POST_REVIEW : 0;
1056          $forum_data_ary['forum_flags'] += ($forum_data_ary['enable_quick_reply']) ? FORUM_FLAG_QUICK_REPLY : 0;
1057  
1058          // Unset data that are not database fields
1059          $forum_data_sql = $forum_data_ary;
1060  
1061          unset($forum_data_sql['forum_link_track']);
1062          unset($forum_data_sql['prune_old_polls']);
1063          unset($forum_data_sql['prune_announce']);
1064          unset($forum_data_sql['prune_sticky']);
1065          unset($forum_data_sql['show_active']);
1066          unset($forum_data_sql['enable_post_review']);
1067          unset($forum_data_sql['enable_quick_reply']);
1068          unset($forum_data_sql['forum_password_confirm']);
1069  
1070          // What are we going to do tonight Brain? The same thing we do everynight,
1071          // try to take over the world ... or decide whether to continue update
1072          // and if so, whether it's a new forum/cat/link or an existing one
1073          if (count($errors))
1074          {
1075              return $errors;
1076          }
1077  
1078          // As we don't know the old password, it's kinda tricky to detect changes
1079          if ($forum_data_sql['forum_password_unset'])
1080          {
1081              $forum_data_sql['forum_password'] = '';
1082          }
1083          else if (empty($forum_data_sql['forum_password']))
1084          {
1085              unset($forum_data_sql['forum_password']);
1086          }
1087          else
1088          {
1089              // Instantiate passwords manager
1090              /* @var $passwords_manager \phpbb\passwords\manager */
1091              $passwords_manager = $phpbb_container->get('passwords.manager');
1092  
1093              $forum_data_sql['forum_password'] = $passwords_manager->hash($forum_data_sql['forum_password']);
1094          }
1095          unset($forum_data_sql['forum_password_unset']);
1096  
1097          $forum_data = $forum_data_ary;
1098          /**
1099          * Remove invalid values from forum_data_sql that should not be updated
1100          *
1101          * @event core.acp_manage_forums_update_data_before
1102          * @var    array    forum_data        Array with forum data
1103          * @var    array    forum_data_sql    Array with data we are going to update
1104          *                        If forum_data_sql[forum_id] is set, we update
1105          *                        that forum, otherwise a new one is created.
1106          * @since 3.1.0-a1
1107          */
1108          $vars = array('forum_data', 'forum_data_sql');
1109          extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_before', compact($vars)));
1110          $forum_data_ary = $forum_data;
1111          unset($forum_data);
1112  
1113          $is_new_forum = !isset($forum_data_sql['forum_id']);
1114  
1115          if ($is_new_forum)
1116          {
1117              // no forum_id means we're creating a new forum
1118              unset($forum_data_sql['type_action']);
1119  
1120              if ($forum_data_sql['parent_id'])
1121              {
1122                  $sql = 'SELECT left_id, right_id, forum_type
1123                      FROM ' . FORUMS_TABLE . '
1124                      WHERE forum_id = ' . $forum_data_sql['parent_id'];
1125                  $result = $db->sql_query($sql);
1126                  $row = $db->sql_fetchrow($result);
1127                  $db->sql_freeresult($result);
1128  
1129                  if (!$row)
1130                  {
1131                      trigger_error($user->lang['PARENT_NOT_EXIST'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);
1132                  }
1133  
1134                  if ($row['forum_type'] == FORUM_LINK)
1135                  {
1136                      $errors[] = $user->lang['PARENT_IS_LINK_FORUM'];
1137                      return $errors;
1138                  }
1139  
1140                  $sql = 'UPDATE ' . FORUMS_TABLE . '
1141                      SET left_id = left_id + 2, right_id = right_id + 2
1142                      WHERE left_id > ' . $row['right_id'];
1143                  $db->sql_query($sql);
1144  
1145                  $sql = 'UPDATE ' . FORUMS_TABLE . '
1146                      SET right_id = right_id + 2
1147                      WHERE ' . $row['left_id'] . ' BETWEEN left_id AND right_id';
1148                  $db->sql_query($sql);
1149  
1150                  $forum_data_sql['left_id'] = $row['right_id'];
1151                  $forum_data_sql['right_id'] = $row['right_id'] + 1;
1152              }
1153              else
1154              {
1155                  $sql = 'SELECT MAX(right_id) AS right_id
1156                      FROM ' . FORUMS_TABLE;
1157                  $result = $db->sql_query($sql);
1158                  $row = $db->sql_fetchrow($result);
1159                  $db->sql_freeresult($result);
1160  
1161                  $forum_data_sql['left_id'] = $row['right_id'] + 1;
1162                  $forum_data_sql['right_id'] = $row['right_id'] + 2;
1163              }
1164  
1165              $sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $forum_data_sql);
1166              $db->sql_query($sql);
1167  
1168              $forum_data_ary['forum_id'] = $db->sql_nextid();
1169  
1170              $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_ADD', false, array($forum_data_ary['forum_name']));
1171          }
1172          else
1173          {
1174              $row = $this->get_forum_info($forum_data_sql['forum_id']);
1175  
1176              if ($row['forum_type'] == FORUM_POST && $row['forum_type'] != $forum_data_sql['forum_type'])
1177              {
1178                  // Has subforums and want to change into a link?
1179                  if ($row['right_id'] - $row['left_id'] > 1 && $forum_data_sql['forum_type'] == FORUM_LINK)
1180                  {
1181                      $errors[] = $user->lang['FORUM_WITH_SUBFORUMS_NOT_TO_LINK'];
1182                      return $errors;
1183                  }
1184  
1185                  // we're turning a postable forum into a non-postable forum
1186                  if ($forum_data_sql['type_action'] == 'move')
1187                  {
1188                      $to_forum_id = $request->variable('to_forum_id', 0);
1189  
1190                      if ($to_forum_id)
1191                      {
1192                          $errors = $this->move_forum_content($forum_data_sql['forum_id'], $to_forum_id);
1193                      }
1194                      else
1195                      {
1196                          return array($user->lang['NO_DESTINATION_FORUM']);
1197                      }
1198                  }
1199                  else if ($forum_data_sql['type_action'] == 'delete')
1200                  {
1201                      $errors = $this->delete_forum_content($forum_data_sql['forum_id']);
1202                  }
1203                  else
1204                  {
1205                      return array($user->lang['NO_FORUM_ACTION']);
1206                  }
1207  
1208                  $forum_data_sql['forum_posts_approved'] = $forum_data_sql['forum_posts_unapproved'] = $forum_data_sql['forum_posts_softdeleted'] = $forum_data_sql['forum_topics_approved'] = $forum_data_sql['forum_topics_unapproved'] = $forum_data_sql['forum_topics_softdeleted'] = 0;
1209                  $forum_data_sql['forum_last_post_id'] = $forum_data_sql['forum_last_poster_id'] = $forum_data_sql['forum_last_post_time'] = 0;
1210                  $forum_data_sql['forum_last_poster_name'] = $forum_data_sql['forum_last_poster_colour'] = '';
1211              }
1212              else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_LINK)
1213              {
1214                  // Has subforums?
1215                  if ($row['right_id'] - $row['left_id'] > 1)
1216                  {
1217                      // We are turning a category into a link - but need to decide what to do with the subforums.
1218                      $action_subforums = $request->variable('action_subforums', '');
1219                      $subforums_to_id = $request->variable('subforums_to_id', 0);
1220  
1221                      if ($action_subforums == 'delete')
1222                      {
1223                          $rows = get_forum_branch($row['forum_id'], 'children', 'descending', false);
1224  
1225                          foreach ($rows as $_row)
1226                          {
1227                              // Do not remove the forum id we are about to change. ;)
1228                              if ($_row['forum_id'] == $row['forum_id'])
1229                              {
1230                                  continue;
1231                              }
1232  
1233                              $forum_ids[] = $_row['forum_id'];
1234                              $errors = array_merge($errors, $this->delete_forum_content($_row['forum_id']));
1235                          }
1236  
1237                          if (count($errors))
1238                          {
1239                              return $errors;
1240                          }
1241  
1242                          if (count($forum_ids))
1243                          {
1244                              $sql = 'DELETE FROM ' . FORUMS_TABLE . '
1245                                  WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
1246                              $db->sql_query($sql);
1247  
1248                              $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
1249                                  WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
1250                              $db->sql_query($sql);
1251  
1252                              $sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
1253                                  WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
1254                              $db->sql_query($sql);
1255  
1256                              // Delete forum ids from extension groups table
1257                              $sql = 'SELECT group_id, allowed_forums
1258                                  FROM ' . EXTENSION_GROUPS_TABLE;
1259                              $result = $db->sql_query($sql);
1260  
1261                              while ($_row = $db->sql_fetchrow($result))
1262                              {
1263                                  if (!$_row['allowed_forums'])
1264                                  {
1265                                      continue;
1266                                  }
1267  
1268                                  $allowed_forums = unserialize(trim($_row['allowed_forums']));
1269                                  $allowed_forums = array_diff($allowed_forums, $forum_ids);
1270  
1271                                  $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . "
1272                                      SET allowed_forums = '" . ((count($allowed_forums)) ? serialize($allowed_forums) : '') . "'
1273                                      WHERE group_id = {$_row['group_id']}";
1274                                  $db->sql_query($sql);
1275                              }
1276                              $db->sql_freeresult($result);
1277  
1278                              $cache->destroy('_extensions');
1279                          }
1280                      }
1281                      else if ($action_subforums == 'move')
1282                      {
1283                          if (!$subforums_to_id)
1284                          {
1285                              return array($user->lang['NO_DESTINATION_FORUM']);
1286                          }
1287  
1288                          $sql = 'SELECT forum_name
1289                              FROM ' . FORUMS_TABLE . '
1290                              WHERE forum_id = ' . $subforums_to_id;
1291                          $result = $db->sql_query($sql);
1292                          $_row = $db->sql_fetchrow($result);
1293                          $db->sql_freeresult($result);
1294  
1295                          if (!$_row)
1296                          {
1297                              return array($user->lang['NO_FORUM']);
1298                          }
1299  
1300                          $sql = 'SELECT forum_id
1301                              FROM ' . FORUMS_TABLE . "
1302                              WHERE parent_id = {$row['forum_id']}";
1303                          $result = $db->sql_query($sql);
1304  
1305                          while ($_row = $db->sql_fetchrow($result))
1306                          {
1307                              $this->move_forum($_row['forum_id'], $subforums_to_id);
1308                          }
1309                          $db->sql_freeresult($result);
1310  
1311                          $sql = 'UPDATE ' . FORUMS_TABLE . "
1312                              SET parent_id = $subforums_to_id
1313                              WHERE parent_id = {$row['forum_id']}";
1314                          $db->sql_query($sql);
1315                      }
1316  
1317                      // Adjust the left/right id
1318                      $sql = 'UPDATE ' . FORUMS_TABLE . '
1319                          SET right_id = left_id + 1
1320                          WHERE forum_id = ' . $row['forum_id'];
1321                      $db->sql_query($sql);
1322                  }
1323              }
1324              else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_POST)
1325              {
1326                  // Changing a category to a forum? Reset the data (you can't post directly in a cat, you must use a forum)
1327                  $forum_data_sql['forum_posts_approved'] = 0;
1328                  $forum_data_sql['forum_posts_unapproved'] = 0;
1329                  $forum_data_sql['forum_posts_softdeleted'] = 0;
1330                  $forum_data_sql['forum_topics_approved'] = 0;
1331                  $forum_data_sql['forum_topics_unapproved'] = 0;
1332                  $forum_data_sql['forum_topics_softdeleted'] = 0;
1333                  $forum_data_sql['forum_last_post_id'] = 0;
1334                  $forum_data_sql['forum_last_post_subject'] = '';
1335                  $forum_data_sql['forum_last_post_time'] = 0;
1336                  $forum_data_sql['forum_last_poster_id'] = 0;
1337                  $forum_data_sql['forum_last_poster_name'] = '';
1338                  $forum_data_sql['forum_last_poster_colour'] = '';
1339              }
1340  
1341              if (count($errors))
1342              {
1343                  return $errors;
1344              }
1345  
1346              if ($row['parent_id'] != $forum_data_sql['parent_id'])
1347              {
1348                  if ($row['forum_id'] != $forum_data_sql['parent_id'])
1349                  {
1350                      $errors = $this->move_forum($forum_data_sql['forum_id'], $forum_data_sql['parent_id']);
1351                  }
1352                  else
1353                  {
1354                      $forum_data_sql['parent_id'] = $row['parent_id'];
1355                  }
1356              }
1357  
1358              if (count($errors))
1359              {
1360                  return $errors;
1361              }
1362  
1363              unset($forum_data_sql['type_action']);
1364  
1365              if ($row['forum_name'] != $forum_data_sql['forum_name'])
1366              {
1367                  // the forum name has changed, clear the parents list of all forums (for safety)
1368                  $sql = 'UPDATE ' . FORUMS_TABLE . "
1369                      SET forum_parents = ''";
1370                  $db->sql_query($sql);
1371              }
1372  
1373              // Setting the forum id to the forum id is not really received well by some dbs. ;)
1374              $forum_id = $forum_data_sql['forum_id'];
1375              unset($forum_data_sql['forum_id']);
1376  
1377              $sql = 'UPDATE ' . FORUMS_TABLE . '
1378                  SET ' . $db->sql_build_array('UPDATE', $forum_data_sql) . '
1379                  WHERE forum_id = ' . $forum_id;
1380              $db->sql_query($sql);
1381  
1382              // Add it back
1383              $forum_data_ary['forum_id'] = $forum_id;
1384  
1385              $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_EDIT', false, array($forum_data_ary['forum_name']));
1386          }
1387  
1388          $forum_data = $forum_data_ary;
1389          /**
1390          * Event after a forum was updated or created
1391          *
1392          * @event core.acp_manage_forums_update_data_after
1393          * @var    array    forum_data        Array with forum data
1394          * @var    array    forum_data_sql    Array with data we updated
1395          * @var    bool    is_new_forum    Did we create a forum or update one
1396          *                                If you want to overwrite this value,
1397          *                                ensure to set forum_data_sql[forum_id]
1398          * @var    array    errors        Array of errors, should be strings and not
1399          *                            language key.
1400          * @since 3.1.0-a1
1401          */
1402          $vars = array('forum_data', 'forum_data_sql', 'is_new_forum', 'errors');
1403          extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_after', compact($vars)));
1404          $forum_data_ary = $forum_data;
1405          unset($forum_data);
1406  
1407          return $errors;
1408      }
1409  
1410      /**
1411      * Move forum
1412      */
1413  	function move_forum($from_id, $to_id)
1414      {
1415          global $db, $user, $phpbb_dispatcher;
1416  
1417          $errors = array();
1418  
1419          // Check if we want to move to a parent with link type
1420          if ($to_id > 0)
1421          {
1422              $to_data = $this->get_forum_info($to_id);
1423  
1424              if ($to_data['forum_type'] == FORUM_LINK)
1425              {
1426                  $errors[] = $user->lang['PARENT_IS_LINK_FORUM'];
1427              }
1428          }
1429  
1430          /**
1431          * Event when we move all children of one forum to another
1432          *
1433          * This event may be triggered, when a forum is deleted
1434          *
1435          * @event core.acp_manage_forums_move_children
1436          * @var    int        from_id        Id of the current parent forum
1437          * @var    int        to_id        Id of the new parent forum
1438          * @var    array    errors        Array of errors, should be strings and not
1439          *                            language key.
1440          * @since 3.1.0-a1
1441          */
1442          $vars = array('from_id', 'to_id', 'errors');
1443          extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_children', compact($vars)));
1444  
1445          // Return if there were errors
1446          if (!empty($errors))
1447          {
1448              return $errors;
1449          }
1450  
1451          $db->sql_transaction('begin');
1452  
1453          $moved_forums = get_forum_branch($from_id, 'children', 'descending');
1454          $from_data = $moved_forums[0];
1455          $diff = count($moved_forums) * 2;
1456  
1457          $moved_ids = array();
1458          for ($i = 0, $size = count($moved_forums); $i < $size; ++$i)
1459          {
1460              $moved_ids[] = $moved_forums[$i]['forum_id'];
1461          }
1462  
1463          // Resync parents
1464          $sql = 'UPDATE ' . FORUMS_TABLE . "
1465              SET right_id = right_id - $diff, forum_parents = ''
1466              WHERE left_id < " . $from_data['right_id'] . "
1467                  AND right_id > " . $from_data['right_id'];
1468          $db->sql_query($sql);
1469  
1470          // Resync righthand side of tree
1471          $sql = 'UPDATE ' . FORUMS_TABLE . "
1472              SET left_id = left_id - $diff, right_id = right_id - $diff, forum_parents = ''
1473              WHERE left_id > " . $from_data['right_id'];
1474          $db->sql_query($sql);
1475  
1476          if ($to_id > 0)
1477          {
1478              // Retrieve $to_data again, it may have been changed...
1479              $to_data = $this->get_forum_info($to_id);
1480  
1481              // Resync new parents
1482              $sql = 'UPDATE ' . FORUMS_TABLE . "
1483                  SET right_id = right_id + $diff, forum_parents = ''
1484                  WHERE " . $to_data['right_id'] . ' BETWEEN left_id AND right_id
1485                      AND ' . $db->sql_in_set('forum_id', $moved_ids, true);
1486              $db->sql_query($sql);
1487  
1488              // Resync the righthand side of the tree
1489              $sql = 'UPDATE ' . FORUMS_TABLE . "
1490                  SET left_id = left_id + $diff, right_id = right_id + $diff, forum_parents = ''
1491                  WHERE left_id > " . $to_data['right_id'] . '
1492                      AND ' . $db->sql_in_set('forum_id', $moved_ids, true);
1493              $db->sql_query($sql);
1494  
1495              // Resync moved branch
1496              $to_data['right_id'] += $diff;
1497  
1498              if ($to_data['right_id'] > $from_data['right_id'])
1499              {
1500                  $diff = '+ ' . ($to_data['right_id'] - $from_data['right_id'] - 1);
1501              }
1502              else
1503              {
1504                  $diff = '- ' . abs($to_data['right_id'] - $from_data['right_id'] - 1);
1505              }
1506          }
1507          else
1508          {
1509              $sql = 'SELECT MAX(right_id) AS right_id
1510                  FROM ' . FORUMS_TABLE . '
1511                  WHERE ' . $db->sql_in_set('forum_id', $moved_ids, true);
1512              $result = $db->sql_query($sql);
1513              $row = $db->sql_fetchrow($result);
1514              $db->sql_freeresult($result);
1515  
1516              $diff = '+ ' . ($row['right_id'] - $from_data['left_id'] + 1);
1517          }
1518  
1519          $sql = 'UPDATE ' . FORUMS_TABLE . "
1520              SET left_id = left_id $diff, right_id = right_id $diff, forum_parents = ''
1521              WHERE " . $db->sql_in_set('forum_id', $moved_ids);
1522          $db->sql_query($sql);
1523  
1524          $db->sql_transaction('commit');
1525  
1526          return $errors;
1527      }
1528  
1529      /**
1530      * Move forum content from one to another forum
1531      */
1532  	function move_forum_content($from_id, $to_id, $sync = true)
1533      {
1534          global $db, $phpbb_dispatcher;
1535  
1536          $errors = array();
1537  
1538          /**
1539          * Event when we move content from one forum to another
1540          *
1541          * @event core.acp_manage_forums_move_content
1542          * @var    int        from_id        Id of the current parent forum
1543          * @var    int        to_id        Id of the new parent forum
1544          * @var    bool    sync        Shall we sync the "to"-forum's data
1545          * @var    array    errors        Array of errors, should be strings and not
1546          *                            language key. If this array is not empty,
1547          *                            The content will not be moved.
1548          * @since 3.1.0-a1
1549          */
1550          $vars = array('from_id', 'to_id', 'sync', 'errors');
1551          extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_content', compact($vars)));
1552  
1553          // Return if there were errors
1554          if (!empty($errors))
1555          {
1556              return $errors;
1557          }
1558  
1559          $table_ary = array(LOG_TABLE, POSTS_TABLE, TOPICS_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
1560  
1561          /**
1562           * Perform additional actions before move forum content
1563           *
1564           * @event core.acp_manage_forums_move_content_sql_before
1565           * @var    array    table_ary    Array of tables from which forum_id will be updated
1566           * @since 3.2.4-RC1
1567           */
1568          $vars = array('table_ary');
1569          extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_content_sql_before', compact($vars)));
1570  
1571          foreach ($table_ary as $table)
1572          {
1573              $sql = "UPDATE $table
1574                  SET forum_id = $to_id
1575                  WHERE forum_id = $from_id";
1576              $db->sql_query($sql);
1577          }
1578          unset($table_ary);
1579  
1580          $table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, MODERATOR_CACHE_TABLE);
1581  
1582          foreach ($table_ary as $table)
1583          {
1584              $sql = "DELETE FROM $table
1585                  WHERE forum_id = $from_id";
1586              $db->sql_query($sql);
1587          }
1588  
1589          /**
1590           * Event when content has been moved from one forum to another
1591           *
1592           * @event core.acp_manage_forums_move_content_after
1593           * @var    int        from_id        Id of the current parent forum
1594           * @var    int        to_id        Id of the new parent forum
1595           * @var    bool    sync        Shall we sync the "to"-forum's data
1596           *
1597           * @since 3.2.9-RC1
1598           */
1599          $vars = array('from_id', 'to_id', 'sync');
1600          extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_content_after', compact($vars)));
1601  
1602          if ($sync)
1603          {
1604              // Delete ghost topics that link back to the same forum then resync counters
1605              sync('topic_moved');
1606              sync('forum', 'forum_id', $to_id, false, true);
1607          }
1608  
1609          return array();
1610      }
1611  
1612      /**
1613      * Remove complete forum
1614      */
1615  	function delete_forum($forum_id, $action_posts = 'delete', $action_subforums = 'delete', $posts_to_id = 0, $subforums_to_id = 0)
1616      {
1617          global $db, $user, $cache, $phpbb_log;
1618  
1619          $forum_data = $this->get_forum_info($forum_id);
1620  
1621          $errors = array();
1622          $log_action_posts = $log_action_forums = $posts_to_name = $subforums_to_name = '';
1623          $forum_ids = array($forum_id);
1624  
1625          if ($action_posts == 'delete')
1626          {
1627              $log_action_posts = 'POSTS';
1628              $errors = array_merge($errors, $this->delete_forum_content($forum_id));
1629          }
1630          else if ($action_posts == 'move')
1631          {
1632              if (!$posts_to_id)
1633              {
1634                  $errors[] = $user->lang['NO_DESTINATION_FORUM'];
1635              }
1636              else
1637              {
1638                  $log_action_posts = 'MOVE_POSTS';
1639  
1640                  $sql = 'SELECT forum_name
1641                      FROM ' . FORUMS_TABLE . '
1642                      WHERE forum_id = ' . $posts_to_id;
1643                  $result = $db->sql_query($sql);
1644                  $row = $db->sql_fetchrow($result);
1645                  $db->sql_freeresult($result);
1646  
1647                  if (!$row)
1648                  {
1649                      $errors[] = $user->lang['NO_FORUM'];
1650                  }
1651                  else
1652                  {
1653                      $posts_to_name = $row['forum_name'];
1654                      $errors = array_merge($errors, $this->move_forum_content($forum_id, $posts_to_id));
1655                  }
1656              }
1657          }
1658  
1659          if (count($errors))
1660          {
1661              return $errors;
1662          }
1663  
1664          if ($action_subforums == 'delete')
1665          {
1666              $log_action_forums = 'FORUMS';
1667              $rows = get_forum_branch($forum_id, 'children', 'descending', false);
1668  
1669              foreach ($rows as $row)
1670              {
1671                  $forum_ids[] = $row['forum_id'];
1672                  $errors = array_merge($errors, $this->delete_forum_content($row['forum_id']));
1673              }
1674  
1675              if (count($errors))
1676              {
1677                  return $errors;
1678              }
1679  
1680              $diff = count($forum_ids) * 2;
1681  
1682              $sql = 'DELETE FROM ' . FORUMS_TABLE . '
1683                  WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
1684              $db->sql_query($sql);
1685  
1686              $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
1687                  WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
1688              $db->sql_query($sql);
1689  
1690              $sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
1691                  WHERE ' . $db->sql_in_set('forum_id', $forum_ids);
1692              $db->sql_query($sql);
1693          }
1694          else if ($action_subforums == 'move')
1695          {
1696              if (!$subforums_to_id)
1697              {
1698                  $errors[] = $user->lang['NO_DESTINATION_FORUM'];
1699              }
1700              else
1701              {
1702                  $log_action_forums = 'MOVE_FORUMS';
1703  
1704                  $sql = 'SELECT forum_name
1705                      FROM ' . FORUMS_TABLE . '
1706                      WHERE forum_id = ' . $subforums_to_id;
1707                  $result = $db->sql_query($sql);
1708                  $row = $db->sql_fetchrow($result);
1709                  $db->sql_freeresult($result);
1710  
1711                  if (!$row)
1712                  {
1713                      $errors[] = $user->lang['NO_FORUM'];
1714                  }
1715                  else
1716                  {
1717                      $subforums_to_name = $row['forum_name'];
1718  
1719                      $sql = 'SELECT forum_id
1720                          FROM ' . FORUMS_TABLE . "
1721                          WHERE parent_id = $forum_id";
1722                      $result = $db->sql_query($sql);
1723  
1724                      while ($row = $db->sql_fetchrow($result))
1725                      {
1726                          $this->move_forum($row['forum_id'], $subforums_to_id);
1727                      }
1728                      $db->sql_freeresult($result);
1729  
1730                      // Grab new forum data for correct tree updating later
1731                      $forum_data = $this->get_forum_info($forum_id);
1732  
1733                      $sql = 'UPDATE ' . FORUMS_TABLE . "
1734                          SET parent_id = $subforums_to_id
1735                          WHERE parent_id = $forum_id";
1736                      $db->sql_query($sql);
1737  
1738                      $diff = 2;
1739                      $sql = 'DELETE FROM ' . FORUMS_TABLE . "
1740                          WHERE forum_id = $forum_id";
1741                      $db->sql_query($sql);
1742  
1743                      $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . "
1744                          WHERE forum_id = $forum_id";
1745                      $db->sql_query($sql);
1746  
1747                      $sql = 'DELETE FROM ' . ACL_USERS_TABLE . "
1748                          WHERE forum_id = $forum_id";
1749                      $db->sql_query($sql);
1750                  }
1751              }
1752  
1753              if (count($errors))
1754              {
1755                  return $errors;
1756              }
1757          }
1758          else
1759          {
1760              $diff = 2;
1761              $sql = 'DELETE FROM ' . FORUMS_TABLE . "
1762                  WHERE forum_id = $forum_id";
1763              $db->sql_query($sql);
1764  
1765              $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . "
1766                  WHERE forum_id = $forum_id";
1767              $db->sql_query($sql);
1768  
1769              $sql = 'DELETE FROM ' . ACL_USERS_TABLE . "
1770                  WHERE forum_id = $forum_id";
1771              $db->sql_query($sql);
1772          }
1773  
1774          // Resync tree
1775          $sql = 'UPDATE ' . FORUMS_TABLE . "
1776              SET right_id = right_id - $diff
1777              WHERE left_id < {$forum_data['right_id']} AND right_id > {$forum_data['right_id']}";
1778          $db->sql_query($sql);
1779  
1780          $sql = 'UPDATE ' . FORUMS_TABLE . "
1781              SET left_id = left_id - $diff, right_id = right_id - $diff
1782              WHERE left_id > {$forum_data['right_id']}";
1783          $db->sql_query($sql);
1784  
1785          // Delete forum ids from extension groups table
1786          $sql = 'SELECT group_id, allowed_forums
1787              FROM ' . EXTENSION_GROUPS_TABLE;
1788          $result = $db->sql_query($sql);
1789  
1790          while ($row = $db->sql_fetchrow($result))
1791          {
1792              if (!$row['allowed_forums'])
1793              {
1794                  continue;
1795              }
1796  
1797              $allowed_forums = unserialize(trim($row['allowed_forums']));
1798              $allowed_forums = array_diff($allowed_forums, $forum_ids);
1799  
1800              $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . "
1801                  SET allowed_forums = '" . ((count($allowed_forums)) ? serialize($allowed_forums) : '') . "'
1802                  WHERE group_id = {$row['group_id']}";
1803              $db->sql_query($sql);
1804          }
1805          $db->sql_freeresult($result);
1806  
1807          $cache->destroy('_extensions');
1808  
1809          $log_action = implode('_', array($log_action_posts, $log_action_forums));
1810  
1811          switch ($log_action)
1812          {
1813              case 'MOVE_POSTS_MOVE_FORUMS':
1814                  $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_MOVE_POSTS_MOVE_FORUMS', false, array($posts_to_name, $subforums_to_name, $forum_data['forum_name']));
1815              break;
1816  
1817              case 'MOVE_POSTS_FORUMS':
1818                  $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_MOVE_POSTS_FORUMS', false, array($posts_to_name, $forum_data['forum_name']));
1819              break;
1820  
1821              case 'POSTS_MOVE_FORUMS':
1822                  $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_POSTS_MOVE_FORUMS', false, array($subforums_to_name, $forum_data['forum_name']));
1823              break;
1824  
1825              case '_MOVE_FORUMS':
1826                  $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_MOVE_FORUMS', false, array($subforums_to_name, $forum_data['forum_name']));
1827              break;
1828  
1829              case 'MOVE_POSTS_':
1830                  $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_MOVE_POSTS', false, array($posts_to_name, $forum_data['forum_name']));
1831              break;
1832  
1833              case 'POSTS_FORUMS':
1834                  $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_POSTS_FORUMS', false, array($forum_data['forum_name']));
1835              break;
1836  
1837              case '_FORUMS':
1838                  $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_FORUMS', false, array($forum_data['forum_name']));
1839              break;
1840  
1841              case 'POSTS_':
1842                  $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_POSTS', false, array($forum_data['forum_name']));
1843              break;
1844  
1845              default:
1846                  $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_FORUM', false, array($forum_data['forum_name']));
1847              break;
1848          }
1849  
1850          return $errors;
1851      }
1852  
1853      /**
1854      * Delete forum content
1855      */
1856  	function delete_forum_content($forum_id)
1857      {
1858          global $db, $config, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_dispatcher;
1859  
1860          include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
1861  
1862          $db->sql_transaction('begin');
1863  
1864          // Select then delete all attachments
1865          $sql = 'SELECT a.topic_id
1866              FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a
1867              WHERE p.forum_id = $forum_id
1868                  AND a.in_message = 0
1869                  AND a.topic_id = p.topic_id";
1870          $result = $db->sql_query($sql);
1871  
1872          $topic_ids = array();
1873          while ($row = $db->sql_fetchrow($result))
1874          {
1875              $topic_ids[] = $row['topic_id'];
1876          }
1877          $db->sql_freeresult($result);
1878  
1879          /** @var \phpbb\attachment\manager $attachment_manager */
1880          $attachment_manager = $phpbb_container->get('attachment.manager');
1881          $attachment_manager->delete('topic', $topic_ids, false);
1882          unset($attachment_manager);
1883  
1884          // Delete shadow topics pointing to topics in this forum
1885          delete_topic_shadows($forum_id);
1886  
1887          // Before we remove anything we make sure we are able to adjust the post counts later. ;)
1888          $sql = 'SELECT poster_id
1889              FROM ' . POSTS_TABLE . '
1890              WHERE forum_id = ' . $forum_id . '
1891                  AND post_postcount = 1
1892                  AND post_visibility = ' . ITEM_APPROVED;
1893          $result = $db->sql_query($sql);
1894  
1895          $post_counts = array();
1896          while ($row = $db->sql_fetchrow($result))
1897          {
1898              $post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1;
1899          }
1900          $db->sql_freeresult($result);
1901  
1902          switch ($db->get_sql_layer())
1903          {
1904              case 'mysql4':
1905              case 'mysqli':
1906  
1907                  // Delete everything else and thank MySQL for offering multi-table deletion
1908                  $tables_ary = array(
1909                      SEARCH_WORDMATCH_TABLE    => 'post_id',
1910                      REPORTS_TABLE            => 'post_id',
1911                      WARNINGS_TABLE            => 'post_id',
1912                      BOOKMARKS_TABLE            => 'topic_id',
1913                      TOPICS_WATCH_TABLE        => 'topic_id',
1914                      TOPICS_POSTED_TABLE        => 'topic_id',
1915                      POLL_OPTIONS_TABLE        => 'topic_id',
1916                      POLL_VOTES_TABLE        => 'topic_id',
1917                  );
1918  
1919                  $sql = 'DELETE ' . POSTS_TABLE;
1920                  $sql_using = "\nFROM " . POSTS_TABLE;
1921                  $sql_where = "\nWHERE " . POSTS_TABLE . ".forum_id = $forum_id\n";
1922  
1923                  foreach ($tables_ary as $table => $field)
1924                  {
1925                      $sql .= ", $table ";
1926                      $sql_using .= ", $table ";
1927                      $sql_where .= "\nAND $table.$field = " . POSTS_TABLE . ".$field";
1928                  }
1929  
1930                  $db->sql_query($sql . $sql_using . $sql_where);
1931  
1932              break;
1933  
1934              default:
1935  
1936                  // Delete everything else and curse your DB for not offering multi-table deletion
1937                  $tables_ary = array(
1938                      'post_id'    =>    array(
1939                          SEARCH_WORDMATCH_TABLE,
1940                          REPORTS_TABLE,
1941                          WARNINGS_TABLE,
1942                      ),
1943  
1944                      'topic_id'    =>    array(
1945                          BOOKMARKS_TABLE,
1946                          TOPICS_WATCH_TABLE,
1947                          TOPICS_POSTED_TABLE,
1948                          POLL_OPTIONS_TABLE,
1949                          POLL_VOTES_TABLE,
1950                      )
1951                  );
1952  
1953                  // Amount of rows we select and delete in one iteration.
1954                  $batch_size = 500;
1955  
1956                  foreach ($tables_ary as $field => $tables)
1957                  {
1958                      $start = 0;
1959  
1960                      do
1961                      {
1962                          $sql = "SELECT $field
1963                              FROM " . POSTS_TABLE . '
1964                              WHERE forum_id = ' . $forum_id;
1965                          $result = $db->sql_query_limit($sql, $batch_size, $start);
1966  
1967                          $ids = array();
1968                          while ($row = $db->sql_fetchrow($result))
1969                          {
1970                              $ids[] = $row[$field];
1971                          }
1972                          $db->sql_freeresult($result);
1973  
1974                          if (count($ids))
1975                          {
1976                              $start += count($ids);
1977  
1978                              foreach ($tables as $table)
1979                              {
1980                                  $db->sql_query("DELETE FROM $table WHERE " . $db->sql_in_set($field, $ids));
1981                              }
1982                          }
1983                      }
1984                      while (count($ids) == $batch_size);
1985                  }
1986                  unset($ids);
1987  
1988              break;
1989          }
1990  
1991          $table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, LOG_TABLE, MODERATOR_CACHE_TABLE, POSTS_TABLE, TOPICS_TABLE, TOPICS_TRACK_TABLE);
1992  
1993          /**
1994           * Perform additional actions before forum content deletion
1995           *
1996           * @event core.delete_forum_content_before_query
1997           * @var    array    table_ary    Array of tables from which all rows will be deleted that hold the forum_id
1998           * @var    int        forum_id    the forum id
1999           * @var    array    topic_ids    Array of the topic ids from the forum to be deleted
2000           * @var    array    post_counts    Array of counts of posts in the forum, by poster_id
2001           * @since 3.1.6-RC1
2002           */
2003          $vars = array(
2004                  'table_ary',
2005                  'forum_id',
2006                  'topic_ids',
2007                  'post_counts',
2008          );
2009          extract($phpbb_dispatcher->trigger_event('core.delete_forum_content_before_query', compact($vars)));
2010  
2011          foreach ($table_ary as $table)
2012          {
2013              $db->sql_query("DELETE FROM $table WHERE forum_id = $forum_id");
2014          }
2015  
2016          // Set forum ids to 0
2017          $table_ary = array(DRAFTS_TABLE);
2018  
2019          foreach ($table_ary as $table)
2020          {
2021              $db->sql_query("UPDATE $table SET forum_id = 0 WHERE forum_id = $forum_id");
2022          }
2023  
2024          // Adjust users post counts
2025          if (count($post_counts))
2026          {
2027              foreach ($post_counts as $poster_id => $substract)
2028              {
2029                  $sql = 'UPDATE ' . USERS_TABLE . '
2030                      SET user_posts = 0
2031                      WHERE user_id = ' . $poster_id . '
2032                      AND user_posts < ' . $substract;
2033                  $db->sql_query($sql);
2034  
2035                  $sql = 'UPDATE ' . USERS_TABLE . '
2036                      SET user_posts = user_posts - ' . $substract . '
2037                      WHERE user_id = ' . $poster_id . '
2038                      AND user_posts >= ' . $substract;
2039                  $db->sql_query($sql);
2040              }
2041          }
2042  
2043          $db->sql_transaction('commit');
2044  
2045          // Make sure the overall post/topic count is correct...
2046          $sql = 'SELECT COUNT(post_id) AS stat
2047              FROM ' . POSTS_TABLE . '
2048              WHERE post_visibility = ' . ITEM_APPROVED;
2049          $result = $db->sql_query($sql);
2050          $row = $db->sql_fetchrow($result);
2051          $db->sql_freeresult($result);
2052  
2053          $config->set('num_posts', (int) $row['stat'], false);
2054  
2055          $sql = 'SELECT COUNT(topic_id) AS stat
2056              FROM ' . TOPICS_TABLE . '
2057              WHERE topic_visibility = ' . ITEM_APPROVED;
2058          $result = $db->sql_query($sql);
2059          $row = $db->sql_fetchrow($result);
2060          $db->sql_freeresult($result);
2061  
2062          $config->set('num_topics', (int) $row['stat'], false);
2063  
2064          $sql = 'SELECT COUNT(attach_id) as stat
2065              FROM ' . ATTACHMENTS_TABLE;
2066          $result = $db->sql_query($sql);
2067          $row = $db->sql_fetchrow($result);
2068          $db->sql_freeresult($result);
2069  
2070          $config->set('num_files', (int) $row['stat'], false);
2071  
2072          $sql = 'SELECT SUM(filesize) as stat
2073              FROM ' . ATTACHMENTS_TABLE;
2074          $result = $db->sql_query($sql);
2075          $row = $db->sql_fetchrow($result);
2076          $db->sql_freeresult($result);
2077  
2078          $config->set('upload_dir_size', (float) $row['stat'], false);
2079  
2080          return array();
2081      }
2082  
2083      /**
2084      * Move forum position by $steps up/down
2085      */
2086  	function move_forum_by($forum_row, $action = 'move_up', $steps = 1)
2087      {
2088          global $db;
2089  
2090          /**
2091          * Fetch all the siblings between the module's current spot
2092          * and where we want to move it to. If there are less than $steps
2093          * siblings between the current spot and the target then the
2094          * module will move as far as possible
2095          */
2096          $sql = 'SELECT forum_id, forum_name, left_id, right_id
2097              FROM ' . FORUMS_TABLE . "
2098              WHERE parent_id = {$forum_row['parent_id']}
2099                  AND " . (($action == 'move_up') ? "right_id < {$forum_row['right_id']} ORDER BY right_id DESC" : "left_id > {$forum_row['left_id']} ORDER BY left_id ASC");
2100          $result = $db->sql_query_limit($sql, $steps);
2101  
2102          $target = array();
2103          while ($row = $db->sql_fetchrow($result))
2104          {
2105              $target = $row;
2106          }
2107          $db->sql_freeresult($result);
2108  
2109          if (!count($target))
2110          {
2111              // The forum is already on top or bottom
2112              return false;
2113          }
2114  
2115          /**
2116          * $left_id and $right_id define the scope of the nodes that are affected by the move.
2117          * $diff_up and $diff_down are the values to substract or add to each node's left_id
2118          * and right_id in order to move them up or down.
2119          * $move_up_left and $move_up_right define the scope of the nodes that are moving
2120          * up. Other nodes in the scope of ($left_id, $right_id) are considered to move down.
2121          */
2122          if ($action == 'move_up')
2123          {
2124              $left_id = $target['left_id'];
2125              $right_id = $forum_row['right_id'];
2126  
2127              $diff_up = $forum_row['left_id'] - $target['left_id'];
2128              $diff_down = $forum_row['right_id'] + 1 - $forum_row['left_id'];
2129  
2130              $move_up_left = $forum_row['left_id'];
2131              $move_up_right = $forum_row['right_id'];
2132          }
2133          else
2134          {
2135              $left_id = $forum_row['left_id'];
2136              $right_id = $target['right_id'];
2137  
2138              $diff_up = $forum_row['right_id'] + 1 - $forum_row['left_id'];
2139              $diff_down = $target['right_id'] - $forum_row['right_id'];
2140  
2141              $move_up_left = $forum_row['right_id'] + 1;
2142              $move_up_right = $target['right_id'];
2143          }
2144  
2145          // Now do the dirty job
2146          $sql = 'UPDATE ' . FORUMS_TABLE . "
2147              SET left_id = left_id + CASE
2148                  WHEN left_id BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up}
2149                  ELSE {$diff_down}
2150              END,
2151              right_id = right_id + CASE
2152                  WHEN right_id BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up}
2153                  ELSE {$diff_down}
2154              END,
2155              forum_parents = ''
2156              WHERE
2157                  left_id BETWEEN {$left_id} AND {$right_id}
2158                  AND right_id BETWEEN {$left_id} AND {$right_id}";
2159          $db->sql_query($sql);
2160  
2161          return $target['forum_name'];
2162      }
2163  
2164      /**
2165      * Display progress bar for syncinc forums
2166      */
2167  	function display_progress_bar($start, $total)
2168      {
2169          global $template, $user;
2170  
2171          adm_page_header($user->lang['SYNC_IN_PROGRESS']);
2172  
2173          $template->set_filenames(array(
2174              'body'    => 'progress_bar.html')
2175          );
2176  
2177          $template->assign_vars(array(
2178              'L_PROGRESS'            => $user->lang['SYNC_IN_PROGRESS'],
2179              'L_PROGRESS_EXPLAIN'    => ($start && $total) ? sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $start, $total) : $user->lang['SYNC_IN_PROGRESS'])
2180          );
2181  
2182          adm_page_footer();
2183      }
2184  
2185      /**
2186      * Display copy permission page
2187      * Not used at the moment - we will have a look at it for 3.0.7
2188      */
2189  	function copy_permission_page($forum_data)
2190      {
2191          global $phpEx, $phpbb_admin_path, $template, $user;
2192  
2193          $acl_url = '&amp;mode=setting_forum_local&amp;forum_id[]=' . $forum_data['forum_id'];
2194          $action = append_sid($this->u_action . "&amp;parent_id={$this->parent_id}&amp;f={$forum_data['forum_id']}&amp;action=copy_perm");
2195  
2196          $l_acl = sprintf($user->lang['COPY_TO_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>');
2197  
2198          $this->tpl_name = 'acp_forums_copy_perm';
2199  
2200          $template->assign_vars(array(
2201              'U_ACL'                => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url),
2202              'L_ACL_LINK'        => $l_acl,
2203              'L_BACK_LINK'        => adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id),
2204              'S_COPY_ACTION'        => $action,
2205              'S_FORUM_OPTIONS'    => make_forum_select($forum_data['parent_id'], $forum_data['forum_id'], false, false, false),
2206          ));
2207      }
2208  
2209  }


Generated: Wed Nov 11 20:33:01 2020 Cross-referenced by PHPXref 0.7.1