From 57645ad5bc2469e166cb3e5d54628d87ffa74c42 Mon Sep 17 00:00:00 2001 From: David M Date: Sun, 6 Jan 2008 02:21:44 +0000 Subject: the end of an era... - MySQL < 4.1.3 support is removed - renamed mysql4 to mysql, no need to cause confusion - changed the cfg cacher, reduces file system lookups and include count by two on every page load git-svn-id: file:///svn/phpbb/trunk@8307 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index bb8f437b80..faf3b7b296 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1649,7 +1649,7 @@ class acp_forums switch ($db->sql_layer) { - case 'mysql4': + case 'mysql': case 'mysqli': // Delete everything else and thank MySQL for offering multi-table deletion -- cgit v1.2.1 From 2928574ed46334bb8dbbb6612a62db3c3654ba12 Mon Sep 17 00:00:00 2001 From: David M Date: Mon, 7 Jan 2008 15:19:38 +0000 Subject: - a few tiny clean ups - a new MS SQL DBAL, it does not work so hot because of issues with the extension it depends on git-svn-id: file:///svn/phpbb/trunk@8313 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index faf3b7b296..6338559cfc 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1647,10 +1647,9 @@ class acp_forums } $db->sql_freeresult($result); - switch ($db->sql_layer) + if ($db->dbms_type) { case 'mysql': - case 'mysqli': // Delete everything else and thank MySQL for offering multi-table deletion $tables_ary = array( -- cgit v1.2.1 From 835558ea38cdc9641109b6b405518bfddf225a38 Mon Sep 17 00:00:00 2001 From: "Marek A. R" Date: Tue, 22 Jan 2008 19:38:05 +0000 Subject: Fix parse error git-svn-id: file:///svn/phpbb/trunk@8329 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 6338559cfc..930545c093 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1647,7 +1647,7 @@ class acp_forums } $db->sql_freeresult($result); - if ($db->dbms_type) + switch ($db->dbms_type) { case 'mysql': -- cgit v1.2.1 From 3b669aedfde10b95996d529da9b21e31c46cc8a6 Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Sun, 3 Feb 2008 22:39:38 +0000 Subject: adding a new option to hide the entire list of subforums on listforums git-svn-id: file:///svn/phpbb/trunk@8373 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 930545c093..1677440cb9 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -132,6 +132,7 @@ class acp_forums '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), @@ -471,6 +472,7 @@ class acp_forums 'forum_rules_link' => '', 'forum_image' => '', 'forum_style' => 0, + 'display_subforum_list' => true, 'display_on_index' => false, 'forum_topics_per_page' => 0, 'enable_indexing' => true, @@ -670,6 +672,7 @@ class acp_forums 'S_FORUM_CAT' => ($forum_data['forum_type'] == FORUM_CAT) ? true : false, 'S_ENABLE_INDEXING' => ($forum_data['enable_indexing']) ? true : false, 'S_TOPIC_ICONS' => ($forum_data['enable_icons']) ? true : false, + 'S_DISPLAY_SUBFORUM_LIST' => ($forum_data['display_subforum_list']) ? true : false, 'S_DISPLAY_ON_INDEX' => ($forum_data['display_on_index']) ? true : false, 'S_PRUNE_ENABLE' => ($forum_data['enable_prune']) ? true : false, 'S_FORUM_LINK_TRACK' => ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? true : false, -- cgit v1.2.1 From 2a3eb724a84120e1d89e56536dcd1f1f5e20a408 Mon Sep 17 00:00:00 2001 From: Henry Sudhof Date: Wed, 27 Feb 2008 15:21:23 +0000 Subject: cross-ci git-svn-id: file:///svn/phpbb/trunk@8411 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 1677440cb9..6f11c88d60 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -918,6 +918,13 @@ class acp_forums $forum_data['prune_days'] = $forum_data['prune_viewed'] = $forum_data['prune_freq'] = 0; $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'), + ); + validate_range($range_test_ary, $errors); + + // Set forum flags // 1 = link tracking -- cgit v1.2.1 From 2f4a618900e2c3b6ea14c68cbeb5897cd2ac1a04 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 29 May 2008 12:25:56 +0000 Subject: ok... i hope i haven't messed too much with the code and everything is still working. Changes: - Ascraeus now uses constants for the phpbb root path and the php extension. This ensures more security for external applications and modifications (no more overwriting of root path and extension possible through insecure mods and register globals enabled) as well as no more globalizing needed. - A second change implemented here is an additional short-hand-notation for append_sid(). It is allowed to omit the root path and extension now (for example calling append_sid('memberlist')) - in this case the root path and extension get added automatically. The hook is called after these are added. git-svn-id: file:///svn/phpbb/trunk@8572 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 6f11c88d60..4a5db8f7a0 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -26,8 +26,7 @@ class acp_forums function main($id, $mode) { - global $db, $user, $auth, $template, $cache; - global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx; + global $db, $user, $auth, $template, $cache, $config; $user->add_lang('acp/forums'); $this->tpl_name = 'acp_forums'; @@ -253,13 +252,13 @@ class acp_forums // Redirect to permissions if ($auth->acl_get('a_fauth')) { - $message .= '

' . sprintf($user->lang['REDIRECT_ACL'], '', ''); + $message .= '

