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

[ljcom] r12441: LJSUP-13229 (refactor userlog code into ...

Committer: ailyin
LJSUP-13229 (refactor userlog code into LJ::User::Userlog / LJ::User::UserlogRecord)
U   trunk/cgi-bin/LJ/Client/Twitter.pm
A   trunk/cgi-bin/LJ/Controller/
A   trunk/cgi-bin/LJ/Controller/Admin/
A   trunk/cgi-bin/LJ/Controller/Admin/Userlog.pm
U   trunk/cgi-bin/LJ/Hooks/S2Styles.pm
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/PaidAccount.pm
U   trunk/cgi-bin/LJ/TwitterDigest.pm
A   trunk/cgi-bin/LJ/User/UserlogRecord/
A   trunk/cgi-bin/LJ/User/UserlogRecord/DeleteVGift.pm
A   trunk/cgi-bin/LJ/User/UserlogRecord/DeleteVGiftRow.pm
A   trunk/cgi-bin/LJ/User/UserlogRecord/S2StyleChange.pm
A   trunk/cgi-bin/LJ/User/UserlogRecord/TryNBuyUpgrade.pm
A   trunk/cgi-bin/LJ/User/UserlogRecord/TwitterFailed.pm
A   trunk/cgi-bin/LJ/User/UserlogRecord/TwitterSkipped.pm
A   trunk/cgi-bin/LJ/User/UserlogRecord/TwitterSuccess.pm
A   trunk/cgi-bin/LJ/User/UserlogRecord/UserpicResizer.pm
U   trunk/cgi-bin/LJ/VGift.pm
U   trunk/cgi-bin/LJ/Widget/FindFriendsResultsAdd.pm
U   trunk/cgi-bin/LJ/Widget/FindFriendsResultsInvite.pm
U   trunk/cgi-bin/LJ/Widget/FindFriendsResultsPartially.pm
U   trunk/htdocs/admin/support/index.bml
U   trunk/htdocs/friends/invite.bml.sup
U   trunk/htdocs/shop/userpicresizer.bml
A   trunk/templates/Admin/
A   trunk/templates/Admin/Userlog/
A   trunk/templates/Admin/Userlog/error.tmpl
A   trunk/templates/Admin/Userlog/list.tmpl
A   trunk/templates/Admin/Userlog/search.tmpl
Modified: trunk/cgi-bin/LJ/Client/Twitter.pm
===================================================================
--- trunk/cgi-bin/LJ/Client/Twitter.pm	2012-08-07 14:59:16 UTC (rev 12440)
+++ trunk/cgi-bin/LJ/Client/Twitter.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -296,8 +296,10 @@
             return LJ::JSON->from_json($res->content);
         } else {
             if ($res->code eq '401' && $u) {
-                $u->log_event ("twitter_failed", { text => '401 Unauthorized' } )
-                    if $opts{'call_from_digest'};
+                if ( $opts{'call_from_digest'} ) {
+                    LJ::User::UserlogRecord::TwitterFailed->create( $u,
+                        'text' => '401 Unauthorized' );
+                }
 
                 $u->clear_prop($_)
                     foreach qw(
@@ -318,8 +320,11 @@
                 } ) or warn "Unable to send_mail";
                 die "twitter error: 401 Unauthorized\n";
             } else {
-                $u->log_event ("twitter_failed", { text => $res->status_line } )
-                    if $opts{'call_from_digest'};
+                if ( $opts{'call_from_digest'} ) {
+                    LJ::User::UserlogRecord::TwitterFailed->create( $u,
+                        'text' => $res->status_line );
+                }
+
                 if( $res->code eq '502' && --$retry_number ) {
                     sleep 1;
                     next RETRY;

Added: trunk/cgi-bin/LJ/Controller/Admin/Userlog.pm
===================================================================
--- trunk/cgi-bin/LJ/Controller/Admin/Userlog.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/Controller/Admin/Userlog.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -0,0 +1,125 @@
+package LJ::Controller::Admin::Userlog;
+use strict;
+use warnings;
+
+use base qw( LJ::Controller );
+
+sub process {
+    my $uri = LJ::Request->uri;
+
+    my $remote = LJ::get_remote();
+    unless ($remote) {
+        return LJ::Response::Redirect->new(
+            'where' => LJ::needlogin_redirect_url() );
+    }
+
+    my %privs = (
+        'view' =>
+            LJ::check_priv( $remote, 'canview', 'userlog' ) || undef,
+
+        'viewlight' =>
+            LJ::check_priv( $remote, 'canview', 'userloglight' ) || undef,
+
+        'viewuniq' =>
+            LJ::check_priv( $remote, 'canview', 'uniq' ) || undef,        
+    );
+
+    unless ( $privs{'view'} || $privs{'viewlight'} ) {
+        return LJ::Response::Error->new(
+            'error_type' => 'insufficient_privs',
+            'status'     => LJ::Request::FORBIDDEN,
+        );
+    }
+
+    my $username = LJ::Request->get_param('user');
+    unless ($username) {
+        ($username) = ( $uri =~ m{/admin/userlog/(\w+)} );
+    }
+    $username = '' unless defined $username;
+
+    my $canonical_uri = '/admin/userlog/' . LJ::canonical_username($username);
+    unless ( $uri eq $canonical_uri ) {
+        return LJ::Response::Redirect->new(
+            'where' => $LJ::SITEROOT . $canonical_uri );
+    }
+
+    if ( $username eq '' ) {
+        return LJ::Response::Template->new(
+            'file'            => 'templates/Admin/Userlog/search.tmpl',
+            'params'          => { 'form_user' => $username },
+            'use_site_scheme' => 1,
+            'title'           => 'User Log Viewer',
+        );
+    }
+
+    # we have a username here
+    my $u = LJ::load_user($username);
+    unless ($u) {
+        return LJ::Response::Template->new(
+            'file'            => 'templates/Admin/Userlog/error.tmpl',
+            'params'          => {
+                'error_type' => 'user_not_found',
+                'form_user'  => $username,
+            },
+            'use_site_scheme' => 1,
+            'title'           => 'User Log Viewer',
+        );
+    }
+
+    my $records = LJ::User::Userlog->get_records($u);
+    unless ( $records && @$records ) {
+        return LJ::Response::Template->new(
+            'file'            => 'templates/Admin/Userlog/error.tmpl',
+            'params'          => {
+                'error_type'  => 'userlog_empty',
+                'form_user'   => $username,
+                'user_ljuser' => $u->ljuser_display,
+            },
+            'use_site_scheme' => 1,
+            'title'           => 'User Log Viewer',
+        );
+    }
+
+    my @records_display;
+    foreach my $record (@$records) {
+        my $actor_ljuser = '';
+        if ( my $actor = $record->remote ) {
+            $actor_ljuser = $actor->ljuser_display;
+        }
+
+        my ( $ip_display, $uniq_display, $uniq_valid ) = ( '***', '***', 0 );
+
+        if ( $privs{'view'} ) {
+            $ip_display = $record->ip;
+        }
+
+        if ( $privs{'view'} || $privs{'viewuniq'} ) {
+            $uniq_display = $record->uniq;
+            $uniq_valid   = 1;
+        }
+
+        push @records_display, {
+            'time'       =>
+                LJ::TimeUtil->mysql_time( $record->logtime ) || undef,
+
+            'action'     => $record->description || undef,
+            'actor'      => $actor_ljuser,
+            'ip'         => $ip_display,
+            'uniq'       => $uniq_display,
+            'uniq_valid' => $uniq_valid,
+        };
+    }
+
+    return LJ::Response::Template->new(
+        'file'            => 'templates/Admin/Userlog/list.tmpl',
+        'params'          => {
+            'form_user'   => $username,
+            'user_ljuser' => $u->ljuser_display,
+            'records'     => \@records_display,
+        },
+        'use_site_scheme' => 1,
+        'title'           => 'User Log Viewer',
+    );
+}
+
+1;

Modified: trunk/cgi-bin/LJ/Hooks/S2Styles.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/S2Styles.pm	2012-08-07 14:59:16 UTC (rev 12440)
+++ trunk/cgi-bin/LJ/Hooks/S2Styles.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -43,10 +43,8 @@
         $stylename = $style->{'name'};
     }
 
-    $u->log_event( 's2_style_change' => {
-        'id' => $styleid,
-        'name' => $stylename,
-    });
+    LJ::User::UserlogRecord::S2StyleChange->create( $u,
+        'id' => $styleid, 'name' => $stylename );
 });
 
 1;

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/PaidAccount.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/PaidAccount.pm	2012-08-07 14:59:16 UTC (rev 12440)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/PaidAccount.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -690,7 +690,7 @@
         my $rcpt_u_up = LJ::modify_caps($rcpt_u->userid, [], ['trynbuy']);
         if ($rcpt_u){
             $rcpt_u = $rcpt_u_up;
-            $rcpt_u->log_event('upgraded_to_paid_from_trynbuy');
+            LJ::User::UserlogRecord::TryNBuyUpgrade->create($rcpt_u);
         }
 
     }

