__section__
default
__description__
Prints table detailing history of moderation of a comment, or a user, or
	an IPID or SubnetID, or the mods a user did

* type = type of id being logged (cid, uid, ipid, etc.)
* mod_admin = boolean for if current user is an admin
* mods = arrayref of hashref of comment moderations (sid, cid, val, reason,
	score, ts, active, uid, cuid, nickname)
* reasonTotal = total moderations
* reasonHist = arrayref of number of moderations at each reason
* show_cid = show the cid of each comment?
* show_modder = show who modded each comment?
* mod_to_from = "to" means each nickname/uid is who the moderation was
	done to; "from" means each nickname/uid is the moderator
* both_mods = if true (1), this is an ipid or subnetid page, and both
	moderator and moderatee columns are needed
* timestamp_hr = time to place an <hr> at
* skip_ip_disp = number of ip display to skip when both_mods are on ( 1 or 2) 0 if you don't want to skip any
* this_user    = user whose mods we are looking at
* title	       = title to display -- if none is given none is shown
* mods_to_m2s  = hashref keyed by mod id containing arrays of m2s done to that mod
* show_m2s     = whether we are currently trying to show_m2s
* value	       = value of item we're looking at uid of user, or netid value
* need_m2_form = whether we need to open and close a form for m2
* need_m2_button = whether we need to show a button for m2
* meta_mod_only = whether meta_moderation is the only thing going on in this form

