From 9c3d84f4e1b1140dcca5f2e43b9c1bf986d3a939 Mon Sep 17 00:00:00 2001 From: Meik Sievertsen Date: Fri, 28 Feb 2003 16:39:38 +0000 Subject: [PATCH] fixed bug #1370, #1447 (moderator status update, extensively tested, should work :D), #1309, poll delete checkbox fixed (now it is only displayed if there is a poll to delete) git-svn-id: file:///svn/phpbb/branches/phpBB-2_0_0@3580 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/admin/admin_groups.php | 50 +++++++++++++++++++++++++++++++ phpBB/admin/index.php | 1 + phpBB/includes/functions_post.php | 3 +- phpBB/posting.php | 2 +- 4 files changed, 54 insertions(+), 2 deletions(-) diff --git a/phpBB/admin/admin_groups.php b/phpBB/admin/admin_groups.php index 413507f180..b3fcf3fbd2 100644 --- a/phpBB/admin/admin_groups.php +++ b/phpBB/admin/admin_groups.php @@ -171,6 +171,56 @@ else if ( isset($HTTP_POST_VARS['group_update']) ) // if ( isset($HTTP_POST_VARS['group_delete']) ) { + // + // Reset User Moderator Level + // + + // Is Group moderating a forum ? + $sql = "SELECT auth_mod FROM " . AUTH_ACCESS_TABLE . " + WHERE group_id = " . $group_id; + if ( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not select auth_access', '', __LINE__, __FILE__, $sql); + } + + $row = $db->sql_fetchrow($result); + if (intval($row['auth_mod']) == 1) + { + // Yes, get the assigned users and update their Permission if they are no longer moderator of one of the forums + $sql = "SELECT user_id FROM " . USER_GROUP_TABLE . " + WHERE group_id = " . $group_id; + if ( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not select user_group', '', __LINE__, __FILE__, $sql); + } + + $rows = $db->sql_fetchrowset($result); + for ($i = 0; $i < count($rows); $i++) + { + $sql = "SELECT g.group_id FROM " . AUTH_ACCESS_TABLE . " a, " . GROUPS_TABLE . " g, " . USER_GROUP_TABLE . " ug + WHERE (a.auth_mod = 1) AND (g.group_id = a.group_id) AND (a.group_id = ug.group_id) AND (g.group_id = ug.group_id) + AND (ug.user_id = " . intval($rows[$i]['user_id']) . ") AND (ug.group_id <> " . $group_id . ")"; + if ( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not obtain moderator permissions', '', __LINE__, __FILE__, $sql); + } + + if ($db->sql_numrows($result) == 0) + { + $sql = "UPDATE " . USERS_TABLE . " SET user_level = " . USER . " + WHERE user_level = " . MOD . " AND user_id = " . intval($rows[$i]['user_id']); + + if ( !$db->sql_query($sql) ) + { + message_die(GENERAL_ERROR, 'Could not update moderator permissions', '', __LINE__, __FILE__, $sql); + } + } + } + } + + // + // Delete Group + // $sql = "DELETE FROM " . GROUPS_TABLE . " WHERE group_id = " . $group_id; if ( !$db->sql_query($sql) ) diff --git a/phpBB/admin/index.php b/phpBB/admin/index.php index 6c824ece31..9a3f75276e 100644 --- a/phpBB/admin/index.php +++ b/phpBB/admin/index.php @@ -132,6 +132,7 @@ elseif( isset($HTTP_GET_VARS['pane']) && $HTTP_GET_VARS['pane'] == 'right' ) "L_ADMIN_INTRO" => $lang['Admin_intro'], "L_FORUM_STATS" => $lang['Forum_stats'], "L_WHO_IS_ONLINE" => $lang['Who_is_Online'], + "L_USERNAME" => $lang['Username'], "L_LOCATION" => $lang['Location'], "L_LAST_UPDATE" => $lang['Last_updated'], "L_IP_ADDRESS" => $lang['IP_Address'], diff --git a/phpBB/includes/functions_post.php b/phpBB/includes/functions_post.php index d4cf5ae483..acaaf4d7cf 100644 --- a/phpBB/includes/functions_post.php +++ b/phpBB/includes/functions_post.php @@ -251,7 +251,8 @@ function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_ if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post'])) { $topic_vote = (!empty($poll_title) && count($poll_options) >= 2) ? 1 : 0; - $sql = ($mode != "editpost") ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote)" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '$post_subject', topic_type = $topic_type, topic_vote = $topic_vote WHERE topic_id = $topic_id"; + + $sql = ($mode != "editpost") ? "INSERT INTO " . TOPICS_TABLE . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_vote) VALUES ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_vote)" : "UPDATE " . TOPICS_TABLE . " SET topic_title = '$post_subject', topic_type = $topic_type " . (($post_data['edit_vote'] || !empty($poll_title)) ? ", topic_vote = " . $topic_vote : "") . " WHERE topic_id = $topic_id"; if (!$db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error in posting', '', __LINE__, __FILE__, $sql); diff --git a/phpBB/posting.php b/phpBB/posting.php index 134e7cca07..8359f365a4 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -1058,7 +1058,7 @@ if( ( $mode == 'newtopic' || ( $mode == 'editpost' && $post_data['edit_poll']) ) 'POLL_LENGTH' => $poll_length) ); - if( $mode == 'editpost' && $post_data['edit_poll'] ) + if( $mode == 'editpost' && $post_data['edit_poll'] && $post_data['has_poll']) { $template->assign_block_vars('switch_poll_delete_toggle', array()); }