Sfoglia il codice sorgente

+ Hook into quick moderation option box on search results

Signed-off-by: John Rayes <[email protected]>
John Rayes 12 anni fa
parent
commit
2129ab04f5
2 ha cambiato i file con 21 aggiunte e 16 eliminazioni
  1. 5 1
      Sources/Search.php
  2. 16 15
      Themes/default/Search.template.php

+ 5 - 1
Sources/Search.php

@@ -1712,7 +1712,7 @@ function PlushSearch2()
 		// How's about some quick moderation?
 		if (!empty($options['display_quick_mod']))
 		{
-			$boards_can = boardsAllowedTo(array('lock_any', 'lock_own', 'make_sticky', 'move_any', 'move_own', 'remove_any', 'remove_own', 'merge_any', true, false));
+			$boards_can = array_merge($boards_can, boardsAllowedTo(array('lock_any', 'lock_own', 'make_sticky', 'move_any', 'move_own', 'remove_any', 'remove_own', 'merge_any'), true, false));
 
 			$context['can_lock'] = in_array(0, $boards_can['lock_any']);
 			$context['can_sticky'] = in_array(0, $boards_can['make_sticky']) && !empty($modSettings['enableStickyTopics']);
@@ -2054,6 +2054,7 @@ function prepareSearchContext($reset = false)
 		$context['can_move'] |= $output['quick_mod']['move'];
 		$context['can_remove'] |= $output['quick_mod']['remove'];
 		$context['can_merge'] |= in_array($output['board']['id'], $boards_can['merge_any']);
+		$context['can_markread'] = $context['user']['is_logged'];
 
 		// If we've found a message we can move, and we don't already have it, load the destinations.
 		if ($options['display_quick_mod'] == 1 && !isset($context['move_to_boards']) && $context['can_move'])
@@ -2066,6 +2067,9 @@ function prepareSearchContext($reset = false)
 			);
 			$context['move_to_boards'] = getBoardList($boardListOptions);
 		}
+
+		$context['qmod_actions'] = array('remove', 'lock', 'sticky', 'move', 'merge', 'restore', 'markread');
+		call_integration_hook('integrate_quick_mod_actions_search');
 	}
 
 	foreach ($context['key_words'] as $query)

+ 16 - 15
Themes/default/Search.template.php

@@ -71,11 +71,11 @@ function template_main()
 					</dt>
 					<dd>
 						<input type="text" name="search" id="searchfor" ', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40" class="input_text" />';
-		
+
 		if (empty($modSettings['search_simple_fulltext']))
 			echo '
 				<em class="smalltext">', $txt['search_example'], '</em>';
-				
+
 		echo '
 					</dd>
 
@@ -94,7 +94,7 @@ function template_main()
 					<dd>
 						<input id="userspec" type="text" name="userspec" value="', empty($context['search_params']['userspec']) ? '*' : $context['search_params']['userspec'], '" size="40" class="input_text" />
 					</dd>
-					<dt class="righttext"><label for="sort">', 
+					<dt class="righttext"><label for="sort">',
 						$txt['search_order'], ':</label>
 					</dt>
 					<dd>
@@ -106,7 +106,7 @@ function template_main()
 							<option value="id_msg|asc">', $txt['search_orderby_old_first'], '</option>
 						</select>
 					</dd>
-					<dt class="righttext options">', 
+					<dt class="righttext options">',
 						$txt['search_options'], ':
 					</dt>
 					<dd class="options">
@@ -117,10 +117,10 @@ function template_main()
 							<input type="checkbox" name="subject_only" id="subject_only" value="1"', !empty($context['search_params']['subject_only']) ? ' checked="checked"' : '', ' class="input_check" />
 						</label>
 					</dd>
-					<dt class="righttext between">', 
+					<dt class="righttext between">',
 						$txt['search_post_age'], ':
 					</dt>
-					<dd><label for="minage">', 
+					<dd><label for="minage">',
 						$txt['search_between'], '</label><input type="text" name="minage" id="minage" value="', empty($context['search_params']['minage']) ? '0' : $context['search_params']['minage'], '" size="5" maxlength="4" class="input_text" />&nbsp;<label for="maxage">', $txt['search_and'], '&nbsp;</label><input type="text" name="maxage" id="maxage" value="', empty($context['search_params']['maxage']) ? '9999' : $context['search_params']['maxage'], '" size="5" maxlength="4" class="input_text" /> ', $txt['days_word'], '
 					</dd>
 				</dl>
@@ -269,7 +269,7 @@ function template_results()
 						<input type="text" name="search"', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' maxlength="', $context['search_string_limit'], '" size="40" class="input_text" />
 					</dd>
 				</dl>
-				
+
 				<input type="submit" name="edit_search" value="', $txt['search_adjust_submit'], '" class="button_submit" />
 				<br class="clear_right" />
 				<input type="hidden" name="searchtype" value="', !empty($context['search_params']['searchtype']) ? $context['search_params']['searchtype'] : 0, '" />
@@ -311,7 +311,7 @@ function template_results()
 				<span class="ie6_header floatleft"><img src="' . $settings['images_url'] . '/buttons/search.png" alt="?" class="centericon" />&nbsp;', $txt['mlist_search_results'],':&nbsp;',$context['search_params']['search'],'</span>
 			</h3>
 		</div>';
-		
+
 		// was anything even found?
 		if (!empty($context['topics']))
 		echo'
@@ -410,13 +410,14 @@ function template_results()
 			<div class="middletext titlebg2" style="padding: 4px;">
 				<div class="floatright">
 					<select name="qaction"', $context['can_move'] ? ' onchange="this.form.moveItTo.disabled = (this.options[this.selectedIndex].value != \'move\');"' : '', '>
-						<option value="">--------</option>', $context['can_remove'] ? '
-						<option value="remove">' . $txt['quick_mod_remove'] . '</option>' : '', $context['can_lock'] ? '
-						<option value="lock">' . $txt['quick_mod_lock'] . '</option>' : '', $context['can_sticky'] ? '
-						<option value="sticky">' . $txt['quick_mod_sticky'] . '</option>' : '',	$context['can_move'] ? '
-						<option value="move">' . $txt['quick_mod_move'] . ': </option>' : '', $context['can_merge'] ? '
-						<option value="merge">' . $txt['quick_mod_merge'] . '</option>' : '', '
-						<option value="markread">', $txt['quick_mod_markread'], '</option>
+						<option value="">--------</option>';
+
+			foreach ($context['qmod_actions'] as $qmod_action)
+				if ($context['can_' . $qmod_action])
+					echo '
+							<option value="' . $qmod_action . '">' . $txt['quick_mod_'  . $qmod_action] . '</option>';
+
+			echo '
 					</select>';
 
 			if ($context['can_move'])