Первый фоллен на хелле (wildkin) wrote in changelog,
Первый фоллен на хелле
wildkin
changelog

[livejournal] r19148: LJSUP-8896: Button "Select tags" shouldn...

Committer: dnikolaev
LJSUP-8896: Button "Select tags" shouldn't appear if the user wants to add as a friend identity account

U   trunk/htdocs/friends/add.bml
Modified: trunk/htdocs/friends/add.bml
===================================================================
--- trunk/htdocs/friends/add.bml	2011-05-27 03:05:55 UTC (rev 19147)
+++ trunk/htdocs/friends/add.bml	2011-05-27 03:34:49 UTC (rev 19148)
@@ -73,7 +73,7 @@
 
      if ($POST{'action:delete'}) {
          $req->{"editfriend_delete_$user"} = 1;
-         $friend_tags_str = undef;
+         $friend_tags_str = '';
      } else {
          $req->{"editfriend_add_1_user"} = $user;
          $req->{"editfriend_add_1_fg"} = $POST{'editfriend_add_1_fg'};
@@ -93,10 +93,12 @@
             LJ::set_alias($u, $POST{'user_note'});
         }
 
-         my $friends_tags = LJ::FriendsTags->load($remote);
-         $friends_tags->set($u->{userid}, $POST{friend_tags_mode} || 'A', $friend_tags_str);
-         unless ($friends_tags->save()) {
-             $body .= '<br>' . BML::ml('.error.friendstags', { aopts => "href='/friends/add.bml?user=$user'" }) . '<br><br>';
+         if (defined $friend_tags_str) {
+             my $friends_tags = LJ::FriendsTags->load($remote);
+             $friends_tags->set($u->{userid}, $POST{friend_tags_mode} || 'A', $friend_tags_str);
+             unless ($friends_tags->save()) {
+                 $body .= '<br>' . BML::ml('.error.friendstags', { aopts => "href='/friends/add.bml?user=$user'" }) . '<br><br>';
+             }
          }
         
          $body .= LJ::get_ads({ 
@@ -255,86 +257,88 @@
  $body .= '</div>';
  }
 
- my $to_lower_case = sub {
-     my $s = shift;
-     return Encode::encode('utf-8', lc(Encode::decode('utf-8', $s)));
- };
+ unless ($u->is_identity()) {
+     my $to_lower_case = sub {
+         my $s = shift;
+         return Encode::encode('utf-8', lc(Encode::decode('utf-8', $s)));
+     };
 
- my $user_tags_map = LJ::Tags::get_usertags($u, { remote => $remote }) || {};
- $user_tags_map = {
-     map {
-         $to_lower_case->($_->{name}) => (
-             $_->{uses} < 2 ?
-                 '' :
-                 ($_->{uses} > 999 ? '(999+)' : "($_->{uses})")
-         )
-     }
-     grep { $_->{display} }
-     values %$user_tags_map
- };
+     my $user_tags_map = LJ::Tags::get_usertags($u, { remote => $remote }) || {};
+     $user_tags_map = {
+         map {
+             $to_lower_case->($_->{name}) => (
+                 $_->{uses} < 2 ?
+                     '' :
+                     ($_->{uses} > 999 ? '(999+)' : "($_->{uses})")
+             )
+         }
+         grep { $_->{display} }
+         values %$user_tags_map
+     };
 
- my $friends_tags = LJ::FriendsTags->load($remote);
- my ($friend_tags_mode, $friend_tags_list) = $friends_tags->get_tags($u->{userid});
- my $friend_tags_map = {};
- $friend_tags_list = [ map { $to_lower_case->($_) } @$friend_tags_list ];
+     my $friends_tags = LJ::FriendsTags->load($remote);
+     my ($friend_tags_mode, $friend_tags_list) = $friends_tags->get_tags($u->{userid});
+     my $friend_tags_map = {};
+     $friend_tags_list = [ map { $to_lower_case->($_) } @$friend_tags_list ];
 
- $body .= '<div class="b-addfriend-option b-addfriend-tags">';
- $body .= '<h3 class="b-addfriend-subhead">' . $ML{'.tags.read'} . '</h3>';
- $body .= '<p class="b-addfriend-notice">' . BML::ml('.tags.text', { ljuser => LJ::ljuser($u), tagscount => scalar(keys %$user_tags_map) }) . '</p>';
- $body .= '<dl class="b-addfriend-showmore b-addfriend-showmore-closed">';
- $body .= '<dt class="b-addfriend-showmore-head"><i class="i-addfriend-showmore-arr"></i>' . $ML{'.tags.select'} . '</dt>';
- $body .= '<dd class="b-addfriend-showmore-content">';
- $body .= '<p>';
- $body .= '<input type="radio" name="friend_tags_mode" id="tags_including" value="A" ' . 
-          (LJ::FriendsTags->is_allow_mode($friend_tags_mode) ? 'checked="checked" ' : '') .
-          '/><label for="tags_including">' . $ML{'.tags.including'} . '</label><br />';
- $body .= '<input type="radio" name="friend_tags_mode" id="tags_excluding" value="D" ' .
-          (LJ::FriendsTags->is_allow_mode($friend_tags_mode) ? '' : 'checked="checked" ') .
-          '/><label for="tags_excluding">' . $ML{'.tags.excluding'} . '</label>';
- $body .= '</p>';
- $body .= '<h4>' . $ML{'.tags.selected.by.you'} . '</h4>';
- $body .= '<ul class="b-pending-users" id="selectedTagsList">';
+     $body .= '<div class="b-addfriend-option b-addfriend-tags">';
+     $body .= '<h3 class="b-addfriend-subhead">' . $ML{'.tags.read'} . '</h3>';
+     $body .= '<p class="b-addfriend-notice">' . BML::ml('.tags.text', { ljuser => LJ::ljuser($u), tagscount => scalar(keys %$user_tags_map) }) . '</p>';
+     $body .= '<dl class="b-addfriend-showmore b-addfriend-showmore-closed">';
+     $body .= '<dt class="b-addfriend-showmore-head"><i class="i-addfriend-showmore-arr"></i>' . $ML{'.tags.select'} . '</dt>';
+     $body .= '<dd class="b-addfriend-showmore-content">';
+     $body .= '<p>';
+     $body .= '<input type="radio" name="friend_tags_mode" id="tags_including" value="A" ' . 
+              (LJ::FriendsTags->is_allow_mode($friend_tags_mode) ? 'checked="checked" ' : '') .
+              '/><label for="tags_including">' . $ML{'.tags.including'} . '</label><br />';
+     $body .= '<input type="radio" name="friend_tags_mode" id="tags_excluding" value="D" ' .
+              (LJ::FriendsTags->is_allow_mode($friend_tags_mode) ? '' : 'checked="checked" ') .
+              '/><label for="tags_excluding">' . $ML{'.tags.excluding'} . '</label>';
+     $body .= '</p>';
+     $body .= '<h4>' . $ML{'.tags.selected.by.you'} . '</h4>';
+     $body .= '<ul class="b-pending-users" id="selectedTagsList">';
 
- {
-     my $not_last = scalar(@$friend_tags_list);
-     foreach (@$friend_tags_list) {
-         $body .= '<li><span><a target="_blank" href="#">' . LJ::ehtml($_) . '</a> ' . (exists $user_tags_map->{$_} ? $user_tags_map->{$_} : '(-)') . '<i title="Remove tag from list" class="i-pending-close"></i></span>' . (--$not_last ? ',' : '') . '</li>';
-         $friend_tags_map->{$_} = 1;
+     {
+         my $not_last = scalar(@$friend_tags_list);
+         foreach (@$friend_tags_list) {
+             $body .= '<li><span><a target="_blank" href="#">' . LJ::ehtml($_) . '</a> ' . (exists $user_tags_map->{$_} ? $user_tags_map->{$_} : '(-)') . '<i title="Remove tag from list" class="i-pending-close"></i></span>' . (--$not_last ? ',' : '') . '</li>';
+             $friend_tags_map->{$_} = 1;
+         }
      }
- }
 
- $body .= '</ul>';
- $body .= '<p class="i-bubble b-bubble-alert b-bubble-noarrow">' . $ML{'.tags.remove.tags'} . '</p>';
- $body .= '<h4>' . $ML{'.tags.select.more'} . '</h4>';
- $body .= '<p><input type="text" class="b-addfriend-input" id="searchTag" autocomplete="off" placeholder="' . $ML{'.tags.input.tag'} . '" /> <input id="selectTag" type="button" value="Select" /></p>';
- $body .= '<input type="hidden" id="selectedTags" name="friend_tags">';
- $body .= '<p class="i-bubble b-bubble-alert b-bubble-noarrow">' . $ML{'.tags.find.tags'} . '</p>';
- $body .= '<ul class="b-pending-users b-addfriend-alltags">';
+     $body .= '</ul>';
+     $body .= '<p class="i-bubble b-bubble-alert b-bubble-noarrow">' . $ML{'.tags.remove.tags'} . '</p>';
+     $body .= '<h4>' . $ML{'.tags.select.more'} . '</h4>';
+     $body .= '<p><input type="text" class="b-addfriend-input" id="searchTag" autocomplete="off" placeholder="' . $ML{'.tags.input.tag'} . '" /> <input id="selectTag" type="button" value="Select" /></p>';
+     $body .= '<input type="hidden" id="selectedTags" name="friend_tags">';
+     $body .= '<p class="i-bubble b-bubble-alert b-bubble-noarrow">' . $ML{'.tags.find.tags'} . '</p>';
+     $body .= '<ul class="b-pending-users b-addfriend-alltags">';
 
- {
-     my @tags = sort grep { !$friend_tags_map->{$_} } keys %$user_tags_map;
-     my $not_last = scalar(@tags);
-     foreach my $tag (@tags) {
-         $body .= '<li><span><a target="_blank" href="#">' . LJ::ehtml($tag) . '</a> ' . (exists $user_tags_map->{$tag} ? $user_tags_map->{$tag} : '(-)') . '<i title="Remove tag from list" class="i-pending-close"></i></span>' . (--$not_last ? ',' : '') . '</li>';
+     {
+         my @tags = sort grep { !$friend_tags_map->{$_} } keys %$user_tags_map;
+         my $not_last = scalar(@tags);
+         foreach my $tag (@tags) {
+             $body .= '<li><span><a target="_blank" href="#">' . LJ::ehtml($tag) . '</a> ' . (exists $user_tags_map->{$tag} ? $user_tags_map->{$tag} : '(-)') . '<i title="Remove tag from list" class="i-pending-close"></i></span>' . (--$not_last ? ',' : '') . '</li>';
+         }
      }
- }
 
- $body .= '</ul>';
- $body .= '</dd>';
- $body .= '</dl>';
- $body .= '</div>';
+     $body .= '</ul>';
+     $body .= '</dd>';
+     $body .= '</dl>';
+     $body .= '</div>';
 
- $body .= '<script id="tagTmpl" type="text/x-jquery-tmpl">
-       <li>
-       <span class="ljappippu_pers">
-               <a href="#">${tagName}</a>
-               (-)
-               {{if hasCloseButton }}
-               <i title="Remove tag from list" class="i-pending-close" ></i>
-               {{/if}}
-       </span>
-       </li>
-</script>';
+     $body .= '<script id="tagTmpl" type="text/x-jquery-tmpl">
+           <li>
+           <span class="ljappippu_pers">
+                   <a href="#">${tagName}</a>
+                   (-)
+                   {{if hasCloseButton }}
+                   <i title="Remove tag from list" class="i-pending-close" ></i>
+                   {{/if}}
+           </span>
+           </li>
+    </script>';
+ }
  
  $body .= '<div class="b-addfriend-option b-addfriend-colors">';
  $body .= '<h3 class="b-addfriend-subhead">' . $ML{'.colors.select.user'} . '</h3>';

Tags: bml, livejournal, wildkin
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