holyandrew (holyandrew) wrote in changelog,
holyandrew
holyandrew
changelog

[ljcom] r11716: LJSUP-11857: Cyr sub domains

Committer: akanashin
LJSUP-11857: Cyr sub domains
U   trunk/bin/upgrading/en_LJ.dat
A   trunk/cgi-bin/LJ/Console/Command/DomainRU.pm
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/RenameAction.pm
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem.pm
A   trunk/cgi-bin/LJ/Widget/Shop/View/DomainRU.pm
U   trunk/cgi-bin/LJ/Widget/Shop/View/RenameAccount.pm
U   trunk/htdocs/rename/use.bml.text.local
A   trunk/htdocs/shop/domainRU.bml
A   trunk/templates/Shop/DomainRU.tmpl
U   trunk/templates/Shop/RenameAccount.tmpl
Modified: trunk/bin/upgrading/en_LJ.dat
===================================================================
--- trunk/bin/upgrading/en_LJ.dat	2012-04-17 06:47:40 UTC (rev 11715)
+++ trunk/bin/upgrading/en_LJ.dat	2012-04-17 07:41:08 UTC (rev 11716)
@@ -1523,6 +1523,8 @@
 customize.cats.special|staleness=1
 customize.cats.special=Sponsored
 
+domain.bml.error.domainru=You can't to use domains жж.рф and живойжурнал.рф
+
 dystopia.btn.login=LOGIN
 
 dystopia.hello_anonymous=Welcome to LiveJournal!
@@ -3211,6 +3213,8 @@
 
 horizon.nav.shop.rename_account=Rename Account
 
+horizon.nav.shop.domainru=Domain РФ
+
 horizon.nav.shop.vgifts|staleness=1
 horizon.nav.shop.vgifts=Virtual Gifts
 
@@ -5226,6 +5230,11 @@
 
 pay.product.rename_action.details.redir.yes=Auto forward; 
 
+pay.product.rename_action.details.domainru.no=No store domains РФ; 
+
+pay.product.rename_action.details.domainru.yes=Store domains РФ; 
+
+
 pay.product.rename_action.short=Rename
 
 pay.product.rename_action.users|staleness=1
@@ -5234,8 +5243,12 @@
 pay.product.rename_action.users2|staleness=1
 pay.product.rename_action.users2=<strong>[[old_username]]</strong> &rarr; <strong>[[new_username]]</strong><br />
 
+pay.product.domainru.short=DomainRU
+pay.product.domainru.users|staleness=1
+pay.product.domainru.users=<strong>[[domain_name]]</strong> &rarr; <strong>[[username]]</strong><br />
+
 pay.product.userhead|staleness=1
-pay.product.userhead=Custom UserHead
+pay.product.userhead=UserHead
 
 pay.product.vgift=Virtual Gift
 
@@ -8010,6 +8023,11 @@
 
 shop.error.userhead.not_personal=You can buy custom userheads for personal accounts only.
 
+shop.error.domainru.needtokens=There was an error processing your request: You only have [[tokens]] LJ Tokens in your Wallet, which is not enough to pay [[price]] for domain РФ.
+shop.error.domainru.errordomain=Invalid format. Please enter other domain name
+shop.error.domainru.useddomain=Sorry, this domain is already in use. You can track user if he has been purged somewhen and his domain become vacant
+shop.error.domainru.not_your_account=You do not own this account
+
 shop.history.forwhat.appbill|staleness=1
 shop.history.forwhat.appbill=Application payment
 
@@ -8430,6 +8448,36 @@
 shop.view.renameaccount.title|staleness=1
 shop.view.renameaccount.title=Rename Account
 
