holyandrew (holyandrew) wrote in changelog,
holyandrew
holyandrew
changelog

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

Committer: akanashin
LJSUP-11857: Cyr sub domains
U   trunk/cgi-bin/LJ/Console/Command/DomainRU.pm
A   trunk/htdocs/tools/endpoints/domain_ru.bml
A   trunk/htdocs/tools/endpoints/domain_ru.bml.text.local
Modified: trunk/cgi-bin/LJ/Console/Command/DomainRU.pm
===================================================================
--- trunk/cgi-bin/LJ/Console/Command/DomainRU.pm	2012-04-24 08:36:29 UTC (rev 11767)
+++ trunk/cgi-bin/LJ/Console/Command/DomainRU.pm	2012-04-24 10:43:21 UTC (rev 11768)
@@ -15,7 +15,7 @@
                  'reason'  => "Necessary, when domain is added or removed (optional)",
                  ] }
 
-sub usage { '<account> <domain> <action> ["<reason>"]' }
+sub usage { '<account> [<domain>] <action> ["<reason>"]' }
 
 sub can_execute {
     my $remote = LJ::get_remote();
@@ -27,8 +27,11 @@
     my ($self, $account, $domain, $action, $reason) = @_;
     my ($rval, @errs);
 
-    return $self->error("This command takes three arguments. Consult the reference.")
-        unless $account && $domain && $action;
+    if ($action eq 'show' && !$account) {
+        return $self->error("This command takes two arguments. Consult the reference.")
+    } elsif (!$account || !$domain || !$action) {
+        return $self->error("This command takes three arguments. Consult the reference.")
+    }
 
     my $u = LJ::load_user($account);
     return $self->error("Invalid user $account") unless $u;

Added: trunk/htdocs/tools/endpoints/domain_ru.bml
===================================================================
--- trunk/htdocs/tools/endpoints/domain_ru.bml	                        (rev 0)
+++ trunk/htdocs/tools/endpoints/domain_ru.bml	2012-04-24 10:43:21 UTC (rev 11768)
@@ -0,0 +1,64 @@
+<?_code # -*-bml-*-
+{
+    use strict;
+    use LJ::User;
+    use LJ::JSON;
+    use LJ::Auth;
+
+    BML::set_language_scope('/tools/endpoints/domain_ru.bml');
+
+    use vars qw(%GET %POST);
+    my $remote = LJ::get_remote();
+    my $ret    = {};
+#    my $token  = $POST{'token'};
+    my $action = $POST{'action'};
+
+#    if ( $token && $action && ( $action eq 'delete' ) ) {
+#        return LJ::JSON->to_json({
+#            'status' => 'error',
+#            'msg'    => LJ::Lang::ml('domain_ru.bml.bad.auth.token'),
+#        }) unless LJ::Auth->check_ajax_auth_token( $remote, '/domain_ru.bml', 'action' => 'delete', 'auth_token' => $token );
+#    }
+
+    # processing remove
+    my $user     = $POST{'authas'};
+    my $src_name = $POST{'src_name'};
+
+    unless (LJ::load_user($user)) {
+        return LJ::JSON->to_json({
+               'status' => 'error',
+               'msg'    => LJ::Lang::ml('domain_ru.bml.bad.username'),
+        });
+    }
+
+    my $userid = LJ::load_user($user)->userid;
+
+    if ($action eq 'delete') {
+        LJ::Pay::Payment::PayItem::DomainRU->delete_domains($userid, $src_name);
+        $ret->{status} = 'ok';
+        $ret->{msg}    = LJ::Lang::ml('domain_ru.bml.deleted');
+    }
+
+    if ($action eq 'check') {
+
+        my @subitem_params = (
+            $src_name, $user,
+        );
+
+        my $it = LJ::Pay::Payment::PayItem::DomainRU->new_memonly(
+            'item'    => 'domainru',
+            'subitem' => join(':', @subitem_params),
+            'qty'     => 1,
+            'anon'    => 0,
+            'status'  => 1,
+            'rcptid'  => $remote->userid,
+        );
+        my @errs;
+        $ret->{status} = $it->can_belong_to(undef, \@errs, undef, 'additem') ? 'ok' : 'error';
+        $ret->{msg}    = join(';', @errs);
+    }
+
+    BML::set_content_type('text/javascript; charset=utf-8');
+    return LJ::JSON->to_json($ret);
+}
+_code?>

Added: trunk/htdocs/tools/endpoints/domain_ru.bml.text.local
===================================================================
--- trunk/htdocs/tools/endpoints/domain_ru.bml.text.local	                        (rev 0)
+++ trunk/htdocs/tools/endpoints/domain_ru.bml.text.local	2012-04-24 10:43:21 UTC (rev 11768)
@@ -0,0 +1,6 @@
+;; -*- coding: utf-8 -*-
+
+.bad.auth.token=Bad auth token
+.bad.username=Bad username 
+.no.remote=No remote user
+.deleted=User is deleted

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