afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] changelog2009-08-11 05:51 pm

[dw-free] manage circle page doesn't error if an invalid account is provided

[commit: http://hg.dwscoalition.org/dw-free/rev/057055a4b0b0]

http://bugs.dwscoalition.org/show_bug.cgi?id=962

Save all valid users, then show a list of invalid users after posting.

Patch by [personal profile] carynb.

Files modified:
  • htdocs/manage/circle/edit.bml
  • htdocs/manage/circle/edit.bml.text
--------------------------------------------------------------------------------
diff -r 7df36af52680 -r 057055a4b0b0 htdocs/manage/circle/edit.bml
--- a/htdocs/manage/circle/edit.bml	Tue Aug 11 06:14:27 2009 +0000
+++ b/htdocs/manage/circle/edit.bml	Tue Aug 11 17:49:34 2009 +0000
@@ -320,6 +320,9 @@ body<=
         # interface, since anyone who's in both the add and edit interfaces should
         # only be proccessed via the add interface and not by the edit interface
         my %userid_processed;
+        
+        #  Maintain a list of invalid userids for display to the user
+        my @not_user;
 
         # process the additions
         foreach my $key ( keys %POST ) {
@@ -328,7 +331,10 @@ body<=
                 next unless $POST{"editfriend_add_${num}_user"};
 
                 my $other_u = LJ::load_user_or_identity( $POST{"editfriend_add_${num}_user"} );
-                next unless $other_u;
+                unless ( $other_u ) {
+                    push @not_user, $POST{"editfriend_add_${num}_user"};
+                    next;
+                }
 
                 my $trusted_nonotify = $u->trusts( $other_u ) ? 1 : 0;
                 my $watched_nonotify = $u->watches( $other_u ) ? 1 : 0;
@@ -392,7 +398,13 @@ body<=
             }
         }
 
-        $ret .= "<?h1 $ML{'.success.head'} h1?>";
+        #if there are entries in the not_user array, tell the user there were problems.
+        if ( @not_user > 0 ) {
+            $ret .= "<?h1 $ML{'.error.adding.header'} h1?>";
+            $ret .= "<br>" . BML::ml('.error.adding.text', { username => LJ::ehtml( $_ ) } ) foreach @not_user;
+        } else {
+            $ret .= "<?h1 $ML{'.success.head'} h1?>";
+        }
         $ret .= "<?p $ML{'.success.fromhere'} p?>";
         $ret .= "<ul>";
         $ret .= "<li><a href='" . $u->journal_base . "/read'>$ML{'.success.friendspage'}</a></li>";
diff -r 7df36af52680 -r 057055a4b0b0 htdocs/manage/circle/edit.bml.text
--- a/htdocs/manage/circle/edit.bml.text	Tue Aug 11 06:14:27 2009 +0000
+++ b/htdocs/manage/circle/edit.bml.text	Tue Aug 11 17:49:34 2009 +0000
@@ -90,6 +90,10 @@
 
 .editfriends.username=Username
 
+.error.adding.header=Problems Encountered
+
+.error.adding.text=User <strong>[[username]]</strong> does not exist.
+
 .error.badjournaltype=Cannot modify friends of this journal type.
 
 .error.updating=There was an error updating your friends list:
--------------------------------------------------------------------------------
denise: Image: Me, facing away from camera, on top of the Castel Sant'Angelo in Rome (Default)

[staff profile] denise 2009-08-12 02:19 am (UTC)(link)
SO MUCH LOVE FOR THIS OMG
carynb: (Coding)

[personal profile] carynb 2009-08-12 02:20 pm (UTC)(link)
Glad you like it! *g*