Committer: ailyin
LJSUP-10815 (Fotki.ru: store data on our own servers)U trunk/bin/upgrading/update-db.pl U trunk/cgi-bin/LJ/SiteMessages.pm U trunk/cgi-bin/LJ/Widget/EntryForm.pm U trunk/htdocs/editjournal.bml
Modified: trunk/bin/upgrading/update-db.pl =================================================================== --- trunk/bin/upgrading/update-db.pl 2011-12-19 13:30:26 UTC (rev 20810) +++ trunk/bin/upgrading/update-db.pl 2011-12-19 13:58:54 UTC (rev 20811) @@ -122,6 +122,7 @@ my %post_create = (); # $table -> [ [ $action, $what ]* ] my %coltype = (); # $table -> { $col -> [ $type, $null ] } my %indexname = (); # $table -> "INDEX"|"UNIQUE" . ":" . "col1-col2-col3" -> "PRIMARY" | index_name +my %primarykey = (); # $table -> "INDEX:col1-col2-col3" my @alters = (); my $dbh; my $sth; @@ -143,7 +144,7 @@ # reset everything %clustered_table = %table_exists = %table_unknown = %table_create = %table_drop = %post_create = - %coltype = %indexname = %table_status = (); + %coltype = %indexname = %primarykey = %table_status = (); @alters = (); ## figure out what tables already exist (but not details of their structure) @@ -1092,6 +1093,7 @@ my $table = shift; delete $coltype{$table}; delete $indexname{$table}; + delete $primarykey{$table}; delete $table_status{$table}; } @@ -1144,6 +1146,10 @@ foreach my $idx (keys %idx_type) { my $val = "$idx_type{$idx}:" . join("-", @{$idx_parts{$idx}}); $indexname{$table}->{$val} = $idx; + + if ( $idx eq 'PRIMARY' ) { + $primarykey{$table} = $val; + } } } @@ -1154,6 +1160,12 @@ return $indexname{$table}->{$idx} || ""; } +sub primary_key { + my ($table) = @_; + load_table_info($table) unless $indexname{$table}; + return $primarykey{$table} || ''; +} + sub table_relevant { my $table = shift; Modified: trunk/cgi-bin/LJ/SiteMessages.pm =================================================================== --- trunk/cgi-bin/LJ/SiteMessages.pm 2011-12-19 13:30:26 UTC (rev 20810) +++ trunk/cgi-bin/LJ/SiteMessages.pm 2011-12-19 13:58:54 UTC (rev 20811) @@ -1,7 +1,7 @@ package LJ::SiteMessages; use strict; use Carp qw(croak); -use LJ::Fotki::Migration; +use LJ::Pics::Migration; use constant AccountMask => { Permanent => { @@ -136,7 +136,7 @@ group => 5, validate => sub { my ($u) = @_; - return !(LJ::Fotki::Migration->user_enabled_new_photohosting($u)); + return !(LJ::Pics::Migration->user_enabled_new_photohosting($u)); } }, }; Modified: trunk/cgi-bin/LJ/Widget/EntryForm.pm =================================================================== --- trunk/cgi-bin/LJ/Widget/EntryForm.pm 2011-12-19 13:30:26 UTC (rev 20810) +++ trunk/cgi-bin/LJ/Widget/EntryForm.pm 2011-12-19 13:58:54 UTC (rev 20811) @@ -2,10 +2,9 @@ use strict; use base 'LJ::Widget'; -use LJ::Widget::Calendar; -use LJ::Fotki::Photo; -use LJ::Fotki::Album; +use LJ::Pics; +use LJ::Widget::Calendar; use LJ::Widget::Fotki::Upload; use LJ::GeoLocation; @@ -1571,51 +1570,51 @@ my $photos_id = $opts->{'photos_id'}; my @photos = grep { $_ } map { - my $photo = LJ::Fotki::Photo->new ( url_id => $_, userid => $remote->userid ); + my $photo = LJ::Pics::Photo->load_and_check_auth( $remote, $_ ); $photo; } split (/,/, $photos_id); foreach my $album_id (split /,/, $albums_id) { - my $album = LJ::Fotki::Album->new ( url_id => $album_id, userid => $remote->userid ); + my $album = LJ::Pics::Album->load_and_check_auth( $remote, $album_id ); next unless $album; - push @photos, @{$album->get_all_photos() || []}; + push @photos, $album->photos; } $insert_photos = [ grep { $_ } map { my $photo = $_; my $res = $photo->is_valid ? { - photo_desc => $photo->desc, - photo_title => $photo->title, - photo_url => @photos > 1 ? $photo->u100_url : $photo->u600_url, - photo_id => $photo->url_id, + photo_desc => $photo->prop('description'), + photo_title => $photo->prop('title'), + photo_url => $photo->image_url( 'size' => @photos > 1 ? 100 : 600 ), + photo_id => $photo->photo_id_displayed, } : undef; $res; } @photos ]; - my @photo_sizes = map { - my $size = $_; - $size->{'text'} = $BML::ML{$_->{'text'}}; - $size; - } @{LJ::Fotki::Photo->get_photo_sizes()}; + my @photo_sizes = map { { + 'size' => $_, + 'text' => LJ::Lang::ml("fotki.size.$_.text"), + 'is_default' => ( $_ == $LJ::Pics::Photo::DEFAULT_SIZE ) ? 1 : 0, + } } @LJ::Pics::Photo::SUPPORTED_SIZES; my $photo_sizes_json = LJ::JSON->to_json ( \@photo_sizes ); my $album_list = []; my $album_list_json = ''; my $available_space = ''; - $album_list = LJ::Fotki::Album->get_albums ($remote->userid); + $album_list = [ LJ::Pics::Album->list( 'userid' => $remote->userid ) ]; $album_list = [ map { my $album = $_; - my $main_photo = $album->main_photo_url; { - album_title => $album->title, - album_id => $album->url_id, + album_title => $album->album_title, + album_id => $album->album_id_displayed, } } @$album_list ]; $album_list_json = LJ::JSON->to_json ( $album_list ); - my $available_space = LJ::Fotki::UserSpace->get_available_space(); + my $available_space = LJ::Widget::Fotki::UserSpace->display_space( + LJ::Pics->get_free_space($remote) ); my $auth_token = LJ::Auth->sessionless_auth_token ($LJ::DOMAIN_WEB."/pics/upload", user => $remote ? $remote->user : undef); my $user_groups = LJ::JSON->to_json (LJ::Widget::Fotki::Photo->get_user_groups ($remote)); Modified: trunk/htdocs/editjournal.bml =================================================================== --- trunk/htdocs/editjournal.bml 2011-12-19 13:30:26 UTC (rev 20810) +++ trunk/htdocs/editjournal.bml 2011-12-19 13:58:54 UTC (rev 20811) @@ -9,10 +9,7 @@ use vars qw(%GET %POST $title); BML::decl_params(_default => qr/./); - use LJ::Fotki::Photo; use LJ::DelayedEntry; - use LJ::Fotki::Album; - use LJ::Fotki::UserSpace; use LJ::Widget::Fotki::Upload; use LJ::Widget::Calendar; use List::Util;