' . sprintf($user->lang['REDIRECT_ACL'], '', ''); } // 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.' . PHP_EXT, 'i=permissions' . $acl_url)); } trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); @@ -636,7 +635,7 @@ class acp_forums 'FORUM_NAME' => $forum_data['forum_name'], 'FORUM_DATA_LINK' => $forum_data['forum_link'], 'FORUM_IMAGE' => $forum_data['forum_image'], - 'FORUM_IMAGE_SRC' => ($forum_data['forum_image']) ? $phpbb_root_path . $forum_data['forum_image'] : '', + 'FORUM_IMAGE_SRC' => ($forum_data['forum_image']) ? PHPBB_ROOT_PATH . $forum_data['forum_image'] : '', 'FORUM_POST' => FORUM_POST, 'FORUM_LINK' => FORUM_LINK, 'FORUM_CAT' => FORUM_CAT, @@ -810,8 +809,8 @@ class acp_forums $template->assign_block_vars('forums', array( 'FOLDER_IMAGE' => $folder_image, - 'FORUM_IMAGE' => ($row['forum_image']) ? '' : '', - 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', + 'FORUM_IMAGE' => ($row['forum_image']) ? '' : '', + 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? PHPBB_ROOT_PATH . $row['forum_image'] : '', 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESCRIPTION' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), 'FORUM_TOPICS' => $row['forum_topics'], @@ -1620,9 +1619,9 @@ class acp_forums */ function delete_forum_content($forum_id) { - global $db, $config, $phpbb_root_path, $phpEx; + global $db, $config; - include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); + include_once(PHPBB_ROOT_PATH . 'includes/functions_posting.' . PHP_EXT); $db->sql_transaction('begin'); -- cgit v1.2.1 From eeba8f456003cdcbdd4a6573b6a3b25250bbccef Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 13 Jun 2008 19:44:40 +0000 Subject: Fix some instances where we left db connections open (registration -> captcha for example) git-svn-id: file:///svn/phpbb/trunk@8656 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 4a5db8f7a0..b978bad1bc 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -55,7 +55,7 @@ class acp_forums $total = request_var('total', 0); $this->display_progress_bar($start, $total); - exit_handler(); + exit; break; case 'delete': @@ -73,7 +73,7 @@ class acp_forums { trigger_error($user->lang['NO_PERMISSION_FORUM_ADD'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } - + break; } @@ -99,7 +99,7 @@ class acp_forums $cache->destroy('sql', FORUMS_TABLE); trigger_error($user->lang['FORUM_DELETED'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); - + break; case 'edit': @@ -188,7 +188,7 @@ class acp_forums $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); @@ -244,7 +244,7 @@ class acp_forums $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']; @@ -542,7 +542,7 @@ class acp_forums $forum_type_options = ''; $forum_type_ary = array(FORUM_CAT => 'CAT', FORUM_POST => 'FORUM', FORUM_LINK => 'LINK'); - + foreach ($forum_type_ary as $value => $lang) { $forum_type_options .= ''; @@ -612,7 +612,7 @@ class acp_forums } } } - + if (strlen($forum_data['forum_password']) == 32) { $errors[] = $user->lang['FORUM_PASSWORD_OLD']; @@ -917,7 +917,7 @@ class acp_forums $forum_data['prune_days'] = $forum_data['prune_viewed'] = $forum_data['prune_freq'] = 0; $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'), ); @@ -973,7 +973,7 @@ class acp_forums $forum_data_sql['forum_password'] = phpbb_hash($forum_data_sql['forum_password']); } unset($forum_data_sql['forum_password_unset']); - + if (!isset($forum_data_sql['forum_id'])) { // no forum_id means we're creating a new forum @@ -1631,7 +1631,7 @@ class acp_forums WHERE p.forum_id = $forum_id AND a.in_message = 0 AND a.topic_id = p.topic_id"; - $result = $db->sql_query($sql); + $result = $db->sql_query($sql); $topic_ids = array(); while ($row = $db->sql_fetchrow($result)) @@ -1688,7 +1688,7 @@ class acp_forums break; default: - + // Delete everything else and curse your DB for not offering multi-table deletion $tables_ary = array( 'post_id' => array( -- cgit v1.2.1 From 44416f4744b9a55e35c7945a13759d3e7d71fd3d Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 4 Sep 2008 14:04:30 +0000 Subject: - queue trigger feature - queued posts do not affect user_posts - show links to MCP + queued posts in ucp and acp git-svn-id: file:///svn/phpbb/trunk@8816 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index b978bad1bc..3bd270e23d 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1646,7 +1646,8 @@ class acp_forums $sql = 'SELECT poster_id FROM ' . POSTS_TABLE . ' WHERE forum_id = ' . $forum_id . ' - AND post_postcount = 1'; + AND post_postcount = 1 + AND post_approved = 1'; $result = $db->sql_query($sql); $post_counts = array(); @@ -1766,6 +1767,7 @@ class acp_forums WHERE user_id = ' . $poster_id . ' AND user_posts < ' . $substract; $db->sql_query($sql); + $sql = 'UPDATE ' . USERS_TABLE . ' SET user_posts = user_posts - ' . $substract . ' WHERE user_id = ' . $poster_id . ' -- cgit v1.2.1 From 76c0e5aa5e6cda11b7fef213c11640e3b3943395 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 18 Sep 2008 13:22:15 +0000 Subject: Do not allow setting forums parent to the forum itself. (Bug #18855) git-svn-id: file:///svn/phpbb/trunk@8871 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 3bd270e23d..edeac78d22 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -921,9 +921,8 @@ class acp_forums $range_test_ary = array( array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data['forum_topics_per_page'], 'column_type' => 'TINT:0'), ); - validate_range($range_test_ary, $errors); - + validate_range($range_test_ary, $errors); // Set forum flags // 1 = link tracking @@ -1205,7 +1204,14 @@ class acp_forums if ($row['parent_id'] != $forum_data_sql['parent_id']) { - $errors = $this->move_forum($forum_data_sql['forum_id'], $forum_data_sql['parent_id']); + if ($row['forum_id'] != $forum_data_sql['parent_id']) + { + $errors = $this->move_forum($forum_data_sql['forum_id'], $forum_data_sql['parent_id']); + } + else + { + $forum_data_sql['parent_id'] = $row['parent_id']; + } } if (sizeof($errors)) -- cgit v1.2.1 From 4649b93e0d41cf1133ac4850c52d524227420c80 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Thu, 18 Sep 2008 14:27:27 +0000 Subject: Prevent integer overflow - Bug #19895 git-svn-id: file:///svn/phpbb/trunk@8877 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index edeac78d22..69c44f9edc 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1817,7 +1817,7 @@ class acp_forums $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); - set_config('upload_dir_size', (int) $row['stat'], true); + set_config('upload_dir_size', (float) $row['stat'], true); return array(); } -- cgit v1.2.1 From 6f0ea3c9d241b90e83ba669befcc38cf94bd6849 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 19 Sep 2008 17:07:45 +0000 Subject: do not allow categories to be locked by accident (Bug #14548) git-svn-id: file:///svn/phpbb/trunk@8899 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 69c44f9edc..da32a66fa7 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -153,8 +153,11 @@ class acp_forums if ($forum_data['forum_type'] == FORUM_LINK) { $forum_data['display_on_index'] = request_var('link_display_on_index', false); + } - // Linked forums are not able to be locked... + // Linked forums and categories are not able to be locked... + if ($forum_data['forum_type'] == FORUM_LINK || $forum_data['forum_type'] == FORUM_CAT) + { $forum_data['forum_status'] = ITEM_UNLOCKED; } -- cgit v1.2.1 From 07e9b83a3de0264916a058b9cf180b91b297604f Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Mon, 24 Nov 2008 00:20:33 +0000 Subject: - updated all code to use the request class instead of any direct access to super globals - disabled super globals in common.php. See commit r9101 for more information - cleaned up/simplified a few lines along the way. git-svn-id: file:///svn/phpbb/trunk@9102 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index da32a66fa7..37453f2f34 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -36,7 +36,7 @@ class acp_forums add_form_key($form_key); $action = request_var('action', ''); - $update = (isset($_POST['update'])) ? true : false; + $update = request::is_set_post('update'); $forum_id = request_var('f', 0); $this->parent_id = request_var('parent_id', 0); -- cgit v1.2.1 From 68aa6bd29a0ea8c3e5b981677ace1ac188469bb8 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 24 Dec 2008 14:08:15 +0000 Subject: put acp, mcp and ucp into modules/ directory git-svn-id: file:///svn/phpbb/trunk@9223 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 1931 ------------------------------------- 1 file changed, 1931 deletions(-) delete mode 100644 phpBB/includes/acp/acp_forums.php (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php deleted file mode 100644 index 37453f2f34..0000000000 --- a/phpBB/includes/acp/acp_forums.php +++ /dev/null @@ -1,1931 +0,0 @@ -add_lang('acp/forums'); - $this->tpl_name = 'acp_forums'; - $this->page_title = 'ACP_MANAGE_FORUMS'; - - $form_key = 'acp_forums'; - add_form_key($form_key); - - $action = request_var('action', ''); - $update = request::is_set_post('update'); - $forum_id = request_var('f', 0); - - $this->parent_id = request_var('parent_id', 0); - $forum_data = $errors = array(); - if ($update && !check_form_key($form_key)) - { - $update = false; - $errors[] = $user->lang['FORM_INVALID']; - } - - // Check additional permissions - switch ($action) - { - case 'progress_bar': - $start = request_var('start', 0); - $total = request_var('total', 0); - - $this->display_progress_bar($start, $total); - exit; - break; - - case 'delete': - - if (!$auth->acl_get('a_forumdel')) - { - trigger_error($user->lang['NO_PERMISSION_FORUM_DELETE'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - break; - - case 'add': - - if (!$auth->acl_get('a_forumadd')) - { - trigger_error($user->lang['NO_PERMISSION_FORUM_ADD'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - break; - } - - // Major routines - if ($update) - { - 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); - - $errors = $this->delete_forum($forum_id, $action_posts, $action_subforums, $posts_to_id, $subforums_to_id); - - if (sizeof($errors)) - { - break; - } - - $auth->acl_clear_prefetch(); - $cache->destroy('sql', FORUMS_TABLE); - - trigger_error($user->lang['FORUM_DELETED'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); - - break; - - case 'edit': - $forum_data = array( - 'forum_id' => $forum_id - ); - - // No break here - - 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), - '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_desc_uid' => '', - 'forum_desc_options' => 7, - 'forum_desc_bitfield' => '', - 'forum_rules' => utf8_normalize_nfc(request_var('forum_rules', '', true)), - '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), - '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), - '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), - ); - - // 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); - } - - // Linked forums and categories are not able to be locked... - if ($forum_data['forum_type'] == FORUM_LINK || $forum_data['forum_type'] == FORUM_CAT) - { - $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); - - // 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)); - } - - // 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)); - } - - $errors = $this->update_forum_data($forum_data); - - if (!sizeof($errors)) - { - $forum_perm_from = request_var('forum_perm_from', 0); - - // 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 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); - } - - // 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)) - { - $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'] - ); - } - $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(); - $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']; - - // Redirect to permissions - if ($auth->acl_get('a_fauth')) - { - $message .= '

' . sprintf($user->lang['REDIRECT_ACL'], '', ''); - } - - // 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.' . PHP_EXT, 'i=permissions' . $acl_url)); - } - - trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); - } - - break; - } - } - - switch ($action) - { - case 'move_up': - case 'move_down': - - if (!$forum_id) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - $sql = 'SELECT * - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - $move_forum_name = $this->move_forum_by($row, $action, 1); - - if ($move_forum_name !== false) - { - add_log('admin', 'LOG_FORUM_' . strtoupper($action), $row['forum_name'], $move_forum_name); - $cache->destroy('sql', FORUMS_TABLE); - } - - break; - - case 'sync': - if (!$forum_id) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - @set_time_limit(0); - - $sql = 'SELECT forum_name, forum_topics_real - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - if ($row['forum_topics_real']) - { - $sql = 'SELECT MIN(topic_id) as min_topic_id, MAX(topic_id) as max_topic_id - FROM ' . TOPICS_TABLE . ' - WHERE forum_id = ' . $forum_id; - $result = $db->sql_query($sql); - $row2 = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - // Typecast to int if there is no data available - $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']); - - $batch_size = 2000; - $end = $start + $batch_size; - - // Sync all topics in batch mode... - sync('topic_approved', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, false); - sync('topic', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, true); - - if ($end < $row2['max_topic_id']) - { - // We really need to find a way of showing statistics... no progress here - $sql = 'SELECT COUNT(topic_id) as num_topics - FROM ' . TOPICS_TABLE . ' - 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'); - $db->sql_freeresult($result); - - $start += $batch_size; - - $url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync&start=$start&topics_done=$topics_done&total={$row['forum_topics_real']}"; - - meta_refresh(0, $url); - - $template->assign_vars(array( - 'U_PROGRESS_BAR' => $this->u_action . "&action=progress_bar&start=$topics_done&total={$row['forum_topics_real']}", - 'UA_PROGRESS_BAR' => addslashes($this->u_action . "&action=progress_bar&start=$topics_done&total={$row['forum_topics_real']}"), - 'S_CONTINUE_SYNC' => true, - 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $topics_done, $row['forum_topics_real'])) - ); - - return; - } - } - - $url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync_forum"; - meta_refresh(0, $url); - - $template->assign_vars(array( - 'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar', - 'UA_PROGRESS_BAR' => addslashes($this->u_action . '&action=progress_bar'), - 'S_CONTINUE_SYNC' => true, - 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], 0, $row['forum_topics_real'])) - ); - - return; - - break; - - case 'sync_forum': - - $sql = 'SELECT forum_name, forum_type - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - sync('forum', 'forum_id', $forum_id, false, true); - - add_log('admin', 'LOG_FORUM_SYNC', $row['forum_name']); - $cache->destroy('sql', FORUMS_TABLE); - - $template->assign_var('L_FORUM_RESYNCED', sprintf($user->lang['FORUM_RESYNCED'], $row['forum_name'])); - - break; - - case 'add': - case 'edit': - - 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'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0; - $forum_data['forum_flags'] += (request_var('enable_post_review', true)) ? FORUM_FLAG_POST_REVIEW : 0; - } - - // Show form to create/modify a forum - if ($action == 'edit') - { - $this->page_title = 'EDIT_FORUM'; - $row = $this->get_forum_info($forum_id); - $old_forum_type = $row['forum_type']; - - if (!$update) - { - $forum_data = $row; - } - else - { - $forum_data['left_id'] = $row['left_id']; - $forum_data['right_id'] = $row['right_id']; - } - - // Make sure no direct child forums are able to be selected as parents. - $exclude_forums = array(); - foreach (get_forum_branch($forum_id, 'children') as $row) - { - $exclude_forums[] = $row['forum_id']; - } - - $parents_list = make_forum_select($forum_data['parent_id'], $exclude_forums, false, false, false); - - $forum_data['forum_password_confirm'] = $forum_data['forum_password']; - } - else - { - $this->page_title = 'CREATE_FORUM'; - - $forum_id = $this->parent_id; - $parents_list = make_forum_select($this->parent_id, false, false, false, false); - - // Fill forum data with default values - if (!$update) - { - $forum_data = array( - 'parent_id' => $this->parent_id, - 'forum_type' => FORUM_POST, - 'forum_status' => ITEM_UNLOCKED, - 'forum_name' => utf8_normalize_nfc(request_var('forum_name', '', true)), - 'forum_link' => '', - 'forum_link_track' => false, - 'forum_desc' => '', - 'forum_rules' => '', - 'forum_rules_link' => '', - 'forum_image' => '', - 'forum_style' => 0, - 'display_subforum_list' => true, - 'display_on_index' => false, - 'forum_topics_per_page' => 0, - 'enable_indexing' => true, - 'enable_icons' => false, - 'enable_prune' => false, - 'prune_days' => 7, - 'prune_viewed' => 7, - 'prune_freq' => 1, - 'forum_flags' => FORUM_FLAG_POST_REVIEW, - 'forum_password' => '', - 'forum_password_confirm'=> '', - ); - } - } - - $forum_rules_data = array( - 'text' => $forum_data['forum_rules'], - 'allow_bbcode' => true, - 'allow_smilies' => true, - 'allow_urls' => true - ); - - $forum_desc_data = array( - 'text' => $forum_data['forum_desc'], - 'allow_bbcode' => true, - 'allow_smilies' => true, - 'allow_urls' => true - ); - - $forum_rules_preview = ''; - - // Parse rules if specified - if ($forum_data['forum_rules']) - { - 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... - $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 preview content - $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']); - - // decode... - $forum_rules_data = generate_text_for_edit($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_options']); - } - - // Parse desciption if specified - if ($forum_data['forum_desc']) - { - 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... - $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)); - } - - // decode... - $forum_desc_data = generate_text_for_edit($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_options']); - } - - $forum_type_options = ''; - $forum_type_ary = array(FORUM_CAT => 'CAT', FORUM_POST => 'FORUM', FORUM_LINK => 'LINK'); - - foreach ($forum_type_ary as $value => $lang) - { - $forum_type_options .= ''; - } - - $styles_list = style_select($forum_data['forum_style'], true); - - $statuslist = ''; - - $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)) - { - $template->assign_vars(array( - 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false)) - ); - } - $db->sql_freeresult($result); - - // Subforum move options - if ($action == 'edit' && $forum_data['forum_type'] == FORUM_CAT) - { - $subforums_id = array(); - $subforums = get_forum_branch($forum_id, 'children'); - - foreach ($subforums as $row) - { - $subforums_id[] = $row['forum_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)) - { - $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) - ); - } - - $s_show_display_on_index = false; - - if ($forum_data['parent_id'] > 0) - { - // if this forum is a subforum put the "display on index" checkbox - if ($parent_info = $this->get_forum_info($forum_data['parent_id'])) - { - if ($parent_info['parent_id'] > 0 || $parent_info['forum_type'] == FORUM_CAT) - { - $s_show_display_on_index = true; - } - } - } - - if (strlen($forum_data['forum_password']) == 32) - { - $errors[] = $user->lang['FORUM_PASSWORD_OLD']; - } - - $template->assign_vars(array( - 'S_EDIT_FORUM' => true, - 'S_ERROR' => (sizeof($errors)) ? true : false, - 'S_PARENT_ID' => $this->parent_id, - 'S_FORUM_PARENT_ID' => $forum_data['parent_id'], - 'S_ADD_ACTION' => ($action == 'add') ? true : false, - - 'U_BACK' => $this->u_action . '&parent_id=' . $this->parent_id, - 'U_EDIT_ACTION' => $this->u_action . "&parent_id={$this->parent_id}&action=$action&f=$forum_id", - - 'L_COPY_PERMISSIONS_EXPLAIN' => $user->lang['COPY_PERMISSIONS_' . strtoupper($action) . '_EXPLAIN'], - 'L_TITLE' => $user->lang[$this->page_title], - 'ERROR_MSG' => (sizeof($errors)) ? implode('
', $errors) : '', - - 'FORUM_NAME' => $forum_data['forum_name'], - 'FORUM_DATA_LINK' => $forum_data['forum_link'], - 'FORUM_IMAGE' => $forum_data['forum_image'], - 'FORUM_IMAGE_SRC' => ($forum_data['forum_image']) ? PHPBB_ROOT_PATH . $forum_data['forum_image'] : '', - 'FORUM_POST' => FORUM_POST, - 'FORUM_LINK' => FORUM_LINK, - 'FORUM_CAT' => FORUM_CAT, - 'PRUNE_FREQ' => $forum_data['prune_freq'], - 'PRUNE_DAYS' => $forum_data['prune_days'], - 'PRUNE_VIEWED' => $forum_data['prune_viewed'], - 'TOPICS_PER_PAGE' => $forum_data['forum_topics_per_page'], - 'FORUM_RULES_LINK' => $forum_data['forum_rules_link'], - 'FORUM_RULES' => $forum_data['forum_rules'], - 'FORUM_RULES_PREVIEW' => $forum_rules_preview, - 'FORUM_RULES_PLAIN' => $forum_rules_data['text'], - 'S_BBCODE_CHECKED' => ($forum_rules_data['allow_bbcode']) ? true : false, - 'S_SMILIES_CHECKED' => ($forum_rules_data['allow_smilies']) ? true : false, - 'S_URLS_CHECKED' => ($forum_rules_data['allow_urls']) ? true : false, - 'S_FORUM_PASSWORD_SET' => (empty($forum_data['forum_password'])) ? false : true, - - 'FORUM_DESC' => $forum_desc_data['text'], - 'S_DESC_BBCODE_CHECKED' => ($forum_desc_data['allow_bbcode']) ? true : false, - 'S_DESC_SMILIES_CHECKED' => ($forum_desc_data['allow_smilies']) ? true : false, - 'S_DESC_URLS_CHECKED' => ($forum_desc_data['allow_urls']) ? true : false, - - 'S_FORUM_TYPE_OPTIONS' => $forum_type_options, - 'S_STATUS_OPTIONS' => $statuslist, - 'S_PARENT_OPTIONS' => $parents_list, - 'S_STYLES_OPTIONS' => $styles_list, - 'S_FORUM_OPTIONS' => make_forum_select(($action == 'add') ? $forum_data['parent_id'] : false, ($action == 'edit') ? $forum_data['forum_id'] : false, false, false, false), - 'S_SHOW_DISPLAY_ON_INDEX' => $s_show_display_on_index, - 'S_FORUM_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, - 'S_FORUM_ORIG_POST' => (isset($old_forum_type) && $old_forum_type == FORUM_POST) ? true : false, - 'S_FORUM_ORIG_CAT' => (isset($old_forum_type) && $old_forum_type == FORUM_CAT) ? true : false, - 'S_FORUM_ORIG_LINK' => (isset($old_forum_type) && $old_forum_type == FORUM_LINK) ? true : false, - 'S_FORUM_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false, - 'S_FORUM_CAT' => ($forum_data['forum_type'] == FORUM_CAT) ? true : false, - 'S_ENABLE_INDEXING' => ($forum_data['enable_indexing']) ? true : false, - 'S_TOPIC_ICONS' => ($forum_data['enable_icons']) ? true : false, - 'S_DISPLAY_SUBFORUM_LIST' => ($forum_data['display_subforum_list']) ? true : false, - 'S_DISPLAY_ON_INDEX' => ($forum_data['display_on_index']) ? true : false, - 'S_PRUNE_ENABLE' => ($forum_data['enable_prune']) ? true : false, - 'S_FORUM_LINK_TRACK' => ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? 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_ENABLE_POST_REVIEW' => ($forum_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) ? 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, - )); - - return; - - break; - - case 'delete': - - if (!$forum_id) - { - trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - - $forum_data = $this->get_forum_info($forum_id); - - $subforums_id = array(); - $subforums = get_forum_branch($forum_id, 'children'); - - foreach ($subforums as $row) - { - $subforums_id[] = $row['forum_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)) - { - $template->assign_vars(array( - 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id, false, true)) // , false, true, false??? - ); - } - $db->sql_freeresult($result); - - $parent_id = ($this->parent_id == $forum_id) ? 0 : $this->parent_id; - - $template->assign_vars(array( - 'S_DELETE_FORUM' => true, - 'U_ACTION' => $this->u_action . "&parent_id={$parent_id}&action=delete&f=$forum_id", - 'U_BACK' => $this->u_action . '&parent_id=' . $this->parent_id, - - 'FORUM_NAME' => $forum_data['forum_name'], - 'S_FORUM_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, - 'S_FORUM_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false, - 'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false, - 'S_FORUMS_LIST' => $forums_list, - 'S_ERROR' => (sizeof($errors)) ? true : false, - 'ERROR_MSG' => (sizeof($errors)) ? implode('
', $errors) : '') - ); - - return; - break; - } - - // Default management page - if (!$this->parent_id) - { - $navigation = $user->lang['FORUM_INDEX']; - } - else - { - $navigation = '' . $user->lang['FORUM_INDEX'] . ''; - - $forums_nav = get_forum_branch($this->parent_id, 'parents', 'descending'); - foreach ($forums_nav as $row) - { - if ($row['forum_id'] == $this->parent_id) - { - $navigation .= ' -> ' . $row['forum_name']; - } - else - { - $navigation .= ' -> ' . $row['forum_name'] . ''; - } - } - } - - // Jumpbox - $forum_box = make_forum_select($this->parent_id, false, false, false, false); //make_forum_select($this->parent_id); - - if ($action == 'sync' || $action == 'sync_forum') - { - $template->assign_var('S_RESYNCED', true); - } - - $sql = 'SELECT * - FROM ' . FORUMS_TABLE . " - WHERE parent_id = $this->parent_id - ORDER BY left_id"; - $result = $db->sql_query($sql); - - if ($row = $db->sql_fetchrow($result)) - { - do - { - $forum_type = $row['forum_type']; - - if ($row['forum_status'] == ITEM_LOCKED) - { - $folder_image = '' . $user->lang['LOCKED'] . ''; - } - else - { - switch ($forum_type) - { - case FORUM_LINK: - $folder_image = '' . $user->lang['LINK'] . ''; - break; - - default: - $folder_image = ($row['left_id'] + 1 != $row['right_id']) ? '' . $user->lang['SUBFORUM'] . '' : '' . $user->lang['FOLDER'] . ''; - break; - } - } - - $url = $this->u_action . "&parent_id=$this->parent_id&f={$row['forum_id']}"; - - $forum_title = ($forum_type != FORUM_LINK) ? '' : ''; - $forum_title .= $row['forum_name']; - $forum_title .= ($forum_type != FORUM_LINK) ? '' : ''; - - $template->assign_block_vars('forums', array( - 'FOLDER_IMAGE' => $folder_image, - 'FORUM_IMAGE' => ($row['forum_image']) ? '' : '', - 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? PHPBB_ROOT_PATH . $row['forum_image'] : '', - 'FORUM_NAME' => $row['forum_name'], - 'FORUM_DESCRIPTION' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), - 'FORUM_TOPICS' => $row['forum_topics'], - 'FORUM_POSTS' => $row['forum_posts'], - - 'S_FORUM_LINK' => ($forum_type == FORUM_LINK) ? true : false, - 'S_FORUM_POST' => ($forum_type == FORUM_POST) ? true : false, - - 'U_FORUM' => $this->u_action . '&parent_id=' . $row['forum_id'], - 'U_MOVE_UP' => $url . '&action=move_up', - 'U_MOVE_DOWN' => $url . '&action=move_down', - 'U_EDIT' => $url . '&action=edit', - 'U_DELETE' => $url . '&action=delete', - 'U_SYNC' => $url . '&action=sync') - ); - } - while ($row = $db->sql_fetchrow($result)); - } - else if ($this->parent_id) - { - $row = $this->get_forum_info($this->parent_id); - - $url = $this->u_action . '&parent_id=' . $this->parent_id . '&f=' . $row['forum_id']; - - $template->assign_vars(array( - 'S_NO_FORUMS' => true, - - 'U_EDIT' => $url . '&action=edit', - 'U_DELETE' => $url . '&action=delete', - 'U_SYNC' => $url . '&action=sync') - ); - } - $db->sql_freeresult($result); - - $template->assign_vars(array( - 'ERROR_MSG' => (sizeof($errors)) ? implode('
', $errors) : '', - 'NAVIGATION' => $navigation, - 'FORUM_BOX' => $forum_box, - 'U_SEL_ACTION' => $this->u_action, - 'U_ACTION' => $this->u_action . '&parent_id=' . $this->parent_id, - - 'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar', - 'UA_PROGRESS_BAR' => addslashes($this->u_action . '&action=progress_bar'), - )); - } - - /** - * Get forum details - */ - function get_forum_info($forum_id) - { - global $db; - - $sql = 'SELECT * - FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error("Forum #$forum_id does not exist", E_USER_ERROR); - } - - return $row; - } - - /** - * Update forum data - */ - function update_forum_data(&$forum_data) - { - global $db, $user, $cache; - - $errors = array(); - - if (!$forum_data['forum_name']) - { - $errors[] = $user->lang['FORUM_NAME_EMPTY']; - } - - if (utf8_strlen($forum_data['forum_desc']) > 4000) - { - $errors[] = $user->lang['FORUM_DESC_TOO_LONG']; - } - - if (utf8_strlen($forum_data['forum_rules']) > 4000) - { - $errors[] = $user->lang['FORUM_RULES_TOO_LONG']; - } - - if ($forum_data['forum_password'] || $forum_data['forum_password_confirm']) - { - if ($forum_data['forum_password'] != $forum_data['forum_password_confirm']) - { - $forum_data['forum_password'] = $forum_data['forum_password_confirm'] = ''; - $errors[] = $user->lang['FORUM_PASSWORD_MISMATCH']; - } - } - - if ($forum_data['prune_days'] < 0 || $forum_data['prune_viewed'] < 0 || $forum_data['prune_freq'] < 0) - { - $forum_data['prune_days'] = $forum_data['prune_viewed'] = $forum_data['prune_freq'] = 0; - $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'), - ); - - validate_range($range_test_ary, $errors); - - // Set forum flags - // 1 = link tracking - // 2 = prune old polls - // 4 = prune announcements - // 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; - - // Unset data that are not database fields - $forum_data_sql = $forum_data; - - unset($forum_data_sql['forum_link_track']); - unset($forum_data_sql['prune_old_polls']); - unset($forum_data_sql['prune_announce']); - unset($forum_data_sql['prune_sticky']); - unset($forum_data_sql['show_active']); - unset($forum_data_sql['enable_post_review']); - unset($forum_data_sql['forum_password_confirm']); - - // What are we going to do tonight Brain? The same thing we do everynight, - // try to take over the world ... or decide whether to continue update - // and if so, whether it's a new forum/cat/link or an existing one - if (sizeof($errors)) - { - return $errors; - } - - // As we don't know the old password, it's kinda tricky to detect changes - if ($forum_data_sql['forum_password_unset']) - { - $forum_data_sql['forum_password'] = ''; - } - else if (empty($forum_data_sql['forum_password'])) - { - unset($forum_data_sql['forum_password']); - } - else - { - $forum_data_sql['forum_password'] = phpbb_hash($forum_data_sql['forum_password']); - } - unset($forum_data_sql['forum_password_unset']); - - if (!isset($forum_data_sql['forum_id'])) - { - // no forum_id means we're creating a new forum - unset($forum_data_sql['type_action']); - - if ($forum_data_sql['parent_id']) - { - $sql = 'SELECT left_id, right_id, forum_type - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $forum_data_sql['parent_id']; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - trigger_error($user->lang['PARENT_NOT_EXIST'] . adm_back_link($this->u_action . '&' . $this->parent_id), E_USER_WARNING); - } - - if ($row['forum_type'] == FORUM_LINK) - { - $errors[] = $user->lang['PARENT_IS_LINK_FORUM']; - return $errors; - } - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET left_id = left_id + 2, right_id = right_id + 2 - WHERE left_id > ' . $row['right_id']; - $db->sql_query($sql); - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET right_id = right_id + 2 - WHERE ' . $row['left_id'] . ' BETWEEN left_id AND right_id'; - $db->sql_query($sql); - - $forum_data_sql['left_id'] = $row['right_id']; - $forum_data_sql['right_id'] = $row['right_id'] + 1; - } - else - { - $sql = 'SELECT MAX(right_id) AS right_id - FROM ' . FORUMS_TABLE; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $forum_data_sql['left_id'] = $row['right_id'] + 1; - $forum_data_sql['right_id'] = $row['right_id'] + 2; - } - - $sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $forum_data_sql); - $db->sql_query($sql); - - $forum_data['forum_id'] = $db->sql_nextid(); - - add_log('admin', 'LOG_FORUM_ADD', $forum_data['forum_name']); - } - else - { - $row = $this->get_forum_info($forum_data_sql['forum_id']); - - if ($row['forum_type'] == FORUM_POST && $row['forum_type'] != $forum_data_sql['forum_type']) - { - // Has subforums and want to change into a link? - if ($row['right_id'] - $row['left_id'] > 1 && $forum_data_sql['forum_type'] == FORUM_LINK) - { - $errors[] = $user->lang['FORUM_WITH_SUBFORUMS_NOT_TO_LINK']; - return $errors; - } - - // 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); - - if ($to_forum_id) - { - $errors = $this->move_forum_content($forum_data_sql['forum_id'], $to_forum_id); - } - else - { - return array($user->lang['NO_DESTINATION_FORUM']); - } - } - else if ($forum_data_sql['type_action'] == 'delete') - { - $errors = $this->delete_forum_content($forum_data_sql['forum_id']); - } - else - { - return array($user->lang['NO_FORUM_ACTION']); - } - - $forum_data_sql['forum_posts'] = $forum_data_sql['forum_topics'] = $forum_data_sql['forum_topics_real'] = $forum_data_sql['forum_last_post_id'] = $forum_data_sql['forum_last_poster_id'] = $forum_data_sql['forum_last_post_time'] = 0; - $forum_data_sql['forum_last_poster_name'] = $forum_data_sql['forum_last_poster_colour'] = ''; - } - else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_LINK) - { - // Has 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); - - if ($action_subforums == 'delete') - { - $rows = get_forum_branch($row['forum_id'], 'children', 'descending', false); - - foreach ($rows as $_row) - { - // Do not remove the forum id we are about to change. ;) - if ($_row['forum_id'] == $row['forum_id']) - { - continue; - } - - $forum_ids[] = $_row['forum_id']; - $errors = array_merge($errors, $this->delete_forum_content($_row['forum_id'])); - } - - if (sizeof($errors)) - { - return $errors; - } - - if (sizeof($forum_ids)) - { - $sql = 'DELETE FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - - // Delete forum ids from extension groups table - $sql = 'SELECT group_id, allowed_forums - FROM ' . EXTENSION_GROUPS_TABLE; - $result = $db->sql_query($sql); - - while ($_row = $db->sql_fetchrow($result)) - { - if (!$_row['allowed_forums']) - { - continue; - } - - $allowed_forums = unserialize(trim($_row['allowed_forums'])); - $allowed_forums = array_diff($allowed_forums, $forum_ids); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . " - SET allowed_forums = '" . ((sizeof($allowed_forums)) ? serialize($allowed_forums) : '') . "' - WHERE group_id = {$_row['group_id']}"; - $db->sql_query($sql); - } - $db->sql_freeresult($result); - - $cache->destroy('_extensions'); - } - } - else if ($action_subforums == 'move') - { - if (!$subforums_to_id) - { - return array($user->lang['NO_DESTINATION_FORUM']); - } - - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $subforums_to_id; - $result = $db->sql_query($sql); - $_row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$_row) - { - return array($user->lang['NO_FORUM']); - } - - $subforums_to_name = $_row['forum_name']; - - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . " - WHERE parent_id = {$row['forum_id']}"; - $result = $db->sql_query($sql); - - while ($_row = $db->sql_fetchrow($result)) - { - $this->move_forum($_row['forum_id'], $subforums_to_id); - } - $db->sql_freeresult($result); - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET parent_id = $subforums_to_id - WHERE parent_id = {$row['forum_id']}"; - $db->sql_query($sql); - } - - // Adjust the left/right id - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET right_id = left_id + 1 - WHERE forum_id = ' . $row['forum_id']; - $db->sql_query($sql); - } - } - else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_POST) - { - // Changing a category to a forum? Reset the data (you can't post directly in a cat, you must use a forum) - $forum_data_sql['forum_posts'] = 0; - $forum_data_sql['forum_topics'] = 0; - $forum_data_sql['forum_topics_real'] = 0; - $forum_data_sql['forum_last_post_id'] = 0; - $forum_data_sql['forum_last_post_subject'] = ''; - $forum_data_sql['forum_last_post_time'] = 0; - $forum_data_sql['forum_last_poster_id'] = 0; - $forum_data_sql['forum_last_poster_name'] = ''; - $forum_data_sql['forum_last_poster_colour'] = ''; - } - - if (sizeof($errors)) - { - return $errors; - } - - if ($row['parent_id'] != $forum_data_sql['parent_id']) - { - if ($row['forum_id'] != $forum_data_sql['parent_id']) - { - $errors = $this->move_forum($forum_data_sql['forum_id'], $forum_data_sql['parent_id']); - } - else - { - $forum_data_sql['parent_id'] = $row['parent_id']; - } - } - - if (sizeof($errors)) - { - return $errors; - } - - unset($forum_data_sql['type_action']); - - if ($row['forum_name'] != $forum_data_sql['forum_name']) - { - // the forum name has changed, clear the parents list of all forums (for safety) - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET forum_parents = ''"; - $db->sql_query($sql); - } - - // Setting the forum id to the forum id is not really received well by some dbs. ;) - $forum_id = $forum_data_sql['forum_id']; - unset($forum_data_sql['forum_id']); - - $sql = 'UPDATE ' . FORUMS_TABLE . ' - SET ' . $db->sql_build_array('UPDATE', $forum_data_sql) . ' - WHERE forum_id = ' . $forum_id; - $db->sql_query($sql); - - // Add it back - $forum_data['forum_id'] = $forum_id; - - add_log('admin', 'LOG_FORUM_EDIT', $forum_data['forum_name']); - } - - return $errors; - } - - /** - * Move forum - */ - function move_forum($from_id, $to_id) - { - global $db, $user; - - $to_data = $moved_ids = $errors = array(); - - // Check if we want to move to a parent with link type - if ($to_id > 0) - { - $to_data = $this->get_forum_info($to_id); - - if ($to_data['forum_type'] == FORUM_LINK) - { - $errors[] = $user->lang['PARENT_IS_LINK_FORUM']; - return $errors; - } - } - - $moved_forums = get_forum_branch($from_id, 'children', 'descending'); - $from_data = $moved_forums[0]; - $diff = sizeof($moved_forums) * 2; - - $moved_ids = array(); - for ($i = 0; $i < sizeof($moved_forums); ++$i) - { - $moved_ids[] = $moved_forums[$i]['forum_id']; - } - - // Resync parents - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET right_id = right_id - $diff, forum_parents = '' - WHERE left_id < " . $from_data['right_id'] . " - AND right_id > " . $from_data['right_id']; - $db->sql_query($sql); - - // Resync righthand side of tree - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id - $diff, right_id = right_id - $diff, forum_parents = '' - WHERE left_id > " . $from_data['right_id']; - $db->sql_query($sql); - - if ($to_id > 0) - { - // Retrieve $to_data again, it may have been changed... - $to_data = $this->get_forum_info($to_id); - - // Resync new parents - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET right_id = right_id + $diff, forum_parents = '' - WHERE " . $to_data['right_id'] . ' BETWEEN left_id AND right_id - AND ' . $db->sql_in_set('forum_id', $moved_ids, true); - $db->sql_query($sql); - - // Resync the righthand side of the tree - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id + $diff, right_id = right_id + $diff, forum_parents = '' - WHERE left_id > " . $to_data['right_id'] . ' - AND ' . $db->sql_in_set('forum_id', $moved_ids, true); - $db->sql_query($sql); - - // Resync moved branch - $to_data['right_id'] += $diff; - - if ($to_data['right_id'] > $from_data['right_id']) - { - $diff = '+ ' . ($to_data['right_id'] - $from_data['right_id'] - 1); - } - else - { - $diff = '- ' . abs($to_data['right_id'] - $from_data['right_id'] - 1); - } - } - else - { - $sql = 'SELECT MAX(right_id) AS right_id - FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $moved_ids, true); - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - $diff = '+ ' . ($row['right_id'] - $from_data['left_id'] + 1); - } - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id $diff, right_id = right_id $diff, forum_parents = '' - WHERE " . $db->sql_in_set('forum_id', $moved_ids); - $db->sql_query($sql); - - return $errors; - } - - /** - * Move forum content from one to another forum - */ - function move_forum_content($from_id, $to_id, $sync = true) - { - global $db; - - $table_ary = array(LOG_TABLE, POSTS_TABLE, TOPICS_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); - - foreach ($table_ary as $table) - { - $sql = "UPDATE $table - SET forum_id = $to_id - WHERE forum_id = $from_id"; - $db->sql_query($sql); - } - unset($table_ary); - - $table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, MODERATOR_CACHE_TABLE); - - foreach ($table_ary as $table) - { - $sql = "DELETE FROM $table - WHERE forum_id = $from_id"; - $db->sql_query($sql); - } - - if ($sync) - { - // Delete ghost topics that link back to the same forum then resync counters - sync('topic_moved'); - sync('forum', 'forum_id', $to_id, false, true); - } - - return array(); - } - - /** - * Remove complete forum - */ - function delete_forum($forum_id, $action_posts = 'delete', $action_subforums = 'delete', $posts_to_id = 0, $subforums_to_id = 0) - { - global $db, $user, $cache; - - $forum_data = $this->get_forum_info($forum_id); - - $errors = array(); - $log_action_posts = $log_action_forums = $posts_to_name = $subforums_to_name = ''; - $forum_ids = array($forum_id); - - if ($action_posts == 'delete') - { - $log_action_posts = 'POSTS'; - $errors = array_merge($errors, $this->delete_forum_content($forum_id)); - } - else if ($action_posts == 'move') - { - if (!$posts_to_id) - { - $errors[] = $user->lang['NO_DESTINATION_FORUM']; - } - else - { - $log_action_posts = 'MOVE_POSTS'; - - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $posts_to_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $errors[] = $user->lang['NO_FORUM']; - } - else - { - $posts_to_name = $row['forum_name']; - $errors = array_merge($errors, $this->move_forum_content($forum_id, $posts_to_id)); - } - } - } - - if (sizeof($errors)) - { - return $errors; - } - - if ($action_subforums == 'delete') - { - $log_action_forums = 'FORUMS'; - $rows = get_forum_branch($forum_id, 'children', 'descending', false); - - foreach ($rows as $row) - { - $forum_ids[] = $row['forum_id']; - $errors = array_merge($errors, $this->delete_forum_content($row['forum_id'])); - } - - if (sizeof($errors)) - { - return $errors; - } - - $diff = sizeof($forum_ids) * 2; - - $sql = 'DELETE FROM ' . FORUMS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' - WHERE ' . $db->sql_in_set('forum_id', $forum_ids); - $db->sql_query($sql); - } - else if ($action_subforums == 'move') - { - if (!$subforums_to_id) - { - $errors[] = $user->lang['NO_DESTINATION_FORUM']; - } - else - { - $log_action_forums = 'MOVE_FORUMS'; - - $sql = 'SELECT forum_name - FROM ' . FORUMS_TABLE . ' - WHERE forum_id = ' . $subforums_to_id; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - if (!$row) - { - $errors[] = $user->lang['NO_FORUM']; - } - else - { - $subforums_to_name = $row['forum_name']; - - $sql = 'SELECT forum_id - FROM ' . FORUMS_TABLE . " - WHERE parent_id = $forum_id"; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - $this->move_forum($row['forum_id'], $subforums_to_id); - } - $db->sql_freeresult($result); - - // Grab new forum data for correct tree updating later - $forum_data = $this->get_forum_info($forum_id); - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET parent_id = $subforums_to_id - WHERE parent_id = $forum_id"; - $db->sql_query($sql); - - $diff = 2; - $sql = 'DELETE FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - } - } - - if (sizeof($errors)) - { - return $errors; - } - } - else - { - $diff = 2; - $sql = 'DELETE FROM ' . FORUMS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - - $sql = 'DELETE FROM ' . ACL_USERS_TABLE . " - WHERE forum_id = $forum_id"; - $db->sql_query($sql); - } - - // Resync tree - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET right_id = right_id - $diff - WHERE left_id < {$forum_data['right_id']} AND right_id > {$forum_data['right_id']}"; - $db->sql_query($sql); - - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id - $diff, right_id = right_id - $diff - WHERE left_id > {$forum_data['right_id']}"; - $db->sql_query($sql); - - // Delete forum ids from extension groups table - $sql = 'SELECT group_id, allowed_forums - FROM ' . EXTENSION_GROUPS_TABLE; - $result = $db->sql_query($sql); - - while ($row = $db->sql_fetchrow($result)) - { - if (!$row['allowed_forums']) - { - continue; - } - - $allowed_forums = unserialize(trim($row['allowed_forums'])); - $allowed_forums = array_diff($allowed_forums, $forum_ids); - - $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . " - SET allowed_forums = '" . ((sizeof($allowed_forums)) ? serialize($allowed_forums) : '') . "' - WHERE group_id = {$row['group_id']}"; - $db->sql_query($sql); - } - $db->sql_freeresult($result); - - $cache->destroy('_extensions'); - - $log_action = implode('_', array($log_action_posts, $log_action_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']); - break; - - case 'MOVE_POSTS_FORUMS': - add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS_FORUMS', $posts_to_name, $forum_data['forum_name']); - break; - - case 'POSTS_MOVE_FORUMS': - add_log('admin', 'LOG_FORUM_DEL_POSTS_MOVE_FORUMS', $subforums_to_name, $forum_data['forum_name']); - break; - - case '_MOVE_FORUMS': - add_log('admin', 'LOG_FORUM_DEL_MOVE_FORUMS', $subforums_to_name, $forum_data['forum_name']); - break; - - case 'MOVE_POSTS_': - add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS', $posts_to_name, $forum_data['forum_name']); - break; - - case 'POSTS_FORUMS': - add_log('admin', 'LOG_FORUM_DEL_POSTS_FORUMS', $forum_data['forum_name']); - break; - - case '_FORUMS': - add_log('admin', 'LOG_FORUM_DEL_FORUMS', $forum_data['forum_name']); - break; - - case 'POSTS_': - add_log('admin', 'LOG_FORUM_DEL_POSTS', $forum_data['forum_name']); - break; - - default: - add_log('admin', 'LOG_FORUM_DEL_FORUM', $forum_data['forum_name']); - break; - } - - return $errors; - } - - /** - * Delete forum content - */ - function delete_forum_content($forum_id) - { - global $db, $config; - - include_once(PHPBB_ROOT_PATH . 'includes/functions_posting.' . PHP_EXT); - - $db->sql_transaction('begin'); - - // Select then delete all attachments - $sql = 'SELECT a.topic_id - FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a - WHERE p.forum_id = $forum_id - AND a.in_message = 0 - AND a.topic_id = p.topic_id"; - $result = $db->sql_query($sql); - - $topic_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - delete_attachments('topic', $topic_ids, false); - - // Before we remove anything we make sure we are able to adjust the post counts later. ;) - $sql = 'SELECT poster_id - FROM ' . POSTS_TABLE . ' - WHERE forum_id = ' . $forum_id . ' - AND post_postcount = 1 - AND post_approved = 1'; - $result = $db->sql_query($sql); - - $post_counts = array(); - while ($row = $db->sql_fetchrow($result)) - { - $post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1; - } - $db->sql_freeresult($result); - - switch ($db->dbms_type) - { - case 'mysql': - - // Delete everything else and thank MySQL for offering multi-table deletion - $tables_ary = array( - SEARCH_WORDMATCH_TABLE => 'post_id', - REPORTS_TABLE => 'post_id', - WARNINGS_TABLE => 'post_id', - BOOKMARKS_TABLE => 'topic_id', - TOPICS_WATCH_TABLE => 'topic_id', - TOPICS_POSTED_TABLE => 'topic_id', - POLL_OPTIONS_TABLE => 'topic_id', - POLL_VOTES_TABLE => 'topic_id', - ); - - $sql = 'DELETE ' . POSTS_TABLE; - $sql_using = "\nFROM " . POSTS_TABLE; - $sql_where = "\nWHERE " . POSTS_TABLE . ".forum_id = $forum_id\n"; - - foreach ($tables_ary as $table => $field) - { - $sql .= ", $table "; - $sql_using .= ", $table "; - $sql_where .= "\nAND $table.$field = " . POSTS_TABLE . ".$field"; - } - - $db->sql_query($sql . $sql_using . $sql_where); - - break; - - default: - - // Delete everything else and curse your DB for not offering multi-table deletion - $tables_ary = array( - 'post_id' => array( - SEARCH_WORDMATCH_TABLE, - REPORTS_TABLE, - WARNINGS_TABLE, - ), - - 'topic_id' => array( - BOOKMARKS_TABLE, - TOPICS_WATCH_TABLE, - TOPICS_POSTED_TABLE, - POLL_OPTIONS_TABLE, - POLL_VOTES_TABLE, - ) - ); - - foreach ($tables_ary as $field => $tables) - { - $start = 0; - - do - { - $sql = "SELECT $field - FROM " . POSTS_TABLE . ' - WHERE forum_id = ' . $forum_id; - $result = $db->sql_query_limit($sql, 500, $start); - - $ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $ids[] = $row[$field]; - } - $db->sql_freeresult($result); - - if (sizeof($ids)) - { - $start += sizeof($ids); - - foreach ($tables as $table) - { - $db->sql_query("DELETE FROM $table WHERE " . $db->sql_in_set($field, $ids)); - } - } - } - while ($row); - } - unset($ids); - - break; - } - - $table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, LOG_TABLE, MODERATOR_CACHE_TABLE, POSTS_TABLE, TOPICS_TABLE, TOPICS_TRACK_TABLE); - - foreach ($table_ary as $table) - { - $db->sql_query("DELETE FROM $table WHERE forum_id = $forum_id"); - } - - // Set forum ids to 0 - $table_ary = array(DRAFTS_TABLE); - - foreach ($table_ary as $table) - { - $db->sql_query("UPDATE $table SET forum_id = 0 WHERE forum_id = $forum_id"); - } - - // Adjust users post counts - if (sizeof($post_counts)) - { - foreach ($post_counts as $poster_id => $substract) - { - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = 0 - WHERE user_id = ' . $poster_id . ' - AND user_posts < ' . $substract; - $db->sql_query($sql); - - $sql = 'UPDATE ' . USERS_TABLE . ' - SET user_posts = user_posts - ' . $substract . ' - WHERE user_id = ' . $poster_id . ' - AND user_posts >= ' . $substract; - $db->sql_query($sql); - } - } - - $db->sql_transaction('commit'); - - // Make sure the overall post/topic count is correct... - $sql = 'SELECT COUNT(post_id) AS stat - FROM ' . POSTS_TABLE . ' - WHERE post_approved = 1'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - set_config('num_posts', (int) $row['stat'], true); - - $sql = 'SELECT COUNT(topic_id) AS stat - FROM ' . TOPICS_TABLE . ' - WHERE topic_approved = 1'; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - set_config('num_topics', (int) $row['stat'], true); - - $sql = 'SELECT COUNT(attach_id) as stat - FROM ' . ATTACHMENTS_TABLE; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - set_config('num_files', (int) $row['stat'], true); - - $sql = 'SELECT SUM(filesize) as stat - FROM ' . ATTACHMENTS_TABLE; - $result = $db->sql_query($sql); - $row = $db->sql_fetchrow($result); - $db->sql_freeresult($result); - - set_config('upload_dir_size', (float) $row['stat'], true); - - return array(); - } - - /** - * Move forum position by $steps up/down - */ - function move_forum_by($forum_row, $action = 'move_up', $steps = 1) - { - global $db; - - /** - * Fetch all the siblings between the module's current spot - * and where we want to move it to. If there are less than $steps - * siblings between the current spot and the target then the - * module will move as far as possible - */ - $sql = 'SELECT forum_id, forum_name, left_id, right_id - FROM ' . FORUMS_TABLE . " - WHERE parent_id = {$forum_row['parent_id']} - 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"); - $result = $db->sql_query_limit($sql, $steps); - - $target = array(); - while ($row = $db->sql_fetchrow($result)) - { - $target = $row; - } - $db->sql_freeresult($result); - - if (!sizeof($target)) - { - // The forum is already on top or bottom - return false; - } - - /** - * $left_id and $right_id define the scope of the nodes that are affected by the move. - * $diff_up and $diff_down are the values to substract or add to each node's left_id - * and right_id in order to move them up or down. - * $move_up_left and $move_up_right define the scope of the nodes that are moving - * up. Other nodes in the scope of ($left_id, $right_id) are considered to move down. - */ - if ($action == 'move_up') - { - $left_id = $target['left_id']; - $right_id = $forum_row['right_id']; - - $diff_up = $forum_row['left_id'] - $target['left_id']; - $diff_down = $forum_row['right_id'] + 1 - $forum_row['left_id']; - - $move_up_left = $forum_row['left_id']; - $move_up_right = $forum_row['right_id']; - } - else - { - $left_id = $forum_row['left_id']; - $right_id = $target['right_id']; - - $diff_up = $forum_row['right_id'] + 1 - $forum_row['left_id']; - $diff_down = $target['right_id'] - $forum_row['right_id']; - - $move_up_left = $forum_row['right_id'] + 1; - $move_up_right = $target['right_id']; - } - - // Now do the dirty job - $sql = 'UPDATE ' . FORUMS_TABLE . " - SET left_id = left_id + CASE - WHEN left_id BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up} - ELSE {$diff_down} - END, - right_id = right_id + CASE - WHEN right_id BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up} - ELSE {$diff_down} - END, - forum_parents = '' - WHERE - left_id BETWEEN {$left_id} AND {$right_id} - AND right_id BETWEEN {$left_id} AND {$right_id}"; - $db->sql_query($sql); - - return $target['forum_name']; - } - - /** - * Display progress bar for syncinc forums - */ - function display_progress_bar($start, $total) - { - global $template, $user; - - adm_page_header($user->lang['SYNC_IN_PROGRESS']); - - $template->set_filenames(array( - 'body' => 'progress_bar.html') - ); - - $template->assign_vars(array( - 'L_PROGRESS' => $user->lang['SYNC_IN_PROGRESS'], - 'L_PROGRESS_EXPLAIN' => ($start && $total) ? sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $start, $total) : $user->lang['SYNC_IN_PROGRESS']) - ); - - adm_page_footer(); - } -} - -?> \ No newline at end of file -- cgit v1.2.1 From 2e17e448deed073f8614bb555a8ef20c57291c2a Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Sun, 4 Oct 2009 18:14:59 +0000 Subject: Copy 3.0.x branch to trunk git-svn-id: file:///svn/phpbb/trunk@10211 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 1947 +++++++++++++++++++++++++++++++++++++ 1 file changed, 1947 insertions(+) create mode 100644 phpBB/includes/acp/acp_forums.php (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php new file mode 100644 index 0000000000..2ff597ee98 --- /dev/null +++ b/phpBB/includes/acp/acp_forums.php @@ -0,0 +1,1947 @@ +add_lang('acp/forums'); + $this->tpl_name = 'acp_forums'; + $this->page_title = 'ACP_MANAGE_FORUMS'; + + $form_key = 'acp_forums'; + add_form_key($form_key); + + $action = request_var('action', ''); + $update = (isset($_POST['update'])) ? true : false; + $forum_id = request_var('f', 0); + + $this->parent_id = request_var('parent_id', 0); + $forum_data = $errors = array(); + if ($update && !check_form_key($form_key)) + { + $update = false; + $errors[] = $user->lang['FORM_INVALID']; + } + + // Check additional permissions + switch ($action) + { + case 'progress_bar': + $start = request_var('start', 0); + $total = request_var('total', 0); + + $this->display_progress_bar($start, $total); + exit; + break; + + case 'delete': + + if (!$auth->acl_get('a_forumdel')) + { + trigger_error($user->lang['NO_PERMISSION_FORUM_DELETE'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + } + + break; + + case 'add': + + if (!$auth->acl_get('a_forumadd')) + { + trigger_error($user->lang['NO_PERMISSION_FORUM_ADD'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + } + + case 'copy_perm': + + if (!(($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')))) + { + trigger_error($user->lang['NO_PERMISSION_COPY'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + } + + break; + } + + // Major routines + if ($update) + { + 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); + + $errors = $this->delete_forum($forum_id, $action_posts, $action_subforums, $posts_to_id, $subforums_to_id); + + if (sizeof($errors)) + { + break; + } + + $auth->acl_clear_prefetch(); + $cache->destroy('sql', FORUMS_TABLE); + + trigger_error($user->lang['FORUM_DELETED'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); + + break; + + case 'edit': + $forum_data = array( + 'forum_id' => $forum_id + ); + + // No break here + + 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), + 'forum_parents' => '', + 'forum_options' => 0, + '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_desc_uid' => '', + 'forum_desc_options' => 7, + 'forum_desc_bitfield' => '', + 'forum_rules' => utf8_normalize_nfc(request_var('forum_rules', '', true)), + '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), + '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), + '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), + ); + + // 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); + } + + // Linked forums and categories are not able to be locked... + if ($forum_data['forum_type'] == FORUM_LINK || $forum_data['forum_type'] == FORUM_CAT) + { + $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', true); + + // 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)); + } + + // 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)); + } + + $errors = $this->update_forum_data($forum_data); + + if (!sizeof($errors)) + { + $forum_perm_from = request_var('forum_perm_from', 0); + $cache->destroy('sql', FORUMS_TABLE); + + // Copy permissions? + 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')))) + { + copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false); + cache_moderators(); + } +/* 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')) + { + $this->copy_permission_page($forum_data); + return; + } +*/ + $auth->acl_clear_prefetch(); + + $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')) + { + $message .= '

' . sprintf($user->lang['REDIRECT_ACL'], '', ''); + } + + // 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)); + } + + trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); + } + + break; + } + } + + switch ($action) + { + case 'move_up': + case 'move_down': + + if (!$forum_id) + { + trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + } + + $sql = 'SELECT * + FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row) + { + trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + } + + $move_forum_name = $this->move_forum_by($row, $action, 1); + + if ($move_forum_name !== false) + { + add_log('admin', 'LOG_FORUM_' . strtoupper($action), $row['forum_name'], $move_forum_name); + $cache->destroy('sql', FORUMS_TABLE); + } + + break; + + case 'sync': + if (!$forum_id) + { + trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + } + + @set_time_limit(0); + + $sql = 'SELECT forum_name, forum_topics_real + FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row) + { + trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + } + + if ($row['forum_topics_real']) + { + $sql = 'SELECT MIN(topic_id) as min_topic_id, MAX(topic_id) as max_topic_id + FROM ' . TOPICS_TABLE . ' + WHERE forum_id = ' . $forum_id; + $result = $db->sql_query($sql); + $row2 = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + // Typecast to int if there is no data available + $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']); + + $batch_size = 2000; + $end = $start + $batch_size; + + // Sync all topics in batch mode... + sync('topic_approved', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, false); + sync('topic', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, true); + + if ($end < $row2['max_topic_id']) + { + // We really need to find a way of showing statistics... no progress here + $sql = 'SELECT COUNT(topic_id) as num_topics + FROM ' . TOPICS_TABLE . ' + 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'); + $db->sql_freeresult($result); + + $start += $batch_size; + + $url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync&start=$start&topics_done=$topics_done&total={$row['forum_topics_real']}"; + + meta_refresh(0, $url); + + $template->assign_vars(array( + 'U_PROGRESS_BAR' => $this->u_action . "&action=progress_bar&start=$topics_done&total={$row['forum_topics_real']}", + 'UA_PROGRESS_BAR' => addslashes($this->u_action . "&action=progress_bar&start=$topics_done&total={$row['forum_topics_real']}"), + 'S_CONTINUE_SYNC' => true, + 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $topics_done, $row['forum_topics_real'])) + ); + + return; + } + } + + $url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync_forum"; + meta_refresh(0, $url); + + $template->assign_vars(array( + 'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar', + 'UA_PROGRESS_BAR' => addslashes($this->u_action . '&action=progress_bar'), + 'S_CONTINUE_SYNC' => true, + 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], 0, $row['forum_topics_real'])) + ); + + return; + + break; + + case 'sync_forum': + + $sql = 'SELECT forum_name, forum_type + FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row) + { + trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + } + + sync('forum', 'forum_id', $forum_id, false, true); + + add_log('admin', 'LOG_FORUM_SYNC', $row['forum_name']); + $cache->destroy('sql', FORUMS_TABLE); + + $template->assign_var('L_FORUM_RESYNCED', sprintf($user->lang['FORUM_RESYNCED'], $row['forum_name'])); + + break; + + case 'add': + case 'edit': + + 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'] += ($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 + if ($action == 'edit') + { + $this->page_title = 'EDIT_FORUM'; + $row = $this->get_forum_info($forum_id); + $old_forum_type = $row['forum_type']; + + if (!$update) + { + $forum_data = $row; + } + else + { + $forum_data['left_id'] = $row['left_id']; + $forum_data['right_id'] = $row['right_id']; + } + + // Make sure no direct child forums are able to be selected as parents. + $exclude_forums = array(); + foreach (get_forum_branch($forum_id, 'children') as $row) + { + $exclude_forums[] = $row['forum_id']; + } + + $parents_list = make_forum_select($forum_data['parent_id'], $exclude_forums, false, false, false); + + $forum_data['forum_password_confirm'] = $forum_data['forum_password']; + } + else + { + $this->page_title = 'CREATE_FORUM'; + + $forum_id = $this->parent_id; + $parents_list = make_forum_select($this->parent_id, false, false, false, false); + + // Fill forum data with default values + if (!$update) + { + $forum_data = array( + 'parent_id' => $this->parent_id, + 'forum_type' => FORUM_POST, + 'forum_status' => ITEM_UNLOCKED, + 'forum_name' => utf8_normalize_nfc(request_var('forum_name', '', true)), + 'forum_link' => '', + 'forum_link_track' => false, + 'forum_desc' => '', + 'forum_rules' => '', + 'forum_rules_link' => '', + 'forum_image' => '', + 'forum_style' => 0, + 'display_subforum_list' => true, + 'display_on_index' => false, + 'forum_topics_per_page' => 0, + 'enable_indexing' => true, + 'enable_icons' => false, + 'enable_prune' => false, + 'prune_days' => 7, + 'prune_viewed' => 7, + 'prune_freq' => 1, + 'forum_flags' => FORUM_FLAG_POST_REVIEW + FORUM_FLAG_ACTIVE_TOPICS, + 'forum_options' => 0, + 'forum_password' => '', + 'forum_password_confirm'=> '', + ); + } + } + + $forum_rules_data = array( + 'text' => $forum_data['forum_rules'], + 'allow_bbcode' => true, + 'allow_smilies' => true, + 'allow_urls' => true + ); + + $forum_desc_data = array( + 'text' => $forum_data['forum_desc'], + 'allow_bbcode' => true, + 'allow_smilies' => true, + 'allow_urls' => true + ); + + $forum_rules_preview = ''; + + // Parse rules if specified + if ($forum_data['forum_rules']) + { + 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... + $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 preview content + $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']); + + // decode... + $forum_rules_data = generate_text_for_edit($forum_data['forum_rules'], $forum_data['forum_rules_uid'], $forum_data['forum_rules_options']); + } + + // Parse desciption if specified + if ($forum_data['forum_desc']) + { + 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... + $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)); + } + + // decode... + $forum_desc_data = generate_text_for_edit($forum_data['forum_desc'], $forum_data['forum_desc_uid'], $forum_data['forum_desc_options']); + } + + $forum_type_options = ''; + $forum_type_ary = array(FORUM_CAT => 'CAT', FORUM_POST => 'FORUM', FORUM_LINK => 'LINK'); + + foreach ($forum_type_ary as $value => $lang) + { + $forum_type_options .= ''; + } + + $styles_list = style_select($forum_data['forum_style'], true); + + $statuslist = ''; + + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . ' + WHERE forum_type = ' . FORUM_POST . " + AND forum_id <> $forum_id"; + $result = $db->sql_query_limit($sql, 1); + + $postable_forum_exists = false; + if ($db->sql_fetchrow($result)) + { + $postable_forum_exists = true; + } + $db->sql_freeresult($result); + + // Subforum move options + if ($action == 'edit' && $forum_data['forum_type'] == FORUM_CAT) + { + $subforums_id = array(); + $subforums = get_forum_branch($forum_id, 'children'); + + foreach ($subforums as $row) + { + $subforums_id[] = $row['forum_id']; + } + + $forums_list = make_forum_select($forum_data['parent_id'], $subforums_id); + + 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_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)) + ); + } + + $s_show_display_on_index = false; + + if ($forum_data['parent_id'] > 0) + { + // if this forum is a subforum put the "display on index" checkbox + if ($parent_info = $this->get_forum_info($forum_data['parent_id'])) + { + if ($parent_info['parent_id'] > 0 || $parent_info['forum_type'] == FORUM_CAT) + { + $s_show_display_on_index = true; + } + } + } + + if (strlen($forum_data['forum_password']) == 32) + { + $errors[] = $user->lang['FORUM_PASSWORD_OLD']; + } + + $template->assign_vars(array( + 'S_EDIT_FORUM' => true, + 'S_ERROR' => (sizeof($errors)) ? true : false, + 'S_PARENT_ID' => $this->parent_id, + 'S_FORUM_PARENT_ID' => $forum_data['parent_id'], + 'S_ADD_ACTION' => ($action == 'add') ? true : false, + + 'U_BACK' => $this->u_action . '&parent_id=' . $this->parent_id, + 'U_EDIT_ACTION' => $this->u_action . "&parent_id={$this->parent_id}&action=$action&f=$forum_id", + + 'L_COPY_PERMISSIONS_EXPLAIN' => $user->lang['COPY_PERMISSIONS_' . strtoupper($action) . '_EXPLAIN'], + 'L_TITLE' => $user->lang[$this->page_title], + 'ERROR_MSG' => (sizeof($errors)) ? implode('
', $errors) : '', + + 'FORUM_NAME' => $forum_data['forum_name'], + 'FORUM_DATA_LINK' => $forum_data['forum_link'], + 'FORUM_IMAGE' => $forum_data['forum_image'], + 'FORUM_IMAGE_SRC' => ($forum_data['forum_image']) ? $phpbb_root_path . $forum_data['forum_image'] : '', + 'FORUM_POST' => FORUM_POST, + 'FORUM_LINK' => FORUM_LINK, + 'FORUM_CAT' => FORUM_CAT, + 'PRUNE_FREQ' => $forum_data['prune_freq'], + 'PRUNE_DAYS' => $forum_data['prune_days'], + 'PRUNE_VIEWED' => $forum_data['prune_viewed'], + 'TOPICS_PER_PAGE' => $forum_data['forum_topics_per_page'], + 'FORUM_RULES_LINK' => $forum_data['forum_rules_link'], + 'FORUM_RULES' => $forum_data['forum_rules'], + 'FORUM_RULES_PREVIEW' => $forum_rules_preview, + 'FORUM_RULES_PLAIN' => $forum_rules_data['text'], + 'S_BBCODE_CHECKED' => ($forum_rules_data['allow_bbcode']) ? true : false, + 'S_SMILIES_CHECKED' => ($forum_rules_data['allow_smilies']) ? true : false, + 'S_URLS_CHECKED' => ($forum_rules_data['allow_urls']) ? true : false, + 'S_FORUM_PASSWORD_SET' => (empty($forum_data['forum_password'])) ? false : true, + + 'FORUM_DESC' => $forum_desc_data['text'], + 'S_DESC_BBCODE_CHECKED' => ($forum_desc_data['allow_bbcode']) ? true : false, + 'S_DESC_SMILIES_CHECKED' => ($forum_desc_data['allow_smilies']) ? true : false, + 'S_DESC_URLS_CHECKED' => ($forum_desc_data['allow_urls']) ? true : false, + + 'S_FORUM_TYPE_OPTIONS' => $forum_type_options, + 'S_STATUS_OPTIONS' => $statuslist, + 'S_PARENT_OPTIONS' => $parents_list, + 'S_STYLES_OPTIONS' => $styles_list, + 'S_FORUM_OPTIONS' => make_forum_select(($action == 'add') ? $forum_data['parent_id'] : false, ($action == 'edit') ? $forum_data['forum_id'] : false, false, false, false), + 'S_SHOW_DISPLAY_ON_INDEX' => $s_show_display_on_index, + 'S_FORUM_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, + 'S_FORUM_ORIG_POST' => (isset($old_forum_type) && $old_forum_type == FORUM_POST) ? true : false, + 'S_FORUM_ORIG_CAT' => (isset($old_forum_type) && $old_forum_type == FORUM_CAT) ? true : false, + 'S_FORUM_ORIG_LINK' => (isset($old_forum_type) && $old_forum_type == FORUM_LINK) ? true : false, + 'S_FORUM_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false, + 'S_FORUM_CAT' => ($forum_data['forum_type'] == FORUM_CAT) ? true : false, + 'S_ENABLE_INDEXING' => ($forum_data['enable_indexing']) ? true : false, + 'S_TOPIC_ICONS' => ($forum_data['enable_icons']) ? true : false, + 'S_DISPLAY_SUBFORUM_LIST' => ($forum_data['display_subforum_list']) ? true : false, + 'S_DISPLAY_ON_INDEX' => ($forum_data['display_on_index']) ? true : false, + 'S_PRUNE_ENABLE' => ($forum_data['enable_prune']) ? true : false, + 'S_FORUM_LINK_TRACK' => ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? 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_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, + )); + + return; + + break; + + case 'delete': + + if (!$forum_id) + { + trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); + } + + $forum_data = $this->get_forum_info($forum_id); + + $subforums_id = array(); + $subforums = get_forum_branch($forum_id, 'children'); + + foreach ($subforums as $row) + { + $subforums_id[] = $row['forum_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_limit($sql, 1); + + if ($db->sql_fetchrow($result)) + { + $template->assign_vars(array( + 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id, false, true)) // , false, true, false??? + ); + } + $db->sql_freeresult($result); + + $parent_id = ($this->parent_id == $forum_id) ? 0 : $this->parent_id; + + $template->assign_vars(array( + 'S_DELETE_FORUM' => true, + 'U_ACTION' => $this->u_action . "&parent_id={$parent_id}&action=delete&f=$forum_id", + 'U_BACK' => $this->u_action . '&parent_id=' . $this->parent_id, + + 'FORUM_NAME' => $forum_data['forum_name'], + 'S_FORUM_POST' => ($forum_data['forum_type'] == FORUM_POST) ? true : false, + 'S_FORUM_LINK' => ($forum_data['forum_type'] == FORUM_LINK) ? true : false, + 'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false, + 'S_FORUMS_LIST' => $forums_list, + 'S_ERROR' => (sizeof($errors)) ? true : false, + 'ERROR_MSG' => (sizeof($errors)) ? implode('
', $errors) : '') + ); + + 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 = '&mode=setting_forum_local&forum_id[]=' . $forum_id; + + $message = $user->lang['FORUM_UPDATED']; + + // Redirect to permissions + if ($auth->acl_get('a_fauth')) + { + $message .= '

' . sprintf($user->lang['REDIRECT_ACL'], '', ''); + } + + trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); + } + + break; + } + + // Default management page + if (!$this->parent_id) + { + $navigation = $user->lang['FORUM_INDEX']; + } + else + { + $navigation = '' . $user->lang['FORUM_INDEX'] . ''; + + $forums_nav = get_forum_branch($this->parent_id, 'parents', 'descending'); + foreach ($forums_nav as $row) + { + if ($row['forum_id'] == $this->parent_id) + { + $navigation .= ' -> ' . $row['forum_name']; + } + else + { + $navigation .= ' -> ' . $row['forum_name'] . ''; + } + } + } + + // Jumpbox + $forum_box = make_forum_select($this->parent_id, false, false, false, false); //make_forum_select($this->parent_id); + + if ($action == 'sync' || $action == 'sync_forum') + { + $template->assign_var('S_RESYNCED', true); + } + + $sql = 'SELECT * + FROM ' . FORUMS_TABLE . " + WHERE parent_id = $this->parent_id + ORDER BY left_id"; + $result = $db->sql_query($sql); + + if ($row = $db->sql_fetchrow($result)) + { + do + { + $forum_type = $row['forum_type']; + + if ($row['forum_status'] == ITEM_LOCKED) + { + $folder_image = '' . $user->lang['LOCKED'] . ''; + } + else + { + switch ($forum_type) + { + case FORUM_LINK: + $folder_image = '' . $user->lang['LINK'] . ''; + break; + + default: + $folder_image = ($row['left_id'] + 1 != $row['right_id']) ? '' . $user->lang['SUBFORUM'] . '' : '' . $user->lang['FOLDER'] . ''; + break; + } + } + + $url = $this->u_action . "&parent_id=$this->parent_id&f={$row['forum_id']}"; + + $template->assign_block_vars('forums', array( + 'FOLDER_IMAGE' => $folder_image, + 'FORUM_IMAGE' => ($row['forum_image']) ? '' : '', + 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', + 'FORUM_NAME' => $row['forum_name'], + 'FORUM_DESCRIPTION' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), + 'FORUM_TOPICS' => $row['forum_topics'], + 'FORUM_POSTS' => $row['forum_posts'], + + 'S_FORUM_LINK' => ($forum_type == FORUM_LINK) ? true : false, + 'S_FORUM_POST' => ($forum_type == FORUM_POST) ? true : false, + + 'U_FORUM' => $this->u_action . '&parent_id=' . $row['forum_id'], + 'U_MOVE_UP' => $url . '&action=move_up', + 'U_MOVE_DOWN' => $url . '&action=move_down', + 'U_EDIT' => $url . '&action=edit', + 'U_DELETE' => $url . '&action=delete', + 'U_SYNC' => $url . '&action=sync') + ); + } + while ($row = $db->sql_fetchrow($result)); + } + else if ($this->parent_id) + { + $row = $this->get_forum_info($this->parent_id); + + $url = $this->u_action . '&parent_id=' . $this->parent_id . '&f=' . $row['forum_id']; + + $template->assign_vars(array( + 'S_NO_FORUMS' => true, + + 'U_EDIT' => $url . '&action=edit', + 'U_DELETE' => $url . '&action=delete', + 'U_SYNC' => $url . '&action=sync') + ); + } + $db->sql_freeresult($result); + + $template->assign_vars(array( + 'ERROR_MSG' => (sizeof($errors)) ? implode('
', $errors) : '', + 'NAVIGATION' => $navigation, + 'FORUM_BOX' => $forum_box, + 'U_SEL_ACTION' => $this->u_action, + 'U_ACTION' => $this->u_action . '&parent_id=' . $this->parent_id, + + 'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar', + 'UA_PROGRESS_BAR' => addslashes($this->u_action . '&action=progress_bar'), + )); + } + + /** + * Get forum details + */ + function get_forum_info($forum_id) + { + global $db; + + $sql = 'SELECT * + FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row) + { + trigger_error("Forum #$forum_id does not exist", E_USER_ERROR); + } + + return $row; + } + + /** + * Update forum data + */ + function update_forum_data(&$forum_data) + { + global $db, $user, $cache, $phpbb_root_path; + + $errors = array(); + + if (!$forum_data['forum_name']) + { + $errors[] = $user->lang['FORUM_NAME_EMPTY']; + } + + if (utf8_strlen($forum_data['forum_desc']) > 4000) + { + $errors[] = $user->lang['FORUM_DESC_TOO_LONG']; + } + + if (utf8_strlen($forum_data['forum_rules']) > 4000) + { + $errors[] = $user->lang['FORUM_RULES_TOO_LONG']; + } + + if ($forum_data['forum_password'] || $forum_data['forum_password_confirm']) + { + if ($forum_data['forum_password'] != $forum_data['forum_password_confirm']) + { + $forum_data['forum_password'] = $forum_data['forum_password_confirm'] = ''; + $errors[] = $user->lang['FORUM_PASSWORD_MISMATCH']; + } + } + + if ($forum_data['prune_days'] < 0 || $forum_data['prune_viewed'] < 0 || $forum_data['prune_freq'] < 0) + { + $forum_data['prune_days'] = $forum_data['prune_viewed'] = $forum_data['prune_freq'] = 0; + $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'), + ); + + 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); + + // Set forum flags + // 1 = link tracking + // 2 = prune old polls + // 4 = prune announcements + // 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; + + // Unset data that are not database fields + $forum_data_sql = $forum_data; + + unset($forum_data_sql['forum_link_track']); + unset($forum_data_sql['prune_old_polls']); + unset($forum_data_sql['prune_announce']); + 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, + // try to take over the world ... or decide whether to continue update + // and if so, whether it's a new forum/cat/link or an existing one + if (sizeof($errors)) + { + return $errors; + } + + // As we don't know the old password, it's kinda tricky to detect changes + if ($forum_data_sql['forum_password_unset']) + { + $forum_data_sql['forum_password'] = ''; + } + else if (empty($forum_data_sql['forum_password'])) + { + unset($forum_data_sql['forum_password']); + } + else + { + $forum_data_sql['forum_password'] = phpbb_hash($forum_data_sql['forum_password']); + } + unset($forum_data_sql['forum_password_unset']); + + if (!isset($forum_data_sql['forum_id'])) + { + // no forum_id means we're creating a new forum + unset($forum_data_sql['type_action']); + + if ($forum_data_sql['parent_id']) + { + $sql = 'SELECT left_id, right_id, forum_type + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $forum_data_sql['parent_id']; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row) + { + trigger_error($user->lang['PARENT_NOT_EXIST'] . adm_back_link($this->u_action . '&' . $this->parent_id), E_USER_WARNING); + } + + if ($row['forum_type'] == FORUM_LINK) + { + $errors[] = $user->lang['PARENT_IS_LINK_FORUM']; + return $errors; + } + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET left_id = left_id + 2, right_id = right_id + 2 + WHERE left_id > ' . $row['right_id']; + $db->sql_query($sql); + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET right_id = right_id + 2 + WHERE ' . $row['left_id'] . ' BETWEEN left_id AND right_id'; + $db->sql_query($sql); + + $forum_data_sql['left_id'] = $row['right_id']; + $forum_data_sql['right_id'] = $row['right_id'] + 1; + } + else + { + $sql = 'SELECT MAX(right_id) AS right_id + FROM ' . FORUMS_TABLE; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + $forum_data_sql['left_id'] = $row['right_id'] + 1; + $forum_data_sql['right_id'] = $row['right_id'] + 2; + } + + $sql = 'INSERT INTO ' . FORUMS_TABLE . ' ' . $db->sql_build_array('INSERT', $forum_data_sql); + $db->sql_query($sql); + + $forum_data['forum_id'] = $db->sql_nextid(); + + add_log('admin', 'LOG_FORUM_ADD', $forum_data['forum_name']); + } + else + { + $row = $this->get_forum_info($forum_data_sql['forum_id']); + + if ($row['forum_type'] == FORUM_POST && $row['forum_type'] != $forum_data_sql['forum_type']) + { + // Has subforums and want to change into a link? + if ($row['right_id'] - $row['left_id'] > 1 && $forum_data_sql['forum_type'] == FORUM_LINK) + { + $errors[] = $user->lang['FORUM_WITH_SUBFORUMS_NOT_TO_LINK']; + return $errors; + } + + // 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); + + if ($to_forum_id) + { + $errors = $this->move_forum_content($forum_data_sql['forum_id'], $to_forum_id); + } + else + { + return array($user->lang['NO_DESTINATION_FORUM']); + } + } + else if ($forum_data_sql['type_action'] == 'delete') + { + $errors = $this->delete_forum_content($forum_data_sql['forum_id']); + } + else + { + return array($user->lang['NO_FORUM_ACTION']); + } + + $forum_data_sql['forum_posts'] = $forum_data_sql['forum_topics'] = $forum_data_sql['forum_topics_real'] = $forum_data_sql['forum_last_post_id'] = $forum_data_sql['forum_last_poster_id'] = $forum_data_sql['forum_last_post_time'] = 0; + $forum_data_sql['forum_last_poster_name'] = $forum_data_sql['forum_last_poster_colour'] = ''; + } + else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_LINK) + { + // Has 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); + + if ($action_subforums == 'delete') + { + $rows = get_forum_branch($row['forum_id'], 'children', 'descending', false); + + foreach ($rows as $_row) + { + // Do not remove the forum id we are about to change. ;) + if ($_row['forum_id'] == $row['forum_id']) + { + continue; + } + + $forum_ids[] = $_row['forum_id']; + $errors = array_merge($errors, $this->delete_forum_content($_row['forum_id'])); + } + + if (sizeof($errors)) + { + return $errors; + } + + if (sizeof($forum_ids)) + { + $sql = 'DELETE FROM ' . FORUMS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $forum_ids); + $db->sql_query($sql); + + $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $forum_ids); + $db->sql_query($sql); + + $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $forum_ids); + $db->sql_query($sql); + + // Delete forum ids from extension groups table + $sql = 'SELECT group_id, allowed_forums + FROM ' . EXTENSION_GROUPS_TABLE; + $result = $db->sql_query($sql); + + while ($_row = $db->sql_fetchrow($result)) + { + if (!$_row['allowed_forums']) + { + continue; + } + + $allowed_forums = unserialize(trim($_row['allowed_forums'])); + $allowed_forums = array_diff($allowed_forums, $forum_ids); + + $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . " + SET allowed_forums = '" . ((sizeof($allowed_forums)) ? serialize($allowed_forums) : '') . "' + WHERE group_id = {$_row['group_id']}"; + $db->sql_query($sql); + } + $db->sql_freeresult($result); + + $cache->destroy('_extensions'); + } + } + else if ($action_subforums == 'move') + { + if (!$subforums_to_id) + { + return array($user->lang['NO_DESTINATION_FORUM']); + } + + $sql = 'SELECT forum_name + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $subforums_to_id; + $result = $db->sql_query($sql); + $_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$_row) + { + return array($user->lang['NO_FORUM']); + } + + $subforums_to_name = $_row['forum_name']; + + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . " + WHERE parent_id = {$row['forum_id']}"; + $result = $db->sql_query($sql); + + while ($_row = $db->sql_fetchrow($result)) + { + $this->move_forum($_row['forum_id'], $subforums_to_id); + } + $db->sql_freeresult($result); + + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET parent_id = $subforums_to_id + WHERE parent_id = {$row['forum_id']}"; + $db->sql_query($sql); + } + + // Adjust the left/right id + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET right_id = left_id + 1 + WHERE forum_id = ' . $row['forum_id']; + $db->sql_query($sql); + } + } + else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_POST) + { + // Changing a category to a forum? Reset the data (you can't post directly in a cat, you must use a forum) + $forum_data_sql['forum_posts'] = 0; + $forum_data_sql['forum_topics'] = 0; + $forum_data_sql['forum_topics_real'] = 0; + $forum_data_sql['forum_last_post_id'] = 0; + $forum_data_sql['forum_last_post_subject'] = ''; + $forum_data_sql['forum_last_post_time'] = 0; + $forum_data_sql['forum_last_poster_id'] = 0; + $forum_data_sql['forum_last_poster_name'] = ''; + $forum_data_sql['forum_last_poster_colour'] = ''; + } + + if (sizeof($errors)) + { + return $errors; + } + + if ($row['parent_id'] != $forum_data_sql['parent_id']) + { + if ($row['forum_id'] != $forum_data_sql['parent_id']) + { + $errors = $this->move_forum($forum_data_sql['forum_id'], $forum_data_sql['parent_id']); + } + else + { + $forum_data_sql['parent_id'] = $row['parent_id']; + } + } + + if (sizeof($errors)) + { + return $errors; + } + + unset($forum_data_sql['type_action']); + + if ($row['forum_name'] != $forum_data_sql['forum_name']) + { + // the forum name has changed, clear the parents list of all forums (for safety) + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET forum_parents = ''"; + $db->sql_query($sql); + } + + // Setting the forum id to the forum id is not really received well by some dbs. ;) + $forum_id = $forum_data_sql['forum_id']; + unset($forum_data_sql['forum_id']); + + $sql = 'UPDATE ' . FORUMS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $forum_data_sql) . ' + WHERE forum_id = ' . $forum_id; + $db->sql_query($sql); + + // Add it back + $forum_data['forum_id'] = $forum_id; + + add_log('admin', 'LOG_FORUM_EDIT', $forum_data['forum_name']); + } + + return $errors; + } + + /** + * Move forum + */ + function move_forum($from_id, $to_id) + { + global $db, $user; + + $to_data = $moved_ids = $errors = array(); + + // Check if we want to move to a parent with link type + if ($to_id > 0) + { + $to_data = $this->get_forum_info($to_id); + + if ($to_data['forum_type'] == FORUM_LINK) + { + $errors[] = $user->lang['PARENT_IS_LINK_FORUM']; + return $errors; + } + } + + $moved_forums = get_forum_branch($from_id, 'children', 'descending'); + $from_data = $moved_forums[0]; + $diff = sizeof($moved_forums) * 2; + + $moved_ids = array(); + for ($i = 0; $i < sizeof($moved_forums); ++$i) + { + $moved_ids[] = $moved_forums[$i]['forum_id']; + } + + // Resync parents + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET right_id = right_id - $diff, forum_parents = '' + WHERE left_id < " . $from_data['right_id'] . " + AND right_id > " . $from_data['right_id']; + $db->sql_query($sql); + + // Resync righthand side of tree + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET left_id = left_id - $diff, right_id = right_id - $diff, forum_parents = '' + WHERE left_id > " . $from_data['right_id']; + $db->sql_query($sql); + + if ($to_id > 0) + { + // Retrieve $to_data again, it may have been changed... + $to_data = $this->get_forum_info($to_id); + + // Resync new parents + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET right_id = right_id + $diff, forum_parents = '' + WHERE " . $to_data['right_id'] . ' BETWEEN left_id AND right_id + AND ' . $db->sql_in_set('forum_id', $moved_ids, true); + $db->sql_query($sql); + + // Resync the righthand side of the tree + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET left_id = left_id + $diff, right_id = right_id + $diff, forum_parents = '' + WHERE left_id > " . $to_data['right_id'] . ' + AND ' . $db->sql_in_set('forum_id', $moved_ids, true); + $db->sql_query($sql); + + // Resync moved branch + $to_data['right_id'] += $diff; + + if ($to_data['right_id'] > $from_data['right_id']) + { + $diff = '+ ' . ($to_data['right_id'] - $from_data['right_id'] - 1); + } + else + { + $diff = '- ' . abs($to_data['right_id'] - $from_data['right_id'] - 1); + } + } + else + { + $sql = 'SELECT MAX(right_id) AS right_id + FROM ' . FORUMS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $moved_ids, true); + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + $diff = '+ ' . ($row['right_id'] - $from_data['left_id'] + 1); + } + + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET left_id = left_id $diff, right_id = right_id $diff, forum_parents = '' + WHERE " . $db->sql_in_set('forum_id', $moved_ids); + $db->sql_query($sql); + + return $errors; + } + + /** + * Move forum content from one to another forum + */ + function move_forum_content($from_id, $to_id, $sync = true) + { + global $db; + + $table_ary = array(LOG_TABLE, POSTS_TABLE, TOPICS_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); + + foreach ($table_ary as $table) + { + $sql = "UPDATE $table + SET forum_id = $to_id + WHERE forum_id = $from_id"; + $db->sql_query($sql); + } + unset($table_ary); + + $table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, MODERATOR_CACHE_TABLE); + + foreach ($table_ary as $table) + { + $sql = "DELETE FROM $table + WHERE forum_id = $from_id"; + $db->sql_query($sql); + } + + if ($sync) + { + // Delete ghost topics that link back to the same forum then resync counters + sync('topic_moved'); + sync('forum', 'forum_id', $to_id, false, true); + } + + return array(); + } + + /** + * Remove complete forum + */ + function delete_forum($forum_id, $action_posts = 'delete', $action_subforums = 'delete', $posts_to_id = 0, $subforums_to_id = 0) + { + global $db, $user, $cache; + + $forum_data = $this->get_forum_info($forum_id); + + $errors = array(); + $log_action_posts = $log_action_forums = $posts_to_name = $subforums_to_name = ''; + $forum_ids = array($forum_id); + + if ($action_posts == 'delete') + { + $log_action_posts = 'POSTS'; + $errors = array_merge($errors, $this->delete_forum_content($forum_id)); + } + else if ($action_posts == 'move') + { + if (!$posts_to_id) + { + $errors[] = $user->lang['NO_DESTINATION_FORUM']; + } + else + { + $log_action_posts = 'MOVE_POSTS'; + + $sql = 'SELECT forum_name + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $posts_to_id; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row) + { + $errors[] = $user->lang['NO_FORUM']; + } + else + { + $posts_to_name = $row['forum_name']; + $errors = array_merge($errors, $this->move_forum_content($forum_id, $posts_to_id)); + } + } + } + + if (sizeof($errors)) + { + return $errors; + } + + if ($action_subforums == 'delete') + { + $log_action_forums = 'FORUMS'; + $rows = get_forum_branch($forum_id, 'children', 'descending', false); + + foreach ($rows as $row) + { + $forum_ids[] = $row['forum_id']; + $errors = array_merge($errors, $this->delete_forum_content($row['forum_id'])); + } + + if (sizeof($errors)) + { + return $errors; + } + + $diff = sizeof($forum_ids) * 2; + + $sql = 'DELETE FROM ' . FORUMS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $forum_ids); + $db->sql_query($sql); + + $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $forum_ids); + $db->sql_query($sql); + + $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' + WHERE ' . $db->sql_in_set('forum_id', $forum_ids); + $db->sql_query($sql); + } + else if ($action_subforums == 'move') + { + if (!$subforums_to_id) + { + $errors[] = $user->lang['NO_DESTINATION_FORUM']; + } + else + { + $log_action_forums = 'MOVE_FORUMS'; + + $sql = 'SELECT forum_name + FROM ' . FORUMS_TABLE . ' + WHERE forum_id = ' . $subforums_to_id; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$row) + { + $errors[] = $user->lang['NO_FORUM']; + } + else + { + $subforums_to_name = $row['forum_name']; + + $sql = 'SELECT forum_id + FROM ' . FORUMS_TABLE . " + WHERE parent_id = $forum_id"; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $this->move_forum($row['forum_id'], $subforums_to_id); + } + $db->sql_freeresult($result); + + // Grab new forum data for correct tree updating later + $forum_data = $this->get_forum_info($forum_id); + + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET parent_id = $subforums_to_id + WHERE parent_id = $forum_id"; + $db->sql_query($sql); + + $diff = 2; + $sql = 'DELETE FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $db->sql_query($sql); + + $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . " + WHERE forum_id = $forum_id"; + $db->sql_query($sql); + + $sql = 'DELETE FROM ' . ACL_USERS_TABLE . " + WHERE forum_id = $forum_id"; + $db->sql_query($sql); + } + } + + if (sizeof($errors)) + { + return $errors; + } + } + else + { + $diff = 2; + $sql = 'DELETE FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $db->sql_query($sql); + + $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . " + WHERE forum_id = $forum_id"; + $db->sql_query($sql); + + $sql = 'DELETE FROM ' . ACL_USERS_TABLE . " + WHERE forum_id = $forum_id"; + $db->sql_query($sql); + } + + // Resync tree + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET right_id = right_id - $diff + WHERE left_id < {$forum_data['right_id']} AND right_id > {$forum_data['right_id']}"; + $db->sql_query($sql); + + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET left_id = left_id - $diff, right_id = right_id - $diff + WHERE left_id > {$forum_data['right_id']}"; + $db->sql_query($sql); + + // Delete forum ids from extension groups table + $sql = 'SELECT group_id, allowed_forums + FROM ' . EXTENSION_GROUPS_TABLE; + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + if (!$row['allowed_forums']) + { + continue; + } + + $allowed_forums = unserialize(trim($row['allowed_forums'])); + $allowed_forums = array_diff($allowed_forums, $forum_ids); + + $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . " + SET allowed_forums = '" . ((sizeof($allowed_forums)) ? serialize($allowed_forums) : '') . "' + WHERE group_id = {$row['group_id']}"; + $db->sql_query($sql); + } + $db->sql_freeresult($result); + + $cache->destroy('_extensions'); + + $log_action = implode('_', array($log_action_posts, $log_action_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']); + break; + + case 'MOVE_POSTS_FORUMS': + add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS_FORUMS', $posts_to_name, $forum_data['forum_name']); + break; + + case 'POSTS_MOVE_FORUMS': + add_log('admin', 'LOG_FORUM_DEL_POSTS_MOVE_FORUMS', $subforums_to_name, $forum_data['forum_name']); + break; + + case '_MOVE_FORUMS': + add_log('admin', 'LOG_FORUM_DEL_MOVE_FORUMS', $subforums_to_name, $forum_data['forum_name']); + break; + + case 'MOVE_POSTS_': + add_log('admin', 'LOG_FORUM_DEL_MOVE_POSTS', $posts_to_name, $forum_data['forum_name']); + break; + + case 'POSTS_FORUMS': + add_log('admin', 'LOG_FORUM_DEL_POSTS_FORUMS', $forum_data['forum_name']); + break; + + case '_FORUMS': + add_log('admin', 'LOG_FORUM_DEL_FORUMS', $forum_data['forum_name']); + break; + + case 'POSTS_': + add_log('admin', 'LOG_FORUM_DEL_POSTS', $forum_data['forum_name']); + break; + + default: + add_log('admin', 'LOG_FORUM_DEL_FORUM', $forum_data['forum_name']); + break; + } + + return $errors; + } + + /** + * Delete forum content + */ + function delete_forum_content($forum_id) + { + global $db, $config, $phpbb_root_path, $phpEx; + + include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); + + $db->sql_transaction('begin'); + + // Select then delete all attachments + $sql = 'SELECT a.topic_id + FROM ' . POSTS_TABLE . ' p, ' . ATTACHMENTS_TABLE . " a + WHERE p.forum_id = $forum_id + AND a.in_message = 0 + AND a.topic_id = p.topic_id"; + $result = $db->sql_query($sql); + + $topic_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $topic_ids[] = $row['topic_id']; + } + $db->sql_freeresult($result); + + delete_attachments('topic', $topic_ids, false); + + // Before we remove anything we make sure we are able to adjust the post counts later. ;) + $sql = 'SELECT poster_id + FROM ' . POSTS_TABLE . ' + WHERE forum_id = ' . $forum_id . ' + AND post_postcount = 1 + AND post_approved = 1'; + $result = $db->sql_query($sql); + + $post_counts = array(); + while ($row = $db->sql_fetchrow($result)) + { + $post_counts[$row['poster_id']] = (!empty($post_counts[$row['poster_id']])) ? $post_counts[$row['poster_id']] + 1 : 1; + } + $db->sql_freeresult($result); + + switch ($db->sql_layer) + { + case 'mysql4': + case 'mysqli': + + // Delete everything else and thank MySQL for offering multi-table deletion + $tables_ary = array( + SEARCH_WORDMATCH_TABLE => 'post_id', + REPORTS_TABLE => 'post_id', + WARNINGS_TABLE => 'post_id', + BOOKMARKS_TABLE => 'topic_id', + TOPICS_WATCH_TABLE => 'topic_id', + TOPICS_POSTED_TABLE => 'topic_id', + POLL_OPTIONS_TABLE => 'topic_id', + POLL_VOTES_TABLE => 'topic_id', + ); + + $sql = 'DELETE ' . POSTS_TABLE; + $sql_using = "\nFROM " . POSTS_TABLE; + $sql_where = "\nWHERE " . POSTS_TABLE . ".forum_id = $forum_id\n"; + + foreach ($tables_ary as $table => $field) + { + $sql .= ", $table "; + $sql_using .= ", $table "; + $sql_where .= "\nAND $table.$field = " . POSTS_TABLE . ".$field"; + } + + $db->sql_query($sql . $sql_using . $sql_where); + + break; + + default: + + // Delete everything else and curse your DB for not offering multi-table deletion + $tables_ary = array( + 'post_id' => array( + SEARCH_WORDMATCH_TABLE, + REPORTS_TABLE, + WARNINGS_TABLE, + ), + + 'topic_id' => array( + BOOKMARKS_TABLE, + TOPICS_WATCH_TABLE, + TOPICS_POSTED_TABLE, + POLL_OPTIONS_TABLE, + POLL_VOTES_TABLE, + ) + ); + + foreach ($tables_ary as $field => $tables) + { + $start = 0; + + do + { + $sql = "SELECT $field + FROM " . POSTS_TABLE . ' + WHERE forum_id = ' . $forum_id; + $result = $db->sql_query_limit($sql, 500, $start); + + $ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $ids[] = $row[$field]; + } + $db->sql_freeresult($result); + + if (sizeof($ids)) + { + $start += sizeof($ids); + + foreach ($tables as $table) + { + $db->sql_query("DELETE FROM $table WHERE " . $db->sql_in_set($field, $ids)); + } + } + } + while ($row); + } + unset($ids); + + break; + } + + $table_ary = array(FORUMS_ACCESS_TABLE, FORUMS_TRACK_TABLE, FORUMS_WATCH_TABLE, LOG_TABLE, MODERATOR_CACHE_TABLE, POSTS_TABLE, TOPICS_TABLE, TOPICS_TRACK_TABLE); + + foreach ($table_ary as $table) + { + $db->sql_query("DELETE FROM $table WHERE forum_id = $forum_id"); + } + + // Set forum ids to 0 + $table_ary = array(DRAFTS_TABLE); + + foreach ($table_ary as $table) + { + $db->sql_query("UPDATE $table SET forum_id = 0 WHERE forum_id = $forum_id"); + } + + // Adjust users post counts + if (sizeof($post_counts)) + { + foreach ($post_counts as $poster_id => $substract) + { + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_posts = 0 + WHERE user_id = ' . $poster_id . ' + AND user_posts < ' . $substract; + $db->sql_query($sql); + + $sql = 'UPDATE ' . USERS_TABLE . ' + SET user_posts = user_posts - ' . $substract . ' + WHERE user_id = ' . $poster_id . ' + AND user_posts >= ' . $substract; + $db->sql_query($sql); + } + } + + $db->sql_transaction('commit'); + + // Make sure the overall post/topic count is correct... + $sql = 'SELECT COUNT(post_id) AS stat + FROM ' . POSTS_TABLE . ' + WHERE post_approved = 1'; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + set_config('num_posts', (int) $row['stat'], true); + + $sql = 'SELECT COUNT(topic_id) AS stat + FROM ' . TOPICS_TABLE . ' + WHERE topic_approved = 1'; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + set_config('num_topics', (int) $row['stat'], true); + + $sql = 'SELECT COUNT(attach_id) as stat + FROM ' . ATTACHMENTS_TABLE; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + set_config('num_files', (int) $row['stat'], true); + + $sql = 'SELECT SUM(filesize) as stat + FROM ' . ATTACHMENTS_TABLE; + $result = $db->sql_query($sql); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + set_config('upload_dir_size', (float) $row['stat'], true); + + return array(); + } + + /** + * Move forum position by $steps up/down + */ + function move_forum_by($forum_row, $action = 'move_up', $steps = 1) + { + global $db; + + /** + * Fetch all the siblings between the module's current spot + * and where we want to move it to. If there are less than $steps + * siblings between the current spot and the target then the + * module will move as far as possible + */ + $sql = 'SELECT forum_id, forum_name, left_id, right_id + FROM ' . FORUMS_TABLE . " + WHERE parent_id = {$forum_row['parent_id']} + 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"); + $result = $db->sql_query_limit($sql, $steps); + + $target = array(); + while ($row = $db->sql_fetchrow($result)) + { + $target = $row; + } + $db->sql_freeresult($result); + + if (!sizeof($target)) + { + // The forum is already on top or bottom + return false; + } + + /** + * $left_id and $right_id define the scope of the nodes that are affected by the move. + * $diff_up and $diff_down are the values to substract or add to each node's left_id + * and right_id in order to move them up or down. + * $move_up_left and $move_up_right define the scope of the nodes that are moving + * up. Other nodes in the scope of ($left_id, $right_id) are considered to move down. + */ + if ($action == 'move_up') + { + $left_id = $target['left_id']; + $right_id = $forum_row['right_id']; + + $diff_up = $forum_row['left_id'] - $target['left_id']; + $diff_down = $forum_row['right_id'] + 1 - $forum_row['left_id']; + + $move_up_left = $forum_row['left_id']; + $move_up_right = $forum_row['right_id']; + } + else + { + $left_id = $forum_row['left_id']; + $right_id = $target['right_id']; + + $diff_up = $forum_row['right_id'] + 1 - $forum_row['left_id']; + $diff_down = $target['right_id'] - $forum_row['right_id']; + + $move_up_left = $forum_row['right_id'] + 1; + $move_up_right = $target['right_id']; + } + + // Now do the dirty job + $sql = 'UPDATE ' . FORUMS_TABLE . " + SET left_id = left_id + CASE + WHEN left_id BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up} + ELSE {$diff_down} + END, + right_id = right_id + CASE + WHEN right_id BETWEEN {$move_up_left} AND {$move_up_right} THEN -{$diff_up} + ELSE {$diff_down} + END, + forum_parents = '' + WHERE + left_id BETWEEN {$left_id} AND {$right_id} + AND right_id BETWEEN {$left_id} AND {$right_id}"; + $db->sql_query($sql); + + return $target['forum_name']; + } + + /** + * Display progress bar for syncinc forums + */ + function display_progress_bar($start, $total) + { + global $template, $user; + + adm_page_header($user->lang['SYNC_IN_PROGRESS']); + + $template->set_filenames(array( + 'body' => 'progress_bar.html') + ); + + $template->assign_vars(array( + 'L_PROGRESS' => $user->lang['SYNC_IN_PROGRESS'], + 'L_PROGRESS_EXPLAIN' => ($start && $total) ? sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $start, $total) : $user->lang['SYNC_IN_PROGRESS']) + ); + + 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 = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; + $action = append_sid($this->u_action . "&parent_id={$this->parent_id}&f={$forum_data['forum_id']}&action=copy_perm"); + + $l_acl = sprintf($user->lang['COPY_TO_ACL'], '', ''); + + $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 . '&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), + )); + } + +} + +?> \ No newline at end of file -- cgit v1.2.1 From b68de2323d6444b4b3685a98bbcb9500a38e45cb Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Wed, 16 Dec 2009 15:48:23 +0000 Subject: merge changes from 3.0.x branch git-svn-id: file:///svn/phpbb/trunk@10342 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/acp/acp_forums.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 2ff597ee98..bde59ec870 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -75,13 +75,6 @@ class acp_forums trigger_error($user->lang['NO_PERMISSION_FORUM_ADD'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } - case 'copy_perm': - - if (!(($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')))) - { - trigger_error($user->lang['NO_PERMISSION_COPY'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); - } - break; } @@ -125,7 +118,6 @@ class acp_forums 'type_action' => request_var('type_action', ''), 'forum_status' => request_var('forum_status', ITEM_UNLOCKED), 'forum_parents' => '', - 'forum_options' => 0, '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), @@ -159,6 +151,12 @@ class acp_forums '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) { -- cgit v1.2.1 From af5b9a96409d788733fcb1ff367e0c7fb0583702 Mon Sep 17 00:00:00 2001 From: Igor Wiedler Date: Tue, 9 Nov 2010 08:59:25 +0100 Subject: [ticket/9556] Drop php closing tags, add trailing newline Closing tags converted using Oleg's script. remove-php-end-tags.py -a . Trailing newlines added using the following where $ext is file extension. find . -type f -name "*.$ext" -print | xargs printf "e %s\nw\n" | ed -s; Extensions: php, css, html, js, xml. PHPBB3-9556 --- phpBB/includes/acp/acp_forums.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 4d9b9f01e0..4d605e1b82 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1950,5 +1950,3 @@ class acp_forums } } - -?> \ No newline at end of file -- cgit v1.2.1 From 7a04c9048c110f0bd21ea3e9e869e17b408d640e Mon Sep 17 00:00:00 2001 From: Unknown Date: Sat, 31 Dec 2011 13:32:52 +0000 Subject: [ticket/9916] Updating header license and removing Version $Id$ PHPBB3-9916 --- phpBB/includes/acp/acp_forums.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 7fe8915ad1..fad22fc285 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -2,9 +2,8 @@ /** * * @package acp -* @version $Id$ * @copyright (c) 2005 phpBB Group -* @license http://opensource.org/licenses/gpl-license.php GNU Public License +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ -- cgit v1.2.1 From bb7a03f738c97dc225873691c459f2bf9e612ef6 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 27 Jul 2011 12:57:58 +0100 Subject: [ticket/10281] AJAXified reordering forums in the ACP. PHPBB3-10281 --- phpBB/includes/acp/acp_forums.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index fad22fc285..d3e2dbd904 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -255,6 +255,12 @@ class acp_forums add_log('admin', 'LOG_FORUM_' . strtoupper($action), $row['forum_name'], $move_forum_name); $cache->destroy('sql', FORUMS_TABLE); } + + if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') + { + echo json_encode(array('success' => ($move_forum_name !== false))); + exit; + } break; -- cgit v1.2.1 From 94172b54dd09b28e19b4b12933b3f96e498d264a Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 19 Aug 2011 09:38:57 +0100 Subject: [ticket/10271] Changed AJAX functions to $request->is_ajax(). PHPBB3-10271 --- phpBB/includes/acp/acp_forums.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index d3e2dbd904..cb410e361a 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -25,7 +25,7 @@ class acp_forums function main($id, $mode) { - global $db, $user, $auth, $template, $cache; + global $db, $user, $auth, $template, $cache, $request; global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx; $user->add_lang('acp/forums'); @@ -256,7 +256,7 @@ class acp_forums $cache->destroy('sql', FORUMS_TABLE); } - if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') + if ($request->is_ajax()) { echo json_encode(array('success' => ($move_forum_name !== false))); exit; -- cgit v1.2.1 From dce38f44de04bd7a1f91f8e57f6d266bd5e1af86 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Fri, 19 Aug 2011 10:45:03 +0100 Subject: [ticket/10328] Added a JSON class. The JSON class adds a consistent way to send JSON to the client, making it perfect for AJAX (jQuery automatically parses it). PHPBB3-10328 --- phpBB/includes/acp/acp_forums.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index cb410e361a..6c05b1e108 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -258,8 +258,7 @@ class acp_forums if ($request->is_ajax()) { - echo json_encode(array('success' => ($move_forum_name !== false))); - exit; + JSON::send(array('success' => ($move_forum_name !== false))); } break; -- cgit v1.2.1 From 7a933bdb5ad4a9bc4877a7d4d516fa0b21d9e4c0 Mon Sep 17 00:00:00 2001 From: Callum Macrae Date: Wed, 24 Aug 2011 12:25:54 +0100 Subject: [ticket/10328] Renamed the JSON class, also now using autoloading. It is no longer static, and uses autoloading. It has also been renamed from JSON to phpbb_json_response. PHPBB3-10328 --- phpBB/includes/acp/acp_forums.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 6c05b1e108..3a3b2021eb 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -258,7 +258,8 @@ class acp_forums if ($request->is_ajax()) { - JSON::send(array('success' => ($move_forum_name !== false))); + $json_response = new phpbb_json_response; + $json_response->send(array('success' => ($move_forum_name !== false))); } break; -- cgit v1.2.1 From eb7a04d32427d2070befdd10fcec657222bc8fa8 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 15 Mar 2012 21:06:44 +0000 Subject: [feature/events] Add core.acp_foruns_add_forum_data ledge PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 3a3b2021eb..f4d0a93b8d 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -220,6 +220,11 @@ class acp_forums } trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); + + $vars = array('forum_data'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.acp_forums_add_forum_data', $event); + extract($event->get_data_filtered($vars)); } break; -- cgit v1.2.1 From 19a3164e80e9e34cab13d25f205789d7eb27aa66 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Thu, 15 Mar 2012 23:59:40 +0000 Subject: [feature/events] Fixing core.acp_forums_add_forum_data PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index f4d0a93b8d..11843384ed 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -107,6 +107,11 @@ class acp_forums 'forum_id' => $forum_id ); + $vars = array('forum_data'); + $event = new phpbb_event_data(compact($vars)); + $phpbb_dispatcher->dispatch('core.acp_forums_add_forum_data', $event); + extract($event->get_data_filtered($vars)); + // No break here case 'add': @@ -220,11 +225,6 @@ class acp_forums } trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); - - $vars = array('forum_data'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.acp_forums_add_forum_data', $event); - extract($event->get_data_filtered($vars)); } break; -- cgit v1.2.1 From 8af7d225ef481cd26e6fd7862847183d25727117 Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Tue, 20 Mar 2012 11:23:03 +0000 Subject: [feature/events] Change to use the new method of adding events PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 11843384ed..d86925dfab 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -108,9 +108,7 @@ class acp_forums ); $vars = array('forum_data'); - $event = new phpbb_event_data(compact($vars)); - $phpbb_dispatcher->dispatch('core.acp_forums_add_forum_data', $event); - extract($event->get_data_filtered($vars)); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_add_forum_data', compact($vars), $vars)); // No break here -- cgit v1.2.1 From 3f1b4e83aef7f7344cd551463b59de71bb4bd6fe Mon Sep 17 00:00:00 2001 From: Michael Cullum Date: Sat, 31 Mar 2012 13:39:41 +0100 Subject: [feature/events] Removing the third trigger_event parameter PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index d86925dfab..f71e5f85b0 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -108,7 +108,7 @@ class acp_forums ); $vars = array('forum_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_add_forum_data', compact($vars), $vars)); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_add_forum_data', compact($vars))); // No break here -- cgit v1.2.1 From 0f78b4699acd823f773214497f68840178a8b82e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 15:41:02 +0200 Subject: [feature/php-events] Replace core.acp_forums_add_forum_data Add missing global $phpbb_dispatcher, add $action and name the event better PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index f71e5f85b0..b634a3d9a0 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -25,7 +25,7 @@ class acp_forums function main($id, $mode) { - global $db, $user, $auth, $template, $cache, $request; + global $db, $user, $auth, $template, $cache, $request, $phpbb_dispatcher; global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx; $user->add_lang('acp/forums'); @@ -107,9 +107,6 @@ class acp_forums 'forum_id' => $forum_id ); - $vars = array('forum_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_add_forum_data', compact($vars))); - // No break here case 'add': @@ -153,6 +150,9 @@ class acp_forums 'forum_password_unset' => request_var('forum_password_unset', false), ); + $vars = array('action', 'forum_data'); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_modify_forum_data', compact($vars))); + // On add, add empty forum_options... else do not consider it (not updating it) if ($action == 'add') { -- cgit v1.2.1 From 2e5a7ae4dda587bc1f47f2f1fddb4e13235217d4 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 16:22:22 +0200 Subject: [feature/php-events] Add additional events to acp_forums.php PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index b634a3d9a0..1c798a12da 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -151,7 +151,7 @@ class acp_forums ); $vars = array('action', 'forum_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_modify_forum_data', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_get_forum_data', compact($vars))); // On add, add empty forum_options... else do not consider it (not updating it) if ($action == 'add') @@ -416,6 +416,9 @@ class acp_forums $parents_list = make_forum_select($forum_data['parent_id'], $exclude_forums, false, false, false); $forum_data['forum_password_confirm'] = $forum_data['forum_password']; + + $vars = array('forum_id', 'row', 'forum_data'); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_modify_forum_data', compact($vars))); } else { @@ -453,6 +456,9 @@ class acp_forums 'forum_password' => '', 'forum_password_confirm'=> '', ); + + $vars = array('forum_id', 'forum_data'); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_init_forum_data', compact($vars))); } } @@ -585,7 +591,7 @@ class acp_forums $errors[] = $user->lang['FORUM_PASSWORD_OLD']; } - $template->assign_vars(array( + $template_data = array( 'S_EDIT_FORUM' => true, 'S_ERROR' => (sizeof($errors)) ? true : false, 'S_PARENT_ID' => $this->parent_id, @@ -650,7 +656,12 @@ class acp_forums '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, - )); + ); + + $vars = array('forum_id', 'action', 'forum_data', 'template_data', 'old_forum_type', 'forum_desc_data', 'forum_rules_data'); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_assign_template_forum_data', compact($vars))); + + $template->assign_vars($template_data); return; @@ -875,10 +886,13 @@ class acp_forums */ function update_forum_data(&$forum_data) { - global $db, $user, $cache, $phpbb_root_path; + global $db, $user, $cache, $phpbb_root_path, $phpbb_dispatcher; $errors = array(); + $vars = array('forum_data', 'errors'); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_update_forum_data', compact($vars))); + if ($forum_data['forum_name'] == '') { $errors[] = $user->lang['FORUM_NAME_EMPTY']; @@ -1242,6 +1256,9 @@ class acp_forums add_log('admin', 'LOG_FORUM_EDIT', $forum_data['forum_name']); } + $vars = array('forum_data', 'errors'); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_update_forum_data_after', compact($vars))); + return $errors; } @@ -1250,10 +1267,13 @@ class acp_forums */ function move_forum($from_id, $to_id) { - global $db, $user; + global $db, $user, $phpbb_dispatcher; $to_data = $moved_ids = $errors = array(); + $vars = array('from_id', 'to_id'); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_move_forum', compact($vars))); + // Check if we want to move to a parent with link type if ($to_id > 0) { -- cgit v1.2.1 From b1582ece91e7ebd9f635040bbb1a4c6c47786135 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Jun 2012 16:42:47 +0200 Subject: [feature/php-events] Proper name for request forum data to avoid confusion PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 1c798a12da..6631edf438 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -151,7 +151,7 @@ class acp_forums ); $vars = array('action', 'forum_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_get_forum_data', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.acp_forums_request_forum_data', compact($vars))); // On add, add empty forum_options... else do not consider it (not updating it) if ($action == 'add') -- cgit v1.2.1 From e3a9bf0376a9e4d6e9f5730e5118d11ce75296bd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 6 Aug 2012 17:43:46 +0200 Subject: [feature/php-events] Fix doc and naming of core.acp_forums_request_forum_data PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 6631edf438..564181be9e 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -150,8 +150,16 @@ class acp_forums 'forum_password_unset' => request_var('forum_password_unset', false), ); + /** + * Request forum data and operate on it (parse texts, etc.) + * + * @event core.acp_manage_forums_request_data + * @var string action Type of the action: add|edit + * @var array forum_data Array with new forum data + * @since 3.1-A1 + */ $vars = array('action', 'forum_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_request_forum_data', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_request_data', compact($vars))); // On add, add empty forum_options... else do not consider it (not updating it) if ($action == 'add') -- cgit v1.2.1 From 38ba09e707c1fd97fe79d6b8165e1315346cbfef Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Aug 2012 12:01:09 +0200 Subject: [feature/php-events] Fix naming and doc of acp_manage_forums_initialise_data PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 564181be9e..54085d856b 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -397,6 +397,9 @@ class acp_forums $forum_data['forum_flags'] += (request_var('enable_quick_reply', false)) ? FORUM_FLAG_QUICK_REPLY : 0; } + // Initialise $row, so we always have it in the event + $row = array(); + // Show form to create/modify a forum if ($action == 'edit') { @@ -424,9 +427,6 @@ class acp_forums $parents_list = make_forum_select($forum_data['parent_id'], $exclude_forums, false, false, false); $forum_data['forum_password_confirm'] = $forum_data['forum_password']; - - $vars = array('forum_id', 'row', 'forum_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_modify_forum_data', compact($vars))); } else { @@ -464,12 +464,27 @@ class acp_forums 'forum_password' => '', 'forum_password_confirm'=> '', ); - - $vars = array('forum_id', 'forum_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_init_forum_data', compact($vars))); } } + /** + * Initialise data before we display the add/edit form + * + * @event core.acp_manage_forums_initialise_data + * @var string action Type of the action: add|edit + * @var bool update Do we display the form only + * or did the user press submit + * @var int forum_id When editing: the forum id, + * when creating: the parent forum id + * @var array row Array with current forum data + * empty when creating new forum + * @var array forum_data Array with new forum data + * @var string parents_list List of parent options + * @since 3.1-A1 + */ + $vars = array('action', 'update', 'forum_id', 'row', 'forum_data', 'parents_list'); + extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_initialise_data', compact($vars))); + $forum_rules_data = array( 'text' => $forum_data['forum_rules'], 'allow_bbcode' => true, -- cgit v1.2.1 From 3beda0cbabe704b661e3d810db4c62a8d28a6bd6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Aug 2012 12:44:28 +0200 Subject: [feature/php-events] Fix naming and doc of core.acp_manage_forums_display_form PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 54085d856b..c9225744bf 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -681,8 +681,27 @@ class acp_forums '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, ); - $vars = array('forum_id', 'action', 'forum_data', 'template_data', 'old_forum_type', 'forum_desc_data', 'forum_rules_data'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_assign_template_forum_data', compact($vars))); + /** + * Modify forum template data before we display the form + * + * @event core.acp_manage_forums_display_form + * @var string action Type of the action: add|edit + * @var bool update Do we display the form only + * or did the user press submit + * @var int forum_id When editing: the forum id, + * when creating: the parent forum id + * @var array row Array with current forum data + * empty when creating new forum + * @var array forum_data Array with new forum data + * @var string parents_list List of parent options + * @var array errors Array of errors, if you add errors + * ensure to update the template variables + * S_ERROR and ERROR_MSG to display it + * @var array template_data Array with new forum data + * @since 3.1-A1 + */ + $vars = array('action', 'update', 'forum_id', 'row', 'forum_data', 'parents_list', 'errors', 'template_data'); + extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_display_form', compact($vars))); $template->assign_vars($template_data); -- cgit v1.2.1 From caf76b4cebccbfd7e348c89f7bce8d731fa2fd43 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Aug 2012 12:50:47 +0200 Subject: [feature/php-events] Fix naming and doc of core.acp_manage_forums_validate_data PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index c9225744bf..7af2fb822e 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -932,8 +932,17 @@ class acp_forums $errors = array(); + /** + * Validate the forum data before we create/update the forum + * + * @event core.acp_manage_forums_validate_data + * @var array forum_data Array with new forum data + * @var array errors Array of errors, should be strings and not + * language key. + * @since 3.1-A1 + */ $vars = array('forum_data', 'errors'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_update_forum_data', compact($vars))); + extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_validate_data', compact($vars))); if ($forum_data['forum_name'] == '') { -- cgit v1.2.1 From cfd5fcbe2609024f57c900435b02346d5c7e28e0 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Aug 2012 12:58:20 +0200 Subject: [feature/php-events] Add new event core.acp_manage_forums_update_data_before Allows you to remove data from forum_data_sql before we update/create the forum PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 7af2fb822e..151e03f18f 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1036,7 +1036,25 @@ class acp_forums } unset($forum_data_sql['forum_password_unset']); - if (!isset($forum_data_sql['forum_id'])) + $is_new_forum = !isset($forum_data_sql['forum_id']); + + /** + * Remove invalid values from forum_data_sql that should not be updated + * + * @event core.acp_manage_forums_update_data_before + * @var array forum_data Array with forum data + * @var array forum_data_sql Array with data we are going to update + * @var bool is_new_forum Do we create a forum or update one + * If you want to overwrite this value, + * ensure to set forum_data_sql[forum_id] + * @since 3.1-A1 + */ + $vars = array('forum_data', 'forum_data_sql'); + extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_before', compact($vars))); + + $is_new_forum = !isset($forum_data_sql['forum_id']); + + if ($is_new_forum) { // no forum_id means we're creating a new forum unset($forum_data_sql['type_action']); -- cgit v1.2.1 From 70c90bea4f8ba6cc0c4f34f2f55f8171f1b7ba87 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Aug 2012 13:06:20 +0200 Subject: [feature/php-events] Fix doc and naming of acp_manage_forums_update_data_after PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 151e03f18f..542c3ffd77 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1325,8 +1325,21 @@ class acp_forums add_log('admin', 'LOG_FORUM_EDIT', $forum_data['forum_name']); } - $vars = array('forum_data', 'errors'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_update_forum_data_after', compact($vars))); + /** + * Event after a forum was updated or created + * + * @event core.acp_manage_forums_update_data_after + * @var array forum_data Array with forum data + * @var array forum_data_sql Array with data we updated + * @var bool is_new_forum Did we create a forum or update one + * If you want to overwrite this value, + * ensure to set forum_data_sql[forum_id] + * @var array errors Array of errors, should be strings and not + * language key. + * @since 3.1-A1 + */ + $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))); return $errors; } -- cgit v1.2.1 From 43d17b2337eefa0530dea57516138eaf9724862b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Aug 2012 13:16:18 +0200 Subject: [feature/php-events] Fix doc and naming of core.acp_manage_forums_move_children PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 542c3ffd77..d6d8879f7b 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1353,9 +1353,6 @@ class acp_forums $to_data = $moved_ids = $errors = array(); - $vars = array('from_id', 'to_id'); - extract($phpbb_dispatcher->trigger_event('core.acp_forums_move_forum', compact($vars))); - // Check if we want to move to a parent with link type if ($to_id > 0) { @@ -1364,10 +1361,30 @@ class acp_forums if ($to_data['forum_type'] == FORUM_LINK) { $errors[] = $user->lang['PARENT_IS_LINK_FORUM']; - return $errors; } } + /** + * Event when we move all children of one forum to another + * + * This event may be triggered, when a forum is deleted + * + * @event core.acp_manage_forums_move_children + * @var int from_id If of the current parent forum + * @var int to_id If of the new parent forum + * @var array errors Array of errors, should be strings and not + * language key. + * @since 3.1-A1 + */ + $vars = array('from_id', 'to_id', 'errors'); + extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_children', compact($vars))); + + // Return if there were errors + if (!empty($errors)) + { + return $errors; + } + $moved_forums = get_forum_branch($from_id, 'children', 'descending'); $from_data = $moved_forums[0]; $diff = sizeof($moved_forums) * 2; -- cgit v1.2.1 From cdcadf72c4d613e262a06589e7dfe4c81803344c Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 8 Aug 2012 13:20:34 +0200 Subject: [feature/php-events] Add event core.acp_manage_forums_move_content PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index d6d8879f7b..6fb246458c 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1464,7 +1464,30 @@ class acp_forums */ function move_forum_content($from_id, $to_id, $sync = true) { - global $db; + global $db, $phpbb_dispatcher; + + $errors = array(); + + /** + * Event when we move content from one forum to another + * + * @event core.acp_manage_forums_move_children + * @var int from_id If of the current parent forum + * @var int to_id If of the new parent forum + * @var bool sync Shall we sync the "to"-forum's data + * @var array errors Array of errors, should be strings and not + * language key. If this array is not empty, + * The content will not be moved. + * @since 3.1-A1 + */ + $vars = array('from_id', 'to_id', 'sync', 'errors'); + extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_content', compact($vars))); + + // Return if there were errors + if (!empty($errors)) + { + return $errors; + } $table_ary = array(LOG_TABLE, POSTS_TABLE, TOPICS_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE); -- cgit v1.2.1 From b32d5a3edf418e2c9cdfa8cbe027c9da7e31d2f6 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 18 Aug 2012 20:25:11 +0200 Subject: [feature/php-events] Fix core.acp_manage_forums_update_data_after vars PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 6fb246458c..39bc7e39ad 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1338,7 +1338,7 @@ class acp_forums * language key. * @since 3.1-A1 */ - $vars = array('forum_data', 'forum_data_sql' 'is_new_forum', 'errors'); + $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))); return $errors; -- cgit v1.2.1 From 90ed6e734d7a8587e73fb0e37251982adc8d10ab Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 18 Aug 2012 20:28:14 +0200 Subject: [feature/php-events] Fix acp_manage_forums_update_data_before and is_new_forum PHPBB3-9550 --- phpBB/includes/acp/acp_forums.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 39bc7e39ad..c6dbf5eb9c 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1036,17 +1036,14 @@ class acp_forums } unset($forum_data_sql['forum_password_unset']); - $is_new_forum = !isset($forum_data_sql['forum_id']); - /** * Remove invalid values from forum_data_sql that should not be updated * * @event core.acp_manage_forums_update_data_before * @var array forum_data Array with forum data * @var array forum_data_sql Array with data we are going to update - * @var bool is_new_forum Do we create a forum or update one - * If you want to overwrite this value, - * ensure to set forum_data_sql[forum_id] + * If forum_data_sql[forum_id] is set, we update + * that forum, otherwise a new one is created. * @since 3.1-A1 */ $vars = array('forum_data', 'forum_data_sql'); -- cgit v1.2.1 From b8c55291ed7ed86565be2bc651bf20eb1a9ed4dd Mon Sep 17 00:00:00 2001 From: Josh Woody Date: Thu, 17 Jun 2010 23:58:18 -0500 Subject: [feature/soft-delete] Lay the groundwork for a soft-delete feature So far, I've added no new functionality. The biggest change here is adjusting the DB column names to "visibility" rather than "approved". Some things here are pretty likely to change, for example the name and location of the topic_visibility class. Happy birthday phpBB :) PHPBB3-9657 --- phpBB/includes/acp/acp_forums.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index c6dbf5eb9c..622d84d15e 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -314,7 +314,7 @@ class acp_forums $end = $start + $batch_size; // Sync all topics in batch mode... - sync('topic_approved', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, false); + sync('topic_visibility', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, false); sync('topic', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, true); if ($end < $row2['max_topic_id']) @@ -1793,7 +1793,7 @@ class acp_forums FROM ' . POSTS_TABLE . ' WHERE forum_id = ' . $forum_id . ' AND post_postcount = 1 - AND post_approved = 1'; + AND post_visibility = ' . ITEM_APPROVED; $result = $db->sql_query($sql); $post_counts = array(); @@ -1931,7 +1931,7 @@ class acp_forums // Make sure the overall post/topic count is correct... $sql = 'SELECT COUNT(post_id) AS stat FROM ' . POSTS_TABLE . ' - WHERE post_approved = 1'; + WHERE post_visibility = ' . ITEM_APPROVED; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -1940,7 +1940,7 @@ class acp_forums $sql = 'SELECT COUNT(topic_id) AS stat FROM ' . TOPICS_TABLE . ' - WHERE topic_approved = 1'; + WHERE topic_visibility = ' . ITEM_APPROVED; $result = $db->sql_query($sql); $row = $db->sql_fetchrow($result); $db->sql_freeresult($result); -- cgit v1.2.1 From 94417742885d066823314f100b1bdbe5b8b76c91 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 9 Oct 2012 11:55:31 +0200 Subject: [feature/soft-delete] Topic visibility is already synced by sync('topic') PHPBB3-9567 --- phpBB/includes/acp/acp_forums.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 622d84d15e..7f2539ec8d 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -314,7 +314,6 @@ class acp_forums $end = $start + $batch_size; // Sync all topics in batch mode... - sync('topic_visibility', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, false); sync('topic', 'range', 'topic_id BETWEEN ' . $start . ' AND ' . $end, true, true); if ($end < $row2['max_topic_id']) -- cgit v1.2.1 From eb9c39971bfe7c11d62466b8fab239a8fcbc8952 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 22 Oct 2012 17:34:37 +0200 Subject: [feature/soft-delete] Fix forum syncing in ACP and deleting posts PHPBB3-9567 --- phpBB/includes/acp/acp_forums.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 7f2539ec8d..8029181f39 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -283,7 +283,7 @@ class acp_forums @set_time_limit(0); - $sql = 'SELECT forum_name, forum_topics_real + $sql = 'SELECT forum_name, (forum_topics + forum_topics_unapproved + forum_topics_softdeleted) AS total_topics FROM ' . FORUMS_TABLE . " WHERE forum_id = $forum_id"; $result = $db->sql_query($sql); @@ -295,7 +295,7 @@ class acp_forums trigger_error($user->lang['NO_FORUM'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } - if ($row['forum_topics_real']) + if ($row['total_topics']) { $sql = 'SELECT MIN(topic_id) as min_topic_id, MAX(topic_id) as max_topic_id FROM ' . TOPICS_TABLE . ' @@ -329,15 +329,15 @@ class acp_forums $start += $batch_size; - $url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync&start=$start&topics_done=$topics_done&total={$row['forum_topics_real']}"; + $url = $this->u_action . "&parent_id={$this->parent_id}&f=$forum_id&action=sync&start=$start&topics_done=$topics_done&total={$row['total_topics']}"; meta_refresh(0, $url); $template->assign_vars(array( - 'U_PROGRESS_BAR' => $this->u_action . "&action=progress_bar&start=$topics_done&total={$row['forum_topics_real']}", - 'UA_PROGRESS_BAR' => addslashes($this->u_action . "&action=progress_bar&start=$topics_done&total={$row['forum_topics_real']}"), + 'U_PROGRESS_BAR' => $this->u_action . "&action=progress_bar&start=$topics_done&total={$row['total_topics']}", + 'UA_PROGRESS_BAR' => addslashes($this->u_action . "&action=progress_bar&start=$topics_done&total={$row['total_topics']}"), 'S_CONTINUE_SYNC' => true, - 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $topics_done, $row['forum_topics_real'])) + 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], $topics_done, $row['total_topics'])) ); return; @@ -351,7 +351,7 @@ class acp_forums 'U_PROGRESS_BAR' => $this->u_action . '&action=progress_bar', 'UA_PROGRESS_BAR' => addslashes($this->u_action . '&action=progress_bar'), 'S_CONTINUE_SYNC' => true, - 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], 0, $row['forum_topics_real'])) + 'L_PROGRESS_EXPLAIN' => sprintf($user->lang['SYNC_IN_PROGRESS_EXPLAIN'], 0, $row['total_topics'])) ); return; @@ -1143,7 +1143,8 @@ class acp_forums return array($user->lang['NO_FORUM_ACTION']); } - $forum_data_sql['forum_posts'] = $forum_data_sql['forum_topics'] = $forum_data_sql['forum_topics_real'] = $forum_data_sql['forum_last_post_id'] = $forum_data_sql['forum_last_poster_id'] = $forum_data_sql['forum_last_post_time'] = 0; + $forum_data_sql['forum_posts'] = $forum_data_sql['forum_posts_unapproved'] = $forum_data_sql['forum_posts_softdeleted'] = $forum_data_sql['forum_topics'] = $forum_data_sql['forum_topics_unapproved'] = $forum_data_sql['forum_topics_softdeleted'] = 0; + $forum_data_sql['forum_last_post_id'] = $forum_data_sql['forum_last_poster_id'] = $forum_data_sql['forum_last_post_time'] = 0; $forum_data_sql['forum_last_poster_name'] = $forum_data_sql['forum_last_poster_colour'] = ''; } else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_LINK) @@ -1264,8 +1265,11 @@ class acp_forums { // Changing a category to a forum? Reset the data (you can't post directly in a cat, you must use a forum) $forum_data_sql['forum_posts'] = 0; + $forum_data_sql['forum_posts_unapproved'] = 0; + $forum_data_sql['forum_posts_softdeleted'] = 0; $forum_data_sql['forum_topics'] = 0; - $forum_data_sql['forum_topics_real'] = 0; + $forum_data_sql['forum_topics_unapproved'] = 0; + $forum_data_sql['forum_topics_softdeleted'] = 0; $forum_data_sql['forum_last_post_id'] = 0; $forum_data_sql['forum_last_post_subject'] = ''; $forum_data_sql['forum_last_post_time'] = 0; -- cgit v1.2.1 From 9c2a58eff4c2bd164ee3bdb2ec66729d4562963d Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 9 Nov 2012 13:37:53 +0100 Subject: [feature/soft-delete] Append _approved to *_posts and *_topics column names PHPBB3-9567 --- phpBB/includes/acp/acp_forums.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 8029181f39..bb91acba74 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -856,8 +856,8 @@ class acp_forums 'FORUM_IMAGE_SRC' => ($row['forum_image']) ? $phpbb_root_path . $row['forum_image'] : '', 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESCRIPTION' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), - 'FORUM_TOPICS' => $row['forum_topics'], - 'FORUM_POSTS' => $row['forum_posts'], + 'FORUM_TOPICS' => $row['forum_topics_approved'], + 'FORUM_POSTS' => $row['forum_posts_approved'], 'S_FORUM_LINK' => ($forum_type == FORUM_LINK) ? true : false, 'S_FORUM_POST' => ($forum_type == FORUM_POST) ? true : false, @@ -1143,7 +1143,7 @@ class acp_forums return array($user->lang['NO_FORUM_ACTION']); } - $forum_data_sql['forum_posts'] = $forum_data_sql['forum_posts_unapproved'] = $forum_data_sql['forum_posts_softdeleted'] = $forum_data_sql['forum_topics'] = $forum_data_sql['forum_topics_unapproved'] = $forum_data_sql['forum_topics_softdeleted'] = 0; + $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; $forum_data_sql['forum_last_post_id'] = $forum_data_sql['forum_last_poster_id'] = $forum_data_sql['forum_last_post_time'] = 0; $forum_data_sql['forum_last_poster_name'] = $forum_data_sql['forum_last_poster_colour'] = ''; } @@ -1264,10 +1264,10 @@ class acp_forums else if ($row['forum_type'] == FORUM_CAT && $forum_data_sql['forum_type'] == FORUM_POST) { // Changing a category to a forum? Reset the data (you can't post directly in a cat, you must use a forum) - $forum_data_sql['forum_posts'] = 0; + $forum_data_sql['forum_posts_approved'] = 0; $forum_data_sql['forum_posts_unapproved'] = 0; $forum_data_sql['forum_posts_softdeleted'] = 0; - $forum_data_sql['forum_topics'] = 0; + $forum_data_sql['forum_topics_approved'] = 0; $forum_data_sql['forum_topics_unapproved'] = 0; $forum_data_sql['forum_topics_softdeleted'] = 0; $forum_data_sql['forum_last_post_id'] = 0; -- cgit v1.2.1 From f77a6eaab5485329a3b13922649fb8902e6e397f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 10 Nov 2012 11:24:52 +0100 Subject: [feature/soft-delete] Fix the rest of *_approved and the delete_post unit test PHPBB3-9567 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index bb91acba74..e8f0a01b2e 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -283,7 +283,7 @@ class acp_forums @set_time_limit(0); - $sql = 'SELECT forum_name, (forum_topics + forum_topics_unapproved + forum_topics_softdeleted) AS total_topics + $sql = 'SELECT forum_name, (forum_topics_approved + forum_topics_unapproved + forum_topics_softdeleted) AS total_topics FROM ' . FORUMS_TABLE . " WHERE forum_id = $forum_id"; $result = $db->sql_query($sql); -- cgit v1.2.1 From 5c496674f63b31e892d0f3bed7921feb947ed839 Mon Sep 17 00:00:00 2001 From: Oleg Pudeyev Date: Sat, 15 Dec 2012 01:19:55 -0500 Subject: [ticket/10758] Dependency inject parameters into cache_moderators. Also add phpbb prefix since the signature is being changed anyway. PHPBB3-10758 --- phpBB/includes/acp/acp_forums.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index c6dbf5eb9c..7e8d5d8388 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -206,7 +206,7 @@ class acp_forums ($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')))) { copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false); - cache_moderators(); + phpbb_cache_moderators($db, $cache, $auth); $copied_permissions = true; } /* Commented out because of questionable UI workflow - re-visit for 3.0.7 @@ -266,7 +266,7 @@ class acp_forums add_log('admin', 'LOG_FORUM_' . strtoupper($action), $row['forum_name'], $move_forum_name); $cache->destroy('sql', FORUMS_TABLE); } - + if ($request->is_ajax()) { $json_response = new phpbb_json_response; @@ -768,7 +768,7 @@ class acp_forums if (!empty($forum_perm_from) && $forum_perm_from != $forum_id) { copy_forum_permissions($forum_perm_from, $forum_id, true); - cache_moderators(); + phpbb_cache_moderators($db, $cache, $auth); $auth->acl_clear_prefetch(); $cache->destroy('sql', FORUMS_TABLE); -- cgit v1.2.1 From b95fdacdd378877d277e261465da73deb06e50da Mon Sep 17 00:00:00 2001 From: Nils Adermann Date: Tue, 10 Sep 2013 14:01:09 +0200 Subject: [ticket/11700] Move all recent code to namespaces PHPBB3-11700 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 970b033995..580c68f3ed 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -269,7 +269,7 @@ class acp_forums if ($request->is_ajax()) { - $json_response = new phpbb_json_response; + $json_response = new \phpbb\json_response; $json_response->send(array('success' => ($move_forum_name !== false))); } -- cgit v1.2.1 From 61f60d395a5f16105a18790f2f73eddcd830e475 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 13 Oct 2013 16:32:37 +0200 Subject: [feature/passwords] Use passwords manager service instead of functions The old functions phpbb_hash() and phpbb_check_hash() have been replaced with the passwords manager service in all front-end related files. The phpBB2 converter and the release_3_0_5_rc1 migration file have not been changed. The same applies to the security/hash_test that still tests the function phpbb_check_hash(). This will however make sure that the old function still works. PHPBB3-11610 --- phpBB/includes/acp/acp_forums.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 258aabcc0d..6a86e5683d 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -926,7 +926,7 @@ class acp_forums */ function update_forum_data(&$forum_data) { - global $db, $user, $cache, $phpbb_root_path, $phpbb_dispatcher; + global $db, $user, $cache, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher; $errors = array(); @@ -1030,7 +1030,10 @@ class acp_forums } else { - $forum_data_sql['forum_password'] = phpbb_hash($forum_data_sql['forum_password']); + // Instantiate 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']); -- cgit v1.2.1 From 3c9a8a3788f4dda1ef16430f16d6392a9e6f8dad Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 16 Oct 2013 16:32:40 +0200 Subject: [ticket/11924] Fix some minor issues with the php event docs PHPBB3-11924 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 258aabcc0d..029f4b23c9 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1470,7 +1470,7 @@ class acp_forums /** * Event when we move content from one forum to another * - * @event core.acp_manage_forums_move_children + * @event core.acp_manage_forums_move_content * @var int from_id If of the current parent forum * @var int to_id If of the new parent forum * @var bool sync Shall we sync the "to"-forum's data -- cgit v1.2.1 From 3c7ff1c417bd57ab71057fa3d880d58f1ee65f2a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 30 Jan 2014 22:21:06 +0100 Subject: [ticket/12150] Add options to acp PHPBB3-12150 --- phpBB/includes/acp/acp_forums.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index a1af8c489d..4cefc04608 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -457,6 +457,9 @@ class acp_forums 'prune_days' => 7, 'prune_viewed' => 7, 'prune_freq' => 1, + 'enable_shadow_topic_prune' => false, + 'prune_shadow_topic_days' => 7, + 'prune_shadow_topic_freq' => 1, 'forum_flags' => FORUM_FLAG_POST_REVIEW + FORUM_FLAG_ACTIVE_TOPICS, 'forum_options' => 0, 'forum_password' => '', -- cgit v1.2.1 From d97c58aeeaf24b6d76e21642e1764b471f212d87 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 2 Feb 2014 12:52:57 +0100 Subject: [ticket/12150] Add missing prune settings variables in acp_forums PHPBB3-12150 --- phpBB/includes/acp/acp_forums.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 4cefc04608..4cce7b07ce 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -138,12 +138,15 @@ class acp_forums '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_topic_prune' => request_var('enable_shadow_topic_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_topic_days' => request_var('prune_shadow_topic_days', 7), + 'prune_shadow_topic_freq' => request_var('prune_shadow_topic_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), @@ -639,6 +642,8 @@ class acp_forums 'PRUNE_FREQ' => $forum_data['prune_freq'], 'PRUNE_DAYS' => $forum_data['prune_days'], 'PRUNE_VIEWED' => $forum_data['prune_viewed'], + 'PRUNE_SHADOW_TOPIC_FREQ' => $forum_data['prune_shadow_topic_freq'], + 'PRUNE_SHADOW_TOPIC_DAYS' => $forum_data['prune_shadow_topic_days'], 'TOPICS_PER_PAGE' => $forum_data['forum_topics_per_page'], 'FORUM_RULES_LINK' => $forum_data['forum_rules_link'], 'FORUM_RULES' => $forum_data['forum_rules'], @@ -671,6 +676,7 @@ class acp_forums 'S_DISPLAY_SUBFORUM_LIST' => ($forum_data['display_subforum_list']) ? true : false, 'S_DISPLAY_ON_INDEX' => ($forum_data['display_on_index']) ? true : false, 'S_PRUNE_ENABLE' => ($forum_data['enable_prune']) ? true : false, + 'S_PRUNE_SHADOW_TOPIC_ENABLE' => ($forum_data['enable_shadow_topic_prune']) ? true : false, 'S_FORUM_LINK_TRACK' => ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? 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, -- cgit v1.2.1 From d83d819827634931e9317469090e933edfc99f2b Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 14 Mar 2014 23:35:07 +0100 Subject: [ticket/12150] Use shorter column names for prune settings All columns were renamed from having prune_shadow_topics as namebase to just prune_shadow. A missing column was also added to the migration file's remove_schema() method. PHPBB3-12150 --- phpBB/includes/acp/acp_forums.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 4cce7b07ce..c47d9bc185 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -138,15 +138,15 @@ class acp_forums '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_topic_prune' => request_var('enable_shadow_topic_prune', 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_topic_days' => request_var('prune_shadow_topic_days', 7), - 'prune_shadow_topic_freq' => request_var('prune_shadow_topic_freq', 1), + '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), @@ -460,9 +460,9 @@ class acp_forums 'prune_days' => 7, 'prune_viewed' => 7, 'prune_freq' => 1, - 'enable_shadow_topic_prune' => false, - 'prune_shadow_topic_days' => 7, - 'prune_shadow_topic_freq' => 1, + 'enable_shadow_prune' => false, + 'prune_shadow_days' => 7, + 'prune_shadow_freq' => 1, 'forum_flags' => FORUM_FLAG_POST_REVIEW + FORUM_FLAG_ACTIVE_TOPICS, 'forum_options' => 0, 'forum_password' => '', @@ -642,8 +642,8 @@ class acp_forums 'PRUNE_FREQ' => $forum_data['prune_freq'], 'PRUNE_DAYS' => $forum_data['prune_days'], 'PRUNE_VIEWED' => $forum_data['prune_viewed'], - 'PRUNE_SHADOW_TOPIC_FREQ' => $forum_data['prune_shadow_topic_freq'], - 'PRUNE_SHADOW_TOPIC_DAYS' => $forum_data['prune_shadow_topic_days'], + 'PRUNE_SHADOW_FREQ' => $forum_data['prune_shadow_freq'], + 'PRUNE_SHADOW_DAYS' => $forum_data['prune_shadow_days'], 'TOPICS_PER_PAGE' => $forum_data['forum_topics_per_page'], 'FORUM_RULES_LINK' => $forum_data['forum_rules_link'], 'FORUM_RULES' => $forum_data['forum_rules'], @@ -676,7 +676,7 @@ class acp_forums 'S_DISPLAY_SUBFORUM_LIST' => ($forum_data['display_subforum_list']) ? true : false, 'S_DISPLAY_ON_INDEX' => ($forum_data['display_on_index']) ? true : false, 'S_PRUNE_ENABLE' => ($forum_data['enable_prune']) ? true : false, - 'S_PRUNE_SHADOW_TOPIC_ENABLE' => ($forum_data['enable_shadow_topic_prune']) ? true : false, + 'S_PRUNE_SHADOW_ENABLE' => ($forum_data['enable_shadow_prune']) ? true : false, 'S_FORUM_LINK_TRACK' => ($forum_data['forum_flags'] & FORUM_FLAG_LINK_TRACK) ? 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, -- cgit v1.2.1 From c2dace762ec295c7a2d67758006b1fff56f1f573 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 20 Apr 2014 15:13:13 +0200 Subject: [ticket/12273] Fix long $vars lines for existing events PHPBB3-12273 --- phpBB/includes/acp/acp_forums.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index c47d9bc185..0163d12ed0 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -707,7 +707,8 @@ class acp_forums * @var array template_data Array with new forum data * @since 3.1-A1 */ - $vars = array('action', 'update', 'forum_id', 'row', 'forum_data', 'parents_list', 'errors', 'template_data'); + $vars = array('action', 'update', 'forum_id', 'row', 'forum_data'); + $vars = array_merge($vars, array('parents_list', 'errors', 'template_data')); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_display_form', compact($vars))); $template->assign_vars($template_data); -- cgit v1.2.1 From 87899b0e140400e23341ea1286d50e330132be90 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 25 Apr 2014 11:46:44 +0200 Subject: [ticket/12273] Update existing events PHPBB3-12273 --- phpBB/includes/acp/acp_forums.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 0163d12ed0..4d100d32c2 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -707,8 +707,16 @@ class acp_forums * @var array template_data Array with new forum data * @since 3.1-A1 */ - $vars = array('action', 'update', 'forum_id', 'row', 'forum_data'); - $vars = array_merge($vars, array('parents_list', 'errors', 'template_data')); + $vars = array( + 'action', + 'update', + 'forum_id', + 'row', + 'forum_data', + 'parents_list', + 'errors', + 'template_data', + ); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_display_form', compact($vars))); $template->assign_vars($template_data); -- cgit v1.2.1 From b32895308d13d5d9b0cd954fd8ce871a1fa073da Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 25 Apr 2014 12:15:44 +0200 Subject: [ticket/12273] Update since version to 3.1.0-a* style PHPBB3-12273 --- phpBB/includes/acp/acp_forums.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 4d100d32c2..160bfc05de 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -158,7 +158,7 @@ class acp_forums * @event core.acp_manage_forums_request_data * @var string action Type of the action: add|edit * @var array forum_data Array with new forum data - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('action', 'forum_data'); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_request_data', compact($vars))); @@ -484,7 +484,7 @@ class acp_forums * empty when creating new forum * @var array forum_data Array with new forum data * @var string parents_list List of parent options - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('action', 'update', 'forum_id', 'row', 'forum_data', 'parents_list'); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_initialise_data', compact($vars))); @@ -705,7 +705,7 @@ class acp_forums * ensure to update the template variables * S_ERROR and ERROR_MSG to display it * @var array template_data Array with new forum data - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array( 'action', @@ -955,7 +955,7 @@ class acp_forums * @var array forum_data Array with new forum data * @var array errors Array of errors, should be strings and not * language key. - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('forum_data', 'errors'); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_validate_data', compact($vars))); @@ -1063,7 +1063,7 @@ class acp_forums * @var array forum_data_sql Array with data we are going to update * If forum_data_sql[forum_id] is set, we update * that forum, otherwise a new one is created. - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('forum_data', 'forum_data_sql'); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_before', compact($vars))); @@ -1356,7 +1356,7 @@ class acp_forums * ensure to set forum_data_sql[forum_id] * @var array errors Array of errors, should be strings and not * language key. - * @since 3.1-A1 + * @since 3.1.0-a1 */ $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))); @@ -1394,7 +1394,7 @@ class acp_forums * @var int to_id If of the new parent forum * @var array errors Array of errors, should be strings and not * language key. - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('from_id', 'to_id', 'errors'); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_children', compact($vars))); @@ -1498,7 +1498,7 @@ class acp_forums * @var array errors Array of errors, should be strings and not * language key. If this array is not empty, * The content will not be moved. - * @since 3.1-A1 + * @since 3.1.0-a1 */ $vars = array('from_id', 'to_id', 'sync', 'errors'); extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_content', compact($vars))); -- cgit v1.2.1 From a759704b39fc1c1353f865a633759b1369589b67 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 20:18:06 +0200 Subject: [ticket/12594] Remove @package tags and update file headers PHPBB3-12594 --- phpBB/includes/acp/acp_forums.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 160bfc05de..f8c463e158 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ @@ -15,9 +19,6 @@ if (!defined('IN_PHPBB')) exit; } -/** -* @package acp -*/ class acp_forums { var $u_action; -- cgit v1.2.1 From ff6e026a403a622bd1aa498bff396a737735faed Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Thu, 26 Jun 2014 17:17:35 +0200 Subject: [ticket/12446] Unnecessary db connect inphpbb_bootstrap_enabled_exts PHPBB3-12446 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index f8c463e158..adf5de44f5 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1827,7 +1827,7 @@ class acp_forums } $db->sql_freeresult($result); - switch ($db->sql_layer) + switch ($db->get_sql_layer()) { case 'mysql4': case 'mysqli': -- cgit v1.2.1 From e30c6caac8ea71086625348c39e25f000cf531d6 Mon Sep 17 00:00:00 2001 From: alf007 Date: Fri, 15 May 2015 19:45:28 +0200 Subject: [ticket/13311] Add core event on acp_forums for forum content deletes Event added for the function delete_forum_content() in includes/acp/acp_forums.php, so that you can insert any extension's table(s) to be updated when forum content is deleted Incude parameters forum_id, topic_ids and post_counts PHPBB3-13311 --- phpBB/includes/acp/acp_forums.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index adf5de44f5..d457c5dd70 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1786,7 +1786,7 @@ class acp_forums */ function delete_forum_content($forum_id) { - global $db, $config, $phpbb_root_path, $phpEx; + global $db, $config, $phpbb_root_path, $phpEx, $phpbb_dispatcher; include_once($phpbb_root_path . 'includes/functions_posting.' . $phpEx); @@ -1918,6 +1918,24 @@ class acp_forums $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.5-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) { $db->sql_query("DELETE FROM $table WHERE forum_id = $forum_id"); -- cgit v1.2.1 From ce937346f30c09b919b056ff72f2ac8813a6c292 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 22 Jul 2015 09:29:22 +0200 Subject: [ticket/13311] Update @since to 3.1.6-RC1 PHPBB3-13311 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index d457c5dd70..71953e7d8f 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1926,7 +1926,7 @@ class acp_forums * @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.5-RC1 + * @since 3.1.6-RC1 */ $vars = array( 'table_ary', -- cgit v1.2.1 From 23aed664732e3e21ca6be4ec727bd173e5278add Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Wed, 22 Jul 2015 09:54:28 +0200 Subject: [ticket/13311] Remove whitespace at end of line PHPBB3-13311 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 71953e7d8f..7e664c6263 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1924,7 +1924,7 @@ class acp_forums * @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 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 */ -- cgit v1.2.1 From 5b61ac06cbb065d0e5d6c0c108ead96cea0c3333 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sat, 2 Apr 2016 09:46:54 +0200 Subject: [ticket/14577] Do not calculate size of array in for loop For loops that modify the size of the looped arrays were obviously not changed. PHPBB3-14577 --- phpBB/includes/acp/acp_forums.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 7e664c6263..98273f06d9 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -1411,7 +1411,7 @@ class acp_forums $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']; } -- cgit v1.2.1 From 3bf64de247f23f701e92d17ccb7c055fb019623d Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 7 Aug 2016 16:10:49 +0700 Subject: [ticket/14738] Add core events to improve modifying forum lists PHPBB3-14738 --- phpBB/includes/acp/acp_forums.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'phpBB/includes/acp/acp_forums.php') diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index 98273f06d9..1e69a4ad20 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -842,9 +842,26 @@ class acp_forums ORDER BY left_id"; $result = $db->sql_query($sql); - if ($row = $db->sql_fetchrow($result)) + $rowset = array(); + while ($row = $db->sql_fetchrow($result)) + { + $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)) { - do + foreach ($rowset as $row) { $forum_type = $row['forum_type']; @@ -888,7 +905,6 @@ class acp_forums 'U_SYNC' => $url . '&action=sync') ); } - while ($row = $db->sql_fetchrow($result)); } else if ($this->parent_id) { @@ -904,7 +920,7 @@ class acp_forums 'U_SYNC' => $url . '&action=sync') ); } - $db->sql_freeresult($result); + unset($rowset); $template->assign_vars(array( 'ERROR_MSG' => (sizeof($errors)) ? implode('
', $errors) : '', -- cgit v1.2.1