Alexander Nazarov (nfokz) wrote in changelog,
Alexander Nazarov
nfokz
changelog

[ljcom] r11089: LJSV-1152: Add admin mode to manage/file...

Committer: anazarov
LJSV-1152: Add admin mode to manage/files.bml
U   trunk/htdocs/manage/files.bml
U   trunk/htdocs/manage/files.bml.text.local
Modified: trunk/htdocs/manage/files.bml
===================================================================
--- trunk/htdocs/manage/files.bml	2011-10-13 08:14:17 UTC (rev 11088)
+++ trunk/htdocs/manage/files.bml	2011-10-13 11:39:47 UTC (rev 11089)
@@ -13,8 +13,21 @@
     my $remote = LJ::get_remote();
     return "<?needlogin?>" unless $remote;
 
+    my ($u, $view_user_files);
     my $authas = $GET{'authas'} || $remote->{'user'};
-    my $u = LJ::get_authas_user($authas);
+    my $can_view_files = LJ::check_priv($remote, 'canview', 'userfiles');
+
+    # This variable is set when remote user is viewing other users files
+    $view_user_files = 1
+        if $can_view_files and $GET{'user'} and $GET{'user'} ne $authas;
+
+    if ( $view_user_files ) {
+        $u = LJ::canonical_username($GET{'user'});
+        $u = LJ::load_user($u, "force");
+    } else {
+        $u = LJ::get_authas_user($authas);
+    }
+
     return LJ::bad_input($ML{'error.invalidauth'})
         unless $u;
 
@@ -45,6 +58,7 @@
         $uri .= "showtype=$showtype&" if $showtype;
         $uri .= "page=$page&" if $page > 1;
         $uri .= "sort=$sort&" if $sort;
+        $uri .= "user=". $u->{'user'}, '&' if $can_view_files;
         chop $uri;
 
         return $uri;
@@ -225,8 +239,12 @@
 
                 # delete checkbox
                 $ret .= "<tr><td class='tablecontent'>";
-                $ret .= LJ::html_check({ 'type' => 'check', 'name' => "del_${picid}",
-                                         'id' => "del_${picid}", 'value' => 1 }) . "</td>";
+                if ( $view_user_files ) {
+                    $ret .= '&nbsp;</td>';
+                } else {
+                    $ret .= LJ::html_check({ 'type' => 'check', 'name' => "del_${picid}",
+                                             'id' => "del_${picid}", 'value' => 1 }) . "</td>";
+                }
 
                 # display userpic
                 $ret .= "<td class='tablecontent'><label for='del_${picid}'>";
@@ -254,10 +272,12 @@
             }
 
             # delete button
-            $ret .= "<tr><td colspan='4' align='left'>";
-            $ret .= LJ::html_submit('action:delete', "Delete Selected") . "</td>";
-            $ret .= "<td colspan='4' align='right'>[<a href='$LJ::SITEROOT/editpics.bml#upload'>";
-            $ret .= $ML{'.upload.userpics'} . "</a>]";
+            unless ( $view_user_files ) {
+                $ret .= "<tr><td colspan='4' align='left'>";
+                $ret .= LJ::html_submit('action:delete', "Delete Selected") . "</td>";
+                $ret .= "<td colspan='4' align='right'>[<a href='$LJ::SITEROOT/editpics.bml#upload'>";
+                $ret .= $ML{'.upload.userpics'} . "</a>]";
+            }
 
             return $ret;
         },
@@ -408,9 +428,13 @@
                 my $blobid = $bl->{'blobid'};
 
                 # delete checkbox
-                $ret .= "<tr><td class='tablecontent'>";
-                $ret .= LJ::html_check({ 'type' => 'check', 'name' => "del_${blobid}",
-                                         'value' => 1, 'selected' => 0, disabled => $LJ::DISABLE_MEDIA_UPLOADS });
+                if ( $view_user_files ) {
+                    $ret .= '&nbsp;';
+                } else {
+                    $ret .= "<tr><td class='tablecontent'>";
+                    $ret .= LJ::html_check({ 'type' => 'check', 'name' => "del_${blobid}",
+                                             'value' => 1, 'selected' => 0, disabled => $LJ::DISABLE_MEDIA_UPLOADS });
+                }
                 $ret .= "</td>";
 
                 # link to phonepost
@@ -450,9 +474,11 @@
             }
 
             # delete button
-            $ret .= "<tr><td colspan='6' align='left'>";
-            $ret .= LJ::html_submit('action:delete', $ML{'.delete.selected'}, { disabled => $LJ::DISABLE_MEDIA_UPLOADS });
-            $ret .= "</td>";
+            unless ( $view_user_files ) {
+                $ret .= "<tr><td colspan='6' align='left'>";
+                $ret .= LJ::html_submit('action:delete', $ML{'.delete.selected'}, { disabled => $LJ::DISABLE_MEDIA_UPLOADS });
+                $ret .= "</td>";
+            }
 
             return $ret;
         }
@@ -490,9 +516,13 @@
                 $ret .= "<td class='tablecontent' valign='top'>";
                 $ret .= "$pp_display (";
                 $ret .= $max_size && $max_size > 0 ? sprintf("%.2f%%", ($pp_bytes / $max_size) * 100) : '0.00%';
