wisest owl (wisest_owl) wrote in changelog,
wisest owl
wisest_owl
changelog

[ljcom] r10992: LJSUP-9751: Replace 17x17 userheads with...

Committer: gprochaev
LJSUP-9751: Replace 17x17 userheads with corresponding 16x16

U   trunk/cgi-bin/LJ/UserHead.pm
U   trunk/htdocs/admin/userheads/manage.bml
Modified: trunk/cgi-bin/LJ/UserHead.pm
===================================================================
--- trunk/cgi-bin/LJ/UserHead.pm	2011-09-12 08:22:14 UTC (rev 10991)
+++ trunk/cgi-bin/LJ/UserHead.pm	2011-09-12 09:20:04 UTC (rev 10992)
@@ -6,6 +6,8 @@
 __PACKAGE__->follow_best_practice;
 __PACKAGE__->mk_accessors( qw( uh_id uh_author uh_desc uh_desc_sup price visibility ) );
 
+use LJ::FileStore;
+
 sub new {
     my $class = shift;
     my $args = shift || {};
@@ -64,7 +66,9 @@
 sub get_uh_img {
     my $self = shift;
 
-    return $LJ::FILEPREFIX."/userhead/".$self->get_uh_id;
+    my $uh_fs = LJ::FileStore->get_path_info ( path => "/userhead/".$self->get_uh_id );
+
+    return $LJ::FILEPREFIX."/userhead/".$self->get_uh_id . ($uh_fs->{'change_time'} ? "?v=".$uh_fs->{'change_time'} : "");
 }
 
 sub is_enabled {

Modified: trunk/htdocs/admin/userheads/manage.bml
===================================================================
--- trunk/htdocs/admin/userheads/manage.bml	2011-09-12 08:22:14 UTC (rev 10991)
+++ trunk/htdocs/admin/userheads/manage.bml	2011-09-12 09:20:04 UTC (rev 10992)
@@ -15,6 +15,28 @@
 
 my $save_error = '';
 
+if ($FORM{'edit'}) {
+    
+    my $uh = LJ::UserHead->get_userhead ($FORM{'edit'});
+    $ret .= "<title>LJ User Heads: Edit</title>";
+    $ret .= "Edit userhead: #".$FORM{'edit'}."<br/>";
+    $ret .= "<img src='".$uh->get_uh_img."'>";
+    $ret .= <<FORM;
+    <form method="post" enctype="multipart/form-data">
+    <table>
+    <tr>
+        <td><input type="file" name="uh_file"></td>
+        <td><input type="submit" name="upload" value="Replace"></td>
+    </tr>
+    </table>
+    <input type='hidden' name='uh_id' value='$FORM{edit}'>
+    </form>
+    <hr>
+
+FORM
+    return $ret;
+}
+
 if ($FORM{'upload'}) {
     my $error = '';
     #BML::parse_multipart(\%POST, \$error, 999992048);
@@ -23,8 +45,9 @@
     seek $userhead->fh, 0,0;
     read $userhead->fh, my $userhead_content, $userhead->size;
 
+    my $uh_fs = {};
     if ($POST{'uh_file'}) {
-        my $uh = LJ::UserHead->new;
+        my $uh = $POST{'uh_id'} ? LJ::UserHead->get_userhead ($POST{'uh_id'}) : LJ::UserHead->new;
         $uh->save;
 
         my ($result_l, $result_s, $content_length, $magic, $mime_type) = ();
@@ -39,7 +62,9 @@
             $save_error = 'when adding userhead error occurred. please, please try again.';
             $uh->delete;
         }
+        $uh_fs = LJ::FileStore->get_path_info ( path => "/userhead/".$uh->get_uh_id );
     }
+    BML::redirect("/admin/userheads/manage.bml" . ($uh_fs->{'change_time'} ? "?v=".$uh_fs->{'change_time'} : ""));
 }
 
 if ($FORM{'save'}) {
@@ -119,7 +144,7 @@
 
 $ret .= "<form method='POST'>";
 $ret .= "<table border=0 cellspacing=1 cellpadding=4>";
-$ret .= "<tr><td>Id</td><td>Img Enb</td><td>Img Dis</td><td>Cost</td><td>&nbsp;</td><td>Author</td><td>Description</td><td>Description SUP</td></tr>";
+$ret .= "<tr><td>Id</td><td>Img Enb</td><td>Img Dis</td><td>Cost</td><td>&nbsp;</td><td>Author</td><td>Description</td><td>Description SUP</td><td>Edit</td></tr>";
 foreach my $uh (@$uhs) {
     $ret .= "<tr>\n";
     $ret .= "<td><input type='hidden' name='".$uh->get_uh_id."-uh_id' value='".$uh->get_uh_id."'>".$uh->get_uh_id."</td>\n";
@@ -146,6 +171,7 @@
     $ret .= "<td><input type='text' name='".$uh->get_uh_id."-author' value='".$uh->get_uh_author."'></td>\n";
     $ret .= "<td><input type='text' name='".$uh->get_uh_id."-desc' value='".$uh->get_uh_desc."'></td>\n";
     $ret .= "<td><input type='text' name='".$uh->get_uh_id."-desc-sup' value='".$uh->get_uh_desc_sup."'></td>\n";
+    $ret .= "<td><input type='submit' name='edit' value='".$uh->get_uh_id."'></td>\n";
     $ret .= "</tr>\n";
 }
 $ret .= "<tr><td colspan='5'><input type='submit' name='save' value='Save'></td></tr>\n";

Tags: bml, ljcom, pm, wisest-owl
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