+shop.view.domainru.authas=You are now working as the username <strong>'[[username]]'</strong>.
+
+shop.view.domainru.current|staleness=1
+shop.view.domainru.current=Current account
+
+shop.view.domainru.desc<<
+Your domainname can contain only lower-case letters (а-я),digits (0-9), and the underscore character (_). Underscores cannot be at the beginning or the end of the domainname, and there cannot be more then one underscore in row. Undercsores will be replaced with hyphens ( - ) in your journal's URL
+.
+
+shop.view.domainru.desired|staleness=1
+shop.view.domainru.desired=Desired domain
+
+shop.view.domainru.intro.text<<
+Brief description of the service
+.
+
+shop.view.domainru.checkbox=Yes, I understand rules and want to buy this domain
+
+shop.view.domainru.intro.title=Domain РФ
+
+shop.view.domainru.title|staleness=1
+shop.view.domainru.title=Domain РФ
+
+shop.view.domainru.buy=Buy
+shop.view.domainru.total=Total:
+shop.view.domainru.buydomain=BUY DOMAIN
+shop.view.domainru.managedomains=MANAGE DOMAINS
+
+
+
 shop.view.selfpromo.promo.text<<
 This service allows you to promote any of your entries (from your journal or community) at the LiveJournal homepage.
 <br />The promoted entry will be placed on the LiveJournal homepage for up to 3 hours but it can be displaced by another user's entry. <br />

Added: trunk/cgi-bin/LJ/Console/Command/DomainRU.pm
===================================================================
--- trunk/cgi-bin/LJ/Console/Command/DomainRU.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/Console/Command/DomainRU.pm	2012-04-17 07:41:08 UTC (rev 11716)
@@ -0,0 +1,76 @@
+package LJ::Console::Command::DomainRU;
+
+use strict;
+use base qw(LJ::Console::Command);
+use Carp qw(croak);
+
+sub cmd { "domainru" }
+
+sub desc { "Work with Domain РФ" }
+
+sub args_desc { [
+                 'account' => "Name of account",
+                 'domain'  => "Name of appropriate domain ( (warning) also there should be supported  such domains as championat.com, gazeta.ru)",
+                 'action'  => "'add' to join domain with account or 'remove' to unjoined domain from account, 'show' to view the list of account domains",
+                 'reason'  => "Necessary, when domain is added or removed (optional)",
+                 ] }
+
+sub usage { '<account> <domain> <action> ["<reason>"]' }
+
+sub can_execute {
+    my $remote = LJ::get_remote();
+#    return 1;
+    return LJ::check_priv($remote, "domainru");
+}
+
+sub execute {
+    my ($self, $account, $domain, $action, $reason) = @_;
+    my ($rval, @errs);
+
+    return $self->error("This command takes three arguments. Consult the reference.")
+        unless $account && $domain && $action;
+
+    my $u = LJ::load_user($account);
+    return $self->error("Invalid user $account") unless $u;
+
+    my $remote = LJ::get_remote();
+
+    if ($action eq 'add') {
+        my @subitem_params = (
+            $domain, LJ::load_user($account)->userid,
+        );
+        my $it = LJ::Pay::Payment::PayItem::DomainRU->new_memonly(
+            'item'    => 'domainru',
+            'subitem' => join(':', @subitem_params),
+            'qty'     => 1,
+            'anon'    => 0,
+            'rcptid'  => $remote->userid,
+            'amt'     => 0,
+        );
+        $it->calculate_price;
+        my $cart = LJ::Pay::Payment::new_cart($remote);
+        return $self->error(@errs) unless $it->can_belong_to($cart, \@errs, undef, 'additem');
+        $cart->payvar_append('do_not_notify_recepient',1);
+        $cart->add_item(%$it);
+        $cart->set_method( LJ::Pay::Method::Wallet->code );
+        LJ::Pay::Wallet->pay_for_cart( $cart->get_payid );
+        $it->_deliver_item if ($cart); 
+        LJ::statushistory_add($u->userid, $remote->userid, 'domain_alias', $reason);
+        return $self->print("Domain added");
+    } elsif ($action eq 'remove') {
+        LJ::Pay::Payment::PayItem::DomainRU->delete_domains($account, $domain);
+        LJ::Pay::Wallet->try_add($LJ::Pay::Payment::PayItem::DomainRU::shop_price);
+        LJ::statushistory_add($u->userid, $remote->userid, 'domain_alias', $reason);
+        return $self->print("Domain removed");
+    } elsif ($action eq 'show') {
+        my $domains = LJ::Pay::Payment::PayItem::DomainRU->get_domains($u);
+        for (@$domains) {
+            $self->print($_->{dom}." -> ".$_->{auth});
+         }
+    } else {
+        return $self->error("Unknown action. Consult the reference.")
+    }    
+
+}
+
+1;

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/RenameAction.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/RenameAction.pm	2012-04-17 06:47:40 UTC (rev 11715)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/RenameAction.pm	2012-04-17 07:41:08 UTC (rev 11716)
@@ -16,7 +16,7 @@
 sub details_for_name {
     my ($self, $subitem) = @_;
 
-    my ($source_uid, $dest_name, $opt_delfriends, $opt_delfriendofs, $opt_redir) = split(":", $subitem);
+    my ($source_uid, $dest_name, $opt_delfriends, $opt_delfriendofs, $opt_redir, $opt_domainru) = split(":", $subitem);
 
     my $piid = $self->get_piid;
     my $src_name = $self->get_cart->payvar_get("rename:$piid:source");
@@ -26,6 +26,7 @@
     push @parts, LJ::Lang::ml('pay.product.rename_action.details.delfriends.' . ($opt_delfriends ? 'yes' : 'no'));
     push @parts, LJ::Lang::ml('pay.product.rename_action.details.delfriendofs.' . ($opt_delfriendofs ? 'yes' : 'no'));
     push @parts, LJ::Lang::ml('pay.product.rename_action.details.redir.' . ($opt_redir ? 'yes' : 'no'), { old_username => $src_name } );
+    push @parts, LJ::Lang::ml('pay.product.rename_action.details.domainru.' . ($opt_domainru ? 'yes' : 'no'), { old_username => $src_name } );
     return join(' ', @parts);
 }
 
