phpBB

Code Changes

File: includes/acp/acp_forums.php

  Unmodified   Added   Modified   Removed
Line 56Line 56
				$total = request_var('total', 0);

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

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

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

				exit;

 
			break;

case 'delete':

			break;

case 'delete':

Line 139Line 138
						'enable_icons'			=> request_var('enable_icons', false),
'enable_prune' => request_var('enable_prune', false),
'enable_post_review' => request_var('enable_post_review', 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),

						'prune_days'			=> request_var('prune_days', 7),
'prune_viewed' => request_var('prune_viewed', 7),
'prune_freq' => request_var('prune_freq', 1),

						'prune_days'			=> request_var('prune_days', 7),
'prune_viewed' => request_var('prune_viewed', 7),
'prune_freq' => request_var('prune_freq', 1),

Line 149Line 149
						'forum_password_confirm'=> request_var('forum_password_confirm', '', true),
'forum_password_unset' => request_var('forum_password_unset', false),
);

						'forum_password_confirm'=> request_var('forum_password_confirm', '', true),
'forum_password_unset' => request_var('forum_password_unset', false),
);

 

// On add, add empty forum_options... else do not consider it (not updating it)
if ($action == 'add')
{
$forum_data['forum_options'] = 0;
}


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

Line 162Line 168
						$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', false) : request_var('display_active', false);

					$forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? request_var('display_recent', true) : request_var('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'])

Line 181Line 187
					if (!sizeof($errors))
{
$forum_perm_from = request_var('forum_perm_from', 0);

					if (!sizeof($errors))
{
$forum_perm_from = request_var('forum_perm_from', 0);

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





 
						$copied_permissions = false;

						// Copy permissions?

						// Copy permissions?

						if ($forum_perm_from && !empty($forum_perm_from) && $forum_perm_from != $forum_data['forum_id'] &&
(($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'))))

						if ($forum_perm_from && $forum_perm_from != $forum_data['forum_id'] &&
($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'))))

						{

						{

							// if we edit a forum delete current permissions first
if ($action == 'edit')
{
$sql = 'DELETE FROM ' . ACL_USERS_TABLE . '
WHERE forum_id = ' . (int) $forum_data['forum_id'];
$db->sql_query($sql);

$sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . '
WHERE forum_id = ' . (int) $forum_data['forum_id'];
$db->sql_query($sql);

							copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false);
cache_moderators();
$copied_permissions = true;








							}

							}


// From the mysql documentation:
// Prior to MySQL 4.0.14, the target table of the INSERT statement cannot appear in the FROM clause of the SELECT part of the query. This limitation is lifted in 4.0.14.
// Due to this we stay on the safe side if we do the insertion "the manual way"

// Copy permisisons from/to the acl users table (only forum_id gets changed)
$sql = 'SELECT user_id, auth_option_id, auth_role_id, auth_setting
FROM ' . ACL_USERS_TABLE . '
WHERE forum_id = ' . $forum_perm_from;
$result = $db->sql_query($sql);

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

/* Commented out because of questionable UI workflow - re-visit for 3.0.7
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'))












							{

							{

								$users_sql_ary[] = array(
'user_id' => (int) $row['user_id'],
'forum_id' => (int) $forum_data['forum_id'],
'auth_option_id' => (int) $row['auth_option_id'],
'auth_role_id' => (int) $row['auth_role_id'],
'auth_setting' => (int) $row['auth_setting']
);

							$this->copy_permission_page($forum_data);
return;






							}

							}

							$db->sql_freeresult($result);

// Copy permisisons from/to the acl groups table (only forum_id gets changed)
$sql = 'SELECT group_id, auth_option_id, auth_role_id, auth_setting
FROM ' . ACL_GROUPS_TABLE . '
WHERE forum_id = ' . $forum_perm_from;
$result = $db->sql_query($sql);

$groups_sql_ary = array();
while ($row = $db->sql_fetchrow($result))
{
$groups_sql_ary[] = array(
'group_id' => (int) $row['group_id'],
'forum_id' => (int) $forum_data['forum_id'],
'auth_option_id' => (int) $row['auth_option_id'],
'auth_role_id' => (int) $row['auth_role_id'],
'auth_setting' => (int) $row['auth_setting']
);
}
$db->sql_freeresult($result);

// Now insert the data
$db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary);
$db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary);
cache_moderators();
}


*/



























						$auth->acl_clear_prefetch();

						$auth->acl_clear_prefetch();

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

 

$acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id'];

$message = ($action == 'add') ? $user->lang['FORUM_CREATED'] : $user->lang['FORUM_UPDATED'];



$acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id'];

$message = ($action == 'add') ? $user->lang['FORUM_CREATED'] : $user->lang['FORUM_UPDATED'];


						// Redirect to permissions
if ($auth->acl_get('a_fauth'))

						// redirect directly to permission settings screen if authed
if ($action == 'add' && !$copied_permissions && $auth->acl_get('a_fauth'))

						{
$message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>');

						{
$message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>');

						}

 




						// redirect directly to permission settings screen if authed
if ($action == 'add' && !$forum_perm_from && $auth->acl_get('a_fauth'))
{

 
							meta_refresh(4, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url));
}


							meta_refresh(4, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url));
}


Line 423Line 377
					$forum_data['forum_flags'] += (request_var('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'] += (request_var('enable_post_review', true)) ? FORUM_FLAG_POST_REVIEW : 0;

					$forum_data['forum_flags'] += (request_var('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'] += (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;

				}

// Show form to create/modify a forum

				}

// Show form to create/modify a forum

Line 484Line 439
							'prune_days'			=> 7,
'prune_viewed' => 7,
'prune_freq' => 1,

							'prune_days'			=> 7,
'prune_viewed' => 7,
'prune_freq' => 1,

							'forum_flags'			=> FORUM_FLAG_POST_REVIEW,


							'forum_flags'			=> FORUM_FLAG_POST_REVIEW + FORUM_FLAG_ACTIVE_TOPICS,
'forum_options' => 0,

							'forum_password'		=> '',
'forum_password_confirm'=> '',
);

							'forum_password'		=> '',
'forum_password_confirm'=> '',
);

Line 560Line 516
					FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST . "
AND forum_id <> $forum_id";

					FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST . "
AND forum_id <> $forum_id";

				$result = $db->sql_query($sql);

				$result = $db->sql_query_limit($sql, 1);





 
				$postable_forum_exists = false;

				if ($db->sql_fetchrow($result))
{

				if ($db->sql_fetchrow($result))
{

					$template->assign_vars(array(
'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false))
);

					$postable_forum_exists = true;



				}
$db->sql_freeresult($result);


				}
$db->sql_freeresult($result);


Line 583Line 538

$forums_list = make_forum_select($forum_data['parent_id'], $subforums_id);



$forums_list = make_forum_select($forum_data['parent_id'], $subforums_id);


					$sql = 'SELECT forum_id
FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST . "
AND forum_id <> $forum_id";
$result = $db->sql_query($sql);

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

					if ($postable_forum_exists)







					{
$template->assign_vars(array(
'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id)) // , false, true, false???
);
}

					{
$template->assign_vars(array(
'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id)) // , false, true, false???
);
}

					$db->sql_freeresult($result);

 

$template->assign_vars(array(
'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false,
'S_FORUMS_LIST' => $forums_list)


$template->assign_vars(array(
'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false,
'S_FORUMS_LIST' => $forums_list)

 
					);
}
else if ($postable_forum_exists)
{
$template->assign_vars(array(
'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false))

					);
}


					);
}


Line 682Line 636
					'S_PRUNE_OLD_POLLS'			=> ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_POLL) ? true : false,
'S_PRUNE_ANNOUNCE' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_ANNOUNCE) ? true : false,
'S_PRUNE_STICKY' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_STICKY) ? true : false,

					'S_PRUNE_OLD_POLLS'			=> ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_POLL) ? true : false,
'S_PRUNE_ANNOUNCE' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_ANNOUNCE) ? true : false,
'S_PRUNE_STICKY' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_STICKY) ? true : false,

					'S_DISPLAY_ACTIVE_TOPICS'	=> ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) ? true : false,


					'S_DISPLAY_ACTIVE_TOPICS'	=> ($forum_data['forum_type'] == FORUM_POST) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : true,
