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

[ljcom] r9763: LJSUP-7462 (refactor userprops)

Committer: ailyin
LJSUP-7462 (refactor userprops)
U   trunk/cgi-bin/LJ/Hooks/CreatePage.pm
U   trunk/cgi-bin/LJ/Hooks/Underage.pm
U   trunk/cgi-bin/LJ/Pay.pm
U   trunk/cgi-bin/ljcom.pl
U   trunk/htdocs/agecheck/consent.bml
U   trunk/htdocs/community/promotions.bml
U   trunk/htdocs/manage/account/adsettings.bml
U   trunk/htdocs/manage/voicepost.bml
U   trunk/htdocs/singles/mod.bml
Modified: trunk/cgi-bin/LJ/Hooks/CreatePage.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/CreatePage.pm	2010-11-26 05:25:41 UTC (rev 9762)
+++ trunk/cgi-bin/LJ/Hooks/CreatePage.pm	2010-11-29 04:05:00 UTC (rev 9763)
@@ -151,7 +151,7 @@
         $atype = 'plus' unless $atype =~ /^(plus|paid|sponsored)$/;
     }
 
-    LJ::set_userprop($u, "create_accttype", $atype);
+    $u->set_prop( 'create_accttype' => $atype );
 
     return 1 if LJ::is_enabled("basic_signup") && $atype eq 'free' && !$u->is_person;
 

Modified: trunk/cgi-bin/LJ/Hooks/Underage.pm
===================================================================
--- trunk/cgi-bin/LJ/Hooks/Underage.pm	2010-11-26 05:25:41 UTC (rev 9762)
+++ trunk/cgi-bin/LJ/Hooks/Underage.pm	2010-11-29 04:05:00 UTC (rev 9763)
@@ -69,9 +69,7 @@
         url urlname gender jabber journaltitle journalsubtitle
         friendspagetitle external_foaf_url
     );
-    foreach my $prop (@toclear) {
-        LJ::set_userprop($u, $prop, undef);
-    }
+    $u->set_prop({ map { $_ => undef } @toclear });
 
 });
 

Modified: trunk/cgi-bin/LJ/Pay.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay.pm	2010-11-26 05:25:41 UTC (rev 9762)
+++ trunk/cgi-bin/LJ/Pay.pm	2010-11-29 04:05:00 UTC (rev 9763)
@@ -233,18 +233,14 @@
     return 1 if $u->{allow_pay} eq 'Y';
 
     # set allow_pay on this user if necessary
