Шурик (fortl) wrote in changelog,
Шурик
fortl
changelog

[livejournal] r18411: LJSUP-7874 SMS notification - new featu...

Committer: aurbanowich
LJSUP-7874 SMS notification - new features
U   trunk/bin/upgrading/en.dat
U   trunk/bin/upgrading/proplists.dat
U   trunk/cgi-bin/LJ/Event/Befriended.pm
U   trunk/cgi-bin/LJ/Event/Birthday.pm
U   trunk/cgi-bin/LJ/Event/CommunityInvite.pm
U   trunk/cgi-bin/LJ/Event/CommunityJoinRequest.pm
U   trunk/cgi-bin/LJ/Event/Defriended.pm
U   trunk/cgi-bin/LJ/Event/InvitedFriendJoins.pm
U   trunk/cgi-bin/LJ/Event/JournalNewEntry.pm
U   trunk/cgi-bin/LJ/Event/NewUserpic.pm
U   trunk/cgi-bin/LJ/Event/OfficialPost.pm
U   trunk/cgi-bin/LJ/Event/PollVote.pm
U   trunk/cgi-bin/LJ/Event/UserExpunged.pm
U   trunk/cgi-bin/LJ/Event/UserMessageRecvd.pm
U   trunk/cgi-bin/LJ/Event/UserMessageSent.pm
U   trunk/cgi-bin/LJ/Event/UserNewEntry.pm
U   trunk/cgi-bin/LJ/Event.pm
U   trunk/cgi-bin/LJ/Widget/SubscribeInterface.pm
U   trunk/htdocs/manage/profile/index.bml
U   trunk/htdocs/manage/profile/index.bml.text
Modified: trunk/bin/upgrading/en.dat
===================================================================
--- trunk/bin/upgrading/en.dat	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/bin/upgrading/en.dat	2011-02-25 09:02:46 UTC (rev 18411)
@@ -2851,6 +2851,48 @@
 
 notification_method.sms-ru.title=SMS
 
+notification.sms.befriended=[[friend]] has added you to their friends list. Reply with ADD [[friend]] to add them [[disclaimer]]
+
+notification.sms.birthday=[[user]]'s birthday is on [[bday]]!
+
+notification.sms.communityinvite=[[inviter]] sent you an invitation to join the community [[comm]]. Visit the invitation page to accept
+
+notification.sms.communityjoinrequest=[[requestor]] requests membership in [[comm]]. Visit community settings to approve.
+
+notification.sms.defriended=[[friend]] has removed you from their Friends list.
+
+notification.sms.invitedfriendjoins=A friend you invited has created the journal [[friend]]
+
+notification.sms.invitedfriendjoins_uknown=A friend you invited has created a journal.
+
+notification.sms.journalnewentry=[[poster]] has posted with a new entry. To view, send READ [[journal]] to read it. [[disclaimer]]
+
+notification.sms.journalnewentry_comm=[[poster]] has posted with a new entry in [[journal]]. To view, send READ [[journal]] to read it. [[disclaimer]]
+
+notification.sms.newuserpic=[[journal]] has uploaded a new userpic. You can view it at: [[pic_url]]
+
+notification.sms.newvgift=[[journal]] has received a new virtual gift.
+
+notification.sms.officialpost=There is a new [[abbrev]] announcement in [[journal]]. Reply with READ [[journal]] to read it. [[disclaimer]]
+
+notification.sms.pollvote=[[voter]] has voted in [[pollname]] at [[entry_url]]
+
+notification.sms.userexpunged=[[journal]] has been purged.
+
+notification.sms.usermessagerecvd=You've received a new message "[[subject]]" from [[user]]
+
+notification.sms.usermessagesent=message sent to [[user]].
+
+notification.sms.usernewentry=User '[[user]]' posted in their journal
+
+notification.sms.usernewentry_comm=User '[[user]]' posted '[[journal]]'
+
+sms.numbernotverified=Number not verified.
+
+sms.uknowncommand=Incorrect request.
+
+sms.unsubscribesuccesseful=You have successful unsubscribed from LiveJournal sms notification.
+
 number.million|staleness=1
 number.million=[[number]] million
 

