[Slashdotjp-dev 1160] [687] * Fix for reason_modifier setting for users.pl

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2008年 7月 7日 (月) 19:39:29 JST


Revision: 687
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=slashdotjp&view=rev&rev=687
Author:   tach
Date:     2008-07-07 19:39:29 +0900 (Mon, 07 Jul 2008)

Log Message:
-----------
 * Fix for reason_modifier setting for users.pl
   * Use reason_id as key instead of name

Modified Paths:
--------------
    slashjp/branches/2.5.0.192/debian/changelog
    slashjp/branches/2.5.0.192/themes/slashcode/htdocs/users.pl


-------------- next part --------------
Modified: slashjp/branches/2.5.0.192/debian/changelog
===================================================================
--- slashjp/branches/2.5.0.192/debian/changelog	2008-07-05 13:59:10 UTC (rev 686)
+++ slashjp/branches/2.5.0.192/debian/changelog	2008-07-07 10:39:29 UTC (rev 687)
@@ -1,3 +1,10 @@
+slash (2.5.0.192-16) unstable; urgency=low
+
+  * Fix for reason_modifier setting for users.pl
+    * Use reason_id as key instead of name
+
+ -- Taku YASUI <tach****@osdn*****>  Mon,  7 Jul 2008 10:38:26 +0000
+
 slash (2.5.0.192-15) unstable; urgency=low
 
   * Add vars "modreasons_select_disabled" to insert "disabled => 1" for getReasons()

Modified: slashjp/branches/2.5.0.192/themes/slashcode/htdocs/users.pl
===================================================================
--- slashjp/branches/2.5.0.192/themes/slashcode/htdocs/users.pl	2008-07-05 13:59:10 UTC (rev 686)
+++ slashjp/branches/2.5.0.192/themes/slashcode/htdocs/users.pl	2008-07-07 10:39:29 UTC (rev 687)
@@ -2155,6 +2155,8 @@
 
 	my @reasons = ( );
 	my %reason_select = ( );
+	my $reasons_plus = {};
+	my $reasons_minus = {};
 	if ($constants->{m1}) {
 		my $mod_reader = getObject("Slash::$constants->{m1_pluginname}", { db_type => 'reader' });
 		my $reasons = $mod_reader->getReasons();
@@ -2162,12 +2164,20 @@
 			push @reasons, $reasons->{$id}{name};
 		}
 		# Reason modifiers
-		for my $reason_name (@reasons) {
-			my $key = "reason_alter_$reason_name";
-			$reason_select{$reason_name} = createSelect(
+		for my $id (sort { $a <=> $b } keys %$reasons) {
+			next unless ($reasons->{$id}{listable});
+			my $key = "reason_alter_$id";
+			$reasons->{$id}{reason_select} = createSelect(
 				$key, \@range, 
 				$user_edit->{$key} || 0, 1, 1
 			);
+			if ($reasons->{$id}{val} > 0) {
+				$reasons_plus->{$id} = $reasons->{$id};
+			} elsif ($reasons->{$id}{val} < 0) {
+				$reasons_minus->{$id} = $reasons->{$id};
+			} else {
+				next;
+			}
 		}
 	}
 
@@ -2273,6 +2283,8 @@
 		range			=> \@range,
 		reasons			=> \@reasons,
 		reason_select		=> \%reason_select,
+		reasons_minus		=> $reasons_minus,
+		reasons_plus		=> $reasons_plus,
 		people			=> \@people,
 		people_select		=> \%people_select,
 		new_user_percent_select	=> $new_user_percent_select,
@@ -2819,9 +2831,9 @@
 		push @reasons, $reasons->{$id}{name};
 	}
 
-	for my $reason_id (%$reasons) {
-		next unless $reasons->{$reason_id}{listable};
-		my $key = "reason_alter_$reason_id";
+	for my $id (sort { $a <=> $b } keys %$reasons) {
+		next unless $reasons->{$id}{listable};
+		my $key = "reason_alter_$id";
 		my $answer = $form->{$key} || 0;
 		$answer = 0 if !$answer || $answer !~ /^[\-+]?\d+$/;
 		$user_edits_table->{$key} = ($answer == 0) ? '' : $answer;


Slashdotjp-dev メーリングリストの案内
Back to archive index