__page__
misc
__lang__
en_US
__name__
modCommentLog
__template__
[% IF mod_admin %]
[% 
down=0; cnt=0; m2_down=0; m2_count=0; m2_offside=0; 
a_down=0; a_cnt=0; a_m2_down=0; a_m2_up=0; m2_count=0; a_m2_offside=0; a_m2_unfair_votes=0; unanimous = 0; unresolved=0;
show_uid_totals = (type == "uid" && (this_user.totalmods || this_user.downmods || this_user.upmods || this_user.m2unfair || this_user.m2unfairpercent || this_user.stirred));

bg_toggle = 0;
%]
[% IF mods.size > 0  || show_uid_totals %]
	[% IF user.is_admin and need_m2_form %]
	<form  method="post" action="[% gSkin.rootdir %]/comments.pl">
	<div>
	[% END %]
	[% IF meta_mod_only %]
		<input type="hidden" name="meta_mod_only" value="1">
	[% END %]
	[% total_cols = 6 %]	
	[% IF title %]
		[% show_m2s_op = show_m2s ? 0 : 1;
		   self_url = PROCESS base_url_mod;
		   url_tail = PROCESS state_url_mod override = { show_m2s => show_m2s_op};
		   self_url = self_url  _ url_tail;
		   self_url = self_url | strip_attribute;
		   extra = "<a href='" _ self_url _ "'><img src=\"" _  constants.imagedir _ (show_m2s ? "/contract.gif" : "/expand.gif") _ "\"  alt=\"\" width=\"14\" height=\"14\"></a>";
		%]
		[% PROCESS titlebar width="100%" title=title max_min_button = extra %]
	[% END %]
	<table align="center" border="0" cellpadding="2" cellspacing="0" width="100%" class="data">
	<tr class="data_head">
        	<th align=left>Datestamp</th>
		<th align=right>Was</th>
		<th align=right>Now</th>
		<th align=right>Val</th>
		<th align=left>Reason  <span class="admin_data_label">/ Metamod</span></th>
		<th align=right> M2</th>
		[% IF mod_to_from == "from"; total_cols = total_cols + 2; %]
			[% IF skip_ip_disp == 1 and both_mods; total_cols = total_cols - 1; ELSE %]
			<th align=left>IPID </th>
			[% END %]
			<th align="left">Moderator</th>
		[% END %]
		[% IF mod_to_from == "to" || both_mods; total_cols = total_cols + 2; %]
			[% IF both_mods and skip_ip_disp ==2; total_cols = total_cols - 1; ELSE  %]
			<th align=left>IPID </th>
			[% END %]
			<th align=left>Moderatee <span class="admin_data_label">/ Metamoderator</span></th>
		[% END %]
	</tr>
		[% hr_shown = 0; 
		   mod_index = 0; %]
		[% FOREACH moderation = mods %]
		[% IF type == "cid" and constants.show_m2s_with_mods and show_m2s and constants.m2_multicount; 
			prev_index = mod_index - 1;
			next_index = mod_index + 1;
			IF prev_index >= 0; prev_mod = mods.${prev_index}; END;
			IF next_index < mods.size; next_mod = mods.${next_index}; ELSE; next_mod = {}; END;
			IF moderation.m2_identity == prev_mod.m2_identity && moderation.reason == prev_mod.reason; suppress_mod_head = 1; ELSE; suppress_mod_head = 0; END;
			IF moderation.m2_identity == next_mod.m2_identity && moderation.reason == next_mod.reason; suppress_m2s = 1; ELSE; suppress_m2s = 0; END;
		 END %]
		[% IF type=="cid";
			IF !suppress_mod_head; 
				bg_toggle=!bg_toggle;
			END;
		   ELSE;
			bg_toggle=!bg_toggle;
		END; %]
		[% IF (timestamp_hr and timestamp_hr.gt(moderation.ts) and !hr_shown); hr_shown=1 %]<tr class="data_hl2"><td colspan="[% total_cols %]">[% PROCESS horiz_rule %]</td></tr>[% END %]
	<tr class="[% bg_toggle ? "data_hl1" : "data_hl2" %]">
		<td align="left">
			[% IF show_cid %]
			<a href="[% gSkin.rootdir %]/comments.pl?sid=[%
			moderation.sid %]&amp;cid=[% moderation.cid %]">[%
			moderation.ts.substr(5,-3) %]</a>
			[% ELSE %]
				[% moderation.ts.substr(5,-3) %]
			[% END %]
			[% IF !moderation.active %]*[% END %]
		</td>
	        <td align="right">[% moderation.points_orig; %]</td>
		<td align="right">
			[% IF !suppress_mod_head; moderation.score; END %]
		</td>
		<td align="right"> <b>[% IF !suppress_mod_head %][% IF moderation.val > 0; "+"; END; moderation.val %][% END %]</b> </td>
		<td>[% IF !suppress_mod_head %][% PROCESS reason_or_m2_select moderation=moderation reasons=reasons mod_admin=mod_admin %][% END %]</td>
		[% IF !reasons.${moderation.reason}.m2able || !moderation.active;
			m2fair_str = "-";
			m2unfair_str = "-";
		ELSE;
			IF moderation.m2status > 0; 
				m2fair_str = "<b><i>" _ moderation.m2fair _ "</i></b>"; m2unfair_str = "<b><i>" _ moderation.m2unfair _ "</i></b>";
		 	  ELSE;
				unresolved = unresolved + 1;
				m2fair_str = moderation.m2fair; m2unfair_str =  moderation.m2unfair;
		   	END; 
			
		END %]
		<td align="right">[% IF !suppress_mod_head; m2fair_str _ " " _ m2unfair_str; END %] </td>

[% IF !both_mods || skip_ip_disp!=1 %]	
	<td> &nbsp; [% PROCESS link_ipid ipid=moderation.ipid ipid_vis=moderation.ipid_vis %]</td>
[% END %]
<td> [% PROCESS nick_and_uid nickname=moderation.nickname uid=moderation.uid %] &nbsp; </td>
[% IF both_mods %]
	[% IF skip_ip_disp!=2 %]	
		<td> &nbsp; [% PROCESS link_ipid ipid=moderation.ipid2  ipid_vis=moderation.ipid2_vis %]</td>
	[% END %]	
		<td> [% PROCESS nick_and_uid nickname=moderation.nickname2 uid=moderation.uid2 %] &nbsp; </td>