-    if (LJ::set_userprop($u, 'allow_pay', 'Y')) {
+    $u->set_prop( 'allow_pay' => 'Y' );
 
-        # log to statushistory
-        my $sys_id = LJ::get_userid('system');
-        LJ::statushistory_add($u, $sys_id, "allow_pay", "automatically allowing payments after successful transaction");
+    # log to statushistory
+    my $sys_id = LJ::get_userid('system');
+    LJ::statushistory_add($u, $sys_id, "allow_pay", "automatically allowing payments after successful transaction");
 
-        # successfully set
-        return 1;
-    }
-
-    # error setting userprop above
-    return undef;
+    # successfully set
+    return 1;
 }
 
 sub send_fraud_email {

Modified: trunk/cgi-bin/ljcom.pl
===================================================================
--- trunk/cgi-bin/ljcom.pl	2010-11-26 05:25:41 UTC (rev 9762)
+++ trunk/cgi-bin/ljcom.pl	2010-11-29 04:05:00 UTC (rev 9763)
@@ -1121,7 +1121,9 @@
 LJ::register_hook("delete_friend_group", sub {
     my ($u, $bit) = @_;
     LJ::load_user_props($u, 'pp_transallow');
-    LJ::set_userprop($u, 'pp_transallow', -1) if $bit == $u->{pp_transallow};
+
+    $u->set_prop( 'pp_transallow' => -1 )
+        if $bit == $u->{pp_transallow};
 });
 
 LJ::register_hook("forbid_request", sub {

Modified: trunk/htdocs/agecheck/consent.bml
===================================================================
--- trunk/htdocs/agecheck/consent.bml	2010-11-26 05:25:41 UTC (rev 9762)
+++ trunk/htdocs/agecheck/consent.bml	2010-11-29 04:05:00 UTC (rev 9763)
@@ -25,7 +25,7 @@
 
     # now do the work
     LJ::mark_authaction_used($aa);
-    LJ::set_userprop($u, 'parent_email', $aa->{arg1});
+    $u->set_prop( 'parent_email' => $aa->{'arg1'} );
     $u->underage(0, undef, "parent email verification; email=$aa->{arg1}");
 
     # and now we have to send an email validation notice to the child's email

Modified: trunk/htdocs/community/promotions.bml
===================================================================
--- trunk/htdocs/community/promotions.bml	2010-11-26 05:25:41 UTC (rev 9762)
+++ trunk/htdocs/community/promotions.bml	2010-11-29 04:05:00 UTC (rev 9763)
@@ -102,7 +102,7 @@
 
         # If there are no errors save the options and proceed
         unless(@errors) {
-            LJ::set_userprop($u, "ad_categories", $POST{'cat'});
+            $u->set_prop( 'ad_categories' => $POST{'cat'} );
 
             return BML::redirect("$LJ::SITEROOT/newuser.bml?authas=$authas")
                 if $POST{'signup'};

Modified: trunk/htdocs/manage/account/adsettings.bml
===================================================================
--- trunk/htdocs/manage/account/adsettings.bml	2010-11-26 05:25:41 UTC (rev 9762)
+++ trunk/htdocs/manage/account/adsettings.bml	2010-11-29 04:05:00 UTC (rev 9763)
@@ -182,12 +182,8 @@
                 $POST{'state'} = $POST{'statedrop'} || $POST{'stateother'};
 
                 # set userprops
-                foreach my $uprop (@uprops) {
-                    my $eff_val = $POST{$uprop};   # effective value, since 0 isn't stored
-                    $eff_val = "" unless $eff_val;
-                    my $mem_only = $eff_val eq $u->{$uprop};
-                    LJ::set_userprop($u, $uprop, $eff_val, $mem_only);
-                }
+                my %props_update = map { $_ => $POST{$_} } @uprops;
+                $u->set_prop(\%props_update);
 
                 my %update;
                 $update{'bdate'} = sprintf("%04d-%02d-%02d", $POST{'year'}, $bdpart{'month'}, $bdpart{'day'}) if $POST{'year'};
@@ -198,7 +194,7 @@
             }
 
             # Write comma-delimited category list
-            LJ::set_userprop($u, "ad_categories", join(",", @list));
+            $u->set_prop( 'ad_categories' => join(',', @list) );
 
             if (LJ::is_enabled("basic_ads") && LJ::is_enabled("basic_ad_options") && $u->is_personal && LJ::run_hook("user_is_basic", $u)) {
                 my $advis = $POST{ad_visibility} =~ /^[BJA]$/ ? $POST{ad_visibility} : 'B';

Modified: trunk/htdocs/manage/voicepost.bml
===================================================================
--- trunk/htdocs/manage/voicepost.bml	2010-11-26 05:25:41 UTC (rev 9762)
+++ trunk/htdocs/manage/voicepost.bml	2010-11-29 04:05:00 UTC (rev 9763)
@@ -78,11 +78,11 @@
                  $phone, $POST{pin}, $remote->{userid});
 
         $POST{quickpost} = undef if $POST{quickpost} eq 'private';
-        LJ::set_userprop( $remote, 'pp_transallow', $POST{trans} );
-        LJ::set_userprop( $remote, 'pp_format',     $POST{format} );
-        LJ::set_userprop( $remote, 'pp_quickpost',  $POST{quickpost} );
-        LJ::set_userprop( $remote, 'pp_vpgroup',    $POST{vfriends} );
-        LJ::set_userprop( $remote, 'pp_no_spinvox', $POST{no_spinvox} );
+        $u->set_prop({ 'pp_transallow' => $POST{'trans'},
+                       'pp_format'     => $POST{'format'},
+                       'pp_quickpost'  => $POST{'quickpost'},
+                       'pp_vpgroup'    => $POST{'vfriends'},
+                       'pp_no_spinvox' => $POST{'no_spinvox'}, });
 
         $saved = qq{
             <?warningbar

Modified: trunk/htdocs/singles/mod.bml
===================================================================
--- trunk/htdocs/singles/mod.bml	2010-11-26 05:25:41 UTC (rev 9762)
+++ trunk/htdocs/singles/mod.bml	2010-11-29 04:05:00 UTC (rev 9763)
@@ -31,7 +31,7 @@
     if (LJ::did_post()) 
     {
         unless ($POST{'status'}) {
-            LJ::set_userprop($u, "single_status", "");
+            $u->clear_prop('single_status');
             return "Saved.  You won't show up as available.";
         }
 
@@ -50,10 +50,10 @@
             $POST{'age'} >= 18;
         return $ML{'Error'} unless ($POST{'status'} =~ /^[MF][MF]$/);
 
-        LJ::set_userprop($u, "single_status",
-                         join("|", map { $POST{$_} } qw(status country state city age)));
-        LJ::set_userprop($u, "single_pickw",
-                         $POST{'single_pickw'});
+        $u->set_prop( { 'single_status' => join( "|", map { $POST{$_} }
+                                                      qw( status country
+                                                          state city age ) ),
+                        'single_pickw' => $POST{'single_pickw'}, });
 
         $ret .= "Saved.  Now, <a href='search.bml'>go search</a> for somebody!";
         return $ret;

Tags: andy, bml, ljcom, pl, 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