fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-07-05 07:32 am

[dw-free] refactor icon browser and related code

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

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

Include implicit check for LJ::is_enabled( 'userpicselect' ) in
$remote->can_use_userpic_select, instead of checking both the site cap and
the user cap each time.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/LJ/S2/EntryPage.pm
  • cgi-bin/LJ/S2/ReplyPage.pm
  • cgi-bin/LJ/Talk.pm
  • cgi-bin/LJ/User.pm
  • cgi-bin/LJ/Widget/UserpicSelector.pm
  • cgi-bin/weblib.pl
  • htdocs/talkpost.bml
  • htdocs/talkpost_do.bml
  • htdocs/talkread.bml
--------------------------------------------------------------------------------
diff -r 759c2d92f7b8 -r d070c49a0028 cgi-bin/LJ/S2/EntryPage.pm
--- a/cgi-bin/LJ/S2/EntryPage.pm	Mon Jul 05 15:27:12 2010 +0800
+++ b/cgi-bin/LJ/S2/EntryPage.pm	Mon Jul 05 15:38:18 2010 +0800
@@ -93,7 +93,7 @@ sub EntryPage
                     stc/lj_base.css
                     js/datasource.js
                     js/selectable_table.js
-                    )) if LJ::is_enabled('userpicselect') && $remote && $remote->can_use_userpic_select;
+                    )) if $remote && $remote->can_use_userpic_select;
 
     LJ::need_res(qw(
                     js/x_core.js
diff -r 759c2d92f7b8 -r d070c49a0028 cgi-bin/LJ/S2/ReplyPage.pm
--- a/cgi-bin/LJ/S2/ReplyPage.pm	Mon Jul 05 15:27:12 2010 +0800
+++ b/cgi-bin/LJ/S2/ReplyPage.pm	Mon Jul 05 15:38:18 2010 +0800
@@ -79,7 +79,7 @@ sub ReplyPage
                     stc/ups.css
                     js/datasource.js
                     js/selectable_table.js
-                    )) if LJ::is_enabled('userpicselect') && $remote && $remote->can_use_userpic_select;
+                    )) if $remote && $remote->can_use_userpic_select;
 
     if ($u->should_block_robots || $entry->should_block_robots) {
         $p->{'head_content'} .= LJ::robot_meta_tags();
diff -r 759c2d92f7b8 -r d070c49a0028 cgi-bin/LJ/Talk.pm
--- a/cgi-bin/LJ/Talk.pm	Mon Jul 05 15:27:12 2010 +0800
+++ b/cgi-bin/LJ/Talk.pm	Mon Jul 05 15:38:18 2010 +0800
@@ -1772,7 +1772,7 @@ sub talkform {
                 }
             });
             </script>
-        } if LJ::is_enabled('userpicselect') && $remote && $remote->can_use_userpic_select;
+        } if $remote && $remote->can_use_userpic_select;
                 
         $ret .= LJ::help_icon_html("userpics", " ");
     }
diff -r 759c2d92f7b8 -r d070c49a0028 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Mon Jul 05 15:27:12 2010 +0800
+++ b/cgi-bin/LJ/User.pm	Mon Jul 05 15:38:18 2010 +0800
@@ -2098,6 +2098,7 @@ sub can_use_textmessaging {
 }
 
 sub can_use_userpic_select {
+    return 0 unless LJ::is_enabled( 'userpicselect' );
     return $_[0]->get_cap( 'userpicselect' ) ? 1 : 0;
 }
 
diff -r 759c2d92f7b8 -r d070c49a0028 cgi-bin/LJ/Widget/UserpicSelector.pm
--- a/cgi-bin/LJ/Widget/UserpicSelector.pm	Mon Jul 05 15:27:12 2010 +0800
+++ b/cgi-bin/LJ/Widget/UserpicSelector.pm	Mon Jul 05 15:38:18 2010 +0800
@@ -189,7 +189,7 @@ sub render_body {
             });
             // ]]>
             </script>
-        } if LJ::is_enabled('userpicselect') && $u->can_use_userpic_select;
+        } if $u->can_use_userpic_select;
 
         $$pic .= "<div id='userpic' style='display: none;'><p id='userpic_preview'><a href='javascript:void(0);' id='lj_userpicselect_img'><img src='' alt='selected userpic' id='userpic_preview_image' /><span id='lj_userpicselect_img_txt'>$userpic_link_text</span></a></p></div>";
         $$pic .= "\n";
@@ -214,7 +214,7 @@ sub render_body {
                        userpic_preview();
                  };
         $$picform .= "insertViewThumbs()"