-                $ret .= " $ML{'of.your.total'}) <br />";
+                if ( $view_user_files ) {
+                    $ret .= " $ML{'.of.his.total'}) <br />";
+                } else {
+                    $ret .= " $ML{'.of.your.total'}) <br />";
+                    $ret .= BML::ml('.please.visit', {"ahref"=>"<a href='$LJ::FB_SITEROOT'>$LJ::FB_DOMAIN</a>"});
+                }
 
-                $ret .= BML::ml('.please.visit', {"ahref"=>"<a href='$LJ::FB_SITEROOT'>$LJ::FB_DOMAIN</a>"});
                 $ret .= '</td></tr>';
                 return $ret;
             },
@@ -508,11 +538,25 @@
     # authas switcher form
     $ret .= "<form method='get' action='files.bml'>\n";
     $ret .= LJ::html_hidden('showtype' => $showtype) if $showtype;
+    $ret .= LJ::html_hidden('user' => $GET{'user'})
+        if $can_view_files;
     $ret .= LJ::make_authas_select($remote, { 'authas' => $GET{'authas'} }) . "\n";
     $ret .= "</form>\n\n";
 
+    # user select form
+    if ( $can_view_files ) {
+        $ret .= "<form method='get' action='files.bml'>\n";
+        $ret .= "Show user: " . LJ::html_text({ 'name' => 'user', 'size' => 15, 'maxlength' => 15, 'value' => $GET{'user'} }) . " ";
+        $ret .= LJ::html_hidden('authas' => $GET{'authas'}) if $authas ne $remote->{'user'};
+        $ret .= LJ::html_hidden('showtype' => $showtype) if $showtype;
+        $ret .= LJ::html_submit($ML{'.show'}) . "</form>";
+        $ret .= "</form>\n\n";
+    }
+
     # domain type selector
     $ret .= "<form method='get' action='files.bml'>$ML{'.filetype'} ";
+    $ret .= LJ::html_hidden('user' => $GET{'user'})
+        if $can_view_files;
     $ret .= LJ::html_hidden('authas' => $authas) if $authas ne $remote->{'user'};
     $ret .= LJ::html_select({ 'name' => 'showtype', 'selected' => $showtype },
                             '' => '---',
@@ -530,11 +574,20 @@
     if ($max_size) {
 
         $ret .= "<?h2 $ML{'.quota.usage'} h2?>";
-        $ret .= "<p>" . BML::ml('.currently.use', {
-            "used_size"=>$size->($used_size),
-            "used_size_persent"=>sprintf("%.2f%%", ($used_size / $max_size) * 100),
-            "total_size"=>$size->($max_size)
-        }) . "</p>";
+        if ( $view_user_files ) {
+            $ret .= "<p>" . BML::ml('.currently.uses', {
+                user => $u->{'user'},
+                used_size =>$size->($used_size),
+                used_size_persent => sprintf("%.2f%%", ($used_size / $max_size) * 100),
+                total_size => $size->($max_size)
+            }) . "</p>";
+        } else {
+            $ret .= "<p>" . BML::ml('.currently.use', {
+                "used_size"=>$size->($used_size),
+                "used_size_persent"=>sprintf("%.2f%%", ($used_size / $max_size) * 100),
+                "total_size"=>$size->($max_size)
+            }) . "</p>";
+        }
     }
 
     return $ret unless defined $btype{$showtype};
@@ -564,7 +617,11 @@
     # no blobs?
     unless (@blobs) {
         $ret .= "<?h1 $ML{'.no.files'} h1?>";
-        $ret .= "<?p $ML{'.do.not.have.files'} p?>";
+        if ( $view_user_files ) {
+            $ret .= BML::ml('.do.not.has.files', { user => $GET{'user'} });
+        } else {
+            $ret .= "<?p $ML{'.do.not.have.files'} p?>";
+        }
         return $ret;
     }
 
@@ -611,6 +668,8 @@
     ### Perform actions
     ###
     if (LJ::did_post() && $POST{'action:delete'}) {
+        # We should not delete other users files
+        return BML::redirect($self_link->()) if $view_user_files; 
 
         my $res = $bobj->{'delete'}->();
         if ($res) {

Modified: trunk/htdocs/manage/files.bml.text.local
===================================================================
--- trunk/htdocs/manage/files.bml.text.local	2011-10-13 08:14:17 UTC (rev 11088)
+++ trunk/htdocs/manage/files.bml.text.local	2011-10-13 11:39:47 UTC (rev 11089)
@@ -2,12 +2,18 @@
 .currently.use|staleness=1
 .currently.use=You are currently using [[used_size]] ([[used_size_persent]]) of your [[total_size]] quota.
 
+.currently.uses|staleness=1
+.currently.uses=[[user]] is currently using [[used_size]] ([[used_size_persent]]) of his [[total_size]] quota.
+
 .delete.selected|staleness=1
 .delete.selected=Delete Selected
 
 .do.not.have.files|staleness=1
 .do.not.have.files=You do not have any files of the specified type.  Please select a different type from the list above and try again.
 
+.do.not.has.files|staleness=1
+.do.not.has.files=[[user]] has not any files of the specified type.  Please select a different type from the list above and try again.
+
 .filesize.totals|staleness=1
 .filesize.totals=Filesize Totals
 
@@ -29,6 +35,9 @@
 .of.your.total|staleness=1
 .of.your.total=of your total 
 
+.of.his.total|staleness=1
+.of.his.total=of his total 
+
 .photo.hosting|staleness=1
 .photo.hosting=Photo Hosting
 

Tags: anazarov, bml, ljcom, local, nfokz
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