Modified: trunk/cgi-bin/LJ/TwitterDigest.pm
===================================================================
--- trunk/cgi-bin/LJ/TwitterDigest.pm	2012-08-07 14:59:16 UTC (rev 12440)
+++ trunk/cgi-bin/LJ/TwitterDigest.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -233,13 +233,15 @@
     }
     
     if( $twu->protected ) {
-        $u->log_event ("twitter_skipped", { text => "Twitter account is protected" });
+        LJ::User::UserlogRecord::TwitterSkipped->create( $u,
+            'text' => 'Twitter account is protected' );
         return;
     }
 
     if (my $u_system = LJ::load_user('system')) {
         unless ($u_system->rate_log('twitter_digest', 1)) {
-            $u->log_event ("twitter_skipped", { text => "twitter digest rate limit reached" });
+            LJ::User::UserlogRecord::TwitterSkipped->create( $u,
+                'text' => 'Twitter digest rate limit reached' );
 
             # wait a little bit so as to not hit the limit repeatedly,
             # because we're in a worker context right now
@@ -258,7 +260,8 @@
 
     my $tweets = LJ::Client::Twitter->user_last_tweets($u, { 'call_from_digest' => 1 });
     unless (@$tweets) {
-        $u->log_event ("twitter_skipped", { text => "No tweets to import" });
+        LJ::User::UserlogRecord::TwitterSkipped->create( $u,
+            'text' => 'No tweets to import' );
         return;
     }
 
@@ -333,7 +336,10 @@
     }, \$errs, { 'noauth' => 1 });
 
     unless ($errs) {
-        $u->log_event ("twitter_success", { text => scalar(@tweets_sorted) . " tweet(s) posted: ". $res->{'url'} });
+        LJ::User::UserlogRecord::TwitterSuccess->create( $u,
+            'tweets_count' => scalar(@tweets_sorted),
+            'entry_url'    => $res->{'url'},
+        );
     }
 
     warn $errs if $errs;

