Browse Source

! A coulpe of consistency changes to viewWarning template and use of createList in issueWarning area

emanuele 13 years ago
parent
commit
fd46f682b0

+ 92 - 9
Sources/Profile-Actions.php

@@ -236,6 +236,9 @@ function issueWarning($memID)
 
 	$context['page_title'] = $txt['profile_issue_warning'];
 
+	// Let's use a generic list to get all the current warnings
+	require_once($sourcedir . '/Subs-List.php');
+
 	// Work our the various levels.
 	$context['level_effects'] = array(
 		0 => $txt['profile_warning_effect_none'],
@@ -248,16 +251,96 @@ function issueWarning($memID)
 		if ($context['member']['warning'] >= $limit)
 			$context['current_level'] = $limit;
 
-	// Load up all the old warnings - count first!
-	$context['total_warnings'] = list_getUserWarningCount($memID);
-
-	// Make the page index.
-	$context['start'] = (int) $_REQUEST['start'];
-	$perPage = (int) $modSettings['defaultMaxMessages'];
-	$context['page_index'] = constructPageIndex($scripturl . '?action=profile;u=' . $memID . ';area=issuewarning', $context['start'], $context['total_warnings'], $perPage);
+	$listOptions = array(
+		'id' => 'view_warnings',
+		'title' => $txt['profile_viewwarning_previous_warnings'],
+		'items_per_page' => $modSettings['defaultMaxMessages'],
+		'no_items_label' => $txt['profile_viewwarning_no_warnings'],
+		'base_href' => $scripturl . '?action=profile;area=issuewarning;sa=user;u=' . $memID,
+		'default_sort_col' => 'log_time',
+		'get_items' => array(
+			'function' => 'list_getUserWarnings',
+			'params' => array(
+				$memID,
+			),
+		),
+		'get_count' => array(
+			'function' => 'list_getUserWarningCount',
+			'params' => array(
+				$memID,
+			),
+		),
+		'columns' => array(
+			'issued_by' => array(
+				'header' => array(
+					'value' => $txt['profile_warning_previous_issued'],
+					'style' => 'width: 20%;',
+				),
+				'data' => array(
+					'function' => create_function('$warning', '
+						return $warning[\'issuer\'][\'link\'];
+					'
+					),
+				),
+				'sort' => array(
+					'default' => 'lc.member_name DESC',
+					'reverse' => 'lc.member_name',
+				),
+			),
+			'log_time' => array(
+				'header' => array(
+					'value' => $txt['profile_warning_previous_time'],
+					'style' => 'width: 30%;',
+				),
+				'data' => array(
+					'db' => 'time',
+				),
+				'sort' => array(
+					'default' => 'lc.log_time DESC',
+					'reverse' => 'lc.log_time',
+				),
+			),
+			'reason' => array(
+				'header' => array(
+					'value' => $txt['profile_warning_previous_reason'],
+				),
+				'data' => array(
+					'function' => create_function('$warning', '
+						global $scripturl, $txt, $settings;
+
+						$ret = \'
+						<div class="floatleft">
+							\' . $warning[\'reason\'] . \'
+						</div>\';
+
+						if (!empty($warning[\'id_notice\']))
+							$ret .= \'
+						<div class="floatright">
+							<a href="\' . $scripturl . \'?action=moderate;area=notice;nid=\' . $warning[\'id_notice\'] . \'" onclick="window.open(this.href, \\\'\\\', \\\'scrollbars=yes,resizable=yes,width=400,height=250\\\');return false;" target="_blank" class="new_win" title="\' . $txt[\'profile_warning_previous_notice\'] . \'"><img src="\' . $settings[\'images_url\'] . \'/filter.png" alt="" /></a>
+						</div>\';
+
+						return $ret;'),
+				),
+			),
+			'level' => array(
+				'header' => array(
+					'value' => $txt['profile_warning_previous_level'],
+					'style' => 'width: 6%;',
+				),
+				'data' => array(
+					'db' => 'counter',
+				),
+				'sort' => array(
+					'default' => 'lc.counter DESC',
+					'reverse' => 'lc.counter',
+				),
+			),
+		),
+	);
 
-	// Now do the data itself.
-	$context['previous_warnings'] = list_getUserWarnings($context['start'], $perPage, 'log_time DESC', $memID);
+	// Create the list for viewing.
+	require_once($sourcedir . '/Subs-List.php');
+	createList($listOptions);
 
 	// Are they warning because of a message?
 	if (isset($_REQUEST['msg']) && 0 < (int) $_REQUEST['msg'])

+ 0 - 1
Sources/Profile-View.php

@@ -2129,7 +2129,6 @@ function viewWarning($memID)
 	);
 
 	// Create the list for viewing.
-	require_once($sourcedir . '/Subs-List.php');
 	createList($listOptions);
 
 	// Create some common text bits for the template.

+ 1 - 1
Sources/Profile.php

@@ -142,7 +142,7 @@ function ModifyProfile($post_errors = array())
 				),
 				'viewwarning' => array(
 					'label' => $txt['profile_view_warnings'],
-					'enabled' => in_array('w', $context['admin_features']) && $modSettings['warning_settings'][0] == 1 && $cur_profile['warning'] && $context['user']['is_owner'] && !empty($modSettings['warning_show']),
+					'enabled' => in_array('w', $context['admin_features']) && $modSettings['warning_settings'][0] == 1 && $cur_profile['warning'] && (!empty($modSettings['warning_show']) && ($context['user']['is_owner'] || $modSettings['warning_show'] == 2)),
 					'file' => 'Profile-View.php',
 					'function' => 'viewWarning',
 					'permission' => array(

+ 8 - 58
Themes/default/Profile.template.php

@@ -2041,13 +2041,14 @@ function template_viewWarning()
 	template_load_warning_variables();
 
 	echo '
-		<div class="title_bar">
-			<h3 class="titlebg">
+		<div class="cat_bar">
+			<h3 class="catbg">
 				<span class="ie6_header floatleft"><img src="', $settings['images_url'], '/icons/profile_sm.png" alt="" class="icon" />
 				', sprintf($txt['profile_viewwarning_for_user'], $context['member']['name']), '
 				</span>
 			</h3>
 		</div>
+		<p class="description">', $txt['viewWarning_help'], '</p>
 		<div class="windowbg">
 			<span class="topslice"><span></span></span>
 			<div class="content">
@@ -2165,6 +2166,7 @@ function template_issueWarning()
 			size = barWidth * (percent/100);
 
 			setInnerHTML(document.getElementById(\'warning_text\'), percent + "%");
+			document.getElementById(\'warning_text\').innerHTML = percent + "%";
 			document.getElementById(\'warning_level\').value = percent;
 			document.getElementById(\'warning_progress\').style.width = size + "px";
 
@@ -2346,66 +2348,14 @@ function template_issueWarning()
 					<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
 					<input type="submit" name="save" value="', $context['user']['is_owner'] ? $txt['change_profile'] : $txt['profile_warning_issue'], '" class="button_submit" />
 				</div>
+				<br class="clear" />
 			</div>
 			<span class="botslice"><span></span></span>
 		</div>
-	</form>';
-
-	// Previous warnings?
-	echo '<br />
-		<div class="cat_bar">
-			<h3 class="catbg">
-				', $txt['profile_warning_previous'], '
-			</h3>
-		</div>
-		<table border="0" width="100%" cellspacing="0" cellpadding="5" class="table_grid">
-			<thead>
-				<tr class="titlebg lefttext">
-					<th class="first_th" scope="col" width="20%">', $txt['profile_warning_previous_issued'], '</th>
-					<th scope="col" width="30%">', $txt['profile_warning_previous_time'], '</th>
-					<th scope="col">', $txt['profile_warning_previous_reason'], '</th>
-					<th class="last_th" scope="col" width="6%">', $txt['profile_warning_previous_level'], '</th>
-				</tr>
-			</thead>
-			<tbody>';
-
-	// Print the warnings.
-	$alternate = 0;
-	foreach ($context['previous_warnings'] as $warning)
-	{
-		$alternate = !$alternate;
-		echo '
-				<tr class="', $alternate ? 'windowbg' : 'windowbg2', '">
-					<td class="smalltext">', $warning['issuer']['link'], '</td>
-					<td class="smalltext">', $warning['time'], '</td>
-					<td class="smalltext">
-						<div class="floatleft">
-							', $warning['reason'], '
-						</div>';
-
-		if (!empty($warning['id_notice']))
-			echo '
-						<div class="floatright">
-							<a href="', $scripturl, '?action=moderate;area=notice;nid=', $warning['id_notice'], '" onclick="window.open(this.href, \'\', \'scrollbars=yes,resizable=yes,width=400,height=250\');return false;" target="_blank" class="new_win" title="', $txt['profile_warning_previous_notice'], '"><img src="', $settings['images_url'], '/filter.png" alt="" /></a>
-						</div>';
-		echo '
-					</td>
-					<td class="smalltext">', $warning['counter'], '</td>
-				</tr>';
-	}
-
-	if (empty($context['previous_warnings']))
-		echo '
-				<tr class="windowbg2">
-					<td align="center" colspan="4">
-						', $txt['profile_warning_previous_none'], '
-					</td>
-				</tr>';
+	</form>
+	<br />';
 
-	echo '
-			</tbody>
-		</table>
-		<div class="pagesection">', $txt['pages'], ': ', $context['page_index'], '</div>';
+	template_show_list('view_warnings');
 
 	// Do our best to get pretty javascript enabled.
 	echo '

+ 1 - 0
Themes/default/languages/Profile.english.php

@@ -151,6 +151,7 @@ $txt['showPosts_help'] = 'This section allows you to view all posts made by this
 $txt['showMessages'] = 'Messages';
 $txt['showTopics'] = 'Topics';
 $txt['showAttachments'] = 'Attachments';
+$txt['viewWarning_help'] = 'This section allows you to view all warnings issued to this member.';
 $txt['statPanel'] = 'Show Stats';
 $txt['editBuddyIgnoreLists'] = 'Buddies/Ignore List';
 $txt['editBuddies'] = 'Edit Buddies';