소스 검색

Merge pull request #417 from Oldiesmann/release-2.1

Membergroup fixes (fixes #408 and some other things)
Oldiesmann 11 년 전
부모
커밋
c2df50731d

+ 10 - 2
Sources/Groups.php

@@ -102,7 +102,15 @@ function GroupList()
 						else
 						{
 							$color_style = empty($rowData[\'online_color\']) ? \'\' : sprintf(\' style="color: %1$s;"\', $rowData[\'online_color\']);
-							$group_name = sprintf(\'<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>\', $scripturl, $rowData[\'id_group\'], $color_style, $rowData[\'group_name\']);
+							
+							if (allowedTo(\'manage_membergroups\'))
+							{
+								$group_name = sprintf(\'<a href="%1$s?action=admin;area=membergroups;sa=members;group=%2$d"%3$s>%4$s</a>\', $scripturl, $rowData[\'id_group\'], $color_style, $rowData[\'group_name\']);
+							}
+							else
+							{
+								$group_name = sprintf(\'<a href="%1$s?action=groups;sa=members;group=%2$d"%3$s>%4$s</a>\', $scripturl, $rowData[\'id_group\'], $color_style, $rowData[\'group_name\']);
+							}
 						}
 
 						// Add a help option for moderator and administrator.
@@ -213,7 +221,7 @@ function MembergroupMembers()
 
 	// Fix the membergroup icons.
 	$context['group']['icons'] = explode('#', $context['group']['icons']);
-	$context['group']['icons'] = !empty($context['group']['icons'][0]) && !empty($context['group']['icons'][1]) ? str_repeat('<img src="' . $settings['images_url'] . '/' . $context['group']['icons'][1] . '" alt="*" />', $context['group']['icons'][0]) : '';
+	$context['group']['icons'] = !empty($context['group']['icons'][0]) && !empty($context['group']['icons'][1]) ? str_repeat('<img src="' . $settings['images_url'] . '/membericons/' . $context['group']['icons'][1] . '" alt="*" />', $context['group']['icons'][0]) : '';
 	$context['group']['can_moderate'] = allowedTo('manage_membergroups') && (allowedTo('admin_forum') || $context['group']['group_type'] != 1);
 
 	$context['linktree'][] = array(

+ 6 - 0
Sources/Subs-BoardIndex.php

@@ -176,6 +176,12 @@ function getBoardIndex($boardIndexOptions)
 				);
 				$this_category[$row_board['id_board']]['link_moderator_groups'][] = '<a href="' . $scripturl . '?action=groups;sa=members;group=' . $row_board['id_moderator_group'] . '" title="' . $txt['board_moderator'] . '">' . $row_board['mod_group_name'] . '</a>';
 			}
+			
+			// Merge the two lists of moderators
+			if (!empty($this_category[$row_board['id_board']]['link_moderator_groups']))
+			{
+				$this_category[$row_board['id_board']]['link_moderators'] = array_merge($this_category[$row_board['id_board']]['link_moderators'], $this_category[$row_board['id_board']]['link_moderator_groups']);
+			}
 		}
 		// Found a child board.... make sure we've found its parent and the child hasn't been set already.
 		elseif (isset($this_category[$row_board['id_parent']]['children']) && !isset($this_category[$row_board['id_parent']]['children'][$row_board['id_board']]))

+ 9 - 3
Sources/Subs-Boards.php

@@ -657,7 +657,7 @@ function modifyBoard($board_id, &$boardOptions)
 		);
 
 	// Set moderators of this board.
-	if (isset($boardOptions['moderators']) || isset($boardOptions['moderator_string']) || isset($boardOptions['moderator_groupss']) || isset($boardOptions['moderator_group_string']))
+	if (isset($boardOptions['moderators']) || isset($boardOptions['moderator_string']) || isset($boardOptions['moderator_groups']) || isset($boardOptions['moderator_group_string']))
 	{
 		// Reset current moderators for this board - if there are any!
 		$smcFunc['db_query']('', '
@@ -742,13 +742,13 @@ function modifyBoard($board_id, &$boardOptions)
 					unset($moderator_groups[$k]);
 			}
 
-			// Find all the id_member's for the member_name's in the list.
+			// Find all the id_group's for all the group names in the list
 			if (empty($boardOptions['moderator_groups']))
 				$boardOptions['moderator_groups'] = array();
 			if (!empty($moderator_groups))
 			{
 				$request = $smcFunc['db_query']('', '
-					SELECT id_group
+					SELECT id_group, min_posts
 					FROM {db_prefix}membergroups
 					WHERE group_name IN ({array_string:moderator_group_list})
 					LIMIT ' . count($moderator_groups),
@@ -757,7 +757,13 @@ function modifyBoard($board_id, &$boardOptions)
 					)
 				);
 				while ($row = $smcFunc['db_fetch_assoc']($request))
+				{
+					// Don't allow post groups, "Administrator" or "Moderator"
+					if ($row['min_posts'] != -1 || in_array($row['id_group'], array(1,3)))
+						continue;
+					
 					$boardOptions['moderator_groups'][] = $row['id_group'];
+				}
 				$smcFunc['db_free_result']($request);
 			}
 		}

+ 4 - 6
Sources/Subs-Editor.php

@@ -2240,7 +2240,7 @@ function AutoSuggest_Search_Member()
  *
  * @return string
  */
-function AutoSuggest_Search_MemberGroup()
+function AutoSuggest_Search_MemberGroups()
 {
 	global $txt, $smcFunc, $context;
 
@@ -2248,20 +2248,18 @@ function AutoSuggest_Search_MemberGroup()
 	$_REQUEST['search'] = strtr($_REQUEST['search'], array('%' => '\%', '_' => '\_', '*' => '%', '?' => '_', '&#038;' => '&amp;'));
 
 	// Find the group.
-	// Only return groups which are not post-based, not "Hidden", not the "Moderators" group and not "Protected"
+	// Only return groups which are not post-based and not "Hidden", but not the "Administrators" or "Moderators" groups.
 	$request = $smcFunc['db_query']('', '
 		SELECT id_group, group_name
 		FROM {db_prefix}membergroups
 		WHERE group_name LIKE {string:search}
 			AND min_posts = {int:min_posts}
-			AND group_type != {int:is_protected}
-			AND id_group != {int:mod_group}
+			AND id_group NOT IN ({array_int:invalid_groups})
 			AND hidden != {int:hidden}
 		',
 		array(
 			'min_posts' => -1,
-			'is_protected' => 1,
-			'mod_group' => 3,
+			'invalid_groups' => array(1,3),
 			'hidden' => 2,
 			'search' => $_REQUEST['search'],
 		)

+ 1 - 3
Sources/Subs-Membergroups.php

@@ -671,14 +671,12 @@ function list_getMembergroups($start, $items_per_page, $sort, $membergroup_type)
 		FROM {db_prefix}membergroups AS mg
 			LEFT JOIN {db_prefix}group_moderators AS gm ON (gm.id_group = mg.id_group AND gm.id_member = {int:current_member})
 		WHERE mg.min_posts {raw:min_posts}' . (allowedTo('admin_forum') ? '' : '
-			AND mg.id_group != {int:mod_group}
-			AND mg.group_type != {int:is_protected}') . '
+			AND mg.id_group != {int:mod_group}') . '
 		ORDER BY {raw:sort}',
 		array(
 			'current_member' => $user_info['id'],
 			'min_posts' => ($membergroup_type === 'post_count' ? '!= ' : '= ') . -1,
 			'mod_group' => 3,
-			'is_protected' => 1,
 			'sort' => $sort,
 		)
 	);

+ 1 - 1
Themes/default/ManageBoards.template.php

@@ -433,7 +433,7 @@ function template_modify_board()
 							<span class="smalltext">', $txt['mboards_moderator_groups_desc'], '</span><br />
 						</dt>
 						<dd>
-							<input type="text" name="moderator_groups" id="moderator_groups" value="', $context['board']['moderator_group_list'], '" size="30" class="input_text" />
+							<input type="text" name="moderator_groups" id="moderator_groups" value="', $context['board']['moderator_groups_list'], '" size="30" class="input_text" />
 							<div id="moderator_group_container"></div>
 						</dd>
 					</dl>

+ 1 - 1
Themes/default/languages/ManageBoards.english.php

@@ -54,7 +54,7 @@ $txt['mboards_groups_post_group'] = 'This group is a post count based group.';
 $txt['mboards_moderators'] = 'Moderators';
 $txt['mboards_moderators_desc'] = 'Additional members to have moderation privileges on this board.  Note that administrators don\'t have to be listed here.';
 $txt['mboards_moderator_groups'] = 'Moderator Groups';
-$txt['mboards_moderator_groups_desc'] = 'Groups whose members have moderation priveleges on this board. Note that this is limited to groups which are not post-based, not "hidden" and not "protected".';
+$txt['mboards_moderator_groups_desc'] = 'Groups whose members have moderation priveleges on this board. Note that this is limited to groups which are not post-based and not "hidden".';
 $txt['mboards_count_posts'] = 'Count Posts';
 $txt['mboards_count_posts_desc'] = 'Makes new replies and topics raise members\' post counts.';
 $txt['mboards_unchanged'] = 'Unchanged';