Modified: trunk/bin/upgrading/proplists.dat
===================================================================
--- trunk/bin/upgrading/proplists.dat	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/bin/upgrading/proplists.dat	2011-02-25 09:02:46 UTC (rev 18411)
@@ -1094,6 +1094,14 @@
   multihomed: 0
   prettyname: What "yes" SMS message means
 
+userproplist.smsru_interval:
+  cldversion: 4
+  datatype: char
+  des: Interval for SMSru notifications. fortmat start_hour-end_hour
+  indexed: 0
+  multihomed: 0
+  prettyname: Interval for SMSru notifications
+
 userproplist.state:
   cldversion: 4
   datatype: char

Modified: trunk/cgi-bin/LJ/Event/Befriended.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/Befriended.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Event/Befriended.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -125,10 +125,18 @@
 }
 
 sub as_sms {
-    my $self = shift;
-    return sprintf("%s has added you to their friends list. Reply with ADD %s to add them " .
-                   "to your friends list. $LJ::SMS_DISCLAIMER",
-                   $self->friend->user, $self->friend->user);
+    my ($self, $u) = @_;
+    my $lang = $u->prop('browselang') || $LJ::DEFAULT_LANG;
+    
+    my $tinyurl = LJ::API::BitLy->shorten( "http://m.livejournal.com/read/user/".$self->friend->user );
+    undef $tinyurl if $tinyurl =~ /^500/;
+
+# [[friend]] has added you to their friends list. Reply with ADD [[friend]] to add them [[disclaimer]]
+    return LJ::Lang::get_text($lang, 'notification.sms.befriended', undef, { 
+        friend     => $self->friend->user,
+        disclaimer => $LJ::SMS_DISCLAIMER,
+        mobile_url => $tinyurl,
+    });
 }
 
 sub as_alert {

Modified: trunk/cgi-bin/LJ/Event/Birthday.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/Birthday.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Event/Birthday.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -36,11 +36,18 @@
 }
 
 sub as_string {
-    my $self = shift;
+    my ($self, $u) = @_;
+    my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG;
 
-    return sprintf("%s's birthday is on %s!",
-                   $self->bdayuser->display_username,
-                   $self->bday);
+# [[user]]'s birthday is on [[bday]]!
+    return LJ::Lang::get_text($lang, 'notification.sms.birthday', undef, {
+        user     => $self->bdayuser->display_username,
+        bday     => $self->bday,
+    });
+
+#    return sprintf("%s's birthday is on %s!",
+#                   $self->bdayuser->display_username,
+#                   $self->bday);
 }
 
 sub as_alert {

Modified: trunk/cgi-bin/LJ/Event/CommunityInvite.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/CommunityInvite.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Event/CommunityInvite.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -127,11 +127,18 @@
 }
 
 sub as_sms {
-    my $self = shift;
+    my ($self, $u) = @_;
+    my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG;
 
-    return sprintf("%s sent you an invitation to join the community %s. Visit the invitation page to accept",
-                   $self->inviter->display_username,
-                   $self->comm->display_username);
+# [[inviter]] sent you an invitation to join the community [[comm]]. Visit the invitation page to accept
+    return LJ::Lang::get_text($lang, 'notification.sms.communityinvite', undef, {
+        inviter => $self->inviter->display_username,
+        comm    => $self->comm->display_username,
+    });
+
+#    return sprintf("%s sent you an invitation to join the community %s. Visit the invitation page to accept",
+#                   $self->inviter->display_username,
+#                   $self->comm->display_username);
 }
 
 sub as_alert {

Modified: trunk/cgi-bin/LJ/Event/CommunityJoinRequest.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/CommunityJoinRequest.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Event/CommunityJoinRequest.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -135,11 +135,14 @@
 }
 
 sub as_sms {
-    my $self = shift;
+    my ($self, $u) = @_;
+    my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG;
 
-    return sprintf("%s requests membership in %s. Visit community settings to approve.",
-                   $self->requestor->display_username,
-                   $self->comm->display_username);
+# [[requestor]] requests membership in [[comm]]. Visit community settings to approve.
+    return LJ::Lang::get_text($lang, 'notification.sms.communityjoinrequest', undef, {
+        requestor => $self->requestor->display_username,
+        comm      => $self->comm->display_username,
+    });
 }
 
 sub as_alert {

Modified: trunk/cgi-bin/LJ/Event/Defriended.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/Defriended.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Event/Defriended.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -108,9 +108,20 @@
 }
 
 sub as_string {
-    my $self = shift;
-    return sprintf("%s has removed you from their Friends list.",
-                   $self->friend->{user});
+    my ($self, $u) = @_;
+    my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG;
+
+    my $tinyurl = LJ::API::BitLy->shorten( "http://m.livejournal.com/read/user/".$self->friend->{user} );
+    undef $tinyurl if $tinyurl =~ /^500/;
+
+# [[friend]] has removed you from their Friends list.
+    return LJ::Lang::get_text($lang, 'notification.sms.defriended', undef, {
+        friend     => $self->friend->{user},
+        mobile_url => $tinyurl,
+    });
+
+#    return sprintf("%s has removed you from their Friends list.",
+#                   $self->friend->{user});
 }
 
 sub as_alert {

Modified: trunk/cgi-bin/LJ/Event/InvitedFriendJoins.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/InvitedFriendJoins.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Event/InvitedFriendJoins.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -101,12 +101,23 @@
 }
 
 sub as_string {
-    my $self = shift;
+    my ($self, $u) = @_;
+    my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG;
+    
+    my $tinyurl;
+    if( $self->friend->user ){
+        $tinyurl = LJ::API::BitLy->shorten( "http://m.livejournal.com/read/user/".$self->friend->user );
+        undef $tinyurl if $tinyurl =~ /^500/;
+    }
+    
+    my $mlstring = $self->friend ? 'notification.sms.invitedfriendjoins' : 'notification.sms.invitedfriendjoins_uknown';
+# A friend you invited has created a journal.
+# A friend you invited has created the journal [[friend]]
+    return LJ::Lang::get_text($lang, $mlstring, undef, {
+        friend     => $self->friend->user,
+        mobile_url => $tinyurl,
+    });
 
-    return 'A friend you invited has created a journal.'
-        unless $self->friend;
-
-    return sprintf "A friend you invited has created the journal %s", $self->friend->user;
 }
 
 sub as_alert {

Modified: trunk/cgi-bin/LJ/Event/JournalNewEntry.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/JournalNewEntry.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Event/JournalNewEntry.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -78,11 +78,23 @@
 }
 
 sub as_sms {
-    my $self = shift;
+    my ($self, $u) = @_;
+    my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG;
+    
+    my $tinyurl;
+    $tinyurl = LJ::API::BitLy->shorten( "http://m.livejournal.com/read/user/" 
+        . $self->entry->journal->user . '/' . $self->entry->ditemid . '/' );
+    undef $tinyurl if $tinyurl =~ /^500/;
 
-    my $incomm = $self->entry->journal->is_comm ? " in " . $self->entry->journal->user : '';
-    sprintf("%s has posted with a new entry$incomm. To view, send READ %s to read it. $LJ::SMS_DISCLAIMER",
-            $self->entry->poster->user, $self->entry->journal->user);
+    my $mlstrng = $self->entry->journal->is_comm ? 'notification.sms.journalnewentry_comm' : 'notification.sms.journalnewentry';
+# [[poster]] has posted with a new entry. To view, send READ [[journal]] to read it. [[disclaimer]]
+# [[poster]] has posted with a new entry in [[journal]]. To view, send READ [[journal]] to read it. [[disclaimer]]
+
+    return LJ::Lang::get_text($lang, $mlstrng, undef, {
+        poster  => $self->entry->poster->user,
+        journal => $self->entry->journal->user,
+        mobile_url => $tinyurl,
+    });
 }
 
 sub as_alert {

Modified: trunk/cgi-bin/LJ/Event/NewUserpic.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/NewUserpic.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Event/NewUserpic.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -26,10 +26,14 @@
 }
 
 sub as_sms {
-    my $self = shift;
+    my ($self, $u) = @_;
+    my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG;
 
-    return $self->event_journal->display_username . " has uploaded a new userpic. You can view it at: " .
-        $self->userpic->url;
+# [[journal]] has uploaded a new userpic. You can view it at: [[pic_url]]
+    return LJ::Lang::get_text($lang, 'notification.sms.newuserpic', undef, {
+        journal => $self->event_journal->display_username,
+        pic_url => $self->userpic->url,
+    });
 }
 
 # esn.new_userpic.alert=[[who]] has uploaded a new userpic. You can view it at: [[userpic]].

