Changeset 702 for trunk/forum/includes/acp/acp_forums.php
- Timestamp:
- Mar 31, 2010, 6:32:40 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/forum/includes/acp/acp_forums.php
r400 r702 3 3 * 4 4 * @package acp 5 * @version $Id : acp_forums.php 8898 2008-09-19 17:07:13Z acydburn$5 * @version $Id$ 6 6 * @copyright (c) 2005 phpBB Group 7 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License … … 140 140 'enable_prune' => request_var('enable_prune', false), 141 141 'enable_post_review' => request_var('enable_post_review', true), 142 'enable_quick_reply' => request_var('enable_quick_reply', false), 142 143 'prune_days' => request_var('prune_days', 7), 143 144 'prune_viewed' => request_var('prune_viewed', 7), … … 151 152 ); 152 153 154 // On add, add empty forum_options... else do not consider it (not updating it) 155 if ($action == 'add') 156 { 157 $forum_data['forum_options'] = 0; 158 } 159 153 160 // Use link_display_on_index setting if forum type is link 154 161 if ($forum_data['forum_type'] == FORUM_LINK) … … 163 170 } 164 171 165 $forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? request_var('display_recent', false) : request_var('display_active', false);172 $forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? request_var('display_recent', true) : request_var('display_active', true); 166 173 167 174 // Get data for forum rules if specified... … … 182 189 { 183 190 $forum_perm_from = request_var('forum_perm_from', 0); 191 $cache->destroy('sql', FORUMS_TABLE); 184 192 185 193 // Copy permissions? 186 if ($forum_perm_from && !empty($forum_perm_from) &&$forum_perm_from != $forum_data['forum_id'] &&187 ( ($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'))))194 if ($forum_perm_from && $forum_perm_from != $forum_data['forum_id'] && 195 ($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')))) 188 196 { 189 // if we edit a forum delete current permissions first 190 if ($action == 'edit') 191 { 192 $sql = 'DELETE FROM ' . ACL_USERS_TABLE . ' 193 WHERE forum_id = ' . (int) $forum_data['forum_id']; 194 $db->sql_query($sql); 195 196 $sql = 'DELETE FROM ' . ACL_GROUPS_TABLE . ' 197 WHERE forum_id = ' . (int) $forum_data['forum_id']; 198 $db->sql_query($sql); 199 } 200 201 // From the mysql documentation: 202 // 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. 203 // Due to this we stay on the safe side if we do the insertion "the manual way" 204 205 // Copy permisisons from/to the acl users table (only forum_id gets changed) 206 $sql = 'SELECT user_id, auth_option_id, auth_role_id, auth_setting 207 FROM ' . ACL_USERS_TABLE . ' 208 WHERE forum_id = ' . $forum_perm_from; 209 $result = $db->sql_query($sql); 210 211 $users_sql_ary = array(); 212 while ($row = $db->sql_fetchrow($result)) 213 { 214 $users_sql_ary[] = array( 215 'user_id' => (int) $row['user_id'], 216 'forum_id' => (int) $forum_data['forum_id'], 217 'auth_option_id' => (int) $row['auth_option_id'], 218 'auth_role_id' => (int) $row['auth_role_id'], 219 'auth_setting' => (int) $row['auth_setting'] 220 ); 221 } 222 $db->sql_freeresult($result); 223 224 // Copy permisisons from/to the acl groups table (only forum_id gets changed) 225 $sql = 'SELECT group_id, auth_option_id, auth_role_id, auth_setting 226 FROM ' . ACL_GROUPS_TABLE . ' 227 WHERE forum_id = ' . $forum_perm_from; 228 $result = $db->sql_query($sql); 229 230 $groups_sql_ary = array(); 231 while ($row = $db->sql_fetchrow($result)) 232 { 233 $groups_sql_ary[] = array( 234 'group_id' => (int) $row['group_id'], 235 'forum_id' => (int) $forum_data['forum_id'], 236 'auth_option_id' => (int) $row['auth_option_id'], 237 'auth_role_id' => (int) $row['auth_role_id'], 238 'auth_setting' => (int) $row['auth_setting'] 239 ); 240 } 241 $db->sql_freeresult($result); 242 243 // Now insert the data 244 $db->sql_multi_insert(ACL_USERS_TABLE, $users_sql_ary); 245 $db->sql_multi_insert(ACL_GROUPS_TABLE, $groups_sql_ary); 197 copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false); 246 198 cache_moderators(); 247 199 } 248 200 /* Commented out because of questionable UI workflow - re-visit for 3.0.7 201 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')) 202 { 203 $this->copy_permission_page($forum_data); 204 return; 205 } 206 */ 249 207 $auth->acl_clear_prefetch(); 250 $cache->destroy('sql', FORUMS_TABLE);251 208 252 209 $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; … … 424 381 $forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0; 425 382 $forum_data['forum_flags'] += (request_var('enable_post_review', true)) ? FORUM_FLAG_POST_REVIEW : 0; 383 $forum_data['forum_flags'] += (request_var('enable_quick_reply', false)) ? FORUM_FLAG_QUICK_REPLY : 0; 426 384 } 427 385 … … 485 443 'prune_viewed' => 7, 486 444 'prune_freq' => 1, 487 'forum_flags' => FORUM_FLAG_POST_REVIEW, 445 'forum_flags' => FORUM_FLAG_POST_REVIEW + FORUM_FLAG_ACTIVE_TOPICS, 446 'forum_options' => 0, 488 447 'forum_password' => '', 489 448 'forum_password_confirm'=> '', … … 561 520 WHERE forum_type = ' . FORUM_POST . " 562 521 AND forum_id <> $forum_id"; 563 $result = $db->sql_query($sql); 564 522 $result = $db->sql_query_limit($sql, 1); 523 524 $postable_forum_exists = false; 565 525 if ($db->sql_fetchrow($result)) 566 526 { 567 $template->assign_vars(array( 568 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false)) 569 ); 527 $postable_forum_exists = true; 570 528 } 571 529 $db->sql_freeresult($result); … … 584 542 $forums_list = make_forum_select($forum_data['parent_id'], $subforums_id); 585 543 586 $sql = 'SELECT forum_id 587 FROM ' . FORUMS_TABLE . ' 588 WHERE forum_type = ' . FORUM_POST . " 589 AND forum_id <> $forum_id"; 590 $result = $db->sql_query($sql); 591 592 if ($db->sql_fetchrow($result)) 544 if ($postable_forum_exists) 593 545 { 594 546 $template->assign_vars(array( … … 596 548 ); 597 549 } 598 $db->sql_freeresult($result);599 550 600 551 $template->assign_vars(array( 601 552 'S_HAS_SUBFORUMS' => ($forum_data['right_id'] - $forum_data['left_id'] > 1) ? true : false, 602 553 'S_FORUMS_LIST' => $forums_list) 554 ); 555 } 556 else if ($postable_forum_exists) 557 { 558 $template->assign_vars(array( 559 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false)) 603 560 ); 604 561 } … … 685 642 'S_DISPLAY_ACTIVE_TOPICS' => ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) ? true : false, 686 643 'S_ENABLE_POST_REVIEW' => ($forum_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) ? true : false, 644 'S_ENABLE_QUICK_REPLY' => ($forum_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) ? true : false, 687 645 '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, 688 646 )); … … 715 673 WHERE forum_type = ' . FORUM_POST . " 716 674 AND forum_id <> $forum_id"; 717 $result = $db->sql_query ($sql);675 $result = $db->sql_query_limit($sql, 1); 718 676 719 677 if ($db->sql_fetchrow($result)) … … 743 701 return; 744 702 break; 703 704 case 'copy_perm': 705 $forum_perm_from = request_var('forum_perm_from', 0); 706 707 // Copy permissions? 708 if (!empty($forum_perm_from) && $forum_perm_from != $forum_id) 709 { 710 copy_forum_permissions($forum_perm_from, $forum_id, true); 711 cache_moderators(); 712 $auth->acl_clear_prefetch(); 713 $cache->destroy('sql', FORUMS_TABLE); 714 715 $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_id; 716 717 $message = $user->lang['FORUM_UPDATED']; 718 719 // Redirect to permissions 720 if ($auth->acl_get('a_fauth')) 721 { 722 $message .= '<br /><br />' . sprintf($user->lang['REDIRECT_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>'); 723 } 724 725 trigger_error($message . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id)); 726 } 727 728 break; 745 729 } 746 730 … … 807 791 808 792 $url = $this->u_action . "&parent_id=$this->parent_id&f={$row['forum_id']}"; 809 810 $forum_title = ($forum_type != FORUM_LINK) ? '<a href="' . $this->u_action . '&parent_id=' . $row['forum_id'] . '">' : '';811 $forum_title .= $row['forum_name'];812 $forum_title .= ($forum_type != FORUM_LINK) ? '</a>' : '';813 793 814 794 $template->assign_block_vars('forums', array( … … 889 869 function update_forum_data(&$forum_data) 890 870 { 891 global $db, $user, $cache ;871 global $db, $user, $cache, $phpbb_root_path; 892 872 893 873 $errors = array(); … … 926 906 array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data['forum_topics_per_page'], 'column_type' => 'TINT:0'), 927 907 ); 908 909 if (!empty($forum_data['forum_image']) && !file_exists($phpbb_root_path . $forum_data['forum_image'])) 910 { 911 $errors[] = $user->lang['FORUM_IMAGE_NO_EXIST']; 912 } 928 913 929 914 validate_range($range_test_ary, $errors); … … 943 928 $forum_data['forum_flags'] += ($forum_data['show_active']) ? FORUM_FLAG_ACTIVE_TOPICS : 0; 944 929 $forum_data['forum_flags'] += ($forum_data['enable_post_review']) ? FORUM_FLAG_POST_REVIEW : 0; 930 $forum_data['forum_flags'] += ($forum_data['enable_quick_reply']) ? FORUM_FLAG_QUICK_REPLY : 0; 945 931 946 932 // Unset data that are not database fields … … 953 939 unset($forum_data_sql['show_active']); 954 940 unset($forum_data_sql['enable_post_review']); 941 unset($forum_data_sql['enable_quick_reply']); 955 942 unset($forum_data_sql['forum_password_confirm']); 956 943 … … 1929 1916 adm_page_footer(); 1930 1917 } 1918 1919 /** 1920 * Display copy permission page 1921 * Not used at the moment - we will have a look at it for 3.0.7 1922 */ 1923 function copy_permission_page($forum_data) 1924 { 1925 global $phpEx, $phpbb_admin_path, $template, $user; 1926 1927 $acl_url = '&mode=setting_forum_local&forum_id[]=' . $forum_data['forum_id']; 1928 $action = append_sid($this->u_action . "&parent_id={$this->parent_id}&f={$forum_data['forum_id']}&action=copy_perm"); 1929 1930 $l_acl = sprintf($user->lang['COPY_TO_ACL'], '<a href="' . append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url) . '">', '</a>'); 1931 1932 $this->tpl_name = 'acp_forums_copy_perm'; 1933 1934 $template->assign_vars(array( 1935 'U_ACL' => append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url), 1936 'L_ACL_LINK' => $l_acl, 1937 'L_BACK_LINK' => adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), 1938 'S_COPY_ACTION' => $action, 1939 'S_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_data['forum_id'], false, false, false), 1940 )); 1941 } 1942 1931 1943 } 1932 1944
Note:
See TracChangeset
for help on using the changeset viewer.