@@ -60,14 +61,14 @@
         return 0;
     }
 
-    my ($source_uid, $dest_name, $opt_delfriends, $opt_delfriendofs, $opt_redir) = split(":", $self->{subitem});
-    unless (defined $source_uid and defined $dest_name and defined $opt_delfriends and defined $opt_delfriendofs and defined $opt_redir) {
+    my ($source_uid, $dest_name, $opt_delfriends, $opt_delfriendofs, $opt_redir, $opt_domainru) = split(":", $self->{subitem});
+    unless (defined $source_uid and defined $dest_name and defined $opt_delfriends and defined $opt_delfriendofs and defined $opt_redir and defined $opt_domainru) {
         push @$errs_ref, 'malformed subitem in request'; # impossible message for non-hacker user
         return 0;
     }
 
     my %correct = ( 0 => 1, 1 => 1 );
-    unless ($correct{$opt_delfriends} and $correct{$opt_delfriendofs} and $correct{$opt_redir}) {
+    unless ($correct{$opt_delfriends} and $correct{$opt_delfriendofs} and $correct{$opt_redir} and $correct{$opt_domainru}) {
         push @$errs_ref, 'malformed subitem value in request'; # impossible message for non-hacker user
         return 0;
     }
@@ -138,7 +139,7 @@
 sub _deliver_item {
     my ($self, $payment, $buyer_u, $rcpt_u, $note_rec_change) = @_;
 
-    my ($source_uid, $dest_name, $opt_delfriends, $opt_delfriendofs, $opt_redir) = split(":", $self->{subitem});
+    my ($source_uid, $dest_name, $opt_delfriends, $opt_delfriendofs, $opt_redir, $opt_domainru) = split(":", $self->{subitem});
 
     my $fromu = LJ::load_userid($source_uid);
     my $tou = LJ::load_user($dest_name);
@@ -196,6 +197,7 @@
         opt_delfriends          => $opt_delfriends,
         opt_delfriendofs        => $opt_delfriendofs,
         opt_redir               => $opt_redir,
+        opt_domainru            => $opt_domainru,
         ip                      => $ip,
         payid                   => $payment->get_payid,
     };

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem.pm	2012-04-17 06:47:40 UTC (rev 11715)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem.pm	2012-04-17 07:41:08 UTC (rev 11716)
@@ -51,6 +51,7 @@
     'appitem'       => 'LJ::Pay::Payment::PayItem::AppItem',
     'royalty'       => 'LJ::Pay::Payment::PayItem::Royalty',
     'selfpromo'     => 'LJ::Pay::Payment::PayItem::SelfPromo',
+    'domainru'      => 'LJ::Pay::Payment::PayItem::DomainRU',
 );
 
 my @FREEZABLE_CLASSES = qw/

Added: trunk/cgi-bin/LJ/Widget/Shop/View/DomainRU.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/Shop/View/DomainRU.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/Widget/Shop/View/DomainRU.pm	2012-04-17 07:41:08 UTC (rev 11716)
@@ -0,0 +1,113 @@
+package LJ::Widget::Shop::View::DomainRU;
+
+use strict;
+use base 'LJ::Widget::Shop::View';
+
+#sub get_subpage { 'renameaccount' }
+sub require_remote { 1 }
+
+sub premature_checks {
+    my ($self) = @_;
+
+    $self->SUPER::premature_checks;
+    return if LJ::Request->redirected;
+
+    my $authas_param =
+        LJ::Request->post_param('authas') ||
+        LJ::get_remote()->user;
+
+    $self->{'authas'} = LJ::get_authas_user($authas_param, 'S');
+}
+
+sub authas {
+    my ($self) = @_;
+
+    return $self->{'authas'};
+}
+
+sub get_page_params {
+    my ($self) = @_;
+
+    my $remote = LJ::get_remote();
+    my $current = $self->authas || $remote;
+
+    my $buy_manage = LJ::Request->get_param('type');
+
+    my $delete = LJ::Request->get_param('delete');
+    my $auth = LJ::Request->get_param('auth');
+    my $dom = LJ::Request->get_param('dom');
+
+    LJ::Pay::Payment::PayItem::DomainRU->delete_domains($auth, $dom) if ($delete);
+
+    my $authas_opts = {
+        'authas' => $current->user,
+        'label' => ' ',
+        'nocomms' => $remote->ljuser_display,
+		'button_tag' => '<noscript>',
+		'button_close_tag' => '</noscript>',
+        'type'  => 'S',
+    };
+
+    my $domains = LJ::Pay::Payment::PayItem::DomainRU->get_domains();
+
+    my %ret = (
+        'current_username' => $current->user,
+        'type'             => $buy_manage ||= 'buy',
+        'domains'          => $domains, 
+    );
+
+    unless ($LJ::TESTING_ENVIRONMENT) {
+        $ret{'authas_select'} =
+            LJ::make_authas_select($remote, $authas_opts);
+
+        # work around a bug in HTML::Template::Pro that prevents a code like
+        # ml('string', param, ljuser(username)) from working properly
+        $ret{'current_ljuser'} = $current->ljuser_display;
+        $ret{'current_username'} = LJ::Lang::ml ('shop.view.renameaccount.authas', { username => $current->user });
+        $ret{'is_authas'} = $current->user eq $remote->user ? 0 : 1;
+    } else {
+        $ret{'authas'} = [ LJ::get_authas_list($remote, $authas_opts) ];
+        $ret{'total_cost'} = $self->{'total_cost'};
+    }
+
+    return \%ret;
+}
+
+sub process_post_request {
+    my ($self) = @_;
+
+    my $src_name = LJ::Request->post_param('src_name');
+    my $remote = LJ::get_remote();
+    my $authas = LJ::load_user(LJ::Request->post_param('authas'))->userid;
+
+    my @subitem_params = (
+        $src_name, $authas,
+    );
+
+    my $it = LJ::Pay::Payment::PayItem::DomainRU->new_memonly(
+        'item'    => 'domainru',
+        'subitem' => join(':', @subitem_params),
+        'qty'     => 1,
+        'anon'    => 0,
+        'status'  => 1,
+        'rcptid'  => $remote->userid,
+    );
+    $it->calculate_price;
+
+    my @errs;
+    my $cart = LJ::Pay::Payment::new_cart($remote);
+    $self->raise_errors(@errs) unless $it->can_belong_to($cart, \@errs, undef, 'additem'); 
+    $cart->payvar_append('do_not_notify_recepient',1);
+    $cart->add_item(%$it);
+    $cart->set_method( LJ::Pay::Method::Wallet->code );
+    LJ::Pay::Wallet->pay_for_cart( $cart->get_payid );
+    $it->_deliver_item if ($cart);
+    LJ::statushistory_add($authas, $remote->userid, 'domain_alias', "Payid: " . $cart->get_payid);
+
+    return LJ::Request->redirect( "$LJ::SITEROOT/shop/thankyou.bml?cart=" . $cart->get_cart_as_string );
+    
+}
+
+sub get_template_file { 'DomainRU' }
+
+1;

Modified: trunk/cgi-bin/LJ/Widget/Shop/View/RenameAccount.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/Shop/View/RenameAccount.pm	2012-04-17 06:47:40 UTC (rev 11715)
+++ trunk/cgi-bin/LJ/Widget/Shop/View/RenameAccount.pm	2012-04-17 07:41:08 UTC (rev 11716)
@@ -67,11 +67,12 @@
     my $opt_delfriends = LJ::Request->post_param('opt_delfriends');
     my $opt_delfriendsof = LJ::Request->post_param('opt_delfriendsof');
     my $opt_redir = LJ::Request->post_param('opt_redir');
+    my $opt_domainru = LJ::Request->post_param('opt_domainru');
     my $source = $self->authas;
 
     my @subitem_params = (
         $source->userid, $dest_name, $opt_delfriends,
-        $opt_delfriendsof, $opt_redir
+        $opt_delfriendsof, $opt_redir, $opt_domainru
     );
 
     my $it = LJ::Pay::Payment::PayItem::RenameAction->new_memonly(

Modified: trunk/htdocs/rename/use.bml.text.local
===================================================================
--- trunk/htdocs/rename/use.bml.text.local	2012-04-17 06:47:40 UTC (rev 11715)
+++ trunk/htdocs/rename/use.bml.text.local	2012-04-17 07:41:08 UTC (rev 11716)
@@ -76,6 +76,10 @@
 
 .options.unlink=Do not keep a connection between [[oldname]] and the new journal.
 
+.options.store=Store all domains for new account.
+
+.options.nostore=No store all domains for new account. Your domains *.жж.рф and *.живойжурнал.рф will be removed.
+
 .success.login=You'll need to <a [[aopts]]>login</a> again now.
 
 .success.moved="[[newuser]]" has been moved out of the way to "[[exname]]"

Added: trunk/htdocs/shop/domainRU.bml
===================================================================
--- trunk/htdocs/shop/domainRU.bml	                        (rev 0)
+++ trunk/htdocs/shop/domainRU.bml	2012-04-17 07:41:08 UTC (rev 11716)
@@ -0,0 +1,19 @@
+<?page
+body<=
+<?_code
+{
+    use strict;
+    use vars qw(%GET %POST $title $headextra @errors @warnings);
+
+    $title = $ML{'shop.view.domainru.title'};
+
+    LJ::Request->redirect ($LJ::PAGE_404) if $LJ::DISABLED{domainru};
+    return LJ::Widget::Shop::View::DomainRU->render();
+}
+_code?>
+<=body
+title=><?_code return $title; _code?>
+head<=
+<?_code return $headextra; _code?>
+<=head
+page?>

Added: trunk/templates/Shop/DomainRU.tmpl
===================================================================
--- trunk/templates/Shop/DomainRU.tmpl	                        (rev 0)
+++ trunk/templates/Shop/DomainRU.tmpl	2012-04-17 07:41:08 UTC (rev 11716)
@@ -0,0 +1,50 @@
+<TMPL_INCLUDE name="templates/Shop/Error.tmpl">
+
+<div id="shop_domainru">
+
+<div class="b-shop-intro b-renacc-intro">
+	<h3><TMPL_VAR expr="ml('shop.view.domainru.intro.title')"></h3>
+	<p><TMPL_VAR expr="ml('shop.view.domainru.intro.text')"></p>
+</div>
+
+<a href="<TMPL_VAR self_uri>?type=buy"><TMPL_VAR expr="ml('shop.view.domainru.buydomain')"></a>
+<a href="<TMPL_VAR self_uri>?type=manage"><TMPL_VAR expr="ml('shop.view.domainru.managedomains')"></a>
+
+<tmpl_if expr="type eq 'buy'">
+<tmpl_if is_authas><p class="b-bubble b-bubble-success b-bubble-intext"><tmpl_var current_username></p></tmpl_if>
+<div class="b-renacc-form">
+	<form method="post">
+		<TMPL_VAR form_auth>
+		<fieldset>
+			<dl class="b-renacc-fields">
+				<dt><TMPL_VAR expr="ml('shop.view.domainru.current')">:</dt>
+				<dd id="authas_container"><TMPL_VAR authas_select></dd>
+			</dl>
+			<dl class="b-renacc-fields">
+				<dt><label for="src_name"><TMPL_VAR expr="ml('shop.view.domainru.desired')">:</label>
+				<dd><input type="text" name="src_name" id="src_name" />.жж.рф</dd>
+			</dl>
+			<p class="b-shop-desc"><TMPL_VAR expr="ml('shop.view.domainru.desc')"></p>
+			<input type="checkbox" name="confirm" id="domainru-confirm">
+			<label for="domainru-confirm"><TMPL_VAR expr="ml('shop.view.domainru.checkbox')"></label>
+		</fieldset>
+			<TMPL_IF 0>
+				<TMPL_VAR expr="ml('shop.view.domainru.total')">
+				<TMPL_VAR total_cost>
+			</TMPL_IF>
+			<button type="submit"><TMPL_VAR expr="ml('shop.view.domainru.buy')"></button>
+	</form>
+</div>
+
+<tmpl_else>
+
+<ul>
+<tmpl_loop domains>
+	<li><tmpl_var auth> <tmpl_var dom> <a href=?type=manage&delete=1&auth=<tmpl_var auth>&dom=<tmpl_var dom>>X</a></li>
+</tmpl_loop>
+</ul>
+
+</tmpl_if>
+
+</div>
+

Modified: trunk/templates/Shop/RenameAccount.tmpl
===================================================================
--- trunk/templates/Shop/RenameAccount.tmpl	2012-04-17 06:47:40 UTC (rev 11715)
+++ trunk/templates/Shop/RenameAccount.tmpl	2012-04-17 07:41:08 UTC (rev 11716)
@@ -47,6 +47,10 @@
 				<li><input type="radio" name="opt_redir" value="0" id="opt_redir_no"> <label for="opt_redir_no"><TMPL_VAR expr="ml('/rename/use.bml.options.unlink', 'oldname', current_ljuser)"></label></li>
 				<li><input type="radio" name="opt_redir" value="1" id="opt_redir_yes" checked="checked"> <label for="opt_redir_yes"><TMPL_VAR expr="ml('/rename/use.bml.options.forward', 'oldname', current_ljuser)"></label></li>
 			</ul>
+			<ul class="b-renacc-options">
+				<li><input type="radio" name="opt_domainru" value="0" id="opt_domainru_no"> <label for="opt_domainru_no"><TMPL_VAR expr="ml('/rename/use.bml.options.nostore')"></label></li>
+				<li><input type="radio" name="opt_domainru" value="1" id="opt_domainru_yes" checked="checked"> <label for="opt_domainru_yes"><TMPL_VAR expr="ml('/rename/use.bml.options.store')"></label></li>
+			</ul>
 			<button type="submit"><TMPL_VAR expr="ml('shop.view.proceed')"></button>
 		</fieldset>
 	</form>

Tags: akanashin, bml, dat, holyandrew, ljcom, local, pm, 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