Added: trunk/cgi-bin/LJ/User/UserlogRecord/DeleteVGift.pm
===================================================================
--- trunk/cgi-bin/LJ/User/UserlogRecord/DeleteVGift.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/User/UserlogRecord/DeleteVGift.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -0,0 +1,24 @@
+package LJ::User::UserlogRecord::DeleteVGift;
+use strict;
+use warnings;
+
+use base qw( LJ::User::UserlogRecord );
+
+sub action {'vgift_deleted'}
+
+sub translate_create_data {
+    my ( $class, %data ) = @_;
+
+    $data{'actiontarget'} = delete $data{'giftid'};
+
+    return %data;
+}
+
+sub description {
+    my ($self) = @_;
+
+    my $targetid = $self->actiontarget;
+    return "Deleted virtual gift #$targetid";
+}
+
+1;

Added: trunk/cgi-bin/LJ/User/UserlogRecord/DeleteVGiftRow.pm
===================================================================
--- trunk/cgi-bin/LJ/User/UserlogRecord/DeleteVGiftRow.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/User/UserlogRecord/DeleteVGiftRow.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -0,0 +1,24 @@
+package LJ::User::UserlogRecord::DeleteVGiftRow;
+use strict;
+use warnings;
+
+use base qw( LJ::User::UserlogRecord );
+
+sub action {'vgift_row_deleted'}
+
+sub translate_create_data {
+    my ( $class, %data ) = @_;
+
+    $data{'actiontarget'} = delete $data{'giftid'};
+
+    return %data;
+}
+
+sub description {
+    my ($self) = @_;
+
+    my $targetid = $self->actiontarget;
+    return "Deleted row for virtual gift #$targetid";
+}
+
+1;

