Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[ljcom] r9300: LJSUP-6137 (FaceBook authorization. Serv...

Committer: ailyin
LJSUP-6137 (FaceBook authorization. Server side): checkpoint commit
U   branches/facebook-integration2/bin/upgrading/en_LJ.dat
U   branches/facebook-integration2/cgi-bin/LJ/Setting/Display/AccountLevel.pm
A   branches/facebook-integration2/cgi-bin/LJ/Widget/ConvertIdentityAccount.pm
U   branches/facebook-integration2/cvs/multicvs-local.conf
A   branches/facebook-integration2/htdocs/identity/convert.bml
A   branches/facebook-integration2/htdocs/identity/convert.bml.text.local
A   branches/facebook-integration2/templates/Identity/Convert.tmpl
Modified: branches/facebook-integration2/bin/upgrading/en_LJ.dat
===================================================================
--- branches/facebook-integration2/bin/upgrading/en_LJ.dat	2010-07-30 07:33:43 UTC (rev 9299)
+++ branches/facebook-integration2/bin/upgrading/en_LJ.dat	2010-08-03 05:57:31 UTC (rev 9300)
@@ -1423,6 +1423,54 @@
 
 Email=E-mail
 
+email.converted_identity.body.A<<
+You're ready to embark on an exciting journey and discover friends, old and new, who share your hobbies and interests!
+
+Here are your vital stats:
+
+ Username: [[username]]
+
+ Journal URL: [[journal_base]]/
+
+ Forgot your password? To receive a reminder, click here:  [[lostinfourl]]
+
+You're all set!
+
+Once you validate your email, you'll be ready to customize and post to your Journal, find friends, and complete your user profile.  We look forward to getting to know you better! 
+
+Best,
+
+The [[sitename]] Team
+.
+
+email.converted_identity.body.N<<
+You're ready to embark on an exciting journey and discover friends, old and new, who share your hobbies and interests!
+
+Here are your vital stats:
+
+ Username: [[username]]
+
+ Journal URL: [[journal_base]]/
+
+ Forgot your password? To receive a reminder, click here:  [[lostinfourl]]
+
+Please click the following link to validate your email address*: 
+
+[[regurl]]
+
+*If you're unable to click on this link, copy and paste it into your browser window.
+
+You need to validate your email to gain access to all the cool features of your new account (posting comments, posting entries in communities, receiving comment notification emails, etc.). Validation is also very important for protecting the security of your new journal.
+
+You're all set!
+
+Once you validate your email, you'll be ready to customize and post to your Journal, find friends, and complete your user profile.  We look forward to getting to know you better! 
+
+Best,
+
+The [[sitename]] Team
+.
+
 email.newacct.body<<
 Congratulations, you have a new LiveJournal account!
 
@@ -2383,6 +2431,8 @@
 
 horizon.nav.home=Home
 
+horizon.nav.identity_convert=Upgrade to full account
+
 horizon.nav.journal=Journal
 
 horizon.nav.journal.calendar=Calendar
@@ -4893,6 +4943,8 @@
 setting.display.accountlevel.actionlink.basic|staleness=1
 setting.display.accountlevel.actionlink.basic=Upgrade
 
+setting.display.accountlevel.actionlink.identity_convert=Upgrade to full account
+
 setting.display.accountlevel.actionlink.paid|staleness=1
 setting.display.accountlevel.actionlink.paid=Manage
 

Modified: branches/facebook-integration2/cgi-bin/LJ/Setting/Display/AccountLevel.pm
===================================================================
--- branches/facebook-integration2/cgi-bin/LJ/Setting/Display/AccountLevel.pm	2010-07-30 07:33:43 UTC (rev 9299)
+++ branches/facebook-integration2/cgi-bin/LJ/Setting/Display/AccountLevel.pm	2010-08-03 05:57:31 UTC (rev 9300)
@@ -12,13 +12,18 @@
 sub helpurl {
     my ($class, $u) = @_;
 
-    return "account_levels";
+    return 'identity_convert' if $u->is_identity;
+    return 'account_levels';
 }
 
 sub actionlink {
     my ($class, $u) = @_;
 
-    return "" if $u->is_identity;
+    if ($u->is_identity) {
+        my $text =
+            LJ::Lang::ml('setting.display.accountlevel.actionlink.identity_convert');
+        return "<a href='$LJ::SSLROOT/identity/convert.bml'>$text</a>";
+    }
 
     my $paid_url = $u->is_community ? "$LJ::SITEROOT/community/account.bml?authas=" . $u->user : "$LJ::SITEROOT/manage/account/";
     my $plus_url = $u->is_community ? "$LJ::SITEROOT/community/account.bml?authas=" . $u->user : "$LJ::SITEROOT/manage/account/?changelevel=1";

Added: branches/facebook-integration2/cgi-bin/LJ/Widget/ConvertIdentityAccount.pm
===================================================================
--- branches/facebook-integration2/cgi-bin/LJ/Widget/ConvertIdentityAccount.pm	                        (rev 0)
+++ branches/facebook-integration2/cgi-bin/LJ/Widget/ConvertIdentityAccount.pm	2010-08-03 05:57:31 UTC (rev 9300)
@@ -0,0 +1,225 @@
+package LJ::Widget::ConvertIdentityAccount;
+use strict;
+
+use base qw(LJ::Widget::CreateAccount);
+
+sub need_res { return qw(); }
+
+sub render_body {
+    my ($class, %opts) = @_;
+
+    my $post = $opts{post};
+    my $get = $opts{get};
+    my $from_post = $opts{from_post};
+    my $errors = $from_post->{errors};
+    my $remote = LJ::get_remote();
+
+    my $template = LJ::HTML::Template->new(
+        { use_expr => 1 }, # force HTML::Template::Pro with Expr support
+        filename => "$ENV{'LJHOME'}/templates/Identity/Convert.tmpl",
+    ) or die "Can't open template: $!";
+
+    $template->param(
+        'form_intro' => LJ::form_auth(),
+        'input_prefix' => $class->input_prefix,
+    );
+
+    $template->param( "form_$_" => LJ::ehtml($post->{$_} || $get->{$_}) )
+        foreach qw( user password1 password2 );
+
+    my %bdpart;
+    if ($remote->{'bdate'} =~ /^(\d\d\d\d)-(\d\d)-(\d\d)$/) {
+        ($bdpart{'year'}, $bdpart{'month'}, $bdpart{'day'}) = ($1, $2, $3);
+        if ($bdpart{'year'} eq "0000") { $bdpart{'year'} = ""; }
+        if ($bdpart{'day'} eq "00") { $bdpart{'day'} = ""; }
+    }
+
+    $template->param(
+        'form_email'     => LJ::ehtml( $post->{'email'}
+                                    || $get->{'email'}
+                                    || $remote->email_raw ),
+        'form_bday_dd'   => LJ::ehtml( $post->{'bday_dd'}
+                                    || $get->{'bday_dd'}
+                                    || $bdpart{'day'} ),
+        'form_bday_yyyy' => LJ::ehtml( $post->{'bday_yyy'}
+                                    || $get->{'bday_yyy'}
+                                    || $bdpart{'year'} ),
+    );
+
+    my $selected_gender    = $post->{'gender'}  || $get->{'gender'}
+                          || $remote->prop('gender') || 'U';
+
+    my $selected_bday_mm   = $post->{'bday_mm'} || $get->{'bday_mm'}
+                          || $bdpart{'month'};
+
+    my $selected_sharebday = $post->{'sharebday'} || $get->{'sharebday'}
+                          || $remote->prop('opt_sharebday') || 'A';
+
+    my @bday_month_options;
+    foreach my $mon (1..12) {
+        push @bday_month_options, {
+            'value' => $mon,
+            'name' => LJ::Lang::ml(LJ::Lang::month_long_langcode($mon)),
+            'selected' => ($selected_bday_mm == $mon),
+        };
+    }
+
+    my $captcha_html;
+
+    my $captcha = Captcha::reCAPTCHA->new;
+    $captcha_html .= $captcha->get_options_setter({
+        'theme' => 'white',
+        'lang'  => BML::get_language(),
+    });
+    $captcha_html .= $captcha->get_html(
+        LJ::conf_test($LJ::RECAPTCHA{public_key}), '', $LJ::IS_SSL );
+
+    $template->param(
+        'gender_options' => [
+            {
+                'value' => 'U',
+                'name' => LJ::Lang::ml(
+                    '/manage/profile/index.bml.gender.unspecified'),
+                'selected' => $selected_gender eq 'U',
+            },
+            {
+                'value' => 'M',
+                'name' => LJ::Lang::ml(
+                    '/manage/profile/index.bml.gender.male'),
+                'selected' => $selected_gender eq 'M',
+            },
+            {
+                'value' => 'F',
+                'name' => LJ::Lang::ml(
+                    '/manage/profile/index.bml.gender.female'),
+                'selected' => $selected_gender eq 'F',
+            },
+        ],
+        'bday_month_options' => \@bday_month_options,
+        'captcha_html' => $captcha_html,
+    );
+
+    $template->param( "error_$_" => LJ::ehtml($errors->{$_}) )
+        foreach qw( username email password confirmpass gender bday captcha );
+
+    return $template->output;
+}
+
+sub create_account {
+    my ($class, $opts) = @_;
+    my %opts = %$opts;
+
+    my $u = LJ::get_remote() or return;
+
+    LJ::User::Rename::basic_rename($u->username, $opts{'user'}, {
+        'token' => '[convert]',
+    });
+    $u->{'user'} = $opts{'user'};
+
+    my $bdate    = $opts{bdate}    || "0000-00-00";
+    my $email    = $opts{email}    || "";
+    my $status   = $email eq $u->email_raw ? $u->email_status : 'N';
+    my $password = $opts{password} || "";
+
+    LJ::update_user($u, {
+        'journaltype' => 'P',
+        'bdate' => $bdate,
+        'email' => $email,
+        'password' => $password,
+        'status' => $status,
+        %LJ::USER_INIT,
+    });
+    $u->remove_identity;
+
+    $u->set_prop("init_bdate", $opts{bdate});
+
+    # so birthday notifications get sent
+    $u->set_next_birthday;
+
+    # Set the default style
+    LJ::run_hook('set_default_style', $u);
+
+    # if we have initial friends for new accounts, add them.
+    my @initial_friends =
+        LJ::SUP->is_sup_enabled($u)
+        ? @LJ::SUP_INITIAL_FRIENDS
+        : @LJ::INITIAL_FRIENDS;
+
+    foreach my $friend (@initial_friends) {
+        my $friendid = LJ::get_userid($friend);
+        LJ::add_friend($u->id, $friendid) if $friendid;
+    }
+
+    # populate some default friends groups
+    my %res;
+    LJ::do_request(
+                   {
+                       'mode'           => 'editfriendgroups',
+                       'user'           => $u->user,
+                       'ver'            => $LJ::PROTOCOL_VER,
+                       'efg_set_1_name' => 'Family',
+                       'efg_set_2_name' => 'Local Friends',
+                       'efg_set_3_name' => 'Online Friends',
+                       'efg_set_4_name' => 'School',
+                       'efg_set_5_name' => 'Work',
+                       'efg_set_6_name' => 'Mobile View',
+                   }, \%res, { 'u' => $u, 'noauth' => 1, }
+                   );
+
+    $u->set_prop("newpost_minsecurity", "friends") if $u->is_child;
+
+    # now flag as underage (and set O to mean was old or Y to mean was young)
+    $u->underage(1, $opts{ofage} ? 'O' : 'Y', 'account creation') if $opts{underage};
+
+    # For settings that are to be set explicitly
+    # on create, with more private settings for non-adults
+    if ($u->underage || $u->is_child) {
+        $u->set_prop("opt_findbyemail", 'N');
+    } else {
+        $u->set_prop("opt_findbyemail", 'H');
+    }
+
+    return $u;
+}
+
+sub send_welcome_email {
+    my ($class, $nu) = @_;
+
+    my $email = $nu->email_raw;
+
+    my $mlkey = $nu->is_validated ? 'email.converted_identity.body.A' :
+                                    'email.converted_identity.body.N';
+
+    my $validate_url;
+    unless ($nu->is_validated) {
+        my $aa = LJ::register_authaction($nu->id, "validateemail", $email);
+        $validate_url = "$LJ::SITEROOT/confirm/$aa->{'aaid'}.$aa->{'authcode'}";
+    }
+
+    my $body = LJ::Lang::ml($mlkey, {
+        sitename => $LJ::SITENAME,
+        regurl => $validate_url,
+        journal_base => $nu->journal_base,
+        username => $nu->user,
+        siteroot => $LJ::SITEROOT,
+        sitenameshort => $LJ::SITENAMESHORT,
+        lostinfourl => "$LJ::SITEROOT/lostinfo.bml",
+        editprofileurl => "$LJ::SITEROOT/manage/profile/",
+        searchinterestsurl => "$LJ::SITEROOT/interests.bml",
+        editpicsurl => "$LJ::SITEROOT/editpics.bml",
+        customizeurl => "$LJ::SITEROOT/customize/",
+        postentryurl => "$LJ::SITEROOT/update.bml",
+        setsecreturl => "$LJ::SITEROOT/set_secret.bml",
+    });
+
+    LJ::send_mail({
+        to => $email,
+        from => $LJ::DONOTREPLY_EMAIL,
+        fromname => $LJ::SITENAME,
+        charset => 'utf-8',
+        subject => LJ::Lang::ml('email.newacct.subject', { sitename => $LJ::SITENAME }),
+        body => $body,
+    });
+}
+
+1;

Modified: branches/facebook-integration2/cvs/multicvs-local.conf
===================================================================
--- branches/facebook-integration2/cvs/multicvs-local.conf	2010-07-30 07:33:43 UTC (rev 9299)
+++ branches/facebook-integration2/cvs/multicvs-local.conf	2010-08-03 05:57:31 UTC (rev 9300)
@@ -94,3 +94,4 @@
 ljcomint/site/htdocs/stc/horizon/10years/10years-out-logo.jpg    ssldocs/stc/horizon/10years/10years-out-logo.jpg
 ljcomint/site/htdocs/stc/horizon/10years/10years-usericon.gif    ssldocs/stc/horizon/10years/10years-usericon.gif
 
+ljcom/htdocs/identity/convert.bml                               ssldocs/identity/convert.bml

Added: branches/facebook-integration2/htdocs/identity/convert.bml
===================================================================
--- branches/facebook-integration2/htdocs/identity/convert.bml	                        (rev 0)
+++ branches/facebook-integration2/htdocs/identity/convert.bml	2010-08-03 05:57:31 UTC (rev 9300)
@@ -0,0 +1,53 @@
+<?page
+body<=
+<?_code
+{
+#line 6
+    use strict;
+    use vars qw($title %GET %POST $getextra);
+
+    $title = LJ::Lang::ml('.title');
+
+    my $u = LJ::get_remote();
+
+    return LJ::needlogin_redirect() unless $u;
+    return LJ::Lang::ml('.error.not_identity') unless ($u->is_identity);
+
+    return LJ::Request->redirect("$LJ::SSLROOT/identity/convert.bml")
+        unless $LJ::IS_SSL;
+
+    my %from_post;
+    if (LJ::Request->did_post) {
+        LJ::Widget->use_specific_form_fields(
+            'post' => \%POST,
+            'widget' => "ConvertIdentityAccount",
+            'fields' => [ qw( recaptcha_response_field
+                              recaptcha_challenge_field ) ]
+        );
+        %from_post = LJ::Widget->handle_post(
+            \%POST,
+            "ConvertIdentityAccount", { 'get'       => \%GET,
+                                        'getextra'  => $getextra, }
+        );
+
+        return if LJ::Request->redirected;
+    }
+
+    my $ret;
+
+    $ret .= "<div id='create-page'>";
+    $ret .= LJ::Widget::ConvertIdentityAccount->render( 
+        post        => LJ::Widget::ConvertIdentityAccount->post_fields(\%POST), 
+        get         => \%GET, 
+        from_post   => \%from_post,
+    );
+    $ret .= '</div>';
+    return $ret;
+}
+_code?>
+<=body
+title=><?_code return $title; _code?>
+head<=
+<?_code return $headextra; _code?>
+<=head
+page?>

Added: branches/facebook-integration2/htdocs/identity/convert.bml.text.local
===================================================================
--- branches/facebook-integration2/htdocs/identity/convert.bml.text.local	                        (rev 0)
+++ branches/facebook-integration2/htdocs/identity/convert.bml.text.local	2010-08-03 05:57:31 UTC (rev 9300)
@@ -0,0 +1,12 @@
+.title=Join LiveJournal
+
+.error.not_identity=You are not logged in with an identity account, so you cannot access this page.
+
+.subtitle=Find yourself and each other on LiveJournal!
+
+.intro=LiveJournal is a global journaling platform that helps you share your unique passions and interests and form deep connections with friends, old and new! Whether you’re interested is baking, writing, politics, photography, or pretty much anything else, you’re sure to find like-minded friends from around the corner and around the world!
+
+.form.title=It only takes a few minutes to sign up! Here's all we need:
+
+.tosagree=By clicking the "Convert Account" button below, you agree to our <a href="http://www.livejournal.com/legal/tos.bml">Terms of Service</a> and <a href="http://www.livejournal.com/legal/privacy.bml">Privacy Policy</a>.
+

Added: branches/facebook-integration2/templates/Identity/Convert.tmpl
===================================================================
--- branches/facebook-integration2/templates/Identity/Convert.tmpl	                        (rev 0)
+++ branches/facebook-integration2/templates/Identity/Convert.tmpl	2010-08-03 05:57:31 UTC (rev 9300)
@@ -0,0 +1,103 @@
+<h2><TMPL_VAR expr="ml('.subtitle')"></h2>
+
+<p><TMPL_VAR expr="ml('.intro')"></p>
+
+<h2><TMPL_VAR expr="ml('.form.title')"></h2>
+
+<form action="" method="post">
+<TMPL_VAR form_intro>
+
+<table>
+
+<tr>
+    <td><label for="<TMPL_VAR input_prefix>_user"><TMPL_VAR expr="ml('widget.createaccount.field.username')"></label></td>
+    <td>
+        <input type="text" name="<TMPL_VAR input_prefix>_user" id="<TMPL_VAR input_prefix>_user" value="<TMPL_VAR form_user>">
+        <TMPL_IF error_username>
+            <p class="error"><TMPL_VAR error_username></p>
+        </TMPL_IF>
+    </td>
+</tr>
+
+<tr>
+    <td><label for="<TMPL_VAR input_prefix>_email"><TMPL_VAR expr="ml('widget.createaccount.field.email')"></label></td>
+    <td>
+        <input type="text" name="<TMPL_VAR input_prefix>_email" id="<TMPL_VAR input_prefix>_email" value="<TMPL_VAR form_email>">
+        <TMPL_IF error_email>
+            <p class="error"><TMPL_VAR error_email></p>
+        </TMPL_IF>
+    </td>
+</tr>
+
+<tr>
+    <td><label for="<TMPL_VAR input_prefix>_password1"><TMPL_VAR expr="ml('widget.createaccount.field.password')"></label></td>
+    <td>
+        <input type="password" name="<TMPL_VAR input_prefix>_password1" id="<TMPL_VAR input_prefix>_password1" value="<TMPL_VAR form_password1>">
+        <TMPL_IF error_password>
+            <p class="error"><TMPL_VAR error_password></p>
+        </TMPL_IF>
+    </td>
+</tr>
+
+<tr>
+    <td><label for="<TMPL_VAR input_prefix>_password2"><TMPL_VAR expr="ml('widget.createaccount.field.confirmpassword')"></label></td>
+    <td>
+        <input type="password" name="<TMPL_VAR input_prefix>_password2" id="<TMPL_VAR input_prefix>_password2" value="<TMPL_VAR form_password2>">
+        <TMPL_IF error_confirmpass>
+            <p class="error"><TMPL_VAR error_confirmpass></p>
+        </TMPL_IF>
+    </td>
+</tr>
+
+<tr>
+    <td><TMPL_VAR expr="ml('widget.createaccount.field.gender')"></td>
+    <td>
+        <TMPL_LOOP gender_options>
+            <input type="radio" name="<TMPL_VAR input_prefix>_gender" value="<TMPL_VAR value>"
+                id="<TMPL_VAR input_prefix>_gender_<TMPL_VAR value>" <TMPL_IF selected>checked="checked"</TMPL_IF>>
+            <label for="<TMPL_VAR input_prefix>_gender_<TMPL_VAR value>"><TMPL_VAR name></label>
+        </TMPL_LOOP>
+        <TMPL_IF error_gender>
+            <p class="error"><TMPL_VAR error_gender></p>
+        </TMPL_IF>
+    </td>
+</tr>
+
+<tr>
+    <td><TMPL_VAR expr="ml('widget.createaccount.field.birthdate')"></td>
+    <td>
+        <select name="<TMPL_VAR input_prefix>_bday_mm">
+            <TMPL_LOOP bday_month_options>
+                <option value="<TMPL_VAR value>" <TMPL_IF selected>selected="selected"</TMPL_IF>><TMPL_VAR name></option>
+            </TMPL_LOOP>
+        </select>
+        <input type="text" name="<TMPL_VAR input_prefix>_bday_dd" value="<TMPL_VAR form_bday_dd>">
+        <input type="text" name="<TMPL_VAR input_prefix>_bday_yyyy" value="<TMPL_VAR form_bday_yyyy>">
+        <TMPL_IF error_bday>
+            <p class="error"><TMPL_VAR error_bday></p>
+        </TMPL_IF>
+    </td>
+</tr>
+
+<tr>
+    <td colspan="2">
+        <TMPL_VAR captcha_html>
+        <TMPL_IF error_captcha>
+            <p class="error"><TMPL_VAR error_captcha></p>
+        </TMPL_IF>
+    </td>
+</tr>
+
+<tr>
+    <td colspan="2">
+        <p><TMPL_VAR expr="ml('.tosagree')"></p>
+
+        <button type="submit">Convert Account</button>
+    </td>
+</tr>
+
+</table>
+
+<form>
+
+<style type="text/css"> td { vertical-align: top; } </style>

Tags: andy, bml, conf, dat, 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