Modified: trunk/cgi-bin/LJ/Event/OfficialPost.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/OfficialPost.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Event/OfficialPost.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -124,11 +124,21 @@
 }
 
 sub as_sms {
-    my $self = shift;
+    my ($self, $u) = @_;
+    my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG;
     my $entry = $self->entry or return "(Invalid entry)";
-    return sprintf("There is a new $LJ::SITENAMEABBREV announcement in %s. " .
-                   "Reply with READ %s to read it. $LJ::SMS_DISCLAIMER",
-                   $entry->journal->display_username, $entry->journal->display_username);
+
+    my $tinyurl = LJ::API::BitLy->shorten( 'http://m.livejournal.com/read/user/'
+         . $entry->journal->user . '/' . $entry->ditemid . '/' );
+    undef $tinyurl if $tinyurl =~ /^500/;
+    
+# There is a new [[abbrev]] announcement in [[journal]]. Reply with READ [[journal]] to read it. [[disclaimer]]
+    return LJ::Lang::get_text($lang, 'notification.sms.officialpost', undef, {
+        abbrev     => $LJ::SITENAMEABBREV,
+        journal    => $entry->journal->display_username,
+        disclaimer => $LJ::SMS_DISCLAIMER,
+        mobile_url => $tinyurl,
+    });    
 }
 
 # esn.officialpost.alert=There is a new [[sitenameabbrev]] announcement in [[username]]. Reply with READ [[username]] to read it. Standard rates apply.