Added: trunk/cgi-bin/LJ/User/UserlogRecord/S2StyleChange.pm
===================================================================
--- trunk/cgi-bin/LJ/User/UserlogRecord/S2StyleChange.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/User/UserlogRecord/S2StyleChange.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -0,0 +1,34 @@
+package LJ::User::UserlogRecord::S2StyleChange;
+use strict;
+use warnings;
+
+use base qw( LJ::User::UserlogRecord );
+
+sub action {'s2_style_change'}
+
+sub translate_create_data {
+    my ( $class, %data ) = @_;
+
+    $data{'extra'} = {
+        'id'   => delete $data{'id'},
+        'name' => delete $data{'name'},
+    };
+
+    return %data;
+}
+
+sub description {
+    my ($self) = @_;
+
+    my $extra = $self->extra_unpacked;
+    my $id    = $extra->{'id'};
+    my $name  = $extra->{'name'};
+
+    if ($id) {
+        return "Changed S2 style to $id ($name)"
+    } else {
+        return 'S2 style reset';
+    }
+}
+
+1;

Added: trunk/cgi-bin/LJ/User/UserlogRecord/TryNBuyUpgrade.pm
===================================================================
--- trunk/cgi-bin/LJ/User/UserlogRecord/TryNBuyUpgrade.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/User/UserlogRecord/TryNBuyUpgrade.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -0,0 +1,15 @@
+package LJ::User::UserlogRecord::TryNBuyUpgrade;
+use strict;
+use warnings;
+
+use base qw( LJ::User::UserlogRecord );
+
+sub action {'upgraded_to_paid_from_trynbuy'}
+
+sub description {
+    my ($self) = @_;
+
+    return 'Upgraded Try&Buy account to Paid account';
+}
+
+1;

Added: trunk/cgi-bin/LJ/User/UserlogRecord/TwitterFailed.pm
===================================================================
--- trunk/cgi-bin/LJ/User/UserlogRecord/TwitterFailed.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/User/UserlogRecord/TwitterFailed.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -0,0 +1,25 @@
+package LJ::User::UserlogRecord::TwitterFailed;
+use strict;
+use warnings;
+
+use base qw( LJ::User::UserlogRecord );
+
+sub action {'twitter_failed'}
+
+sub translate_create_data {
+    my ( $class, %data ) = @_;
+
+    $data{'extra'} = { 'text' => delete $data{'text'} };
+
+    return %data;
+}
+
+sub description {
+    my ($self) = @_;
+
+    my $extra = $self->extra_unpacked;
+    my $text  = $extra->{'text'};
+    return "Twitter API call failed: $text";
+}
+
+1;

Added: trunk/cgi-bin/LJ/User/UserlogRecord/TwitterSkipped.pm
===================================================================
--- trunk/cgi-bin/LJ/User/UserlogRecord/TwitterSkipped.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/User/UserlogRecord/TwitterSkipped.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -0,0 +1,25 @@
+package LJ::User::UserlogRecord::TwitterSkipped;
+use strict;
+use warnings;
+
+use base qw( LJ::User::UserlogRecord );
+
+sub action {'twitter_skipped'}
+
+sub translate_create_data {
+    my ( $class, %data ) = @_;
+
+    $data{'extra'} = { 'text' => delete $data{'text'} };
+
+    return %data;
+}
+
+sub description {
+    my ($self) = @_;
+
+    my $extra = $self->extra_unpacked;
+    my $text  = $extra->{'text'};
+    return "Twitter Digest skipped: $text";
+}
+
+1;

