diff options
Diffstat (limited to 'phpBB/modules/acp')
-rw-r--r-- | phpBB/modules/acp/acp_attachments.php | 4 | ||||
-rw-r--r-- | phpBB/modules/acp/acp_captcha.php | 2 | ||||
-rw-r--r-- | phpBB/modules/acp/acp_email.php | 2 | ||||
-rw-r--r-- | phpBB/modules/acp/acp_forums.php | 35 | ||||
-rw-r--r-- | phpBB/modules/acp/acp_inactive.php | 14 | ||||
-rw-r--r-- | phpBB/modules/acp/acp_jabber.php | 3 | ||||
-rw-r--r-- | phpBB/modules/acp/acp_main.php | 6 | ||||
-rw-r--r-- | phpBB/modules/acp/acp_permissions.php | 6 | ||||
-rw-r--r-- | phpBB/modules/acp/acp_styles.php | 217 | ||||
-rw-r--r-- | phpBB/modules/acp/acp_users.php | 1 | ||||
-rw-r--r-- | phpBB/modules/acp/auth.php | 64 |
11 files changed, 201 insertions, 153 deletions
diff --git a/phpBB/modules/acp/acp_attachments.php b/phpBB/modules/acp/acp_attachments.php index 580490d472..a6c35acdbd 100644 --- a/phpBB/modules/acp/acp_attachments.php +++ b/phpBB/modules/acp/acp_attachments.php @@ -1002,8 +1002,8 @@ class acp_attachments if ($files_added) { - set_config('upload_dir_size', phpbb::$config['upload_dir_size'] + $space_taken, true); - set_config('num_files', phpbb::$config['num_files'] + $files_added, true); + set_config_count('upload_dir_size', $space_taken, true); + set_config_count('num_files', $files_added, true); } } } diff --git a/phpBB/modules/acp/acp_captcha.php b/phpBB/modules/acp/acp_captcha.php index e4a269aaed..3ffefa85a1 100644 --- a/phpBB/modules/acp/acp_captcha.php +++ b/phpBB/modules/acp/acp_captcha.php @@ -52,6 +52,8 @@ class acp_captcha $config_vars = array( 'enable_confirm' => 'REG_ENABLE', 'enable_post_confirm' => 'POST_ENABLE', + 'confirm_refresh' => 'CONFIRM_REFRESH', + 'captcha_gd' => 'CAPTCHA_GD', ); $this->tpl_name = 'acp_captcha'; diff --git a/phpBB/modules/acp/acp_email.php b/phpBB/modules/acp/acp_email.php index 3fc3db2055..b0dbb87641 100644 --- a/phpBB/modules/acp/acp_email.php +++ b/phpBB/modules/acp/acp_email.php @@ -118,7 +118,7 @@ class acp_email { if (($row['user_notify_type'] == NOTIFY_EMAIL && $row['user_email']) || ($row['user_notify_type'] == NOTIFY_IM && $row['user_jabber']) || - ($row['user_notify_type'] == NOTIFY_BOTH && $row['user_email'] && $row['user_jabber'])) + ($row['user_notify_type'] == NOTIFY_BOTH && ($row['user_email'] || $row['user_jabber']))) { if ($i == $max_chunk_size || $row['user_lang'] != $old_lang || $row['user_notify_type'] != $old_notify_type) { diff --git a/phpBB/modules/acp/acp_forums.php b/phpBB/modules/acp/acp_forums.php index 047636c6a1..d0581a2a68 100644 --- a/phpBB/modules/acp/acp_forums.php +++ b/phpBB/modules/acp/acp_forums.php @@ -180,7 +180,7 @@ class acp_forums $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'] && + if (!empty($forum_perm_from) && $forum_perm_from != $forum_data['forum_id'] && (($action != 'edit') || empty($forum_id) || (phpbb::$acl->acl_get('a_fauth') && phpbb::$acl->acl_get('a_authusers') && phpbb::$acl->acl_get('a_authgroups') && phpbb::$acl->acl_get('a_mauth')))) { // if we edit a forum delete current permissions first @@ -557,13 +557,12 @@ class acp_forums FROM ' . FORUMS_TABLE . ' WHERE forum_type = ' . FORUM_POST . " AND forum_id <> $forum_id"; - $result = phpbb::$db->sql_query($sql); + $result = phpbb::$db->sql_query_limit($sql, 1); + $postable_forum_exists = false; if (phpbb::$db->sql_fetchrow($result)) { - phpbb::$template->assign_vars(array( - 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $forum_id, false, true, false), - )); + $postable_forum_exists = true; } phpbb::$db->sql_freeresult($result); @@ -580,25 +579,24 @@ class acp_forums $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 = phpbb::$db->sql_query($sql); - - if (phpbb::$db->sql_fetchrow($result)) + if ($postable_forum_exists) { phpbb::$template->assign_vars(array( 'S_MOVE_FORUM_OPTIONS' => make_forum_select($forum_data['parent_id'], $subforums_id), // , false, true, false??? )); } - phpbb::$db->sql_freeresult($result); phpbb::$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; @@ -711,7 +709,7 @@ class acp_forums FROM ' . FORUMS_TABLE . ' WHERE forum_type = ' . FORUM_POST . " AND forum_id <> $forum_id"; - $result = phpbb::$db->sql_query($sql); + $result = phpbb::$db->sql_query_limit($sql, 1); if (phpbb::$db->sql_fetchrow($result)) { @@ -804,10 +802,6 @@ class acp_forums $url = $this->u_action . "&parent_id=$this->parent_id&f={$row['forum_id']}"; - $forum_title = ($forum_type != FORUM_LINK) ? '<a href="' . $this->u_action . '&parent_id=' . $row['forum_id'] . '">' : ''; - $forum_title .= $row['forum_name']; - $forum_title .= ($forum_type != FORUM_LINK) ? '</a>' : ''; - phpbb::$template->assign_block_vars('forums', array( 'FOLDER_IMAGE' => $folder_image, 'FORUM_IMAGE' => ($row['forum_image']) ? '<img src="' . PHPBB_ROOT_PATH . $row['forum_image'] . '" alt="" />' : '', @@ -919,6 +913,11 @@ class acp_forums array('lang' => 'FORUM_TOPICS_PAGE', 'value' => $forum_data['forum_topics_per_page'], 'column_type' => 'TINT:0'), ); + if (!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 diff --git a/phpBB/modules/acp/acp_inactive.php b/phpBB/modules/acp/acp_inactive.php index 89583575db..d93b2146a6 100644 --- a/phpBB/modules/acp/acp_inactive.php +++ b/phpBB/modules/acp/acp_inactive.php @@ -108,6 +108,7 @@ class acp_inactive $messenger->headers('X-AntiAbuse: Board servername - ' . phpbb::$config['server_name']); $messenger->headers('X-AntiAbuse: User_id - ' . phpbb::$user->data['user_id']); $messenger->headers('X-AntiAbuse: Username - ' . phpbb::$user->data['username']); + $messenger->headers('X-AntiAbuse: User IP - ' . phpbb::$user->ip); $messenger->assign_vars(array( 'USERNAME' => htmlspecialchars_decode($row['username'])) @@ -158,7 +159,11 @@ class acp_inactive $sql = 'SELECT user_id, username, user_email, user_lang, user_jabber, user_notify_type, user_regdate, user_actkey FROM ' . USERS_TABLE . ' - WHERE ' . phpbb::$db->sql_in_set('user_id', $mark); + WHERE ' . phpbb::$db->sql_in_set('user_id', $mark) . ' + AND user_inactive_reason'; + + $sql .= (phpbb::$config['require_activation'] == USER_ACTIVATION_ADMIN) ? ' = ' . INACTIVE_REMIND : ' <> ' . INACTIVE_MANUAL; + $result = phpbb::$db->sql_query($sql); if ($row = phpbb::$db->sql_fetchrow($result)) @@ -176,9 +181,14 @@ class acp_inactive $messenger->to($row['user_email'], $row['username']); $messenger->im($row['user_jabber'], $row['username']); + $messenger->headers('X-AntiAbuse: Board servername - ' . phpbb::$config['server_name']); + $messenger->headers('X-AntiAbuse: User_id - ' . phpbb::$user->data['user_id']); + $messenger->headers('X-AntiAbuse: Username - ' . phpbb::$user->data['username']); + $messenger->headers('X-AntiAbuse: User IP - ' . phpbb::$user->ip); + $messenger->assign_vars(array( 'USERNAME' => htmlspecialchars_decode($row['username']), - 'REGISTER_DATE' => phpbb::$user->format_date($row['user_regdate']), + 'REGISTER_DATE' => phpbb::$user->format_date($row['user_regdate'], false, true), 'U_ACTIVATE' => generate_board_url() . '/ucp.' . PHP_EXT . '?mode=activate&u=' . $row['user_id'] . '&k=' . $row['user_actkey']) ); diff --git a/phpBB/modules/acp/acp_jabber.php b/phpBB/modules/acp/acp_jabber.php index d9c192601c..875998a00c 100644 --- a/phpBB/modules/acp/acp_jabber.php +++ b/phpBB/modules/acp/acp_jabber.php @@ -85,7 +85,8 @@ class acp_jabber else { // This feature is disabled. - // We update the user table to be sure all users that have IM as notify type are set to both as notify type + // We update the user table to be sure all users that have IM as notify type are set to both as notify type + // We set this to both because users still have their jabber address entered and may want to receive jabber notifications again once it is re-enabled. $sql_ary = array( 'user_notify_type' => NOTIFY_BOTH, ); diff --git a/phpBB/modules/acp/acp_main.php b/phpBB/modules/acp/acp_main.php index fb66f5dc15..a7d3dbf0cf 100644 --- a/phpBB/modules/acp/acp_main.php +++ b/phpBB/modules/acp/acp_main.php @@ -503,6 +503,12 @@ class acp_main phpbb::$template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms(PHPBB_ROOT_PATH . 'config.' . PHP_EXT) & 0x0002)); } + // Fill dbms version if not yet filled + if (empty(phpbb::$config['dbms_version'])) + { + set_config('dbms_version', phpbb::$db->sql_server_info(true)); + } + $this->tpl_name = 'acp_main'; $this->page_title = 'ACP_MAIN'; } diff --git a/phpBB/modules/acp/acp_permissions.php b/phpBB/modules/acp/acp_permissions.php index d9db7b1bf0..85b2cda164 100644 --- a/phpBB/modules/acp/acp_permissions.php +++ b/phpBB/modules/acp/acp_permissions.php @@ -1121,7 +1121,11 @@ class acp_permissions { $sql_where = 'AND (' . phpbb::$db->sql_in_set('a.auth_option_id', $option_ids) . ' OR ' . phpbb::$db->sql_in_set('a.auth_role_id', $role_ids) . ')'; } - else + else if (sizeof($role_ids)) + { + $sql_where = 'AND ' . phpbb::$db->sql_in_set('a.auth_role_id', $role_ids); + } + else if (sizeof($option_ids)) { $sql_where = 'AND ' . phpbb::$db->sql_in_set('a.auth_option_id', $option_ids); } diff --git a/phpBB/modules/acp/acp_styles.php b/phpBB/modules/acp/acp_styles.php index 4f21a44e1d..a087348b36 100644 --- a/phpBB/modules/acp/acp_styles.php +++ b/phpBB/modules/acp/acp_styles.php @@ -1101,139 +1101,142 @@ parse_css_file = {PARSE_CSS_FILE} { $this->page_title = 'EDIT_IMAGESET'; + if (!$imageset_id) + { + trigger_error(phpbb::$user->lang['NO_IMAGESET'] . adm_back_link($this->u_action), E_USER_WARNING); + } + $update = phpbb_request::is_set_post('update'); + $imgname = request_var('imgname', 'site_logo'); + $imgname = preg_replace('#[^a-z0-9\-+_]#i', '', $imgname); + $sql_extra = $imgnamelang = ''; - $imgname = request_var('imgname', ''); - $imgpath = request_var('imgpath', ''); - $imgsize = request_var('imgsize', false); - $imgwidth = request_var('imgwidth', 0); - $imgheight = request_var('imgheight', 0); + $sql = 'SELECT imageset_path, imageset_name + FROM ' . STYLES_IMAGESET_TABLE . " + WHERE imageset_id = $imageset_id"; + $result = phpbb::$db->sql_query($sql); + $imageset_row = phpbb::$db->sql_fetchrow($result); + phpbb::$db->sql_freeresult($result); - $imgname = preg_replace('#[^a-z0-9\-+_]#i', '', $imgname); - $imgpath = str_replace('..', '.', $imgpath); + if (!$imageset_row) + { + trigger_error(phpbb::$user->lang['NO_IMAGESET'] . adm_back_link($this->u_action), E_USER_WARNING); + } - if ($imageset_id) + $imageset_path = $imageset_row['imageset_path']; + $imageset_name = $imageset_row['imageset_name']; + + if (strpos($imgname, '-') !== false) { - $sql = 'SELECT imageset_path, imageset_name - FROM ' . STYLES_IMAGESET_TABLE . " - WHERE imageset_id = $imageset_id"; - $result = phpbb::$db->sql_query($sql); - $imageset_row = phpbb::$db->sql_fetchrow($result); - phpbb::$db->sql_freeresult($result); + list($imgname, $imgnamelang) = explode('-', $imgname); + $sql_extra = " AND image_lang IN ('" . phpbb::$db->sql_escape($imgnamelang) . "', '')"; + } + + $sql = 'SELECT image_filename, image_width, image_height, image_lang, image_id + FROM ' . STYLES_IMAGESET_DATA_TABLE . " + WHERE imageset_id = $imageset_id + AND image_name = '" . phpbb::$db->sql_escape($imgname) . "'$sql_extra"; + $result = phpbb::$db->sql_query($sql); + $imageset_data_row = phpbb::$db->sql_fetchrow($result); + phpbb::$db->sql_freeresult($result); + + $image_filename = $imageset_data_row['image_filename']; + $image_width = $imageset_data_row['image_width']; + $image_height = $imageset_data_row['image_height']; + $image_lang = $imageset_data_row['image_lang']; + $image_id = $imageset_data_row['image_id']; + $imgsize = ($imageset_data_row['image_width'] && $imageset_data_row['image_height']) ? 1 : 0; - $imageset_path = $imageset_row['imageset_path']; - $imageset_name = $imageset_row['imageset_name']; + // Check to see whether the selected image exists in the table + $valid_name = ($update) ? false : true; - $sql_extra = ''; - if (strpos($imgname, '-') !== false) + foreach ($this->imageset_keys as $category => $img_ary) + { + if (in_array($imgname, $img_ary)) { - list($imgname, $imgnamelang) = explode('-', $imgname); - $sql_extra = " AND image_lang IN ('" . phpbb::$db->sql_escape($imgnamelang) . "', '')"; + $valid_name = true; + break; } + } - $sql = 'SELECT image_filename, image_width, image_height, image_lang, image_id - FROM ' . STYLES_IMAGESET_DATA_TABLE . " - WHERE imageset_id = $imageset_id - AND image_name = '" . phpbb::$db->sql_escape($imgname) . "'$sql_extra"; - $result = phpbb::$db->sql_query($sql); - $imageset_data_row = phpbb::$db->sql_fetchrow($result); - phpbb::$db->sql_freeresult($result); - - $image_filename = $imageset_data_row['image_filename']; - $image_width = $imageset_data_row['image_width']; - $image_height = $imageset_data_row['image_height']; - $image_lang = $imageset_data_row['image_lang']; - $image_id = $imageset_data_row['image_id']; + if ($update && phpbb_request::is_set_post('imgpath') && $valid_name) + { + // If imgwidth and imgheight are non-zero grab the actual size + // from the image itself ... we ignore width settings for the poll center image + $imgwidth = request_var('imgwidth', 0); + $imgheight = request_var('imgheight', 0); + $imgsize = request_var('imgsize', 0); + $imgpath = request_var('imgpath', ''); + $imgpath = str_replace('..', '.', $imgpath); - if (!$imageset_row) + // If no dimensions selected, we reset width and height to 0 ;) + if (!$imgsize) { - trigger_error(phpbb::$user->lang['NO_IMAGESET'] . adm_back_link($this->u_action), E_USER_WARNING); + $imgwidth = $imgheight = 0; } - // Check to see whether the selected image exists in the table - $valid_name = ($update) ? false : true; + $imglang = ''; - foreach ($this->imageset_keys as $category => $img_ary) + if ($imgpath && !file_exists(PHPBB_ROOT_PATH . "styles/$imageset_path/imageset/$imgpath")) { - if (in_array($imgname, $img_ary)) - { - $valid_name = true; - break; - } + trigger_error(phpbb::$user->lang['NO_IMAGE_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING); } - if ($update && phpbb_request::is_set_post('imgpath')) + // Determine width/height. If dimensions included and no width/height given, we detect them automatically... + if ($imgsize && $imgpath) { - if ($valid_name) + if (!$imgwidth || !$imgheight) { - // If imgwidth and imgheight are non-zero grab the actual size - // from the image itself ... we ignore width settings for the poll center image - $imgwidth = request_var('imgwidth', 0); - $imgheight = request_var('imgheight', 0); - $imglang = ''; - - if ($imgpath && !file_exists(PHPBB_ROOT_PATH . "styles/$imageset_path/imageset/$imgpath")) - { - trigger_error(phpbb::$user->lang['NO_IMAGE_ERROR'] . adm_back_link($this->u_action), E_USER_WARNING); - } - - if ($imgsize && $imgpath) - { - if (!$imgwidth || !$imgheight) - { - list($imgwidth_file, $imgheight_file) = getimagesize(PHPBB_ROOT_PATH . "styles/$imageset_path/imageset/$imgpath"); - $imgwidth = ($imgwidth) ? $imgwidth : $imgwidth_file; - $imgheight = ($imgheight) ? $imgheight : $imgheight_file; - } - $imgwidth = ($imgname != 'poll_center') ? (int) $imgwidth : 0; - $imgheight = (int) $imgheight; - } - + list($imgwidth_file, $imgheight_file) = getimagesize(PHPBB_ROOT_PATH . "styles/$imageset_path/imageset/$imgpath"); + $imgwidth = ($imgwidth) ? $imgwidth : $imgwidth_file; + $imgheight = ($imgheight) ? $imgheight : $imgheight_file; + } + $imgwidth = ($imgname != 'poll_center') ? (int) $imgwidth : 0; + $imgheight = (int) $imgheight; + } - if (strpos($imgpath, '/') !== false) - { - list($imglang, $imgfilename) = explode('/', $imgpath); - } - else - { - $imgfilename = $imgpath; - } + if (strpos($imgpath, '/') !== false) + { + list($imglang, $imgfilename) = explode('/', $imgpath); + } + else + { + $imgfilename = $imgpath; + } - $sql_ary = array( - 'image_filename' => (string) $imgfilename, - 'image_width' => (int) $imgwidth, - 'image_height' => (int) $imgheight, - 'image_lang' => (string) $imglang, - ); + $sql_ary = array( + 'image_filename' => (string) $imgfilename, + 'image_width' => (int) $imgwidth, + 'image_height' => (int) $imgheight, + 'image_lang' => (string) $imglang, + ); - // already exists - if ($imageset_data_row) - { - $sql = 'UPDATE ' . STYLES_IMAGESET_DATA_TABLE . ' - SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . " - WHERE image_id = $image_id"; - phpbb::$db->sql_query($sql); - } - // does not exist - else if (!$imageset_data_row) - { - $sql_ary['image_name'] = $imgname; - $sql_ary['imageset_id'] = (int) $imageset_id; - phpbb::$db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary)); - } + // already exists + if ($imageset_data_row) + { + $sql = 'UPDATE ' . STYLES_IMAGESET_DATA_TABLE . ' + SET ' . phpbb::$db->sql_build_array('UPDATE', $sql_ary) . " + WHERE image_id = $image_id"; + phpbb::$db->sql_query($sql); + } + // does not exist + else if (!$imageset_data_row) + { + $sql_ary['image_name'] = $imgname; + $sql_ary['imageset_id'] = (int) $imageset_id; + phpbb::$db->sql_query('INSERT INTO ' . STYLES_IMAGESET_DATA_TABLE . ' ' . phpbb::$db->sql_build_array('INSERT', $sql_ary)); + } - phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE); + phpbb::$acm->destroy_sql(STYLES_IMAGESET_DATA_TABLE); - add_log('admin', 'LOG_IMAGESET_EDIT', $imageset_name); + add_log('admin', 'LOG_IMAGESET_EDIT', $imageset_name); - phpbb::$template->assign_var('SUCCESS', true); + phpbb::$template->assign_var('SUCCESS', true); - $image_filename = $imgfilename; - $image_width = $imgwidth; - $image_height = $imgheight; - $image_lang = $imglang; - } - } + $image_filename = $imgfilename; + $image_width = $imgwidth; + $image_height = $imgheight; + $image_lang = $imglang; } $imglang = ''; @@ -1355,6 +1358,8 @@ parse_css_file = {PARSE_CSS_FILE} 'U_BACK' => $this->u_action, 'NAME' => $imageset_name, 'A_NAME' => addslashes($imageset_name), + 'PATH' => $imageset_path, + 'A_PATH' => addslashes($imageset_path), 'ERROR' => !$valid_name, 'IMG_SRC' => ($image_found) ? '../styles/' . $imageset_path . '/imageset/' . $img_val : 'images/no_image.png', 'IMAGE_SELECT' => $image_found, diff --git a/phpBB/modules/acp/acp_users.php b/phpBB/modules/acp/acp_users.php index c012612a24..54296c386c 100644 --- a/phpBB/modules/acp/acp_users.php +++ b/phpBB/modules/acp/acp_users.php @@ -971,6 +971,7 @@ class acp_users { $sql = 'DELETE FROM ' . LOG_TABLE . ' WHERE log_type = ' . LOG_USERS . " + AND reportee_id = $user_id $where_sql"; phpbb::$db->sql_query($sql); diff --git a/phpBB/modules/acp/auth.php b/phpBB/modules/acp/auth.php index 396b66c76f..b1dae06cea 100644 --- a/phpBB/modules/acp/auth.php +++ b/phpBB/modules/acp/auth.php @@ -679,6 +679,7 @@ class auth_admin extends auth { $cur_options = array(); + // Determine current options $sql = 'SELECT auth_option, is_global, is_local FROM ' . ACL_OPTIONS_TABLE . ' ORDER BY auth_option_id'; @@ -686,15 +687,7 @@ class auth_admin extends auth while ($row = phpbb::$db->sql_fetchrow($result)) { - if ($row['is_global']) - { - $cur_options['global'][] = $row['auth_option']; - } - - if ($row['is_local']) - { - $cur_options['local'][] = $row['auth_option']; - } + $cur_options[$row['auth_option']] = ($row['is_global'] && $row['is_local']) ? 'both' : (($row['is_global']) ? 'global' : 'local'); } phpbb::$db->sql_freeresult($result); @@ -709,14 +702,11 @@ class auth_admin extends auth foreach ($option_ary as $option_value) { - if (!in_array($option_value, $cur_options[$type])) - { - $new_options[$type][] = $option_value; - } + $new_options[$type][] = $option_value; $flag = substr($option_value, 0, strpos($option_value, '_') + 1); - if (!in_array($flag, $cur_options[$type]) && !in_array($flag, $new_options[$type])) + if (!in_array($flag, $new_options[$type])) { $new_options[$type][] = $flag; } @@ -727,23 +717,53 @@ class auth_admin extends auth $options = array(); $options['local'] = array_diff($new_options['local'], $new_options['global']); $options['global'] = array_diff($new_options['global'], $new_options['local']); - $options['local_global'] = array_intersect($new_options['local'], $new_options['global']); + $options['both'] = array_intersect($new_options['local'], $new_options['global']); - $sql_ary = array(); + // Now check which options to add/update + $add_options = $update_options = array(); + // First local ones... foreach ($options as $type => $option_ary) { foreach ($option_ary as $option) { - $sql_ary[] = array( - 'auth_option' => (string) $option, - 'is_global' => ($type == 'global' || $type == 'local_global') ? 1 : 0, - 'is_local' => ($type == 'local' || $type == 'local_global') ? 1 : 0 - ); + if (!isset($cur_options[$option])) + { + $add_options[] = array( + 'auth_option' => (string) $option, + 'is_global' => ($type == 'global' || $type == 'both') ? 1 : 0, + 'is_local' => ($type == 'local' || $type == 'both') ? 1 : 0 + ); + + continue; + } + + // Else, update existing entry if it is changed... + if ($type === $cur_options[$option]) + { + continue; + } + + // New type is always both: + // If is now both, we set both. + // If it was global the new one is local and we need to set it to both + // If it was local the new one is global and we need to set it to both + $update_options[] = $option; } } - phpbb::$db->sql_multi_insert(ACL_OPTIONS_TABLE, $sql_ary); + if (!empty($add_options)) + { + phpbb::$db->sql_multi_insert(ACL_OPTIONS_TABLE, $add_options); + } + + if (!empty($update_options)) + { + $sql = 'UPDATE ' . ACL_OPTIONS_TABLE . ' + SET is_global = 1, is_local = 1 + WHERE ' . phpbb::$db->sql_in_set('auth_option', $update_options); + phpbb::$db->sql_query($sql); + } phpbb::$acm->destroy('acl_options'); $this->acl_clear_prefetch(); |