Modified: trunk/cgi-bin/LJ/Event/PollVote.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/PollVote.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Event/PollVote.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -54,9 +54,15 @@
 ## notification methods
 
 sub as_string {
-    my $self = shift;
-    return sprintf("%s has voted in %s at %s",
-                   $self->voter->display_username, $self->pollname, $self->entry->url);
+    my ($self, $u) = @_;
+    my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG;
+
+# [[voter]] has voted in [[pollname]] at [[entry_url]]
+    return LJ::Lang::get_text($lang, 'notification.sms.pollvote', undef, {
+        voter     => $self->voter->display_username, 
+        pollname  => $self->pollname, 
+        entry_url => $self->entry->url
+    });    
 }
 
 sub as_html {

Modified: trunk/cgi-bin/LJ/Event/UserExpunged.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/UserExpunged.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Event/UserExpunged.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -11,8 +11,13 @@
 }
 
 sub as_string {
-    my $self = shift;
-    return $self->event_journal->display_username . " has been purged.";
+    my ($self, $u) = @_;
+    my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG;
+
+# [[journal]] has been purged.
+    return LJ::Lang::get_text($lang, 'notification.sms.userexpunged', undef, {
+        journal => $self->event_journal->display_username,
+    });    
 }
 
 sub as_alert {

Modified: trunk/cgi-bin/LJ/Event/UserMessageRecvd.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/UserMessageRecvd.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Event/UserMessageRecvd.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -128,12 +128,17 @@
 }
 
 sub as_sms {
-    my $self = shift;
+    my ($self, $u) = @_;
+    my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG;
 
     my $subject = $self->load_message->subject;
     my $other_u = $self->load_message->other_u;
-    return sprintf("You've received a new message \"%s\" from %s",
-                   $subject, $other_u->user);
+
+# You've received a new message "[[subject]]" from [[user]]
+    return LJ::Lang::get_text($lang, 'notification.sms.usermessagerecvd', undef, {
+        subject => $subject,
+        user    => $other_u->user,
+    });    
 }
 
 sub as_alert {

Modified: trunk/cgi-bin/LJ/Event/UserMessageSent.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/UserMessageSent.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Event/UserMessageSent.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -45,11 +45,15 @@
 }
 
 sub as_string {
-    my $self = shift;
+    my ($self, $u) = @_;
+    my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG;
 
     my $other_u = $self->load_message->other_u;
-    return sprintf("message sent to %s.",
-                   $other_u->{user});
+
+# message sent to [[user]].
+    return LJ::Lang::get_text($lang, 'notification.sms.usermessagesent', undef, {
+        user    => $other_u->{user},
+    });    
 }
 
 sub subscription_as_html {''}

