phpBB

Code Changes

File: includes/acp/acp_forums.php

  Unmodified   Added   Modified   Removed
Line 27Line 27
	function main($id, $mode)
{
global $db, $user, $auth, $template, $cache, $request, $phpbb_dispatcher;

	function main($id, $mode)
{
global $db, $user, $auth, $template, $cache, $request, $phpbb_dispatcher;

		global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx;

		global $phpbb_admin_path, $phpbb_root_path, $phpEx, $phpbb_log;


$user->add_lang('acp/forums');
$this->tpl_name = 'acp_forums';


$user->add_lang('acp/forums');
$this->tpl_name = 'acp_forums';

Line 36Line 36
		$form_key = 'acp_forums';
add_form_key($form_key);


		$form_key = 'acp_forums';
add_form_key($form_key);


		$action		= request_var('action', '');

		$action		= $request->variable('action', '');

		$update		= (isset($_POST['update'])) ? true : false;

		$update		= (isset($_POST['update'])) ? true : false;

		$forum_id	= request_var('f', 0);

		$forum_id	= $request->variable('f', 0);





		$this->parent_id	= request_var('parent_id', 0);

		$this->parent_id	= $request->variable('parent_id', 0);

		$forum_data = $errors = array();
if ($update && !check_form_key($form_key))
{

		$forum_data = $errors = array();
if ($update && !check_form_key($form_key))
{

Line 52Line 52
		switch ($action)
{
case 'progress_bar':

		switch ($action)
{
case 'progress_bar':

				$start = request_var('start', 0);
$total = request_var('total', 0);

				$start = $request->variable('start', 0);
$total = $request->variable('total', 0);


$this->display_progress_bar($start, $total);
break;


$this->display_progress_bar($start, $total);
break;

Line 83Line 83
			switch ($action)
{
case 'delete':

			switch ($action)
{
case 'delete':

					$action_subforums	= request_var('action_subforums', '');
$subforums_to_id = request_var('subforums_to_id', 0);
$action_posts = request_var('action_posts', '');
$posts_to_id = request_var('posts_to_id', 0);

					$action_subforums	= $request->variable('action_subforums', '');
$subforums_to_id = $request->variable('subforums_to_id', 0);
$action_posts = $request->variable('action_posts', '');
$posts_to_id = $request->variable('posts_to_id', 0);


$errors = $this->delete_forum($forum_id, $action_posts, $action_subforums, $posts_to_id, $subforums_to_id);



$errors = $this->delete_forum($forum_id, $action_posts, $action_subforums, $posts_to_id, $subforums_to_id);


Line 112Line 112
				case 'add':

$forum_data += array(

				case 'add':

$forum_data += array(

						'parent_id'				=> request_var('forum_parent_id', $this->parent_id),
'forum_type' => request_var('forum_type', FORUM_POST),
'type_action' => request_var('type_action', ''),
'forum_status' => request_var('forum_status', ITEM_UNLOCKED),

						'parent_id'				=> $request->variable('forum_parent_id', $this->parent_id),
'forum_type' => $request->variable('forum_type', FORUM_POST),
'type_action' => $request->variable('type_action', ''),
'forum_status' => $request->variable('forum_status', ITEM_UNLOCKED),

						'forum_parents'			=> '',

						'forum_parents'			=> '',

						'forum_name'			=> utf8_normalize_nfc(request_var('forum_name', '', true)),
'forum_link' => request_var('forum_link', ''),
'forum_link_track' => request_var('forum_link_track', false),
'forum_desc' => utf8_normalize_nfc(request_var('forum_desc', '', true)),

						'forum_name'			=> $request->variable('forum_name', '', true),
'forum_link' => $request->variable('forum_link', ''),
'forum_link_track' => $request->variable('forum_link_track', false),
'forum_desc' => $request->variable('forum_desc', '', true),

						'forum_desc_uid'		=> '',
'forum_desc_options' => 7,
'forum_desc_bitfield' => '',

						'forum_desc_uid'		=> '',
'forum_desc_options' => 7,
'forum_desc_bitfield' => '',

						'forum_rules'			=> utf8_normalize_nfc(request_var('forum_rules', '', true)),

						'forum_rules'			=> $request->variable('forum_rules', '', true),

						'forum_rules_uid'		=> '',
'forum_rules_options' => 7,
'forum_rules_bitfield' => '',

						'forum_rules_uid'		=> '',
'forum_rules_options' => 7,
'forum_rules_bitfield' => '',

						'forum_rules_link'		=> request_var('forum_rules_link', ''),
'forum_image' => request_var('forum_image', ''),
'forum_style' => request_var('forum_style', 0),
'display_subforum_list' => request_var('display_subforum_list', false),
'display_on_index' => request_var('display_on_index', false),
'forum_topics_per_page' => request_var('topics_per_page', 0),
'enable_indexing' => request_var('enable_indexing', true),
'enable_icons' => request_var('enable_icons', false),
'enable_prune' => request_var('enable_prune', false),
'enable_post_review' => request_var('enable_post_review', true),
'enable_quick_reply' => request_var('enable_quick_reply', false),
'enable_shadow_prune' => request_var('enable_shadow_prune', false),
'prune_days' => request_var('prune_days', 7),
'prune_viewed' => request_var('prune_viewed', 7),
'prune_freq' => request_var('prune_freq', 1),
'prune_old_polls' => request_var('prune_old_polls', false),
'prune_announce' => request_var('prune_announce', false),
'prune_sticky' => request_var('prune_sticky', false),
'prune_shadow_days' => request_var('prune_shadow_days', 7),
'prune_shadow_freq' => request_var('prune_shadow_freq', 1),
'forum_password' => request_var('forum_password', '', true),
'forum_password_confirm'=> request_var('forum_password_confirm', '', true),
'forum_password_unset' => request_var('forum_password_unset', false),

						'forum_rules_link'		=> $request->variable('forum_rules_link', ''),
'forum_image' => $request->variable('forum_image', ''),
'forum_style' => $request->variable('forum_style', 0),
'display_subforum_list' => $request->variable('display_subforum_list', false),
'display_on_index' => $request->variable('display_on_index', false),
'forum_topics_per_page' => $request->variable('topics_per_page', 0),
'enable_indexing' => $request->variable('enable_indexing', true),
'enable_icons' => $request->variable('enable_icons', false),
'enable_prune' => $request->variable('enable_prune', false),
'enable_post_review' => $request->variable('enable_post_review', true),
'enable_quick_reply' => $request->variable('enable_quick_reply', false),
'enable_shadow_prune' => $request->variable('enable_shadow_prune', false),
'prune_days' => $request->variable('prune_days', 7),
'prune_viewed' => $request->variable('prune_viewed', 7),
'prune_freq' => $request->variable('prune_freq', 1),
'prune_old_polls' => $request->variable('prune_old_polls', false),
'prune_announce' => $request->variable('prune_announce', false),
'prune_sticky' => $request->variable('prune_sticky', false),
'prune_shadow_days' => $request->variable('prune_shadow_days', 7),
'prune_shadow_freq' => $request->variable('prune_shadow_freq', 1),
'forum_password' => $request->variable('forum_password', '', true),
'forum_password_confirm'=> $request->variable('forum_password_confirm', '', true),
'forum_password_unset' => $request->variable('forum_password_unset', false),

					);

/**

					);

/**

Line 173Line 173
					// Use link_display_on_index setting if forum type is link
if ($forum_data['forum_type'] == FORUM_LINK)
{

					// Use link_display_on_index setting if forum type is link
if ($forum_data['forum_type'] == FORUM_LINK)
{

						$forum_data['display_on_index'] = request_var('link_display_on_index', false);

						$forum_data['display_on_index'] = $request->variable('link_display_on_index', false);

					}

// Linked forums and categories are not able to be locked...

					}

// Linked forums and categories are not able to be locked...

Line 182Line 182
						$forum_data['forum_status'] = ITEM_UNLOCKED;
}


						$forum_data['forum_status'] = ITEM_UNLOCKED;
}


					$forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? request_var('display_recent', true) : request_var('display_active', false);

					$forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? $request->variable('display_recent', true) : $request->variable('display_active', false);


// Get data for forum rules if specified...
if ($forum_data['forum_rules'])
{


// Get data for forum rules if specified...
if ($forum_data['forum_rules'])
{

						generate_text_for_storage($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options'], request_var('rules_parse_bbcode', false), request_var('rules_parse_urls', false), request_var('rules_parse_smilies', false));

						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));

					}

// Get data for forum description if specified
if ($forum_data['forum_desc'])
{

					}

// Get data for forum description if specified
if ($forum_data['forum_desc'])
{

						generate_text_for_storage($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'], request_var('desc_parse_bbcode', false), request_var('desc_parse_urls', false), request_var('desc_parse_smilies', false));

						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));

					}

$errors = $this->update_forum_data($forum_data);

if (!sizeof($errors))
{

					}

$errors = $this->update_forum_data($forum_data);

if (!sizeof($errors))
{

						$forum_perm_from = request_var('forum_perm_from', 0);

						$forum_perm_from = $request->variable('forum_perm_from', 0);

						$cache->destroy('sql', FORUMS_TABLE);

$copied_permissions = false;

						$cache->destroy('sql', FORUMS_TABLE);

$copied_permissions = false;

Line 266Line 266

if ($move_forum_name !== false)
{


if ($move_forum_name !== false)
{

					add_log('admin', 'LOG_FORUM_' . strtoupper($action), $row['forum_name'], $move_forum_name);

					$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_' . strtoupper($action), false, array($row['forum_name'], $move_forum_name));

					$cache->destroy('sql', FORUMS_TABLE);
}


					$cache->destroy('sql', FORUMS_TABLE);
}


Line 311Line 311
					$row2['min_topic_id'] = (int) $row2['min_topic_id'];
$row2['max_topic_id'] = (int) $row2['max_topic_id'];


					$row2['min_topic_id'] = (int) $row2['min_topic_id'];
$row2['max_topic_id'] = (int) $row2['max_topic_id'];


					$start = request_var('start', $row2['min_topic_id']);

					$start = $request->variable('start', $row2['min_topic_id']);


$batch_size = 2000;
$end = $start + $batch_size;


$batch_size = 2000;
$end = $start + $batch_size;

Line 327Line 327
							WHERE forum_id = ' . $forum_id . '
AND topic_id BETWEEN ' . $start . ' AND ' . $end;
$result = $db->sql_query($sql);

							WHERE forum_id = ' . $forum_id . '
AND topic_id BETWEEN ' . $start . ' AND ' . $end;
$result = $db->sql_query($sql);

						$topics_done = request_var('topics_done', 0) + (int) $db->sql_fetchfield('num_topics');

						$topics_done = $request->variable('topics_done', 0) + (int) $db->sql_fetchfield('num_topics');

						$db->sql_freeresult($result);

$start += $batch_size;

						$db->sql_freeresult($result);

$start += $batch_size;

Line 377Line 377

sync('forum', 'forum_id', $forum_id, false, true);



sync('forum', 'forum_id', $forum_id, false, true);


				add_log('admin', 'LOG_FORUM_SYNC', $row['forum_name']);


				$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_SYNC', false, array($row['forum_name']));


				$cache->destroy('sql', FORUMS_TABLE);

$template->assign_var('L_FORUM_RESYNCED', sprintf($user->lang['FORUM_RESYNCED'], $row['forum_name']));

				$cache->destroy('sql', FORUMS_TABLE);

$template->assign_var('L_FORUM_RESYNCED', sprintf($user->lang['FORUM_RESYNCED'], $row['forum_name']));

Line 390Line 391
				if ($update)
{
$forum_data['forum_flags'] = 0;

				if ($update)
{
$forum_data['forum_flags'] = 0;

					$forum_data['forum_flags'] += (request_var('forum_link_track', false)) ? FORUM_FLAG_LINK_TRACK : 0;
$forum_data['forum_flags'] += (request_var('prune_old_polls', false)) ? FORUM_FLAG_PRUNE_POLL : 0;
$forum_data['forum_flags'] += (request_var('prune_announce', false)) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0;
$forum_data['forum_flags'] += (request_var('prune_sticky', false)) ? FORUM_FLAG_PRUNE_STICKY : 0;

					$forum_data['forum_flags'] += ($request->variable('forum_link_track', false)) ? FORUM_FLAG_LINK_TRACK : 0;
$forum_data['forum_flags'] += ($request->variable('prune_old_polls', false)) ? FORUM_FLAG_PRUNE_POLL : 0;
$forum_data['forum_flags'] += ($request->variable('prune_announce', false)) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0;
$forum_data['forum_flags'] += ($request->variable('prune_sticky', false)) ? FORUM_FLAG_PRUNE_STICKY : 0;

					$forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0;

					$forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0;

					$forum_data['forum_flags'] += (request_var('enable_post_review', true)) ? FORUM_FLAG_POST_REVIEW : 0;
$forum_data['forum_flags'] += (request_var('enable_quick_reply', false)) ? FORUM_FLAG_QUICK_REPLY : 0;

					$forum_data['forum_flags'] += ($request->variable('enable_post_review', true)) ? FORUM_FLAG_POST_REVIEW : 0;
$forum_data['forum_flags'] += ($request->variable('enable_quick_reply', false)) ? FORUM_FLAG_QUICK_REPLY : 0;

				}

// Initialise $row, so we always have it in the event

				}

// Initialise $row, so we always have it in the event

Line 444Line 445
							'parent_id'				=> $this->parent_id,
'forum_type' => FORUM_POST,
'forum_status' => ITEM_UNLOCKED,

							'parent_id'				=> $this->parent_id,
'forum_type' => FORUM_POST,
'forum_status' => ITEM_UNLOCKED,

							'forum_name'			=> utf8_normalize_nfc(request_var('forum_name', '', true)),

							'forum_name'			=> $request->variable('forum_name', '', true),

							'forum_link'			=> '',
'forum_link_track' => false,
'forum_desc' => '',

							'forum_link'			=> '',
'forum_link_track' => false,
'forum_desc' => '',

Line 511Line 512
				{
if (!isset($forum_data['forum_rules_uid']))
{

				{
if (!isset($forum_data['forum_rules_uid']))
{

						// Before we are able to display the preview and plane text, we need to parse our request_var()'d value...

						// Before we are able to display the preview and plane text, we need to parse our $request->variable()'d value...

						$forum_data['forum_rules_uid'] = '';
$forum_data['forum_rules_bitfield'] = '';
$forum_data['forum_rules_options'] = 0;


						$forum_data['forum_rules_uid'] = '';
$forum_data['forum_rules_bitfield'] = '';
$forum_data['forum_rules_options'] = 0;


						generate_text_for_storage($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_bitfield'], $forum_data['forum_rules_options'], request_var('rules_allow_bbcode', false), request_var('rules_allow_urls', false), request_var('rules_allow_smilies', false));

						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));

					}

// Generate preview content

					}

// Generate preview content

Line 531Line 532
				{
if (!isset($forum_data['forum_desc_uid']))
{

				{
if (!isset($forum_data['forum_desc_uid']))
{

						// Before we are able to display the preview and plane text, we need to parse our request_var()'d value...

						// Before we are able to display the preview and plane text, we need to parse our $request->variable()'d value...

						$forum_data['forum_desc_uid'] = '';
$forum_data['forum_desc_bitfield'] = '';
$forum_data['forum_desc_options'] = 0;


						$forum_data['forum_desc_uid'] = '';
$forum_data['forum_desc_bitfield'] = '';
$forum_data['forum_desc_options'] = 0;


						generate_text_for_storage($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_bitfield'], $forum_data['forum_desc_options'], request_var('desc_allow_bbcode', false), request_var('desc_allow_urls', false), request_var('desc_allow_smilies', false));

						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));

					}

// decode...

					}

// decode...

Line 779Line 780
			break;

case 'copy_perm':

			break;

case 'copy_perm':

				$forum_perm_from = request_var('forum_perm_from', 0);

				$forum_perm_from = $request->variable('forum_perm_from', 0);


// Copy permissions?
if (!empty($forum_perm_from) && $forum_perm_from != $forum_id)


// Copy permissions?
if (!empty($forum_perm_from) && $forum_perm_from != $forum_id)

Line 842Line 843
			ORDER BY left_id";
$result = $db->sql_query($sql);


			ORDER BY left_id";
$result = $db->sql_query($sql);


		if ($row = $db->sql_fetchrow($result))


		$rowset = array();
while ($row = $db->sql_fetchrow($result))

		{

		{

			do

















			$rowset[(int) $row['forum_id']] = $row;
}
$db->sql_freeresult($result);

/**
* Modify the forum list data
*
* @event core.acp_manage_forums_modify_forum_list
* @var array rowset Array with the forums list data
* @since 3.1.10-RC1
*/
$vars = array('rowset');
extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_modify_forum_list', compact($vars)));

if (!empty($rowset))
{
foreach ($rowset as $row)

			{
$forum_type = $row['forum_type'];


			{
$forum_type = $row['forum_type'];


Line 888Line 906
					'U_SYNC'			=> $url . '&action=sync')
);
}

					'U_SYNC'			=> $url . '&action=sync')
);
}

			while ($row = $db->sql_fetchrow($result));

 
		}
else if ($this->parent_id)
{

		}
else if ($this->parent_id)
{

Line 904Line 921
				'U_SYNC'			=> $url . '&action=sync')
);
}

				'U_SYNC'			=> $url . '&action=sync')
);
}

		$db->sql_freeresult($result);

		unset($rowset);