Added: trunk/cgi-bin/LJ/User/UserlogRecord/TwitterSuccess.pm
===================================================================
--- trunk/cgi-bin/LJ/User/UserlogRecord/TwitterSuccess.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/User/UserlogRecord/TwitterSuccess.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -0,0 +1,29 @@
+package LJ::User::UserlogRecord::TwitterSuccess;
+use strict;
+use warnings;
+
+use base qw( LJ::User::UserlogRecord );
+
+sub action {'twitter_skipped'}
+
+sub translate_create_data {
+    my ( $class, %data ) = @_;
+
+    my $tweets_count = delete $data{'tweets_count'};
+    my $entry_url    = delete $data{'entry_url'};
+
+    my $text = "$tweets_count tweet(s) posted: $entry_url";
+    $data{'extra'} = { 'text' => $text };
+
+    return %data;
+}
+
+sub description {
+    my ($self) = @_;
+
+    my $extra = $self->extra_unpacked;
+    my $text  = $extra->{'text'};
+    return "Twitter Digest successful: $text";
+}
+
+1;

Added: trunk/cgi-bin/LJ/User/UserlogRecord/UserpicResizer.pm
===================================================================
--- trunk/cgi-bin/LJ/User/UserlogRecord/UserpicResizer.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/User/UserlogRecord/UserpicResizer.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -0,0 +1,39 @@
+package LJ::User::UserlogRecord::UserpicResizer;
+use strict;
+use warnings;
+
+use base qw( LJ::User::UserlogRecord );
+
+sub action {'userpic_resizer'}
+
+sub translate_create_data {
+    my ( $class, %data ) = @_;
+
+    $data{'extra'} = {
+        'upic_type' => delete $data{'upic_type'},
+        'old_packs' => delete $data{'old_packs'},
+        'new_packs' => delete $data{'new_packs'},
+        'old_exp'   => delete $data{'old_exp'},
+        'new_exp'   => delete $data{'new_exp'},
+    };
+
+    return %data;
+}
+
+sub description {
+    my ($self) = @_;
+
+    my $extra  = $self->extra_unpacked;
+
+    my $type     = $extra->{'upic_type'};
+    my $old_size = $extra->{'old_packs'};
+    my $new_size = $extra->{'new_packs'};
+    my $old_exp  = $extra->{'old_exp'};
+    my $new_exp  = $extra->{'new_exp'};
+
+    return "Userpic resizer: changed '$type' userpics " .
+        "from $old_size pack(s) expiring on $old_exp " .
+        "to $new_size pack(s) expiring on $new_exp";
+}
+
+1;

Modified: trunk/cgi-bin/LJ/VGift.pm
===================================================================
--- trunk/cgi-bin/LJ/VGift.pm	2012-08-07 14:59:16 UTC (rev 12440)
+++ trunk/cgi-bin/LJ/VGift.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -132,10 +132,8 @@
     return 0 unless $rv;  # FIXME: use Error::Strict and bomb out if caller doesn't check
     wipe_memcache($u);
 
-    $u->log_event('vgift_row_deleted', {
-                remote => $u,
-                actiontarget => $self->{giftid},
-            });
+    LJ::User::UserlogRecord::DeleteVGiftRow->create( $u,
+        'giftid' => $self->{'giftid'} );
 
     return 1;
 }
@@ -289,10 +287,8 @@
                     "WHERE userid=? AND giftid=?",
                     undef, $self->{userid}, $self->{giftid});
 
-    $u->log_event('vgift_deleted', {
-                remote => $u,
-                actiontarget => $self->{giftid},
-            });
+    LJ::User::UserlogRecord::DeleteVGift->create( $u,
+        'giftid' => $self->{'giftid'} );
 
     return 0 unless $rv;  # FIXME: use Error::Strict and bomb out if caller doesn't check
     wipe_memcache($u);

Modified: trunk/cgi-bin/LJ/Widget/FindFriendsResultsAdd.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/FindFriendsResultsAdd.pm	2012-08-07 14:59:16 UTC (rev 12440)
+++ trunk/cgi-bin/LJ/Widget/FindFriendsResultsAdd.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -105,10 +105,8 @@
                     html     => $message,
                 });
 
-                $remote->log_event('friend_invite_sent', {
-                    remote => $remote,
-                    extra => $email,
-                });
+                LJ::User::UserlogRecord::FriendInviteSent->create( $remote,
+                    'recipient' => $email, 'remote' => $remote );
             } else { # over rate limit
                 push @errors_notify, [$email, $class->ml('widget.findfriendsresultsadd.over.rate')];
             }