Modified: trunk/cgi-bin/LJ/Event/UserNewEntry.pm
===================================================================
--- trunk/cgi-bin/LJ/Event/UserNewEntry.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Event/UserNewEntry.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -100,16 +100,22 @@
 }
 
 sub as_sms {
-    my $self = shift;
+    my ($self, $u) = @_;
+    my $lang = ($u && $u->prop('browselang')) || $LJ::DEFAULT_LANG;
 
     my $entry = $self->entry;
-    my $where = "in their journal";
-    unless ($entry->posterid == $entry->journalid) {
-        $where = "in '" . $entry->journal->{user} . "'";
-    }
-
-    return sprintf("User '%s' posted $where", $self->poster->{user});
-
+    my $mlstring = ($entry->posterid == $entry->journalid)? 'notification.sms.usernewentry':'notification.sms.usernewentry_comm';
+    my $tinyurl = LJ::API::BitLy->shorten( 'http://m.livejournal.com/read/user/'
+         . $entry->journal->user . '/' . $entry->ditemid . '/' );
+    undef $tinyurl if $tinyurl =~ /^500/;
+        
+# User '[[user]]' posted in their journal
+# User '[[user]]' posted '[[journal]]'
+    return LJ::Lang::get_text($lang, '.string', undef, {
+        user       => $self->poster->{user},
+        journal    => $entry->journal->{user},
+        mobile_url => $tinyurl,
+    });    
 }
 
 # esn.user_new_entry.in_their_journal.alert=User '[[user]]' posted in their journal

Modified: trunk/cgi-bin/LJ/Event.pm
===================================================================
--- trunk/cgi-bin/LJ/Event.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Event.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -481,9 +481,9 @@
 #
 # $txtlj->send($u, $event->as_sms($u));
 sub as_sms {
-    my $self = shift;
+    my ($self, $u) = @_;
     return LJ::Text->truncate_with_ellipsis(
-        'str' => $self->as_string,
+        'str' => $self->as_string($u),
         'bytes' => 160,
         'ellipsis' => '...',
     );

Modified: trunk/cgi-bin/LJ/Widget/SubscribeInterface.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/SubscribeInterface.pm	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/cgi-bin/LJ/Widget/SubscribeInterface.pm	2011-02-25 09:02:46 UTC (rev 18411)
@@ -30,10 +30,6 @@
     ){
         @ntypes = grep { $_ ne 'LJ::NotificationMethod::SMSru' ? 1 : 0 } @ntypes;
     }