[% END %]
	</tr>
		[% mod_index = mod_index + 1; %]
		[% IF moderation.active %]
			[%  a_sum = a_sum + moderation.val; IF moderation.val > 0; a_up = a_up+1; END; IF moderation.val < 0; a_down = a_down + 1; END; 
			a_count = a_count+1; a_m2_count = a_m2_count + moderation.m2fair + moderation.m2unfair;
			a_m2_unfair_votes=a_m2_unfair_votes + moderation.m2unfair;
			IF moderation.m2status > 0;
				IF moderation.m2fair > moderation.m2unfair;  a_m2_up = a_m2_up + 1; END;
				IF moderation.m2unfair > moderation.m2fair;  a_m2_down = a_m2_down + 1; END;
				IF (moderation.m2unfair == 0) and (moderation.m2fair>0 ); unanimous=unanimous + 1; END;
				END;
 %]
			[% IF moderation.m2fair >= moderation.m2unfair; a_m2_offside = a_m2_offside + moderation.m2unfair; ELSE; a_m2_offside = a_m2_offside + moderation.m2fair; END %]
			[% IF constants.show_m2s_with_mods %]
			[% FOREACH m2 = mods_to_m2s.${moderation.id} %] 
			[% IF !suppress_m2s %]
			<tr class="data_hl3"><td>[% m2.ts.substr(5,-3)  %][% IF !m2.active %]*[% END %]</td><td colspan="3"></td><td align="right">[% m2.val > 0 ? "Fair" : "Unfair" %]</td><td align="right">[% m2.val > 0 ? "+" : "-" %]</td>
			[%- IF !both_mods || skip_ip_disp!=1 -%]
				<td></td>
			[%- END -%]
			<td>[% IF !both_mods %][% PROCESS nick_and_uid nickname=m2.nickname uid=m2.uid %][% END %] </td>
			[%- IF both_mods -%]
				[%- IF skip_ip_disp!=2 -%]
					<td></td>
				[%- END -%]
				<td>[% PROCESS nick_and_uid nickname=m2.nickname uid=m2.uid %]</td>
			[%- END %]
			</tr>
			[% END %]
		[%- END -%]
		[%- END -%]

		[% END %]
	
		[% sum = sum + moderation.val; IF moderation.val > 0; up = up+1; END; IF moderation.val < 0; down = down + 1; END; count = count+1; 
		IF moderation.m2unfair > moderation.m2fair; m2_down = m2_down + 1; END; m2_count= m2_count + moderation.m2fair + moderation.m2unfair; %]

		[% IF moderation.m2fair >= moderation.m2unfair; m2_offside = m2_offside + moderation.m2unfair; ELSE; m2_offside = m2_offside + moderation.m2fair; END %]
		[% END %]
	[% IF count %]
	<tr class="data_hl2"><td colspan="[% total_cols %]">[% PROCESS horiz_rule %]</td></tr>
	<tr class="data_hl2"><td colspan="2"><b>Total: [% a_count %] </b></td><td></td><td align="right"><b>[% a_down %]</b></td><td><b>[% Slash.getData('percentage', { sum=>a_down, count => a_count},"misc") %] Down</b></td><td align="right"><b>[% a_m2_unfair_votes %]</b></td><td><b>Unfair ([% Slash.getData('percentage', { sum=> a_m2_unfair_votes, count => a_m2_count },"misc") %])</b></td> 
	[% IF both_mods and skip_ip_disp==1 %]<td></td>[% END %]
	<td><b>[% unanimous %] Unanimous [% a_m2_up %] Fair [% a_m2_down %] Unfair [% unresolved %] Unresolved</b></td>
</tr>
	[% END %]
[% IF type=="uid" %]
	<tr class="data_hl2"><td colspan="2"><b>Lifetime Spent: [% this_user.totalmods %]</b></td><td></td><td align="right"></td><td><b>[% Slash.getData('percentage', { sum = this_user.downmods, count=> this_user.downmods + this_user.upmods },"misc") %] Down</b></td><td></td><td><b>[% this_user.m2unfair %] Unfair [% IF this_user.m2unfairpercent %]([% this_user.m2unfairpercent %])[% END %]</b></td>
	[% IF both_mods and skip_ip_disp==1 %]<td></td>[% END %]
	<td><b>[% this_user.stirred %] Stirred</b></td>