'S_ENABLE_ACTIVE_TOPICS' => ($forum_data['forum_type'] == FORUM_CAT) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : false,

					'S_ENABLE_POST_REVIEW'		=> ($forum_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) ? true : false,

					'S_ENABLE_POST_REVIEW'		=> ($forum_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) ? true : false,

 
					'S_ENABLE_QUICK_REPLY'		=> ($forum_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) ? true : false,

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


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


Line 714Line 670
					FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST . "
AND forum_id <> $forum_id";

					FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST . "
AND forum_id <> $forum_id";

				$result = $db->sql_query($sql);

				$result = $db->sql_query_limit($sql, 1);


if ($db->sql_fetchrow($result))
{


if ($db->sql_fetchrow($result))
{

Line 741Line 697
				);

return;

				);

return;

 
			break;

case 'copy_perm':
$forum_perm_from = request_var('forum_perm_from', 0);

// Copy permissions?
if (!empty($forum_perm_from) && $forum_perm_from != $forum_id)
{
copy_forum_permissions($forum_perm_from, $forum_id, true);
cache_moderators();
$auth->acl_clear_prefetch();
$cache->destroy('sql', FORUMS_TABLE);

$acl_url = '&amp;mode=setting_forum_local&amp;forum_id[]=' . $forum_id;

$message = $user->lang['FORUM_UPDATED'];

// Redirect to permissions
if ($auth->acl_get('a_fauth'))
{
$message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>');
}

trigger_error($message . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id));
}


			break;
}


			break;
}


Line 806Line 788
				}