-    ## LJSUP-7040. We are disable using SMS Notifications for Basic accounts
-    if (!$u->get_cap('paid') && !$u->in_class('plus')) {
-        @ntypes = grep { $_ ne 'LJ::NotificationMethod::SMSru' ? 1 : 0 } @ntypes;
-    }
 
     my $colnum = scalar(@ntypes) + 1;
 

Modified: trunk/htdocs/manage/profile/index.bml
===================================================================
--- trunk/htdocs/manage/profile/index.bml	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/htdocs/manage/profile/index.bml	2011-02-25 09:02:46 UTC (rev 18411)
@@ -491,15 +491,8 @@
         my $text_messaging_country = ($country eq 'RU') || ($country eq 'KZ');
         $ret .= "<a name='txtmsg'></a><div class='section_head'>" . 
             ($text_messaging_country ? $ML{'.section.phone'} : $ML{'.section.textmsg'}) . "\n";
-        unless (LJ::get_cap($u, "textmessaging")) {
-            my $inline;
-            if ($inline .= LJ::run_hook("cprod_inline", $u, 'TextMessaging')) {
-                $ret .= "</div>$inline";
-            } else {
-                $ret .= "</div>".BML::ml('cprod.textmessaging.text3.v1');
-            }
-        }
-        if (LJ::get_cap($u, "textmessaging")) {
+            
+        if ($text_messaging_country || LJ::get_cap($u, "textmessaging")) {
             my $tminfo = LJ::TextMessage->tm_info($u, remap_result => 1);
             foreach (values %$tminfo) { LJ::text_out(\$_); }
             $tminfo->{'security'} = "N" if ($u->{'txtmsg_status'} eq 'off' || $u->{'txtmsg_status'} eq 'none');
@@ -541,8 +534,7 @@
             $ret .= '<li class="b-manage-smsn-sms">';
             #$ret .= '<select name="txtmsg_number_code" class="b-manage-smsn-code" disabled="disabled"><option value="+7">+7</option></select>' . ' ';
             $ret .= LJ::html_text({ 'name' => 'txtmsg_number', 'value' => $tminfo->{'number'}, 'size' => '16', 'maxlength' => '16', 'class' => 'b-manage-smsn-phone' });
-            $ret .= '<br /><span class="helper">' . $ML{'.section.textmsg.example_us'} . '</span></li>' if $country eq 'US';
-            $ret .= '<br /><span class="helper">' . $ML{'.section.textmsg.example_ru'} . '</span></li>' if $country eq 'RU';
+            $ret .= '<br /><span class="helper">' . $ML{'.section.textmsg.example_' . ($text_messaging_country?'ru':'us')} . '</span></li>';
             $ret .= '<br /><span class="helper">' . $ML{'.section.textmsg.example_kz'} . '</span></li>' if $country eq 'KZ';
             $ret .= '<li class="b-manage-smsn-status"><i class="i-manage-smsn-icon"></i><i class="help-icon">' . LJ::help_icon('sms_notification') . '</i><span class="i-bubble b-bubble-lite"><i class="i-bubble-arrow-border"></i><i class="i-bubble-arrow"></i><span>' . $ML{'.section.textmsg.info'} . ' </span></span></li>';
             $ret .= "<li class='b-manage-smsn-btn'><input type='button' name='sendsms' value='$ML{'.section.textmsg.button'}' disabled='disabled' /></li>";
@@ -554,6 +546,29 @@
                 $ret .= '<div class="helper">' . $ML{'.section.textmsg.adv'} . '</div>';
             }
 			$ret .= "</td></tr>\n";
+			
+            if( $text_messaging_country && LJ::NotificationMethod::SMSru->configured_for_user($u) ){
+                my($start, $end) = split /-/, $u->prop( 'smsru_interval' );
+                $ret .= "<tr id=\"sms_time\"><td class='field_name'>$ML{'.fn.smsinterval'}</td><td>";
+                $ret .= BML::ml(".fn.smsinterval.info", {url=>'manage'}) . "<br />";
+         
+                $ret .= LJ::html_check({ 'type' => 'check', 'name' => 'sms_interval', 'id' => 'sms_interval',
+                    'selected' =>  defined $start });
+                $ret .= "<label for='sms_interval'>$ML{'.fn.smsinterval.limitrange'}</label><br/>";
+            
+                my @sms_time = map {$_ =>  sprintf("%02d:00", $_)} (0 .. 23);
+                $ret .= "<label for='sms_interval_start'>$ML{'.fn.smsinterval.start'}</label>";
+                $ret .= LJ::html_select({ 'name' => 'sms_interval_start',
+                                                  'selected' => $start || 9, },
+                                                  @sms_time);
+                $ret .= "<label for='sms_interval_end'>$ML{'.fn.smsinterval.end'}</label>";
+                $ret .= LJ::html_select({ 'name' => 'sms_interval_end',
+                                                  'selected' => $end || 1, },
+                                                  @sms_time);
+                $ret .= BML::ml(".fn.smsinterval.localtime") . "<br />";
+    			$ret .= "</td></tr>\n";
+            }
+            
             $ret .= "</table>\n";
 
 			$ret .= "<script type='text/javascript'>";
@@ -575,8 +590,15 @@
 			     for qw(already_use correctNum requestsent smssent badtrans notasubscriber
 			            singlelimitexceeded totallimitexceeded verified wrongcode linkexpired techerror);
 			$ret .= "}</script>\n";
+        }else{
+            my $inline;
+            if ($inline .= LJ::run_hook("cprod_inline", $u, 'TextMessaging')) {
+                $ret .= "</div>$inline";
+            } else {
+                $ret .= "</div>".BML::ml('cprod.textmessaging.text3.v1');
+            }
         }