</tr>
[% END %]
[% IF user.is_admin and (need_m2_form || need_m2_button )%]
	[% IF need_m2_button %]
		<tr class="data_hl1"><td colspan="[% total_cols %]" align="right">
		<input type="hidden" name="op" value="moderate">
		<input type="submit" name="submit" value="MetaModerate">
		</td></tr>
	[% END %]
[% END %]
        </table>
	[% IF need_m2_form %]
		</div>	
		</form>
	[% END %]
[% END %]
[% END %]

[% modifiers = [
	{ label = "moderations",		edit = 0,	name = "Moderation" },
	{ label = "reason_bonus",		edit = 1,	name = "Extra '" _ reasons.$reason.name _ "' Modifier" },
	{ label = "clbig",			edit = 1,	name = "Long Comment Modifier" },
	{ label = "clsmall",			edit = 1,	name = "Small Comment Modifier" },
	{ label = "people_bonus_anonymous",	edit = 1,	name = "Anonymous Modifier" },
	{ label = "new_user_bonus",		edit = 1,	name = "New User Modifier" },
	{ label = "people_bonus_friend",	edit = 1,	name = "Friend Modifier" },
	{ label = "people_bonus_foe",		edit = 1,	name = "Foe Modifier" },
	{ label = "people_bonus_freak",		edit = 1,	name = "Freak Modifier" },
	{ label = "people_bonus_fan",		edit = 1,	name = "Fan Modifier" },
	{ label = "people_bonus_fof",		edit = 1,	name = "Friend-of-Friend Modifier" },
	{ label = "people_bonus_eof",		edit = 1,	name = "Foe-of-Friend Modifier" },
	{ label = "karma_bonus",		edit = 1,	name = "Karma-Bonus Modifier" },
	{ label = "subscriber_bonus",		edit = 1,	name = "Subscriber-Bonus Modifier" },
	{ label = "score_end",			edit = 0,	name = "Total Score:" },
];
num_modifiers = 0;
IF type == 'cid' && (reasonTotal > 0 || reason);
	num_modifiers = 1;
ELSE;
	FOREACH modifier = modifiers;
		IF modifier.label != 'score_end' && modifier_hr.${modifier.label};
			num_modifiers = num_modifiers + 1;
		END;
	END;
END;

IF num_modifiers > 0 %]

<table align="center" border="0" cellpadding="2" cellspacing="0" width="300" class="data" id="mod_summary">

	<tr class="data_head">
		<th align="left">Starting Score:&nbsp;&nbsp;&nbsp;</th>
		<th colspan="2" align="right">[% modifier_hr.score_start || 0 %]</th>
		<th align="left">&nbsp;point[% IF modifier_hr.score_start != 1 %]s[% END %]</th>
	</tr>