$url = $this->u_action . "&amp;parent_id=$this->parent_id&amp;f={$row['forum_id']}";

				}

$url = $this->u_action . "&amp;parent_id=$this->parent_id&amp;f={$row['forum_id']}";


$forum_title = ($forum_type != FORUM_LINK) ? '<a href="' . $this->u_action . '&amp;parent_id=' . $row['forum_id'] . '">' : '';
$forum_title .= $row['forum_name'];
$forum_title .= ($forum_type != FORUM_LINK) ? '</a>' : '';

 

$template->assign_block_vars('forums', array(
'FOLDER_IMAGE' => $folder_image,


$template->assign_block_vars('forums', array(
'FOLDER_IMAGE' => $folder_image,

Line 888Line 866
	*/
function update_forum_data(&$forum_data)
{

	*/
function update_forum_data(&$forum_data)
{

		global $db, $user, $cache;

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


$errors = array();



$errors = array();


		if (!$forum_data['forum_name'])

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

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

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

Line 925Line 903
		$range_test_ary = array(
array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data['forum_topics_per_page'], 'column_type' => 'TINT:0'),
);

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

 

if (!empty($forum_data['forum_image']) && !file_exists($phpbb_root_path . $forum_data['forum_image']))
{
$errors[] = $user->lang['FORUM_IMAGE_NO_EXIST'];
}


validate_range($range_test_ary, $errors);



validate_range($range_test_ary, $errors);


Line 942Line 925
		$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['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;


// Unset data that are not database fields
$forum_data_sql = $forum_data;


// Unset data that are not database fields
$forum_data_sql = $forum_data;

Line 952Line 936
		unset($forum_data_sql['prune_sticky']);
unset($forum_data_sql['show_active']);
unset($forum_data_sql['enable_post_review']);

		unset($forum_data_sql['prune_sticky']);
unset($forum_data_sql['show_active']);
unset($forum_data_sql['enable_post_review']);

 
		unset($forum_data_sql['enable_quick_reply']);

		unset($forum_data_sql['forum_password_confirm']);

// What are we going to do tonight Brain? The same thing we do everynight,

		unset($forum_data_sql['forum_password_confirm']);

// What are we going to do tonight Brain? The same thing we do everynight,

Line 993Line 978

if (!$row)
{


if (!$row)
{

					trigger_error($user->lang['PARENT_NOT_EXIST'] . adm_back_link($this->u_action . '&amp;' . $this->parent_id), E_USER_WARNING);

					trigger_error($user->lang['PARENT_NOT_EXIST'] . adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id), E_USER_WARNING);

				}

if ($row['forum_type'] == FORUM_LINK)

				}

if ($row['forum_type'] == FORUM_LINK)

Line 1651Line 1636
		$db->sql_freeresult($result);

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

		$db->sql_freeresult($result);

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

 

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


// Before we remove anything we make sure we are able to adjust the post counts later. ;)
$sql = 'SELECT poster_id


// Before we remove anything we make sure we are able to adjust the post counts later. ;)
$sql = 'SELECT poster_id

Line 1717Line 1705
						POLL_VOTES_TABLE,
)
);

						POLL_VOTES_TABLE,
)
);

 

// Amount of rows we select and delete in one iteration.
$batch_size = 500;


foreach ($tables_ary as $field => $tables)
{


foreach ($tables_ary as $field => $tables)
{

Line 1727Line 1718
						$sql = "SELECT $field
FROM " . POSTS_TABLE . '
WHERE forum_id = ' . $forum_id;

						$sql = "SELECT $field
FROM " . POSTS_TABLE . '
WHERE forum_id = ' . $forum_id;

						$result = $db->sql_query_limit($sql, 500, $start);

						$result = $db->sql_query_limit($sql, $batch_size, $start);


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


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

Line 1746Line 1737
							}
}
}

							}
}
}

					while ($row);

					while (sizeof($ids) == $batch_size);

				}
unset($ids);


				}
unset($ids);


Line 1928Line 1919

adm_page_footer();
}


adm_page_footer();
}

 

/**
* Display copy permission page
* Not used at the moment - we will have a look at it for 3.0.7
*/
function copy_permission_page($forum_data)
{
global $phpEx, $phpbb_admin_path, $template, $user;

$acl_url = '&amp;mode=setting_forum_local&amp;forum_id[]=' . $forum_data['forum_id'];
$action = append_sid($this->u_action . "&amp;parent_id={$this->parent_id}&amp;f={$forum_data['forum_id']}&amp;action=copy_perm");

$l_acl = sprintf($user->lang['COPY_TO_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>');

$this->tpl_name = 'acp_forums_copy_perm';

$template->assign_vars(array(
'U_ACL' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url),
'L_ACL_LINK' => $l_acl,
'L_BACK_LINK' => adm_back_link($this->u_action . '&amp;parent_id=' . $this->parent_id),
'S_COPY_ACTION' => $action,
'S_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_data['forum_id'], false, false, false),
));
}


}

?>

}

?>