Modified: trunk/cgi-bin/LJ/Widget/FindFriendsResultsInvite.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/FindFriendsResultsInvite.pm	2012-08-07 14:59:16 UTC (rev 12440)
+++ trunk/cgi-bin/LJ/Widget/FindFriendsResultsInvite.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -99,11 +99,8 @@
                             . $message_end,
             });
 
-            $remote->log_event('friend_invite_sent', {
-                remote => $remote,
-                extra => $email,
-            });
-
+            LJ::User::UserlogRecord::FriendInviteSent->create( $remote,
+                'recipient' => $email, 'remote' => $remote );
         } else { # over rate limit
             push @errors, [$email, $class->ml('widget.findfriendsresultsinvite.over.rate')];
             last; # no more addresses are possible

Modified: trunk/cgi-bin/LJ/Widget/FindFriendsResultsPartially.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/FindFriendsResultsPartially.pm	2012-08-07 14:59:16 UTC (rev 12440)
+++ trunk/cgi-bin/LJ/Widget/FindFriendsResultsPartially.pm	2012-08-07 15:06:32 UTC (rev 12441)
@@ -76,11 +76,8 @@
                             . $class->ml('widget.findfriendsresultspartially.message_body_end', { username => $remote->user} ),
             });
 
-            $remote->log_event('friend_invite_sent', {
-                remote => $remote,
-                extra => $email,
-            });
-
+            LJ::User::UserlogRecord::FriendInviteSent->create( $remote,
+                'recipient' => $email, 'remote' => $remote );
         } else { # over rate limit
             push @errors, [$email, $class->ml('widget.findfriendsresultspartially.over.rate')];
             last; # no more addresses are possible

Modified: trunk/htdocs/admin/support/index.bml
===================================================================
--- trunk/htdocs/admin/support/index.bml	2012-08-07 14:59:16 UTC (rev 12440)
+++ trunk/htdocs/admin/support/index.bml	2012-08-07 15:06:32 UTC (rev 12441)
@@ -64,7 +64,7 @@
     $ret .= "<li><a href='/admin/sendmail/query.bml?restrict=support'>Query Support Notes</a></li>";
     $ret .= "<li><a href='/admin/support/dept.bml'>Department Stats</a></li>";
     $ret .= "<li><a href='/admin/support/individual.bml'>Individual Stats</a></li>";
-    $ret .= "<li><a href='/admin/userlog.bml'>User Log Viewer</a></li>";
+    $ret .= "<li><a href='/admin/userlog/'>User Log Viewer</a></li>";
     $ret .= "<li><a href='/admin/uniq.bml'>Uniq Lookup</a></li>";
     $ret .= "</ul>";
 

Modified: trunk/htdocs/friends/invite.bml.sup
===================================================================
--- trunk/htdocs/friends/invite.bml.sup	2012-08-07 14:59:16 UTC (rev 12440)
+++ trunk/htdocs/friends/invite.bml.sup	2012-08-07 15:06:32 UTC (rev 12441)
@@ -420,10 +420,8 @@
                 body     => $msg_custom,
             });
 
-            $u->log_event('friend_invite_sent', {
-                remote => $u,
-                extra => $email,
-            });
+            LJ::User::UserlogRecord::FriendInviteSent->create( $u,
+                'recipient' => $email, 'remote' => $u );
 
             $body .= "<?standout " . BML::ml('.success', {'email' => $email}) . " standout?>";
             return 1;

Modified: trunk/htdocs/shop/userpicresizer.bml
===================================================================
--- trunk/htdocs/shop/userpicresizer.bml	2012-08-07 14:59:16 UTC (rev 12440)
+++ trunk/htdocs/shop/userpicresizer.bml	2012-08-07 15:06:32 UTC (rev 12441)
@@ -57,14 +57,14 @@
             my %old_caps = %rec_caps; %rec_caps = ();
             LJ::get_cap ($remote, 'userpics', \%rec_caps);
 
