Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[livejournal] r23035: LJSUP-12584 (Add link to support/see_req...

Committer: ailyin
LJSUP-12584 (Add link to support/see_request.bml to user's file manager)
U   trunk/htdocs/support/see_request.bml
Modified: trunk/htdocs/support/see_request.bml
===================================================================
--- trunk/htdocs/support/see_request.bml	2012-10-03 08:25:48 UTC (rev 23034)
+++ trunk/htdocs/support/see_request.bml	2012-10-03 08:33:47 UTC (rev 23035)
@@ -176,6 +176,7 @@
 
 <?_code
 {
+#line 180
     use strict;
     use vars qw(%FORM);
     use LJ::Support::Request::Tag;
@@ -383,7 +384,9 @@
     $ret .= LJ::name_caps($u->{'caps'}) || "<i>$ML{'.unknown'}</i>";
     $ret .= "</td></tr>\n";
 
-    if ($u->{'userid'}) {
+    if ($u->{'userid'}) {   
+        my $username = $u->username;
+
         $ret .= "<tr valign='top'><td align='right'><b>$LJ::SITENAMESHORT:</b></td><td>";
 
         if ($u->is_expunged) {
@@ -478,27 +481,51 @@
             }
         }
 
-        my $view_history = LJ::check_priv($remote, 'historyview');
-        my $view_userlog = LJ::check_priv($remote, 'canview', 'userlog') || 
-                           LJ::check_priv($remote, 'canview', 'userloglight') ||
-                           LJ::check_priv($remote, 'canview', '*');
-        my $view_money = LJ::check_priv($remote, 'moneysearch') || LJ::check_priv($remote, 'moneyview');
-        my $view_props = LJ::check_priv($remote, 'siteadmin', 'propview') || 
-                         LJ::check_priv($remote, 'siteadmin', 'propedit') ||
-                         LJ::check_priv($remote, 'siteadmin', '*');
+        my @view_pages = qw( history userlog money props files logins );
 
-        if ($view_history || $view_userlog || $view_money || $view_props) {
-            $ret .= "<br />$ML{'.view'}: ";
-            $ret .= "<a href='$LJ::SITEROOT/admin/statushistory.bml?user=$u->{user}'>$ML{'.statushistory'}</a>&nbsp;&nbsp;&nbsp;"
-                if $view_history;
-            $ret .= "<a href='$LJ::SITEROOT/admin/userlog/$u->{user}'>userlog</a>&nbsp;&nbsp;&nbsp;"
-                if $view_userlog;
-            $ret .= "<a href='$LJ::SITEROOT/admin/accounts/paidsearch.bml?method=user&value=$u->{user}'>payments</a>&nbsp;&nbsp;&nbsp;"
-                if $view_money;
-            $ret .= "<a href='$LJ::SITEROOT/admin/propedit.bml?user=$u->{user}'>props</a>"
-                if $view_props;				
+        my %view_privs_map = (
+            'history' => [ [ 'historyview' ] ],
+            'userlog' => [ [ 'canview', 'userlog' ], [ 'canview', 'userloglight' ] ],
+            'money'   => [ [ 'moneyview' ], [ 'moneysearch' ] ],
+            'props'   => [ [ 'siteadmin', 'propview' ], [ 'siteadmin', 'propedit' ] ],
+            'files'   => [ [ 'canview', 'userfiles' ] ],
+            'logins'  => [ [ 'canview', 'sessions' ] ],
+        );
+
+        my %links_map = (
+            'history' => [ LJ::Lang::ml('/support/see_request.bml.statushistory'), "$LJ::SITEROOT/admin/statushistory.bml?user=$username" ],
+            'userlog' => [ 'userlog',  "$LJ::SITEROOT/admin/userlog/$username" ],
+            'money'   => [ 'payments', "$LJ::SITEROOT/admin/accounts/paidsearch.bml?method=user&value=$username" ],
+            'props'   => [ 'props',    "$LJ::SITEROOT/admin/propedit.bml?user=$username" ],
+            'files'   => [ 'files',    "$LJ::SITEROOT/manage/files.bml?user=$username" ],
+            'logins'  => [ 'sessions', "$LJ::SITEROOT/manage/logins.bml?user=$username" ],
+        );
+
+        my ( %can_view, $can_view_anything );
+        foreach my $page (@view_pages) {
+            warn $page;
+            $can_view{$page} = 0;
+
+            foreach my $priv ( @{ $view_privs_map{$page} } ) {
+                $can_view{$page}   ||= LJ::check_priv( $remote, @$priv );
+                $can_view_anything ||= $can_view{$page};
+            }
         }
 
+        if ($can_view_anything) {
+            my $username = $u->username;
+
+            $ret .= '<br />' .
+                LJ::Lang::ml('/support/see_request.bml.view') . ': ';
+
+            foreach my $page (@view_pages) {
+                next unless $can_view{$page};
+
+                my ( $name, $url ) = @{ $links_map{$page} };
+                $ret .= qq{<a href="$url">$name</a>} . ( "&nbsp;" x 3 );
+            }
+        }
+
         $ret .= "</td></tr>\n";
     }
 
@@ -519,6 +546,20 @@
     $ret .= "<tr><td align='right' nowrap='nowrap'><b>$ML{'.is_beta'}:</b></td>";
     $ret .= "<td>$is_beta</td></tr>";
 
+    if ($u) {
+        my %migration_status_map = (
+            0 => 'not started',
+            1 => 'starting',
+            2 => 'in progress',
+            3 => 'done',
+        );
+
+        my $propval = eval { $u->prop('fotki_migration_status') } || 0;
+        my $status  = $migration_status_map{$propval};
+
+        $ret .= qq{<tr><td align="right" nowrap="nowrap"><b>Photo hosting migration:</b></td><td>$status</td></tr>};
+    }
+
     $ret .= "<tr><td align='right' nowrap='nowrap'><b>$ML{'.supportcategory'}:</b></td><td>";
     if (LJ::Support::can_read_cat($sp->{_cat}, $remote)) {
         $ret .= "<a href='$LJ::SITEROOT/support/help.bml?cat=$sp->{_cat}->{'catkey'}'>$problemarea</a>";

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