wisest owl (wisest_owl) wrote in changelog,
wisest owl
wisest_owl
changelog

[livejournal] r15629: LJSUP-4717

Committer: gprochaev
LJSUP-4717


U   trunk/cgi-bin/LJ/Widget/IPPU/AddAlias.pm
U   trunk/htdocs/friends/add.bml
U   trunk/htdocs/friends/add.bml.text
U   trunk/htdocs/manage/banusers.bml
U   trunk/htdocs/manage/banusers.bml.text
U   trunk/htdocs/manage/notes.bml
U   trunk/htdocs/manage/notes.bml.text
Modified: trunk/cgi-bin/LJ/Widget/IPPU/AddAlias.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/IPPU/AddAlias.pm	2009-08-24 09:15:44 UTC (rev 15628)
+++ trunk/cgi-bin/LJ/Widget/IPPU/AddAlias.pm	2009-08-24 09:30:54 UTC (rev 15629)
@@ -44,8 +44,9 @@
     $body .= $class->html_hidden(
                 foruser => $opts{foruser},
              );
-    $body .= "<p>" . $class->html_submit(BML::ml('widget.alias.aliaschange')) ;
 
+    $body .= "<p>" . $class->html_submit("aliaschange", BML::ml('widget.alias.aliaschange')) . " " . $class->html_submit("aliasdelete", BML::ml('widget.alias.aliasdelete')) ;
+
     $body .= "<span class='helper'>" . BML::ml('widget.addalias.display.helper', {aopts => "href='$LJ::SITEROOT/manage/notes.bml'"}) . "</span>";
     $body .= "</div>";
     $body .= $class->end_form;
@@ -75,6 +76,7 @@
     my $is_edit = 0;
     $is_edit = 1 if $aliases->{$post->{foruser}} ne '';
     my $prepared_alias = substr($post->{alias}, 0, 400);
+    $prepared_alias = '' if $post->{'deletealias'} ne '';
     $aliases->{$user_for_alias->{userid}} = $prepared_alias if $prepared_alias;
     delete $aliases->{$user_for_alias->{userid}} unless $prepared_alias;
 

Modified: trunk/htdocs/friends/add.bml
===================================================================
--- trunk/htdocs/friends/add.bml	2009-08-24 09:15:44 UTC (rev 15628)
+++ trunk/htdocs/friends/add.bml	2009-08-24 09:30:54 UTC (rev 15629)
@@ -1,8 +1,12 @@
 <?_code
 use strict;
 
+use JSON;
+
 use vars qw($body $title $windowtitle %GET %POST);
 