-            ## log event into userlog (htdocs/admin/userlog.bml)
-            $remote->log_event('userpic_resizer', { 
+            ## log event into userlog (/admin/userlog/)
+            LJ::User::UserlogRecord::UserpicResizer->create( $remote,
                 upic_type   => $type,
                 old_packs   => $old_caps{$amount_key},
                 new_packs   => $rec_caps{$amount_key},
                 old_exp     => substr($old_caps{$exp_key}, 0, 10),
                 new_exp     => substr($rec_caps{$exp_key}, 0, 10),
-            });
+            );
 
             $success_message = '<p class="alert-msg">'. BML::ml(".message.success") .'</p>';
         }

Added: trunk/templates/Admin/Userlog/error.tmpl
===================================================================
--- trunk/templates/Admin/Userlog/error.tmpl	                        (rev 0)
+++ trunk/templates/Admin/Userlog/error.tmpl	2012-08-07 15:06:32 UTC (rev 12441)
@@ -0,0 +1,11 @@
+<TMPL_INCLUDE templates/Admin/Userlog/search.tmpl>
+
+<div class="errorbar">
+    <TMPL_IF expr="error_type eq 'user_not_found'">
+        User does not exist: <TMPL_VAR form_user ESCAPE=HTML>.
+    <TMPL_ELSIF expr="error_type eq 'userlog_empty'">
+        Userlog for <TMPL_VAR user_ljuser> is empty.
+    <TMPL_ELSE>
+        Error: <TMPL_VAR error_type ESCAPE=HTML>.
+    </TMPL_IF>
+</div>

Added: trunk/templates/Admin/Userlog/list.tmpl
===================================================================
--- trunk/templates/Admin/Userlog/list.tmpl	                        (rev 0)
+++ trunk/templates/Admin/Userlog/list.tmpl	2012-08-07 15:06:32 UTC (rev 12441)
@@ -0,0 +1,51 @@
+<TMPL_INCLUDE templates/Admin/Userlog/search.tmpl>
+
+<p>Latest log entries for <TMPL_VAR user_ljuser>.</p>
+
+<table style='border: solid 1px black; width: 95%;'>
+
+<tr>
+    <th class='logrow'>Date and Time</th>
+    <th class='logrow'>Action</th>
+    <th class='logrow'>Initiator</th>
+    <th class='logrow'>IP Address</th>
+    <th class='logrow'>Uniq Cookie</th>
+</tr>
+
+<TMPL_LOOP records>
+    <tr>
+        <td class='logrow'><TMPL_VAR time></td>
+        <td class='logrow'><TMPL_VAR action></td>
+        <td class='logrow'><TMPL_IF actor><TMPL_VAR actor><TMPL_ELSE><em>not recorded</em></TMPL_IF></td>
+        <td class='logrow'><TMPL_IF ip><TMPL_VAR ip><TMPL_ELSE><em>not recorded</em></TMPL_IF></td>
+        <td class='logrow'>
+            <TMPL_IF uniq>
+                <TMPL_IF uniq_valid>
+                    <a href="<TMPL_VAR lj_siteroot>/admin/uniq.bml?what=<TMPL_VAR uniq>"><TMPL_VAR uniq></a>
+                <TMPL_ELSE>
+                    ***
+                </TMPL_IF>
+            <TMPL_ELSE>
+                <em>not recorded</em>
+            </TMPL_IF>
+        </td>
+    </tr>
+</TMPL_LOOP>
+
+</table>
+
+<style type="text/css">
+<!--
+td.logrow {
+    border: solid 1px rgb(230,230,230);
+    padding: 2px;
+    margin: 0px;
+}
+th.logrow {
+    border: solid 1px rgb(180,180,180);
+    padding: 2px;
+    margin: 0px;
+    text-weight: bold;
+}
+-->
+</style>

Added: trunk/templates/Admin/Userlog/search.tmpl
===================================================================
--- trunk/templates/Admin/Userlog/search.tmpl	                        (rev 0)
+++ trunk/templates/Admin/Userlog/search.tmpl	2012-08-07 15:06:32 UTC (rev 12441)
@@ -0,0 +1,5 @@
+<form method='get' action='<TMPL_VAR lj_siteroot>/admin/userlog/'>
+    Username:
+    <input type='text' name='user' value='<TMPL_VAR form_user>' maxlength='15' size='15' />
+    <input type='submit' value='View' />
+</form>

Tags: ailyin, andy, bml, ljcom, pm, sup, tmpl
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