-            if LJ::is_enabled('userpicselect') && $u->can_use_userpic_select;
+            if $u->can_use_userpic_select;
         $$picform .= "</script>\n";
 
     } elsif (!$u)  {
diff -r 759c2d92f7b8 -r d070c49a0028 cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl	Mon Jul 05 15:27:12 2010 +0800
+++ b/cgi-bin/weblib.pl	Mon Jul 05 15:38:18 2010 +0800
@@ -703,7 +703,7 @@ sub create_qr_div {
             # userpic browse button
             $qrhtml .= qq {
                 <input type="button" id="lj_userpicselect" value="Browse" />
-                } if LJ::is_enabled('userpicselect') && $remote->can_use_userpic_select;
+                } if $remote->can_use_userpic_select;
 
             $qrhtml .= LJ::help_icon_html("userpics", " ");
         }
@@ -833,7 +833,7 @@ sub create_qr_div {
                 }
             });
         </script>
-        } if LJ::is_enabled('userpicselect') && $remote->can_use_userpic_select;
+        } if $remote->can_use_userpic_select;
 
     return $ret;
 }
@@ -1182,7 +1182,7 @@ sub entry_form {
                     });
                     // ]]>
                     </script>
-                } if LJ::is_enabled('userpicselect') && $remote->can_use_userpic_select;
+                } if $remote->can_use_userpic_select;
 
                 # libs for userpicselect
                 LJ::need_res(qw(
@@ -1199,7 +1199,7 @@ sub entry_form {
                                 stc/ups.css
                                 js/datasource.js
                                 js/selectable_table.js
-                                )) if LJ::is_enabled('userpicselect') && $remote->can_use_userpic_select;
+                                )) if $remote->can_use_userpic_select;
 
                 $out .= "<div id='userpic' style='display: none;'><p id='userpic_preview'><a href='javascript:void(0);' id='lj_userpicselect_img'><img src='' alt='selected userpic' id='userpic_preview_image' /><span id='lj_userpicselect_img_txt'>$userpic_link_text</span></a></p></div>";
                 $out .= "\n";
@@ -1294,7 +1294,7 @@ sub entry_form {
                                         @pickws) . "\n";
                 $out .= "<a href='javascript:void(0);' id='lj_userpicselect'> </a>";
                 # userpic browse button
-                $$onload .= " insertViewThumbs();" if LJ::is_enabled('userpicselect') && $remote->can_use_userpic_select;
+                $$onload .= " insertViewThumbs();" if $remote->can_use_userpic_select;
                 $out .= LJ::help_icon_html("userpics", "", " ") . "\n";
                 $out .= "</p>\n\n";
 
diff -r 759c2d92f7b8 -r d070c49a0028 htdocs/talkpost.bml
--- a/htdocs/talkpost.bml	Mon Jul 05 15:27:12 2010 +0800
+++ b/htdocs/talkpost.bml	Mon Jul 05 15:38:18 2010 +0800
@@ -43,7 +43,7 @@ body<=
                     stc/ups.css
                     js/datasource.js
                     js/selectable_table.js
-                    )) if LJ::is_enabled('userpicselect') && $remote && $remote->can_use_userpic_select;
+                    )) if $remote && $remote->can_use_userpic_select;
 
     my $pics = LJ::Talk::get_subjecticons();
 
diff -r 759c2d92f7b8 -r d070c49a0028 htdocs/talkpost_do.bml
--- a/htdocs/talkpost_do.bml	Mon Jul 05 15:27:12 2010 +0800
+++ b/htdocs/talkpost_do.bml	Mon Jul 05 15:38:18 2010 +0800
@@ -133,7 +133,7 @@ body<=
                     stc/ups.css
                     js/datasource.js
                     js/selectable_table.js
-                    )) if LJ::is_enabled('userpicselect') && $remote && $remote->can_use_userpic_select;
+                    )) if $remote && $remote->can_use_userpic_select;
 
     # FIXME: this isn't entirely correct, if ecphash is present but ignored/incorrect
     # that fix would need to be done in talklib.pl
diff -r 759c2d92f7b8 -r d070c49a0028 htdocs/talkread.bml
--- a/htdocs/talkread.bml	Mon Jul 05 15:27:12 2010 +0800
+++ b/htdocs/talkread.bml	Mon Jul 05 15:38:18 2010 +0800
@@ -221,7 +221,7 @@ body<=
                        stc/lj_base.css
                        js/datasource.js
                        js/selectable_table.js
-                       )) if LJ::is_enabled('userpicselect') && $remote->can_use_userpic_select;
+                       )) if $remote->can_use_userpic_select;
 
          LJ::need_res(qw(
                          js/x_core.js
--------------------------------------------------------------------------------