$template->assign_vars(array(
'ERROR_MSG' => (sizeof($errors)) ? implode('<br />', $errors) : '',


$template->assign_vars(array(
'ERROR_MSG' => (sizeof($errors)) ? implode('<br />', $errors) : '',

Line 943Line 960
	/**
* Update forum data
*/

	/**
* Update forum data
*/

	function update_forum_data(&$forum_data)

	function update_forum_data(&$forum_data_ary)

	{

	{

		global $db, $user, $cache, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher;

		global $db, $user, $cache, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log, $request;


$errors = array();



$errors = array();


 
		$forum_data = $forum_data_ary;

		/**
* Validate the forum data before we create/update the forum
*

		/**
* Validate the forum data before we create/update the forum
*

Line 960Line 978
		*/
$vars = array('forum_data', 'errors');
extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_validate_data', compact($vars)));

		*/
$vars = array('forum_data', 'errors');
extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_validate_data', compact($vars)));

 
		$forum_data_ary = $forum_data;
unset($forum_data);





		if ($forum_data['forum_name'] == '')

		if ($forum_data_ary['forum_name'] == '')

		{
$errors[] = $user->lang['FORUM_NAME_EMPTY'];
}


		{
$errors[] = $user->lang['FORUM_NAME_EMPTY'];
}


		if (utf8_strlen($forum_data['forum_desc']) > 4000)

		if (utf8_strlen($forum_data_ary['forum_desc']) > 4000)

		{
$errors[] = $user->lang['FORUM_DESC_TOO_LONG'];
}


		{
$errors[] = $user->lang['FORUM_DESC_TOO_LONG'];
}


		if (utf8_strlen($forum_data['forum_rules']) > 4000)

		if (utf8_strlen($forum_data_ary['forum_rules']) > 4000)

		{
$errors[] = $user->lang['FORUM_RULES_TOO_LONG'];
}


		{
$errors[] = $user->lang['FORUM_RULES_TOO_LONG'];
}


		if ($forum_data['forum_password'] || $forum_data['forum_password_confirm'])

		if ($forum_data_ary['forum_password'] || $forum_data_ary['forum_password_confirm'])

		{

		{

			if ($forum_data['forum_password'] != $forum_data['forum_password_confirm'])

			if ($forum_data_ary['forum_password'] != $forum_data_ary['forum_password_confirm'])

			{

			{

				$forum_data['forum_password'] = $forum_data['forum_password_confirm'] = '';

				$forum_data_ary['forum_password'] = $forum_data_ary['forum_password_confirm'] = '';

				$errors[] = $user->lang['FORUM_PASSWORD_MISMATCH'];
}
}


				$errors[] = $user->lang['FORUM_PASSWORD_MISMATCH'];
}
}


		if ($forum_data['prune_days'] < 0 || $forum_data['prune_viewed'] < 0 || $forum_data['prune_freq'] < 0)

		if ($forum_data_ary['prune_days'] < 0 || $forum_data_ary['prune_viewed'] < 0 || $forum_data_ary['prune_freq'] < 0)

		{

		{

			$forum_data['prune_days'] = $forum_data['prune_viewed'] = $forum_data['prune_freq'] = 0;

			$forum_data_ary['prune_days'] = $forum_data_ary['prune_viewed'] = $forum_data_ary['prune_freq'] = 0;

			$errors[] = $user->lang['FORUM_DATA_NEGATIVE'];
}

$range_test_ary = array(

			$errors[] = $user->lang['FORUM_DATA_NEGATIVE'];
}

$range_test_ary = array(

			array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data['forum_topics_per_page'], 'column_type' => 'TINT:0'),

			array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data_ary['forum_topics_per_page'], 'column_type' => 'TINT:0'),

		);


		);


		if (!empty($forum_data['forum_image']) && !file_exists($phpbb_root_path . $forum_data['forum_image']))

		if (!empty($forum_data_ary['forum_image']) && !file_exists($phpbb_root_path . $forum_data_ary['forum_image']))

		{
$errors[] = $user->lang['FORUM_IMAGE_NO_EXIST'];
}

		{
$errors[] = $user->lang['FORUM_IMAGE_NO_EXIST'];
}

Line 1009Line 1029
		// 8 = prune stickies
// 16 = show active topics
// 32 = enable post review

		// 8 = prune stickies
// 16 = show active topics
// 32 = enable post review

		$forum_data['forum_flags'] = 0;
$forum_data['forum_flags'] += ($forum_data['forum_link_track']) ? FORUM_FLAG_LINK_TRACK : 0;
$forum_data['forum_flags'] += ($forum_data['prune_old_polls']) ? FORUM_FLAG_PRUNE_POLL : 0;
$forum_data['forum_flags'] += ($forum_data['prune_announce']) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0;
$forum_data['forum_flags'] += ($forum_data['prune_sticky']) ? FORUM_FLAG_PRUNE_STICKY : 0;
$forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0;
$forum_data['forum_flags'] += ($forum_data['enable_post_review']) ? FORUM_FLAG_POST_REVIEW : 0;
$forum_data['forum_flags'] += ($forum_data['enable_quick_reply']) ? FORUM_FLAG_QUICK_REPLY : 0;

		$forum_data_ary['forum_flags'] = 0;
$forum_data_ary['forum_flags'] += ($forum_data_ary['forum_link_track']) ? FORUM_FLAG_LINK_TRACK : 0;
$forum_data_ary['forum_flags'] += ($forum_data_ary['prune_old_polls']) ? FORUM_FLAG_PRUNE_POLL : 0;
$forum_data_ary['forum_flags'] += ($forum_data_ary['prune_announce']) ? FORUM_FLAG_PRUNE_ANNOUNCE : 0;
$forum_data_ary['forum_flags'] += ($forum_data_ary['prune_sticky']) ? FORUM_FLAG_PRUNE_STICKY : 0;
$forum_data_ary['forum_flags'] += ($forum_data_ary['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0;
$forum_data_ary['forum_flags'] += ($forum_data_ary['enable_post_review']) ? FORUM_FLAG_POST_REVIEW : 0;
$forum_data_ary['forum_flags'] += ($forum_data_ary['enable_quick_reply']) ? FORUM_FLAG_QUICK_REPLY : 0;


// Unset data that are not database fields


// Unset data that are not database fields

		$forum_data_sql = $forum_data;

		$forum_data_sql = $forum_data_ary;


unset($forum_data_sql['forum_link_track']);
unset($forum_data_sql['prune_old_polls']);


unset($forum_data_sql['forum_link_track']);
unset($forum_data_sql['prune_old_polls']);

Line 1050Line 1070
		else
{
// Instantiate passwords manager

		else
{
// Instantiate passwords manager

 
			/* @var $passwords_manager \phpbb\passwords\manager */

			$passwords_manager = $phpbb_container->get('passwords.manager');

$forum_data_sql['forum_password'] = $passwords_manager->hash($forum_data_sql['forum_password']);
}
unset($forum_data_sql['forum_password_unset']);


			$passwords_manager = $phpbb_container->get('passwords.manager');

$forum_data_sql['forum_password'] = $passwords_manager->hash($forum_data_sql['forum_password']);
}
unset($forum_data_sql['forum_password_unset']);


 
		$forum_data = $forum_data_ary;

		/**
* Remove invalid values from forum_data_sql that should not be updated
*

		/**
* Remove invalid values from forum_data_sql that should not be updated
*

Line 1068Line 1090
		*/
$vars = array('forum_data', 'forum_data_sql');
extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_before', compact($vars)));

		*/
$vars = array('forum_data', 'forum_data_sql');
extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_before', compact($vars)));

 
		$forum_data_ary = $forum_data;
unset($forum_data);


$is_new_forum = !isset($forum_data_sql['forum_id']);



$is_new_forum = !isset($forum_data_sql['forum_id']);


Line 1124Line 1148
			$sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $forum_data_sql);
$db->sql_query($sql);


			$sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $forum_data_sql);
$db->sql_query($sql);


			$forum_data['forum_id'] = $db->sql_nextid();

			$forum_data_ary['forum_id'] = $db->sql_nextid();





			add_log('admin', 'LOG_FORUM_ADD', $forum_data['forum_name']);

			$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_ADD', false, array($forum_data_ary['forum_name']));

		}
else
{

		}
else
{

Line 1144Line 1168
				// we're turning a postable forum into a non-postable forum
if ($forum_data_sql['type_action'] == 'move')
{

				// we're turning a postable forum into a non-postable forum
if ($forum_data_sql['type_action'] == 'move')
{

					$to_forum_id = request_var('to_forum_id', 0);

					$to_forum_id = $request->variable('to_forum_id', 0);


if ($to_forum_id)
{


if ($to_forum_id)
{

Line 1174Line 1198
				if ($row['right_id'] - $row['left_id'] > 1)
{
// We are turning a category into a link - but need to decide what to do with the subforums.

				if ($row['right_id'] - $row['left_id'] > 1)
{
// We are turning a category into a link - but need to decide what to do with the subforums.

					$action_subforums = request_var('action_subforums', '');
$subforums_to_id = request_var('subforums_to_id', 0);

					$action_subforums = $request->variable('action_subforums', '');
$subforums_to_id = $request->variable('subforums_to_id', 0);


if ($action_subforums == 'delete')
{


if ($action_subforums == 'delete')
{

Line 1255Line 1279
						{
return array($user->lang['NO_FORUM']);
}

						{
return array($user->lang['NO_FORUM']);
}


$subforums_to_name = $_row['forum_name'];

 

$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . "


$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . "

Line 1341Line 1363
			$db->sql_query($sql);

// Add it back

			$db->sql_query($sql);

// Add it back

			$forum_data['forum_id'] = $forum_id;

			$forum_data_ary['forum_id'] = $forum_id;





			add_log('admin', 'LOG_FORUM_EDIT', $forum_data['forum_name']);

			$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_EDIT', false, array($forum_data_ary['forum_name']));

		}


		}


 
		$forum_data = $forum_data_ary;

		/**
* Event after a forum was updated or created
*

		/**
* Event after a forum was updated or created
*

Line 1361Line 1384
		*/
$vars = array('forum_data', 'forum_data_sql', 'is_new_forum', 'errors');
extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_after', compact($vars)));

		*/
$vars = array('forum_data', 'forum_data_sql', 'is_new_forum', 'errors');
extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_after', compact($vars)));

 
		$forum_data_ary = $forum_data;
unset($forum_data);


return $errors;
}


return $errors;
}

Line 1372Line 1397
	{
global $db, $user, $phpbb_dispatcher;


	{
global $db, $user, $phpbb_dispatcher;


		$to_data = $moved_ids = $errors = array();

		$errors = array();


// Check if we want to move to a parent with link type
if ($to_id > 0)


// Check if we want to move to a parent with link type
if ($to_id > 0)

Line 1411Line 1436
		$diff = sizeof($moved_forums) * 2;

$moved_ids = array();

		$diff = sizeof($moved_forums) * 2;

$moved_ids = array();

		for ($i = 0; $i < sizeof($moved_forums); ++$i)

		for ($i = 0, $size = sizeof($moved_forums); $i < $size; ++$i)

		{
$moved_ids[] = $moved_forums[$i]['forum_id'];
}

		{
$moved_ids[] = $moved_forums[$i]['forum_id'];
}

Line 1545Line 1570
	*/
function delete_forum($forum_id, $action_posts = 'delete', $action_subforums = 'delete', $posts_to_id = 0, $subforums_to_id = 0)
{

	*/
function delete_forum($forum_id, $action_posts = 'delete', $action_subforums = 'delete', $posts_to_id = 0, $subforums_to_id = 0)
{

		global $db, $user, $cache;

		global $db, $user, $cache, $phpbb_log;


$forum_data = $this->get_forum_info($forum_id);



$forum_data = $this->get_forum_info($forum_id);


Line 1742Line 1767
		switch ($log_action)
{
case 'MOVE_POSTS_MOVE_FORUMS':

		switch ($log_action)
{
case 'MOVE_POSTS_MOVE_FORUMS':

				add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS_MOVE_FORUMS', $posts_to_name, $subforums_to_name, $forum_data['forum_name']);

				$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']));

			break;

case 'MOVE_POSTS_FORUMS':

			break;

case 'MOVE_POSTS_FORUMS':

				add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS_FORUMS', $posts_to_name, $forum_data['forum_name']);

				$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']));

			break;

case 'POSTS_MOVE_FORUMS':

			break;

case 'POSTS_MOVE_FORUMS':

				add_log('admin', 'LOG_FORUM_DEL_POSTS_MOVE_FORUMS', $subforums_to_name, $forum_data['forum_name']);

				$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']));

			break;

case '_MOVE_FORUMS':

			break;

case '_MOVE_FORUMS':

				add_log('admin', 'LOG_FORUM_DEL_MOVE_FORUMS', $subforums_to_name, $forum_data['forum_name']);

				$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_MOVE_FORUMS', false, array($subforums_to_name, $forum_data['forum_name']));

			break;

case 'MOVE_POSTS_':

			break;

case 'MOVE_POSTS_':

				add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS', $posts_to_name, $forum_data['forum_name']);

				$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_MOVE_POSTS', false, array($posts_to_name, $forum_data['forum_name']));

			break;

case 'POSTS_FORUMS':

			break;

case 'POSTS_FORUMS':

				add_log('admin', 'LOG_FORUM_DEL_POSTS_FORUMS', $forum_data['forum_name']);

				$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_POSTS_FORUMS', false, array($forum_data['forum_name']));

			break;

case '_FORUMS':

			break;

case '_FORUMS':

				add_log('admin', 'LOG_FORUM_DEL_FORUMS', $forum_data['forum_name']);

				$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_FORUMS', false, array($forum_data['forum_name']));

			break;

case 'POSTS_':

			break;

case 'POSTS_':

				add_log('admin', 'LOG_FORUM_DEL_POSTS', $forum_data['forum_name']);

				$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_POSTS', false, array($forum_data['forum_name']));

			break;

default:

			break;

default:

				add_log('admin', 'LOG_FORUM_DEL_FORUM', $forum_data['forum_name']);

				$phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_FORUM_DEL_FORUM', false, array($forum_data['forum_name']));

			break;
}


			break;
}


Line 1786Line 1811
	*/
function delete_forum_content($forum_id)
{

	*/
function delete_forum_content($forum_id)
{

		global $db, $config, $phpbb_root_path, $phpEx;

		global $db, $config, $phpbb_root_path, $phpEx, $phpbb_container, $phpbb_dispatcher;


include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);



include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx);


Line 1807Line 1832
		}
$db->sql_freeresult($result);


		}
$db->sql_freeresult($result);


		delete_attachments('topic', $topic_ids, false);




		/** @var \phpbb\attachment\manager $attachment_manager */
$attachment_manager = $phpbb_container->get('attachment.manager');
$attachment_manager->delete('topic', $topic_ids, false);
unset($attachment_manager);


// Delete shadow topics pointing to topics in this forum
delete_topic_shadows($forum_id);


// Delete shadow topics pointing to topics in this forum
delete_topic_shadows($forum_id);

Line 1917Line 1945
		}

$table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, LOG_TABLE, MODERATOR_CACHE_TABLE, POSTS_TABLE, TOPICS_TABLE, TOPICS_TRACK_TABLE);

		}

$table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, LOG_TABLE, MODERATOR_CACHE_TABLE, POSTS_TABLE, TOPICS_TABLE, TOPICS_TRACK_TABLE);

 

/**
* Perform additional actions before forum content deletion
*
* @event core.delete_forum_content_before_query
* @var array table_ary Array of tables from which all rows will be deleted that hold the forum_id
* @var int forum_id the forum id
* @var array topic_ids Array of the topic ids from the forum to be deleted
* @var array post_counts Array of counts of posts in the forum, by poster_id
* @since 3.1.6-RC1
*/
$vars = array(
'table_ary',
'forum_id',
'topic_ids',
'post_counts',
);
extract($phpbb_dispatcher->trigger_event('core.delete_forum_content_before_query', compact($vars)));


foreach ($table_ary as $table)
{


foreach ($table_ary as $table)
{

Line 1960Line 2006
		$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);


		$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);


		set_config('num_posts', (int) $row['stat'], true);

		$config->set('num_posts', (int) $row['stat'], false);


$sql = 'SELECT COUNT(topic_id) AS stat
FROM ' . TOPICS_TABLE . '


$sql = 'SELECT COUNT(topic_id) AS stat
FROM ' . TOPICS_TABLE . '

Line 1969Line 2015
		$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);


		$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);


		set_config('num_topics', (int) $row['stat'], true);

		$config->set('num_topics', (int) $row['stat'], false);


$sql = 'SELECT COUNT(attach_id) as stat
FROM ' . ATTACHMENTS_TABLE;


$sql = 'SELECT COUNT(attach_id) as stat
FROM ' . ATTACHMENTS_TABLE;

Line 1977Line 2023
		$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);


		$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);


		set_config('num_files', (int) $row['stat'], true);

		$config->set('num_files', (int) $row['stat'], false);


$sql = 'SELECT SUM(filesize) as stat
FROM ' . ATTACHMENTS_TABLE;


$sql = 'SELECT SUM(filesize) as stat
FROM ' . ATTACHMENTS_TABLE;

Line 1985Line 2031
		$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);


		$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);


		set_config('upload_dir_size', (float) $row['stat'], true);

		$config->set('upload_dir_size', (float) $row['stat'], false);


return array();
}


return array();
}