[% FOREACH modifier = modifiers %]
	[% IF type == 'cid' && (
			    modifier.label == 'score_end'
			|| (modifier.label == 'moderations' && reasonTotal > 0)
			|| (modifier.label == 'reason_bonus' && reason)
	)	|| modifier_hr.${modifier.label} %]
	[% sc_end = modifier.label=='score_end' %]
	[% IF sc_end %]<tr class="data_hl2"><td colspan="4">[% PROCESS horiz_rule %]</td></tr>[% END %]
	<tr class="data_hl2">
		<td align="left">[% IF sc_end %]<b>[% END %][% modifier.name %][% IF sc_end %]</b>[% END %]</td>
		<td>&nbsp;</td>
		<td align="right">[% IF sc_end %]<b>[% END %][% modifier_hr.${modifier.label} || 0 %][% IF sc_end %]</b>[% END %]</td>
		<td>
		[%- IF modifier.edit && !user.is_anon -%]
			(<a href="/my/comments/#[% modifier.label | strip_attribute %]">Edit</a>)
		[%- ELSE -%]
			&nbsp;
		[%- END -%]
		</td>

		[% IF modifier.label == 'moderations' && reasonTotal > 0 %]
			</tr><tr class="data_hl2"><td colspan="4">
			[% IF constants.comments_mod_totals_exact -%]
				&nbsp;&nbsp;
				[% FOREACH i = [0 .. reasonHist.max] %]
					[% IF reasonHist.$i %]
						[% reasons.$i.name %]=[% reasonHist.$i %],[% " " %]
					[% END %]
				[% END %]
				<b>Total=[% reasonTotal %]</b>
			[% ELSE %]
				[% seen_first = 0; FOREACH rtop = reasonsTop %]
					[% NEXT UNLESS rtop.percent > 0 %]
					[% IF seen_first %]<br>[% END; seen_first=1 %]&nbsp;&nbsp;[% rtop.percent %]%
					[% reasons.${rtop.reason}.name %]
				[% END %]
			[% END %]
			</td>
		[% END %]

	</tr>
	[% END;
END %]
	[% IF mod_admin %]
	<tr class="data_hl2"><td><b>Comment Karma:</b></td><td>&nbsp;</td><td align="right"><b>[% mods.0.karma %]</b></td><td></td></tr>
	[% END %]
</table>

[% END %]

[% BLOCK link_ipid %]
<a href="[% gSkin.rootdir %]/users.pl?op=userinfo&amp;userfield=[% ipid | strip_attribute %]&amp;fieldname=ipid">[% ipid_vis %]</a>
[% END %] 

[% BLOCK nick_and_uid;
	nickname | strip_literal;
	IF uid != constants.anonymous_coward_uid;
		' (<a href="';
	gSkin.rootdir;
		'/users.pl?op=userinfo&amp;fieldname=uid&amp;userfield=';
		uid;
		'">';
		uid;
		'</a>)';
	END;
END %]

[% BLOCK reason_or_m2_select %]
	[% IF user.is_admin and moderation.active and moderation.m2status==0 and reasons.${moderation.reason}.m2able; 
		h = { ""  => reasons.${moderation.reason}.name,
		      "+" => reasons.${moderation.reason}.name _ " Fair",
		      "-" => reasons.${moderation.reason}.name _ " Unfair"
		    };
		Slash.createSelect("mm${moderation.id}", h, '', 1, 0 );
	ELSE;
		reasons.${moderation.reason}.name;
	END %]

[% END %]

[% BLOCK base_url_mod %]
	[% base_url = gSkin.rootdir _ "/users.pl?op=userinfo&amp;fieldname=";
	IF type == "uid" or type == "cuid";
		base_url = gSkin.rootdir _ "/users.pl?op=userinfo&amp;uid=" _ value;
	ELSIF type =="cid";
		base_url = gSkin.rootdir _ "/comments.pl?sid=${mods.0.sid}&amp;pid=${mods.0.pid}&amp;cid=${mods.0.cid}";
	ELSIF type =="global";
		base_url = gSkin.rootdir _ "/admin.pl?op=recent_mods";
	ELSE; 
		fp_fieldname = BLOCK; form.fieldname | fixparam; END;
		base_url = base_url _ fp_fieldname _ "&amp;userfield=" _ value;
	END;
	base_url;
	%]
[% END %]
[% BLOCK state_url_mod;
	state_url="";
	state_params = ["show_m2s","show_m1s","min_comment", "m2_listing"];
	FOREACH param = state_params;
		IF form.${param}.defined || override.${param}.defined;
			state_url = state_url _ "&amp;" _ param _ "=";
			IF override.${param}.defined;
				fp_val = BLOCK; override.${param} | fixparam; END;
			ELSE;
				fp_val = BLOCK; form.${param} | fixparam; END;
			END;
			state_url = state_url _ fp_val;
		END;
	END;
	state_url;
END %]
__seclev__
10000
__version__
$Id: modCommentLog;misc;default,v 1.47 2006/06/19 19:47:09 tvroom Exp $