-
+    
         ## FRIENDS
         $ret .= "<div class='section_head'>$ML{'.section.friends'}</div>\n";
 
@@ -698,7 +720,21 @@
                 }
             }
         }
+        
+        if( defined $POST{sms_interval} || defined $POST{sms_interval_start} 
+            || defined $POST{sms_interval_end}){
+            if( $POST{sms_interval} ){
+                my $start = $POST{sms_interval_start}+0;
+                my $end = $POST{sms_interval_end}+0;
+                $start = 9 unless ($start >= 0) && ($start <= 23);
+                $end = 1 unless ($end >= 0) && ($end <= 23);
+                $u->set_prop( smsru_interval => "$start-$end" );
 
+            }else{
+                $u->set_prop( smsru_interval => undef ); 
+            }
+        }
+        
         # FIXME: validation AND POSTING are handled by widgets' handle_post() methods
         # (introduce validate_post() ?)
         my $save_search_index = $POST{'opt_showlocation'} =~ /^[YR]$/;

Modified: trunk/htdocs/manage/profile/index.bml.text
===================================================================
--- trunk/htdocs/manage/profile/index.bml.text	2011-02-25 08:28:36 UTC (rev 18410)
+++ trunk/htdocs/manage/profile/index.bml.text	2011-02-25 09:02:46 UTC (rev 18411)
@@ -169,6 +169,18 @@
 
 .fn.vernum=Verification number
 
+.fn.smsinterval=SMS Interval
+
+.fn.smsinterval.info=You can manage your subscriptions <a href="[[url]]">here</a>
+
+.fn.smsinterval.limitrange=Limit range
+
+.fn.smsinterval.start=Send from
+
+.fn.smsinterval.end=till
+
+.fn.smsinterval.localtime=you local timezone.
+
 .fn.zip=ZIP Code
 
 .friendof=Show other users who have friended you, but you have not friended

Tags: bml, dat, fortl, livejournal, pm, text
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