[dw-free] more aggressive adoption of $u->equals
[commit: http://hg.dwscoalition.org/dw-free/rev/7ae60c4b9299]
http://bugs.dwscoalition.org/show_bug.cgi?id=2740
Used $u->equals( $otheru ) instead of $u->{userid} == $otheru->{userid} as
much as possible; where it isn't, clean up the code style and use the
$u->userid function.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2740
Used $u->equals( $otheru ) instead of $u->{userid} == $otheru->{userid} as
much as possible; where it isn't, clean up the code style and use the
$u->userid function.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/LJ/Customize.pm
- cgi-bin/LJ/Entry.pm
- cgi-bin/LJ/S2.pm
- cgi-bin/LJ/S2/FriendsPage.pm
- cgi-bin/LJ/SixDegrees.pm
- cgi-bin/LJ/Talk.pm
- cgi-bin/LJ/User.pm
- cgi-bin/ljprotocol.pl
- htdocs/admin/priv/index.bml
- htdocs/community/settings.bml
- htdocs/customize/advanced/layers.bml
- htdocs/customize/advanced/styles.bml
- htdocs/customize/viewuser.bml
- htdocs/delcomment.bml
- htdocs/interests.bml
- htdocs/manage/circle/add.bml
- htdocs/support/see_request.bml
- htdocs/talkread.bml
- htdocs/view/index.bml
-------------------------------------------------------------------------------- diff -r 9175155e222a -r 7ae60c4b9299 cgi-bin/LJ/Customize.pm --- a/cgi-bin/LJ/Customize.pm Tue Jun 29 11:03:29 2010 -0500 +++ b/cgi-bin/LJ/Customize.pm Wed Jun 30 00:15:33 2010 +0800 @@ -105,7 +105,7 @@ sub verify_and_load_style { $style = undef; } - unless ($style && $style->{'userid'} == $u->{'userid'}) { + unless ( $style && $style->{userid} == $u->userid ) { my $theme; if ($LJ::DEFAULT_STYLE->{theme}) { $theme = LJ::S2Theme->load_by_uniq($LJ::DEFAULT_STYLE->{theme}); @@ -424,8 +424,8 @@ sub load_all_s2_props { $layer->{b2lid} = $LJ::S2LID_REMAP{$b2lid}; } - die "Layer belongs to another user. $layer->{userid} vs $u->{userid}" unless $layer->{'userid'} == $u->{'userid'}; - die "Layer isn't of type user or theme." unless $layer->{'type'} eq "user" || $layer->{'type'} eq "theme"; + die "Layer belongs to another user. $layer->{userid} vs $u->{userid}" unless $layer->{userid} == $u->userid; + die "Layer isn't of type user or theme." unless $layer->{type} eq "user" || $layer->{type} eq "theme"; my @layerids = $class->get_layerids($style); LJ::S2::load_layers(@layerids); @@ -764,7 +764,7 @@ sub s2_implicit_style_create # Create new style if necessary my $s2style = LJ::S2::load_style($u->prop('s2_style')); - if (! ($s2style && $s2style->{'userid'} eq $u->{'userid'}) || $opts->{'force'}) { + if ( ! ( $s2style && $s2style->{userid} == $u->userid ) || $opts->{force} ) { my $themeid = $style{theme}; my $layoutid = $style{layout}; my $layer = $pub->{$themeid} || $userlay->{$themeid} || $userlay->{$layoutid}; diff -r 9175155e222a -r 7ae60c4b9299 cgi-bin/LJ/Entry.pm --- a/cgi-bin/LJ/Entry.pm Tue Jun 29 11:03:29 2010 -0500 +++ b/cgi-bin/LJ/Entry.pm Wed Jun 30 00:15:33 2010 +0800 @@ -1640,7 +1640,7 @@ sub get_log2_recent_user if ($item->{'security'} eq 'usemask') { next unless $remote->is_individual; - my $permit = ($item->{'journalid'} == $remote->{'userid'}); + my $permit = ( $item->{journalid} == $remote->userid ); unless ($permit) { # $mask for $item{journalid} should always be the same since get_log2_recent_log # selects based on the $u we pass in; $u->id == $item->{journalid} from what I can see @@ -1714,7 +1714,7 @@ sub get_itemid_near2 my $remote = LJ::get_remote(); if ($remote) { - if ($remote->{'userid'} == $u->{'userid'}) { + if ( $remote->equals( $u ) ) { $secwhere = ""; # see everything } elsif ( $remote->is_individual ) { my $gmask = $u->is_community ? $remote->member_of( $u ) : $u->trustmask( $remote ); @@ -1797,7 +1797,7 @@ sub set_logprop $u->do("REPLACE INTO logprop2 (journalid, jitemid, propid, value) ". "VALUES $ins_values") if $ins_values; $u->do("DELETE FROM logprop2 WHERE journalid=? AND jitemid=? ". - "AND propid IN ($del_ids)", undef, $u->{'userid'}, $jitemid) if $del_ids; + "AND propid IN ($del_ids)", undef, $u->userid, $jitemid) if $del_ids; LJ::MemCache::delete([$uid,"logprop:$uid:$jitemid"]) if $kill_mem; } @@ -2015,11 +2015,11 @@ sub reject_entry_as_spam { # step 1: get info we need my ($posterid, $logtime) = $dbcr->selectrow_array( "SELECT posterid, logtime FROM modlog WHERE journalid=? AND modid=?", - undef, $journalu->{'userid'}, $modid); + undef, $journalu->userid, $modid); my $frozen = $dbcr->selectrow_array( "SELECT request_stor FROM modblob WHERE journalid=? AND modid=?", - undef, $journalu->{'userid'}, $modid); + undef, $journalu->userid, $modid); use Storable; my $req = $frozen ? Storable::thaw($frozen) : undef; diff -r 9175155e222a -r 7ae60c4b9299 cgi-bin/LJ/S2.pm --- a/cgi-bin/LJ/S2.pm Tue Jun 29 11:03:29 2010 -0500 +++ b/cgi-bin/LJ/S2.pm Wed Jun 30 00:15:33 2010 +0800 @@ -928,7 +928,7 @@ sub create_style return 0 unless $name =~ /\S/; $dbh->do("INSERT INTO s2styles (userid, name, modtime) VALUES (?,?, UNIX_TIMESTAMP())", - undef, $u->{'userid'}, $name); + undef, $u->userid, $name); my $styleid = $dbh->{'mysql_insertid'}; return 0 unless $styleid; @@ -950,7 +950,7 @@ sub load_user_styles my $load_using = sub { my $db = shift; my $sth = $db->prepare("SELECT styleid, name FROM s2styles WHERE userid=?"); - $sth->execute($u->{'userid'}); + $sth->execute( $u->userid ); while (my ($id, $name) = $sth->fetchrow_array) { $styles{$id} = $name; } @@ -1291,15 +1291,15 @@ sub layer_compile $s2ref = \$s2; } - my $is_system = $layer->{'userid'} == LJ::get_userid("system"); - my $untrusted = ! $LJ::S2_TRUSTED{$layer->{'userid'}} && ! $is_system; + my $is_system = $layer->{userid} == LJ::get_userid( "system" ); + my $untrusted = ! $LJ::S2_TRUSTED{$layer->{userid}} && ! $is_system; # system writes go to global. otherwise to user clusters. my $dbcm; if ($is_system) { $dbcm = $dbh; } else { - my $u = LJ::load_userid($layer->{'userid'}); + my $u = LJ::load_userid( $layer->{userid} ); $dbcm = $u; } @@ -1372,7 +1372,7 @@ sub layer_compile my $gzipped = LJ::text_compress($compiled); $dbcm->do("REPLACE INTO s2compiled2 (userid, s2lid, comptime, compdata) ". "VALUES (?, ?, UNIX_TIMESTAMP(), ?)", undef, - $layer->{'userid'}, $lid, $gzipped) or die "replace into s2compiled2 (lid = $lid)"; + $layer->{userid}, $lid, $gzipped) or die "replace into s2compiled2 (lid = $lid)"; } # delete from memcache; we can't store since we don't know the exact comptime @@ -2604,7 +2604,7 @@ sub viewer_is_owner my $remote = LJ::get_remote(); return 0 unless $remote; return 0 unless defined($LJ::S2::CURR_PAGE); - return $remote->{userid} == $LJ::S2::CURR_PAGE->{_u}->{userid}; + return $remote->equals( $LJ::S2::CURR_PAGE->{_u} ); } # NOTE: this method is old and deprecated, but we still support it for people @@ -3742,7 +3742,7 @@ sub _Entry__get_link } if ($key eq "tell_friend") { return $null_link unless LJ::is_enabled('tellafriend'); - my $entry = LJ::Entry->new($journalu->{'userid'}, ditemid => $this->{'itemid'}); + my $entry = LJ::Entry->new( $journalu->userid, ditemid => $this->{itemid} ); return $null_link unless $entry->can_tellafriend($remote); return LJ::S2::Link("$LJ::SITEROOT/tools/tellafriend?journal=$journal&itemid=$this->{'itemid'}", $ctx->[S2::PROPS]->{"text_tell_friend"}, diff -r 9175155e222a -r 7ae60c4b9299 cgi-bin/LJ/S2/FriendsPage.pm --- a/cgi-bin/LJ/S2/FriendsPage.pm Tue Jun 29 11:03:29 2010 -0500 +++ b/cgi-bin/LJ/S2/FriendsPage.pm Wed Jun 30 00:15:33 2010 +0800 @@ -87,8 +87,8 @@ sub FriendsPage # load options for image links my ($maximgwidth, $maximgheight) = (undef, undef); ($maximgwidth, $maximgheight) = ($1, $2) - if ($remote && $remote->{'userid'} == $u->{'userid'} && - $remote->{'opt_imagelinks'} =~ m/^(\d+)\|(\d+)$/); + if ( $remote && $remote->equals( $u ) && + $remote->{opt_imagelinks} =~ m/^(\d+)\|(\d+)$/ ); ## never have spiders index friends pages (change too much, and some ## people might not want to be indexed) diff -r 9175155e222a -r 7ae60c4b9299 cgi-bin/LJ/SixDegrees.pm --- a/cgi-bin/LJ/SixDegrees.pm Tue Jun 29 11:03:29 2010 -0500 +++ b/cgi-bin/LJ/SixDegrees.pm Wed Jun 30 00:15:33 2010 +0800 @@ -32,7 +32,7 @@ sub find_path $cache->{$fu->{userid}} = $fu; $cache->{$tu->{userid}} = $tu; - my $memkey = [ $fu->{'userid'}, "6dpath:$fu->{userid}:$tu->{userid}" ]; + my $memkey = [ $fu->userid, "6dpath:$fu->{userid}:$tu->{userid}" ]; my $exp = 3600; my $path = LJ::MemCache::get($memkey); unless ($path) { @@ -52,20 +52,20 @@ sub _find_path_helper my $time_start = time(); # user is themselves (one element in path) - return [$fu->{userid}] if $fu->{'userid'} == $tu->{'userid'}; + return [$fu->userid] if $fu->equals( $tu ); # from user befriends to user (two elements in path my $fu_friends = links_out($fu, $cache); - if (intersect($fu_friends, [ $tu->{'userid'} ])) { + if ( intersect( $fu_friends, [ $tu->userid ] ) ) { $cache->{'note'} = "2 way path"; - return [$fu->{userid}, $tu->{userid}]; + return [$fu->userid, $tu->userid]; } # try to find a three-way path (fu has a friend who lists tu as a friend) my $tu_friendofs = links_in($tu, $cache); if (my $via = intersect($fu_friends, $tu_friendofs)) { $cache->{'note'} = "3 way path"; - return [$fu->{userid}, $via, $tu->{userid}]; + return [$fu->userid, $via, $tu->userid]; } # try to find four-way path by expanding fu's friends' friends, diff -r 9175155e222a -r 7ae60c4b9299 cgi-bin/LJ/Talk.pm --- a/cgi-bin/LJ/Talk.pm Tue Jun 29 11:03:29 2010 -0500 +++ b/cgi-bin/LJ/Talk.pm Wed Jun 30 00:15:33 2010 +0800 @@ -720,7 +720,7 @@ sub get_talk_data # find all singletons that LJ::Comment knows about, then grep for the ones we've set in # this get_talk_data call (ones for this userid / nodeid) my @comments_for_entry = - grep { $_->journalid == $u->{userid} && $_->nodeid == $nodeid } LJ::Comment->all_singletons; + grep { $_->journalid == $u->userid && $_->nodeid == $nodeid } LJ::Comment->all_singletons; $entry->set_comment_list(@comments_for_entry); }; @@ -3391,7 +3391,7 @@ sub require_captcha_test { ## ## 2. Don't show captcha to the owner of the journal, no more checks ## - if (!$anon_commenter && $commenter->{userid}==$journal->{userid}) { + if ( !$anon_commenter && $commenter->equals( $journal ) ) { return; } diff -r 9175155e222a -r 7ae60c4b9299 cgi-bin/LJ/User.pm --- a/cgi-bin/LJ/User.pm Tue Jun 29 11:03:29 2010 -0500 +++ b/cgi-bin/LJ/User.pm Wed Jun 30 00:15:33 2010 +0800 @@ -1056,7 +1056,7 @@ sub kill_all_sessions { or return 0; # forget this user, if we knew they were logged in - if ($LJ::CACHE_REMOTE && $LJ::CACHE_REMOTE->userid == $u->userid) { + if ( $LJ::CACHE_REMOTE && $u->equals( $LJ::CACHE_REMOTE ) ) { LJ::Session->clear_master_cookie; LJ::User->set_remote(undef); } @@ -1074,7 +1074,7 @@ sub kill_session { $sess->destroy; - if ($LJ::CACHE_REMOTE && $LJ::CACHE_REMOTE->userid == $u->userid) { + if ( $LJ::CACHE_REMOTE && $u->equals( $LJ::CACHE_REMOTE ) ) { LJ::Session->clear_master_cookie; LJ::User->set_remote(undef); } @@ -8382,8 +8382,8 @@ sub make_journal { # hashref has the value of $u's opt_nctalklinks (though with # LJ::load_user caching, this may be assigning between the same # underlying hashref) - $remote->{'opt_nctalklinks'} = $u->{'opt_nctalklinks'} if - ( $remote && $remote->userid == $u->userid ); + $remote->{opt_nctalklinks} = $u->{opt_nctalklinks} + if $remote && $remote->equals( $u ); my $stylesys = 1; if ($styleid == -1) { diff -r 9175155e222a -r 7ae60c4b9299 cgi-bin/ljprotocol.pl --- a/cgi-bin/ljprotocol.pl Tue Jun 29 11:03:29 2010 -0500 +++ b/cgi-bin/ljprotocol.pl Wed Jun 30 00:15:33 2010 +0800 @@ -1162,8 +1162,8 @@ sub postevent my @owner_props = qw(newpost_minsecurity moderated); $u->preload_props( @poster_props, @owner_props ); - if ($uowner->{'userid'} == $u->{'userid'}) { - $uowner->{$_} = $u->{$_} foreach (@owner_props); + if ( $u->equals( $uowner ) ) { + $uowner->{$_} = $u->{$_} foreach @owner_props; } else { $uowner->preload_props( @owner_props ); } @@ -1731,14 +1731,7 @@ sub editevent { ## deleting. return fail($err,304) - if ($req->{'event'} !~ /\S/ && ! - ($ownerid == $u->{'userid'} || - # community account can delete it (ick) - - $u->can_manage_other( $uowner ) - # if user is a community maintainer they can delete - # it too (good) - )); + if $req->{'event'} !~ /\S/ && ! $u->can_manage( $uowner ); ## editing: if ($req->{'event'} =~ /\S/) { @@ -1755,7 +1748,7 @@ sub editevent # if their newesteventtime prop equals the time of the one they're deleting # then delete their newesteventtime. - if ($u->{'userid'} == $uowner->{'userid'}) { + if ( $u->equals( $uowner ) ) { $u->preload_props( { use_master => 1 }, "newesteventtime" ); if ($u->{'newesteventtime'} eq $oldevent->{'eventtime'}) { $u->set_prop( "newesteventtime", undef ); @@ -1877,7 +1870,7 @@ sub editevent $qallowmask != $oldevent->{'allowmask'}) { # are they changing their most recent post? - if ( $u->{userid} == $uowner->{userid} && + if ( $u->equals( $uowner ) && $u->prop( "newesteventtime" ) eq $oldevent->{eventtime} ) { # did they change the time? if ($eventtime ne $oldevent->{eventtime}) { diff -r 9175155e222a -r 7ae60c4b9299 htdocs/admin/priv/index.bml --- a/htdocs/admin/priv/index.bml Tue Jun 29 11:03:29 2010 -0500 +++ b/htdocs/admin/priv/index.bml Wed Jun 30 00:15:33 2010 +0800 @@ -120,7 +120,7 @@ body<= { $dbh->do("DELETE FROM priv_map WHERE prmid=$prmid"); my $privcode = $priv{$prlid}->{'privcode'}; - LJ::statushistory_add( $del_userid1, $remote->{'userid'}, "privdel", + LJ::statushistory_add( $del_userid1, $remote->userid, "privdel", "Denying: \"$privcode\" with arg \"$arg\"" ); $ret .= "Privilege removed.<br />\n"; } @@ -130,7 +130,7 @@ body<= if ($FORM{'grantpriv'}) { my $u = LJ::load_user($FORM{'user'}); return "<b>ERROR:</b> Invalid User." unless $u; - my $userid = $u->{'userid'}; + my $userid = $u->userid; my $qpriv = $FORM{'grantpriv'}+0; my $privcode = $priv{$qpriv}->{'privcode'}; my $arg = $FORM{'arg'}; @@ -142,7 +142,7 @@ body<= } else { my $qarg = $dbh->quote($arg); $dbh->do("INSERT INTO priv_map (prmid, userid, prlid, arg) VALUES (NULL, $userid, $qpriv, $qarg)"); - LJ::statushistory_add( $userid, $remote->{'userid'}, "privadd", "Granting: \"$privcode\" with arg \"$arg\"" ); + LJ::statushistory_add( $userid, $remote->userid, "privadd", "Granting: \"$privcode\" with arg \"$arg\"" ); $ret .= "Privilege <b>$privcode $arg</b> granted.<br />\n"; } } else { @@ -155,7 +155,7 @@ body<= if ($FORM{'grantuser'}) { my $u = LJ::load_user($FORM{'grantuser'}); return "ERROR: Invalid user." unless $u; - my $userid = $u->{'userid'}; + my $userid = $u->userid; my $privid = $pcode2id{$FORM{'priv'}}; my $arg = $FORM{'arg'}; my $qarg = $dbh->quote($arg); @@ -168,7 +168,7 @@ body<= elsif ($userid && $privid) { my $qarg = $dbh->quote($FORM{'arg'}); $dbh->do("INSERT INTO priv_map (prmid, userid, prlid, arg) VALUES (NULL, $userid, $privid, $qarg)"); - LJ::statushistory_add( $userid, $remote->{'userid'}, "privadd", "Granting: \"$privcode\" with arg \"$FORM{'arg'}\"" ); + LJ::statushistory_add( $userid, $remote->userid, "privadd", "Granting: \"$privcode\" with arg \"$FORM{'arg'}\"" ); $ret .= "Privilege added.<br />\n"; } else { @@ -215,7 +215,7 @@ body<= my $pcode = $priv{$prlid}->{'privcode'}; my $can_grant = remote_can_grant($remote, $pcode, $arg); - next unless ($prec->{'is_public'} || ($remote && $remote->{'userid'} == $userid) || $can_grant); + next unless $prec->{is_public} || ( $remote && $remote->userid == $userid ) || $can_grant; $ret .= "<tr><td align='center'>"; if ($can_grant) { diff -r 9175155e222a -r 7ae60c4b9299 htdocs/community/settings.bml --- a/htdocs/community/settings.bml Tue Jun 29 11:03:29 2010 -0500 +++ b/htdocs/community/settings.bml Wed Jun 30 00:15:33 2010 +0800 @@ -76,13 +76,11 @@ body<= my $cuser = LJ::canonical_username($POST{'cuser'}); my $cu = LJ::load_user($cuser); - unless ($cu) { - $errors{'username'} = $ML{'.error.notfound'}; - } + + $errors{username} = $ML{'.error.notfound'} unless $cu; - if ($cu && $cu->{'userid'} == $remote->{'userid'}) { - $errors{'username'} = $ML{'.error.samenames'}; - } + $errors{username} = $ML{'.error.samenames'} + if $cu && $cu->equals( $remote ); # if we're changing rather than creating, check that we can if ( $mode eq 'modify' && ! $remote->can_manage_other( $cu ) ) { diff -r 9175155e222a -r 7ae60c4b9299 htdocs/customize/advanced/layers.bml --- a/htdocs/customize/advanced/layers.bml Tue Jun 29 11:03:29 2010 -0500 +++ b/htdocs/customize/advanced/layers.bml Wed Jun 30 00:15:33 2010 +0800 @@ -124,7 +124,7 @@ _c?> return $err->($ML{'.error.cantcreatelayer'}) unless $id; my $lay = { - 'userid' => $u->{'userid'}, + 'userid' => $u->userid, 'type' => $type, 'b2lid' => $parid, 's2lid' => $id, @@ -152,7 +152,7 @@ _c?> unless $lay; return $err->($ML{'.error.notyourlayer'}) - unless $lay->{'userid'} == $u->{'userid'}; + unless $lay->{userid} == $u->userid; unless ($POST{'confirm'}) { my $layerinfo = {}; diff -r 9175155e222a -r 7ae60c4b9299 htdocs/customize/advanced/styles.bml --- a/htdocs/customize/advanced/styles.bml Tue Jun 29 11:03:29 2010 -0500 +++ b/htdocs/customize/advanced/styles.bml Wed Jun 30 00:15:33 2010 +0800 @@ -108,7 +108,7 @@ _c?> # check that they own the style return $err->($ML{'.error.notyourstyle'}) - unless $style->{'userid'} == $u->{'userid'}; + unless $style->{userid} == $u->userid; # use selected style if ($POST{'action:usestyle'} && !$noactions) { diff -r 9175155e222a -r 7ae60c4b9299 htdocs/customize/viewuser.bml --- a/htdocs/customize/viewuser.bml Tue Jun 29 11:03:29 2010 -0500 +++ b/htdocs/customize/viewuser.bml Wed Jun 30 00:15:33 2010 +0800 @@ -56,8 +56,9 @@ _c?> if ($u->{'stylesys'} == 2) { $style = LJ::S2::load_style($u->{'s2_style'}); - return $err->("Style not found.") unless $style && $style->{'userid'} == $u->{'userid'}; - $layer = LJ::S2::load_layer($dbh, $style->{'layer'}->{'user'}); + return $err->( "Style not found." ) + unless $style && $style->{userid} == $u->userid; + $layer = LJ::S2::load_layer( $dbh, $style->{layer}->{user} ); } unless ($layer) { @@ -65,9 +66,10 @@ _c?> return; } - return $err->($ML{'.layer.belongs'}) unless $layer->{'userid'} == $u->{'userid'}; - return $err->($ML{'.layer.isnt.type2'}) - unless $layer->{'type'} eq "user"; + return $err->( $ML{'.layer.belongs'} ) + unless $layer->{userid} == $u->userid; + return $err->( $ML{'.layer.isnt.type2'} ) + unless $layer->{type} eq "user"; my $lyr_layout = LJ::S2::load_layer($dbh, $layer->{'b2lid'}); return $err->(BML::ml('.layout.layer', {'layertype'=>$layer->{'type'}})) diff -r 9175155e222a -r 7ae60c4b9299 htdocs/delcomment.bml --- a/htdocs/delcomment.bml Tue Jun 29 11:03:29 2010 -0500 +++ b/htdocs/delcomment.bml Wed Jun 30 00:15:33 2010 +0800 @@ -76,7 +76,7 @@ _info?><?_code "nodeid AS 'itemid', parenttalkid, journalid, posterid " . "FROM talk2 ". "WHERE journalid=? AND jtalkid=?", - undef, $u->{'userid'}, $tpid); + undef, $u->userid, $tpid); return $bad_input->($ML{'.error.nocomment'}) unless $tp; @@ -93,7 +93,7 @@ _info?><?_code # userid of user who posted journal entry my $jposterid = $dbcr->selectrow_array("SELECT posterid FROM log2 WHERE " . "journalid=? AND jitemid=?", - undef, $u->{'userid'}, $tp->{'itemid'}); + undef, $u->userid, $tp->{itemid}); my $jposter = LJ::load_userid($jposterid); # can $remote delete this comment? @@ -105,9 +105,9 @@ _info?><?_code my $can_manage = $remote->can_manage( $u ); # can ban if can manage and the comment is by someone else and not anon - my $can_ban = $can_manage && $tp->{'posterid'} - && $remote && $remote->{'userid'} != $tp->{'posterid'}; - my $can_delthread = $can_manage || $jposterid == $remote->{userid}; + my $can_ban = $can_manage && $tp->{posterid} + && $remote && $remote->userid != $tp->{posterid}; + my $can_delthread = $can_manage || $jposterid == $remote->userid; # can mark as spam if they're not the comment poster # or if the account is not sysbanned diff -r 9175155e222a -r 7ae60c4b9299 htdocs/interests.bml --- a/htdocs/interests.bml Tue Jun 29 11:03:29 2010 -0500 +++ b/htdocs/interests.bml Wed Jun 30 00:15:33 2010 +0800 @@ -123,7 +123,7 @@ body<= my $dbh = LJ::get_db_writer(); my $uitable = $table->($remote); $dbh->do("INSERT INTO $uitable (userid, intid) VALUES (?, ?)", - undef, $remote->{'userid'}, $intid); + undef, $remote->userid, $intid); LJ::memcache_kill($remote, "intids"); unless ($dbh->err) { $dbh->do("UPDATE interests SET intcount=intcount+1 WHERE intid=?", undef, $intid); @@ -131,7 +131,7 @@ body<= # if a community, remove any old rows from userinterests if ( $remote->is_community ) { - $dbh->do("DELETE FROM userinterests WHERE userid=?", undef, $remote->{'userid'}); + $dbh->do( "DELETE FROM userinterests WHERE userid=?", undef, $remote->userid ); } $ret .= "<?h1 $ML{'.add.added.head'} h1?><?p $ML{'.add.added.text'} p?>"; @@ -152,7 +152,7 @@ body<= my $dbr = LJ::get_db_reader(); my $sth = $dbr->prepare("SELECT i.intid, i.intcount FROM userinterests ui, interests i ". "WHERE ui.userid=? AND ui.intid=i.intid"); - $sth->execute($u->{'userid'}); + $sth->execute( $u->userid ); while (my ($intid, $count) = $sth->fetchrow_array) { push @ints, $intid; $intcount{$intid} = $count || 1; @@ -171,7 +171,7 @@ body<= my $sth = $dbr->prepare("SELECT userid FROM userinterests WHERE intid=? LIMIT 500"); $sth->execute($int); while (my $uid = $sth->fetchrow_array) { - next if $uid == $u->{'userid'}; + next if $uid == $u->userid; $pt_weight{$uid} += (1 / log($intcount{$int}+1)); $pt_count{$uid}++; } @@ -223,8 +223,8 @@ body<= my $altauthas = $remote->{'user'} ne $u->{'user'}; my $getextra = $altauthas ? "?authas=$u->{'user'}" : ''; - my $userid = $u->{'userid'}; - my $username = $u->{'user'}; + my $userid = $u->userid; + my $username = $u->user; my $fromu = LJ::load_user($GET{'fromuser'} || $username); my %uint; @@ -243,7 +243,7 @@ body<= $ret .= "</form> p?><form method='post' action='interests$getextra'>"; $ret .= "<?h1 $ML{'.enmasse.header'} h1?><?p "; - if ($u->{'userid'} == $fromu->{'userid'}) { + if ( $u->equals( $fromu ) ) { %uint = %fromint; $ret .= $ML{'.enmasse.body.you'}; } else { @@ -330,7 +330,7 @@ body<= my $intid_in = join(",", @todel); my $dbh = LJ::get_db_writer(); $dbh->do("DELETE FROM $uitable WHERE userid=? AND intid IN ($intid_in)", - undef, $u->{'userid'}); + undef, $u->userid); $dbh->do("UPDATE interests SET intcount=intcount-1 WHERE intid IN ($intid_in)"); $deleted = 1; } @@ -340,7 +340,7 @@ body<= } else { my $dbh = LJ::get_db_writer(); my $sqlp = "(?,?)" . (",(?,?)" x (scalar(@toadd) - 1)); - my @bindvars = map { ($u->{'userid'}, $_) } @toadd; + my @bindvars = map { ( $u->userid, $_ ) } @toadd; $dbh->do("REPLACE INTO $uitable (userid, intid) VALUES $sqlp", undef, @bindvars); my $intid_in = join(",", @toadd); @@ -352,7 +352,7 @@ body<= # if a community, remove any old rows from userinterests if ( $u->is_community ) { my $dbh = LJ::get_db_writer(); - $dbh->do("DELETE FROM userinterests WHERE userid=?", undef, $u->{'userid'}); + $dbh->do( "DELETE FROM userinterests WHERE userid=?", undef, $u->userid ); } my $ret = "<?h1 $ML{'.results.header'} h1?><?p "; diff -r 9175155e222a -r 7ae60c4b9299 htdocs/manage/circle/add.bml --- a/htdocs/manage/circle/add.bml Tue Jun 29 11:03:29 2010 -0500 +++ b/htdocs/manage/circle/add.bml Wed Jun 30 00:15:33 2010 +0800 @@ -63,7 +63,7 @@ _c?> return; } - unless ($remote->{'userid'} == $POST{'remid'}) { + unless ( $remote->userid == $POST{remid} ) { $title = $ML{'Error'}; $body = "<?h1 $ML{'Error'} h1?><?p $ML{'.error.sessionchanged'} p?>"; return; diff -r 9175155e222a -r 7ae60c4b9299 htdocs/support/see_request.bml --- a/htdocs/support/see_request.bml Tue Jun 29 11:03:29 2010 -0500 +++ b/htdocs/support/see_request.bml Wed Jun 30 00:15:33 2010 +0800 @@ -371,7 +371,7 @@ body<= $ret .= LJ::name_caps($u->{'caps'}) || "<i>$ML{'.unknown'}</i>"; $ret .= "</td></tr>\n"; - if ($u->{'userid'}) { + if ( $u->userid ) { $ret .= "<tr valign='top'><td align='right'><b>$LJ::SITENAMESHORT:</b></td><td>"; if ($u->is_expunged) { @@ -552,19 +552,18 @@ body<= $most_recent_tier = $le->{tier}; } - next if ($le->{'type'} eq "internal" && ! (LJ::Support::can_read_internal($sp, $remote) || - ($remote && $remote->{'userid'} == $le->{'userid'} ))); - next if ($le->{'type'} eq "screened" && ! (LJ::Support::can_read_screened($sp, $remote) || - ($remote && $remote->{'userid'} == $le->{'userid'} ))); + my $up = LJ::load_userid( $le->{userid} ); + my $remote_is_up = $remote && $remote->equals( $up ); - my $up = LJ::load_userid($le->{'userid'}); - next if ($le->{'type'} eq "screened") && $up && !$up->is_visible; + next if $le->{type} eq "internal" && ! ( LJ::Support::can_read_internal( $sp, $remote ) + || $remote_is_up ); + next if $le->{type} eq "screened" && ! ( LJ::Support::can_read_screened( $sp, $remote ) + || $remote_is_up ); + next if $le->{type} eq "screened" && $up && !$up->is_visible; - if ($le->{'type'} eq "screened") { - push @screened, $le; - } + push @screened, $le if $le->{type} eq "screened"; - my $message = $le->{'message'}; + my $message = $le->{message}; my %url; my $urlN = 0; diff -r 9175155e222a -r 7ae60c4b9299 htdocs/talkread.bml --- a/htdocs/talkread.bml Tue Jun 29 11:03:29 2010 -0500 +++ b/htdocs/talkread.bml Wed Jun 30 00:15:33 2010 +0800 @@ -514,7 +514,7 @@ body<= $bgcolor = BML::get_template_def($bgcolor); if ($post->{'state'} eq "S") { $bgcolor = BML::get_template_def("screenedbarcolor") || $bgcolor; - } elsif ($last_talkid == $dtid && $last_jid == $u->{'userid'}) { + } elsif ( $last_talkid == $dtid && $last_jid == $u->userid ) { $bgcolor = BML::get_template_def("altcolor1"); } @@ -700,7 +700,7 @@ body<= # Comment Posted Notice $ret .= "<br /><b>$ML{'.posted'}</b>" - if $last_talkid == $dtid && $last_jid == $u->{'userid'}; + if $last_talkid == $dtid && $last_jid == $u->userid; $ret .= "</td></tr><tr><td class='commentbody usercontent'>"; @@ -773,7 +773,7 @@ body<= # Comment Posted Notice $ret .= " - <b>$ML{'.posted'}</b>" - if $last_talkid == $dtid && $last_jid == $u->{'userid'}; + if $last_talkid == $dtid && $last_jid == $u->userid; $ret .= "</td></tr></tbody></table></span>\n"; } } diff -r 9175155e222a -r 7ae60c4b9299 htdocs/view/index.bml --- a/htdocs/view/index.bml Tue Jun 29 11:03:29 2010 -0500 +++ b/htdocs/view/index.bml Wed Jun 30 00:15:33 2010 +0800 @@ -102,8 +102,8 @@ _c?> } my $secwhere = "AND l.security='public'"; - if ($remote) { - if ($remote->{'userid'} == $u->{'userid'} || $viewall) { + if ( $remote ) { + if ( $remote->equals( $u ) || $viewall ) { $secwhere = ""; # see everything } elsif ( $remote->is_person ) { my $gmask = $u->trustmask( $remote ); --------------------------------------------------------------------------------