+my $max_alias_length = 400; # max allowed chars(?) or bytes in alias
+
  my $print_with_ad = sub {
     my $str = shift;
     my $ad_box = LJ::get_ads({ location => 'bml.friends.add/error', ljadwrapper => 1 });
@@ -83,7 +87,19 @@
 
      if ($res{'success'} eq "OK")
      {
-         $body = LJ::get_ads({ 
+        if ($remote->get_cap ('paid')) {
+            ## user has been added. setting alias for him
+            my $user_alias = $POST{'user_note'};
+            my $aliases = jsonToObj($remote->prop('aliases')) || {};
+            $user_alias = substr($user_alias, 0, $max_alias_length);
+            $aliases->{$userid} = $user_alias;
+            my $ready_aliases = objToJson($aliases);
+            if (length $ready_aliases < 65536) {
+                $remote->set_prop( aliases => $ready_aliases );
+            }
+        }
+        
+         $body .= LJ::get_ads({ 
             location    => 'bml.friends.add/main', 
             ljadwrapper => 1,
             below_ad    => LJ::CProd->full_box_for($remote, width => 300) 
@@ -184,6 +200,21 @@
 # users that aren't visible can only be removed, not modified
 if ($u->is_visible) {
 
+    ## Add user alias while user's friending
+    if ($remote->get_cap ('paid')) {
+        $body .= "<i>" . $ML{'.optional'}. ":</i> " . BML::ml('.note.text', {'username' => LJ::ljuser($user), aopts => "href='$LJ::SITEROOT/support/faqbrowse.bml?faqid=295'" }) . "<br/>";
+        $body .= "<blockqoute>";
+        $body .= LJ::html_text ( { name => 'user_note' } );
+        $body .= "</blockqoute><br/>";
+    } else {
+        ## TODO!!! must set to gray font text
+        $body .= "<i>" . $ML{'.optional'}. ":</i> " . BML::ml('.note.text', {'username' => LJ::ljuser($user), aopts => "href='$LJ::SITEROOT/support/faqbrowse.bml?faqid=295'" }) . "<br/>";
+        $body .= "<blockqoute>";
+        $body .= LJ::html_text ( { 'disabled', name => 'user_note' } );
+        $body .= "</blockqoute><br/>";
+        $body .= LJ::run_hook("upgrade_link", $u, "paid") . BML::ml('.hint.paid.text', {aopts => "href='$LJ::SITEROOT/manage/account/'" }) unless $remote->get_cap ('paid');
+    }
+
  ## let them pick friend groups
  my $err;
  my $greq = LJ::Protocol::do_request("getfriendgroups", {

Modified: trunk/htdocs/friends/add.bml.text
===================================================================
--- trunk/htdocs/friends/add.bml.text	2009-08-24 09:15:44 UTC (rev 15628)
+++ trunk/htdocs/friends/add.bml.text	2009-08-24 09:30:54 UTC (rev 15629)
@@ -78,12 +78,18 @@
 
 .error3.title=Modify Friend
 
+.error.too.long=You've reached the maximum number of the notes.
+
 .groups.header=Friends Groups
 
 .groups.nogroup=No friend groups set up.
 
 .groups.text1=<i>Optional:</i> Include in one or more custom friends groups.
 
+.hint.paid.text=This feature is available only for <a [[aopts]]>Paid Account Level</a> users.
+
+.note.text=set note for [[username]] (read <a [[aopts]]>FAQ</a> for details):
+
 .optional=Optional
 
 .remove.header=Success
@@ -94,3 +100,4 @@
 
 .remove.title=Friend Removed!
 
+

Modified: trunk/htdocs/manage/banusers.bml
===================================================================
--- trunk/htdocs/manage/banusers.bml	2009-08-24 09:15:44 UTC (rev 15628)
+++ trunk/htdocs/manage/banusers.bml	2009-08-24 09:30:54 UTC (rev 15629)
@@ -5,6 +5,10 @@
     use strict;
     use vars qw(%GET %POST $title $headextra @errors @warnings);
 
+    use JSON;
+
+    my $max_alias_length = 400;
+
     $title = $ML{'.title'};
 
     my $remote = LJ::get_remote();
@@ -15,6 +19,7 @@
     return LJ::bad_input($ML{'error.invalidauth'})
         unless $u;
 
+    my $alias_enable = $u->get_cap('aliases');
     my $getextra = $authas ne $remote->user ? "?authas=$authas" : "";
 
     my $submit_msg;
@@ -27,6 +32,8 @@
         # unban users before banning users so that in the case of a collision (i.e. a particular
         # user is being banned and unbanned at the same time), that user is left banned
 
+        my $aliases = jsonToObj($u->prop('aliases')) || {};
+        
         # unban users
         if ($POST{unban_user}) {
             # first remove any users from the list that are not valid users
@@ -43,6 +50,15 @@
             $u->unban_user_multi(@unbanlist) if @unbanlist;
         }
 
+        if ($POST{unban_users_btn}) {
+            foreach my $new_alias (keys %POST) {
+                my ($uid) = $new_alias =~ m#new_alias_(\d+)#;
+                next unless $uid;
+                $alias = substr($POST{$new_alias}, 0, $max_alias_length)
+                $aliases->{$uid} = $alias if $alias_enable && LJ::load_userid($uid);
+            }
+        }
+
         # ban users
         if ($POST{ban_list}) {
             # first remove any users from the list that are not valid users
@@ -54,8 +70,12 @@
                 my $banu = LJ::load_user($banusername);
                 push @banlist, $banu->id if $banu;
                 push @cantbanlist, $banusername unless $banu;
+
+                ## set alias for banuser if alias was set, aliases available and banuser is exist
+                $alias = substr($POST{ban_note}, 0, $max_alias_length)
+                $aliases->{$banu->id} = $POST{ban_note} if $alias_enable && $POST{ban_note} && $banu;
             }
-
+        
             # make sure the user isn't over the max number of bans allowed
             my $banned = LJ::load_rel_user($u, 'B') || [];
             if (scalar @$banned >= ($LJ::MAX_BANS || 5000)) {
@@ -71,6 +91,13 @@
             }
         }
 
+        my $ready_aliases = objToJson($aliases);
+        if (length $ready_aliases < 65536) {
+            $u->set_prop( aliases => $ready_aliases ) if $alias_enable;
+        } else {
+            $submit_msg = "<?errorbar $ML{'.error.too.long'} errorbar?>";
+        }
+
         $submit_msg = "<?warningbar $ML{'.success'} warningbar?>" unless $submit_msg;
     }
 
@@ -94,6 +121,13 @@
         cols => 50,
     });
 
+    $ret .= "<br/>";
+    $ret .= $ML{'.intro.ban.note.text'} . LJ::html_text ( { name => 'ban_note', value => $ML{'.intro.ban.note.value'} } ) if $alias_enable && !$u->is_community;
+    $ret .= "<br/>" . LJ::html_submit ( 'ban_users_btn', $ML{'.btn.ban_users'} );
+    $ret .= "</form>";
+
+    $ret .= "<form action='$LJ::SITEROOT/manage/banusers.bml$getextra' method='post'>";
+    $ret .= LJ::form_auth();
     # unban users
     $ret .= "<h2 style='margin-top: 20px;'>$ML{'.header.unban'}</h2>";
     my $banned = LJ::load_rel_user($u, 'B');
@@ -111,11 +145,11 @@
                     } 
                 }", selected => 0 });
         $ret .= "</th><th>$ML{'/community/members.bml.key.user'}</th>";
-		$ret .= "<th>$ML{'.intro.unban.alias'}</th></tr>\n" if (not $u->is_community);
+		$ret .= "<th>$ML{'.intro.unban.alias'}</th>\n" if !$u->is_community && $alias_enable;
+        $ret .= "</tr>";
 
         my $rc = 0;
 
-        my $alias_enable = $u->prop('aliases');
         foreach my $banuid (@$banned) {
             my $bu = $us->{$banuid};
             next unless $bu;
@@ -127,8 +161,8 @@
                 value => $bu->id,
             }) . "</td>";
             $ret .= "<td>" . $bu->ljuser_display . "</td>";
-			if (not $u->is_community) {
-            	$ret .= "<td>".LJ::ehtml(LJ::ljuser_alias($bu->{user}))."</td>" if $alias_enable;
+			if (not $u->is_community && $alias_enable) {
+            	$ret .= "<td>".LJ::html_text( { name => 'new_alias_'.$bu->id, value => LJ::ehtml(LJ::ljuser_alias($bu->{user})) })."</td>" if $alias_enable;
 			}
             $ret .= "</tr>";
         }
@@ -137,7 +171,7 @@
         $ret .= $u->is_community ? "<p>$ML{'.intro.unban.comm.none'}</p>" : "<p>$ML{'.intro.unban.self.none'}</p>";
     }
 
-    $ret .= "<p>" . LJ::html_submit($ML{'.btn.banunban'}) . "</p>";
+    $ret .= "<p>" . LJ::html_submit('unban_users_btn', $ML{'.btn.banunban'}) . "</p>";
     $ret .= "</form>";
 
     return $ret;

Modified: trunk/htdocs/manage/banusers.bml.text
===================================================================
--- trunk/htdocs/manage/banusers.bml.text	2009-08-24 09:15:44 UTC (rev 15628)
+++ trunk/htdocs/manage/banusers.bml.text	2009-08-24 09:30:54 UTC (rev 15629)
@@ -1,9 +1,13 @@
 ;; -*- coding: utf-8 -*-
 
-.btn.banunban=Ban and Unban Users
+.btn.banunban=Save changes and unban selected
 
+.btn.ban_users=Ban users
+
 .error.toomanybans=Banning the user(s) that you specified will bring you over the maximum number of allowed bans. Please adjust your lists and try again. Any users that you chose to unban have been unbanned successfully.
 
+.error.too.long=You've reached the maximum number of the notes.
+
 .header.ban=Ban Users
 
 .header.unban=Unban Users
@@ -12,6 +16,10 @@
 
 .intro.ban.self=To ban users from commenting in your journal, type in their usernames below. Separate multiple usernames with commas.
 
+.intro.ban.note.text=Set note for all this users while banning:
+
+.intro.ban.note.value=enter note
+
 .intro.unban.alias=Notes
 
 .intro.unban.comm=You have the following users banned from commenting in your community. Select which ones you'd like to unban.

Modified: trunk/htdocs/manage/notes.bml
===================================================================
--- trunk/htdocs/manage/notes.bml	2009-08-24 09:15:44 UTC (rev 15628)
+++ trunk/htdocs/manage/notes.bml	2009-08-24 09:30:54 UTC (rev 15629)
@@ -43,10 +43,10 @@
         foreach my $userid (@userid_list) {
             my $user_alias = $POST{$key.$userid};
             $user_alias = substr($user_alias, 0, $max_alias_length);
-            if ($user_alias ne '') {
+            if (($POST{"delete_btn"} ne '' && $POST{"check".$userid} eq 'on') || $user_alias eq '') {
+                delete $aliases->{$userid};
+            } elsif ($user_alias ne '' && $POST{"save_btn"} ne '') {
                 $aliases->{$userid} = $user_alias;
-            } else {
-                delete $aliases->{$userid};
             }
         }
 
@@ -106,32 +106,40 @@
 		    aliasTable.insertBefore(newTR2,aliasTable.lastChild);
 		    return false;
 	    }
+        var errmsg_change = '|.LJ::ejs($ML{'.error.override_old_value'}).q|';
 	    </script>|;	
 
     $ret .= q|<table class="aliaslist-table">|;
     
-    $ret .= q|<tr><th>|. $ML{'.alias.header.username'} .q|</th><th>|.$ML{'.alias.header.alias'} .q|</th></tr>|."\n";
     my @userid_list = ();
     my $us = LJ::load_userids(keys %$aliases);
     foreach my $userid (keys %$aliases) {
         delete $aliases->{$userid} unless $us->{$userid}; # need safe sort below
     }
+    my $users_list_html = '';
     foreach my $userid (sort { $us->{$a}->display_name cmp $us->{$b}->display_name } keys %$aliases) {
         my $u = $us->{$userid};
-        $ret .= q|<tr><td>|.LJ::ljuser($u->{user}).q|</td><td class="user_alias"><input type="text" name="|.$key.$userid.q|" value="|
-                .LJ::ehtml(LJ::ljuser_alias($u->{user})).q|" size="50" maxlength="200"></td></tr>|."\n";
+        $users_list_html .= q|<tr><td>|.LJ::ljuser($u->{user}).q|</td><td class="user_alias"><input type="text" name="|.$key.$userid.q|" value="|
+                .LJ::ehtml(LJ::ljuser_alias($u->{user})).q|" size="50" maxlength="200">|
+                .LJ::html_check({ 'type' => 'check',
+                                  'name' => "check".$userid,
+                                  'id' => "check".$userid,
+                                  'value' => 'on' })
+                .q|</td></tr>|."\n";
         push @userid_list, $userid;
     }
     $ret .= q|<tr class="newalias"><td colspan="2"><label for="new-useralias">|. $ML{'.alias.header.newalias'} .q|</label></td></tr>|."\n";
     $ret .= q|<tr><td><input type="text" name="|.${key}.q|new_user" id="new-useralias"></td><td class="user_alias"><input type="text" name="|.${key}.q|new_alias" size="50" maxlenght="200"></td></tr>|."\n";
     $ret .= q|<input type="hidden" name="|.${key}.q|_user_list" value="|.join('|', @userid_list).q|">|."\n";
 	$ret .= q|<tr><td colspan="2"><a href="javascript:void(0)" id="adding-more-alias" onclick="addAliasLine()">|. $ML{'.alias.aliaslist.more'} .q|</a></td></tr>|;
+    $ret .= q|<tr><th>|. $ML{'.alias.header.username'} .q|</th><th>|.$ML{'.alias.header.alias'} .q|</th></tr>|."\n";
+    $ret .= $users_list_html;
     $ret .= q|</table>|."\n";
 
 	
 
     ### ending submit block
-    $ret .= "<?standout " . LJ::html_submit(undef, $ML{'.done.btn.savechanges'}) . " standout?>\n";
+    $ret .= "<?standout " . LJ::html_submit("save_btn", $ML{'.done.btn.savechanges'}) . " " . LJ::html_submit("delete_btn", $ML{'.done.btn.delete'}) . " standout?>\n";
     $ret .= "</form>\n";
 
     return $ret;

Modified: trunk/htdocs/manage/notes.bml.text
===================================================================
--- trunk/htdocs/manage/notes.bml.text	2009-08-24 09:15:44 UTC (rev 15628)
+++ trunk/htdocs/manage/notes.bml.text	2009-08-24 09:30:54 UTC (rev 15629)
@@ -12,12 +12,16 @@
 
 .done.btn.savechanges=Save changes
 
+.done.btn.delete=Delete selected notes
+
 .error.user_not_exist=User "[[username]]" is not exist.
 
 .error.yourself=You cannot add a note to yourself.
 
 .error.too.long=You've reached the maximum number of the notes.
 
+.error.override_old_value=Old note for "%username%" will be deleted!
+
 .not.allowed=This feature is only available to <a [[aopts]]>Paid account</a> users.
 
 .success.head=Success

Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments