Migrate a lot of get_cap calls to LJ::User method calls, part of our
ongoing code cleanup project.
Patch by denise.
diffs (900 lines):
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/Apache/LiveJournal/Interface/S2.pm
--- a/cgi-bin/Apache/LiveJournal/Interface/S2.pm Wed Oct 21 17:24:56
2009 +0000
+++ b/cgi-bin/Apache/LiveJournal/Interface/S2.pm Wed Oct 21 17:30:30
2009 +0000
@@ -72,7 +72,7 @@ sub handler {
unless LJ::can_manage($u, $lu);
return error($r, 403, "Forbidden", "Your account type is not allowed
to edit layers")
- unless LJ::get_cap($u, "s2styles");
+ unless $u->can_create_s2_styles;
# Read in the entity body to get the source
my $len = $r->header_in("Content-length")+0;
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/DW/Logic/LogItems.pm
--- a/cgi-bin/DW/Logic/LogItems.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/DW/Logic/LogItems.pm Wed Oct 21 17:30:30 2009 +0000
@@ -63,7 +63,7 @@ sub watch_items
# friendspage per day is allowed only for journals with the special cap
'friendspage_per_day'
my $events_date = $args{events_date};
- $events_date = '' unless $remote && $u->get_cap( 'friendspage_per_day' );
+ $events_date = '' unless $remote && $u->can_use_daily_readpage;
my $filter = $args{content_filter};
my $max_age = $LJ::MAX_FRIENDS_VIEW_AGE || 3600*24*14; # 2 week default.
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/DW/Logic/MenuNav.pm
--- a/cgi-bin/DW/Logic/MenuNav.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/DW/Logic/MenuNav.pm Wed Oct 21 17:30:30 2009 +0000
@@ -53,7 +53,7 @@ sub get_menu_navigation {
my $loggedin = ( defined( $u ) && $u ) ? 1 : 0;
my $loggedin_hasjournal = ( $loggedin && !$u->is_identity ) ? 1 : 0;
my $loggedin_canjoincomms = ( $loggedin && $u->is_person ) ? 1 : 0; #
note the semantic difference
- my $loggedin_hasnetwork = ( $loggedin && LJ::get_cap($u,
"friendsfriendsview") ) ? 1 : 0;
+ my $loggedin_hasnetwork = ( $loggedin && $u->can_use_network_page ) ? 1 :
0;
my $loggedin_ispaid = ( $loggedin && $u->is_paid ) ? 1 : 0;
my $loggedout = $loggedin ? 0 : 1;
my $always = 1;
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/DW/Setting/EmailAlias.pm
--- a/cgi-bin/DW/Setting/EmailAlias.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/DW/Setting/EmailAlias.pm Wed Oct 21 17:30:30 2009 +0000
@@ -23,7 +23,7 @@ use warnings;
sub should_render {
my ( $class, $u ) = @_;
- return $u && LJ::get_cap( $u, 'useremail' ) ? 1 : 0;
+ return $u && $u->can_have_email_alias;
}
sub label {
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/DW/Setting/TxtMsgSetup.pm
--- a/cgi-bin/DW/Setting/TxtMsgSetup.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/DW/Setting/TxtMsgSetup.pm Wed Oct 21 17:30:30 2009 +0000
@@ -23,7 +23,7 @@ use warnings;
sub should_render {
my ( $class, $u ) = @_;
- return $u && $u->get_cap( 'textmessaging' ) ? 1 : 0;
+ return $u && $u->can_use_textmessaging;
}
sub label {
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/CProd/FriendsFriends.pm
--- a/cgi-bin/LJ/CProd/FriendsFriends.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/CProd/FriendsFriends.pm Wed Oct 21 17:30:30 2009 +0000
@@ -3,7 +3,7 @@ use base 'LJ::CProd';
sub applicable {
my ($class, $u) = @_;
- return 0 unless LJ::get_cap($u, "friendsfriendsview");
+ return 0 unless $u->can_use_network_page;
return 1;
}
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/CProd/Polls.pm
--- a/cgi-bin/LJ/CProd/Polls.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/CProd/Polls.pm Wed Oct 21 17:30:30 2009 +0000
@@ -3,7 +3,7 @@ use base 'LJ::CProd';
sub applicable {
my ($class, $u) = @_;
- return 0 unless LJ::get_cap($u, "makepoll");
+ return 0 unless $u->can_create_polls;
my $dbcr = LJ::get_cluster_reader( $u )
or return 0;
my $used_polls = $dbcr->selectrow_array( "SELECT pollid FROM poll2 WHERE
posterid=?",
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/Comment.pm
--- a/cgi-bin/LJ/Comment.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/Comment.pm Wed Oct 21 17:30:30 2009 +0000
@@ -903,7 +903,7 @@ sub user_can_edit {
# comment editing must be enabled and the user must have the cap
$$errref = LJ::Lang::ml('talk.error.cantedit');
return 0 unless LJ::is_enabled("edit_comments");
- return 0 unless $u->get_cap("edit_comments");
+ return 0 unless $u->can_edit_comments;
# entry cannot be suspended
return 0 if $self->entry->is_suspended;
diff -r d6762606a18d -r 6af3384bd954
cgi-bin/LJ/Console/Command/MoodthemeCreate.pm
--- a/cgi-bin/LJ/Console/Command/MoodthemeCreate.pm Wed Oct 21 17:24:56
2009 +0000
+++ b/cgi-bin/LJ/Console/Command/MoodthemeCreate.pm Wed Oct 21 17:30:30
2009 +0000
@@ -25,7 +25,7 @@ sub execute {
my $remote = LJ::get_remote();
return $self->error("Sorry, your account type doesn't let you create new
mood themes")
- unless $remote->get_cap("moodthemecreate");
+ unless $remote->can_create_moodthemes;
my $dbh = LJ::get_db_writer();
my $sth = $dbh->prepare("INSERT INTO moodthemes (ownerid, name, des,
is_public) VALUES (?, ?, ?, 'N')");
diff -r d6762606a18d -r 6af3384bd954
cgi-bin/LJ/Console/Command/MoodthemeSetpic.pm
--- a/cgi-bin/LJ/Console/Command/MoodthemeSetpic.pm Wed Oct 21 17:24:56
2009 +0000
+++ b/cgi-bin/LJ/Console/Command/MoodthemeSetpic.pm Wed Oct 21 17:30:30
2009 +0000
@@ -28,7 +28,7 @@ sub execute {
my $remote = LJ::get_remote();
return $self->error("Sorry, your account type doesn't let you create new
mood themes")
- unless $remote->get_cap("moodthemecreate");
+ unless $remote->can_create_moodthemes;
my $dbh = LJ::get_db_writer();
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/Customize.pm
--- a/cgi-bin/LJ/Customize.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/Customize.pm Wed Oct 21 17:30:30 2009 +0000
@@ -40,7 +40,7 @@ sub apply_theme {
my $theme = shift;
my %style;
- my $has_cap = $u->get_cap("s2styles");
+ my $has_cap = $u->can_create_s2_styles;
my $pub = LJ::S2::get_public_layers();
my $userlay = LJ::S2::get_layers_of_user($u);
@@ -272,7 +272,7 @@ sub get_custom_layouts_for_dropdown {
my @layers = ();
- my $has_cap = LJ::get_cap($u, "s2styles");
+ my $has_cap = $u->can_create_s2_styles;
my $userlay = LJ::S2::get_layers_of_user($u);
my %style = LJ::S2::get_style($u, "verify");
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/Event/JournalNewComment.pm
--- a/cgi-bin/LJ/Event/JournalNewComment.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/Event/JournalNewComment.pm Wed Oct 21 17:30:30 2009 +0000
@@ -447,7 +447,7 @@ sub matches_filter {
# not a match if this user posted the comment and they don't
# want to be notified of their own posts
if (LJ::u_equals($comment->poster, $watcher)) {
- return 0 unless $watcher->get_cap('getselfemail') &&
$watcher->prop('opt_getselfemail');
+ return 0 unless $watcher->can_get_self_email &&
$watcher->prop('opt_getselfemail');
}
# not a match if this user posted the entry and they don't want comments
emailed,
@@ -504,7 +504,7 @@ sub available_for_user {
my ($class, $u, $subscr) = @_;
# not allowed to track replies to comments
- return 0 if ! $u->get_cap('track_thread') &&
+ return 0 if ! $u->can_track_thread &&
$subscr->arg2;
return 1;
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/Event/NewUserpic.pm
--- a/cgi-bin/LJ/Event/NewUserpic.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/Event/NewUserpic.pm Wed Oct 21 17:30:30 2009 +0000
@@ -132,7 +132,7 @@ sub available_for_user {
sub available_for_user {
my ($class, $u, $subscr) = @_;
- return 0 if ! $u->get_cap('track_user_newuserpic') &&
+ return 0 if ! $u->can_track_new_userpic &&
$subscr->journalid;
return 1;
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/Event/PollVote.pm
--- a/cgi-bin/LJ/Event/PollVote.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/Event/PollVote.pm Wed Oct 21 17:30:30 2009 +0000
@@ -160,7 +160,7 @@ sub subscription_as_html {
# only users with the track_pollvotes cap can use this
sub available_for_user {
my ($class, $u, $subscr) = @_;
- return $u->get_cap("track_pollvotes") ? 1 : 0;
+ return $u->can_track_pollvotes;
}
1;
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/Event/RemovedFromCircle.pm
--- a/cgi-bin/LJ/Event/RemovedFromCircle.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/Event/RemovedFromCircle.pm Wed Oct 21 17:30:30 2009 +0000
@@ -188,7 +188,7 @@ sub subscription_as_html {
# only users with the track_defriended cap can use this
sub available_for_user {
my ( $class, $u, $subscr ) = @_;
- return $u->get_cap( 'track_defriended' ) ? 1 : 0;
+ return $u->can_track_defriending;
}
sub content {
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/S2.pm Wed Oct 21 17:30:30 2009 +0000
@@ -1539,7 +1539,7 @@ sub can_use_layer
sub can_use_layer
{
my ($u, $uniq) = @_; # $uniq = redist_uniq value
- return 1 if LJ::get_cap($u, "s2styles");
+ return 1 if $u->can_create_s2_styles;
return 0 unless $uniq;
return 1 if LJ::run_hook('s2_can_use_layer', {
u => $u,
@@ -1563,8 +1563,8 @@ sub can_use_prop
sub can_use_prop
{
my ($u, $uniq, $prop) = @_; # $uniq = redist_uniq value
- return 1 if LJ::get_cap($u, "s2styles");
- return 1 if LJ::get_cap($u, "s2props");
+ return 1 if $u->can_create_s2_styles;
+ return 1 if $u->can_create_s2_props;
my $pol = get_policy();
my $can = 0;
my @layers = ('*');
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/S2/EntryPage.pm
--- a/cgi-bin/LJ/S2/EntryPage.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/S2/EntryPage.pm Wed Oct 21 17:30:30 2009 +0000
@@ -74,7 +74,7 @@ sub EntryPage
stc/lj_base.css
js/datasource.js
js/selectable_table.js
- )) if LJ::is_enabled('userpicselect') && $remote &&
$remote->get_cap('userpicselect');
+ )) if LJ::is_enabled('userpicselect') && $remote &&
$remote->can_use_userpic_select;
LJ::need_res(qw(
js/x_core.js
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/Setting/Display/DomainMapping.pm
--- a/cgi-bin/LJ/Setting/Display/DomainMapping.pm Wed Oct 21 17:24:56
2009 +0000
+++ b/cgi-bin/LJ/Setting/Display/DomainMapping.pm Wed Oct 21 17:30:30
2009 +0000
@@ -22,7 +22,7 @@ sub actionlink {
my $upgrade_url = LJ::run_hook("upgrade_link", $u, "plus", url_only => 1)
|| "";
my $upgrade_link = LJ::run_hook("upgrade_link", $u, "plus") || "";
- if ($u->get_cap('domainmap')) {
+ if ( $u->can_map_domains ) {
return "<a href='$LJ::SITEROOT/manage/domain?authas=" . $u->user .
"'>" . $class->ml('setting.display.domainmapping.actionlink') . "</a>";
} elsif ($has_domain) {
return "<a href='$LJ::SITEROOT/manage/domain?authas=" . $u->user .
"'>" . $class->ml('setting.display.domainmapping.actionlink.remove') . "</a>
$upgrade_link";
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/Setting/DomainMapping.pm
--- a/cgi-bin/LJ/Setting/DomainMapping.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/Setting/DomainMapping.pm Wed Oct 21 17:30:30 2009 +0000
@@ -8,7 +8,7 @@ sub save {
sub save {
my ($class, $u, $args) = @_;
- my $has_cap = $u->get_cap('domainmap');
+ my $has_cap = $u->can_map_domains;
# sanitize POST value
@@ -60,7 +60,7 @@ sub as_html {
my ($class, $u, $errs) = @_;
$errs ||= {};
- my $has_cap = $u->get_cap('domainmap');
+ my $has_cap = $u->can_map_domains;
my $has_dom = $u->prop('journaldomain') ? 1 : 0;
my $key = $class->pkgkey;
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/Setting/EmailPosting.pm
--- a/cgi-bin/LJ/Setting/EmailPosting.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/Setting/EmailPosting.pm Wed Oct 21 17:30:30 2009 +0000
@@ -25,7 +25,7 @@ sub option {
my ($class, $u, $errs, $args) = @_;
my $key = $class->pkgkey;
- my $can_emailpost = $u->get_cap("emailpost") ? 1 : 0;
+ my $can_emailpost = $u->can_emailpost;
my $upgrade_link = $can_emailpost ? "" : LJ::run_hook("upgrade_link", $u,
"plus");
my $addrlist = LJ::Emailpost::get_allowed_senders($u);
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/Setting/NotifyWeblogs.pm
--- a/cgi-bin/LJ/Setting/NotifyWeblogs.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/Setting/NotifyWeblogs.pm Wed Oct 21 17:30:30 2009 +0000
@@ -26,7 +26,7 @@ sub option {
my $key = $class->pkgkey;
my $notifyweblogs = $class->get_arg($args, "notifyweblogs") ||
$u->prop("opt_weblogscom");
- my $can_use_notifyweblogs = $u->get_cap("weblogscom") ? 1 : 0;
+ my $can_use_notifyweblogs = $u->can_notify_weblogs;
my $upgrade_link = $can_use_notifyweblogs ? "" :
(LJ::run_hook("upgrade_link", $u, "paid") || "");
my $ret = LJ::html_check({
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/Setting/SelfCommentEmail.pm
--- a/cgi-bin/LJ/Setting/SelfCommentEmail.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/Setting/SelfCommentEmail.pm Wed Oct 21 17:30:30 2009 +0000
@@ -12,7 +12,7 @@ sub disabled {
sub disabled {
my ($class, $u) = @_;
- return $u->get_cap("getselfemail") ? 0 : 1;
+ return $u->can_get_self_email;
}
sub selected {
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/User.pm Wed Oct 21 17:30:30 2009 +0000
@@ -1785,6 +1785,57 @@ sub can_be_text_messaged_by {
return 0;
}
+sub can_beta_payments {
+ return $_[0]->get_cap( 'beta_payments' ) ? 1 : 0;
+}
+
+sub can_create_feeds {
+ return $_[0]->get_cap( 'synd_create' ) ? 1 : 0;
+}
+
+sub can_create_moodthemes {
+ return $_[0]->get_cap( 'moodthemecreate' ) ? 1 : 0;
+}
+
+sub can_create_polls {
+ return $_[0]->get_cap( 'makepoll' ) ? 1 : 0;
+}
+
+sub can_create_s2_props {
+ return $_[0]->get_cap( 's2props' ) ? 1 : 0;
+}
+
+sub can_create_s2_styles {
+ return $_[0]->get_cap( 's2styles' ) ? 1 : 0;
+}
+
+sub can_edit_comments {
+ return $_[0]->get_cap( 'edit_comments' ) ? 1 : 0;
+}
+
+sub can_emailpost {
+ return $_[0]->get_cap( 'emailpost' ) ? 1 : 0;
+}
+
+sub can_find_similar {
+ return $_[0]->get_cap( 'findsim' ) ? 1 : 0;
+}
+
+sub can_get_self_email {
+ return $_[0]->get_cap( 'getselfemail' ) ? 1 : 0;
+}
+
+sub can_have_email_alias {
+ return $_[0]->get_cap( 'useremail' ) ? 1 : 0;
+}
+
+sub can_map_domains {
+ return $_[0]->get_cap( 'domainmap' ) ? 1 : 0;
+}
+
+sub can_notify_weblogs {
+ return $_[0]->get_cap( 'weblogscom' ) ? 1 : 0;
+}
sub can_show_location {
my $u = shift;
@@ -1820,11 +1871,49 @@ sub can_show_onlinestatus {
return 0;
}
+sub can_track_defriending {
+ return $_[0]->get_cap( 'track_defriended' ) ? 1 : 0;
+}
+
+sub can_track_new_userpic {
+ return $_[0]->get_cap( 'track_user_newuserpic' ) ? 1 : 0;
+}
+
+sub can_track_pollvotes {
+ return $_[0]->get_cap( 'track_pollvotes' ) ? 1 : 0;
+}
+
+sub can_track_thread {
+ return $_[0]->get_cap( 'track_thread' ) ? 1 : 0;
+}
+
+sub can_use_daily_readpage {
+ return $_[0]->get_cap( 'friendspage_per_day' ) ? 1 : 0;
+}
+
+sub can_use_directory {
+ return $_[0]->get_cap( 'directory' ) ? 1 : 0;
+}
+
+sub can_use_fastlane {
+ return $_[0]->get_cap( 'fastserver' ) ? 1 : 0;
+}
+
+sub can_use_full_rss {
+ return $_[0]->get_cap( 'full_rss' ) ? 1 : 0;
+}
sub can_use_google_analytics {
return $_[0]->get_cap( 'google_analytics' ) ? 1 : 0;
}
+sub can_use_latest_comments_rss {
+ return $_[0]->get_cap( 'latest_comments_rss' ) ? 1 : 0;
+}
+
+sub can_use_mass_privacy {
+ return $_[0]->get_cap( 'mass_privacy' ) ? 1 : 0;
+}
sub can_use_network_page {
return $_[0]->get_cap( 'friendsfriendsview' ) ? 1 : 0;
@@ -1834,6 +1923,18 @@ sub can_use_network_page {
# Check if the user can use *any* page statistic module for their own journal.
sub can_use_page_statistics {
return $_[0]->can_use_google_analytics;
+}
+
+sub can_use_textmessaging {
+ return $_[0]->get_cap( 'textmessaging' ) ? 1 : 0;
+}
+
+sub can_use_userpic_select {
+ return $_[0]->get_cap( 'userpicselect' ) ? 1 : 0;
+}
+
+sub can_view_mailqueue {
+ return $_[0]->get_cap( 'viewmailqueue' ) ? 1 : 0;
}
sub clear_prop {
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/LJ/Widget/UserpicDisplay.pm
--- a/cgi-bin/LJ/Widget/UserpicDisplay.pm Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/LJ/Widget/UserpicDisplay.pm Wed Oct 21 17:30:30 2009 +0000
@@ -35,7 +35,7 @@ sub render_body {
my $u = $user;
return "" unless $u;
- return "" unless LJ::is_enabled('userpicselect') ||
$u->get_cap('userpicselect');
+ return "" unless LJ::is_enabled('userpicselect') ||
$u->can_use_userpic_select;
my $res;
$res = LJ::Protocol::do_request("login", {
@@ -176,7 +176,7 @@ sub render_body {
});
// ]]>
</script>
- } if LJ::is_enabled('userpicselect') && $u->get_cap('userpicselect');
+ } if LJ::is_enabled('userpicselect') && $u->can_use_userpic_select;
$$pic .= "<div id='userpic' style='display: none;'><p
id='userpic_preview'><a href='javascript:void(0);'
id='lj_userpicselect_img'><img src='' alt='selected userpic'
id='userpic_preview_image' /><span
id='lj_userpicselect_img_txt'>$userpic_link_text</span></a></p></div>";
$$pic .= "\n";
@@ -201,7 +201,7 @@ sub render_body {
userpic_preview();
};
$$picform .= "insertViewThumbs()"
- if LJ::is_enabled('userpicselect') && $u->get_cap('userpicselect');
+ if LJ::is_enabled('userpicselect') && $u->can_use_userpic_select;
$$picform .= "</script>\n";
} elsif (!$u) {
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/ljemailgateway.pl
--- a/cgi-bin/ljemailgateway.pl Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/ljemailgateway.pl Wed Oct 21 17:30:30 2009 +0000
@@ -172,7 +172,7 @@ sub process {
}
return $err->("Email gateway access denied for your account type.")
- unless $LJ::T_ALLOW_EMAILPOST || LJ::get_cap($u, "emailpost");
+ unless $LJ::T_ALLOW_EMAILPOST || $u->can_emailpost;
# Is this message from a sprint PCS phone? Sprint doesn't support
# MMS (yet) - when it does, we should just be able to rip this block
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/ljfeed.pl
--- a/cgi-bin/ljfeed.pl Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/ljfeed.pl Wed Oct 21 17:30:30 2009 +0000
@@ -202,7 +202,7 @@ sub make_feed
# users without 'full_rss' get their logtext bodies truncated
# do this now so that the html cleaner will hopefully fix html we
break
- unless (LJ::get_cap($u, 'full_rss')) {
+ unless ( $u->can_use_full_rss ) {
my $trunc = LJ::text_trim($event, 0, 80);
$event = "$trunc $readmore" if $trunc ne $event;
}
@@ -1010,7 +1010,7 @@ sub create_view_comments
return 404;
}
- unless ($u->get_cap('latest_comments_rss')) {
+ unless ( $u->can_use_latest_comments_rss ) {
$opts->{handler_return} = 403;
return;
}
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/ljlib.pl
--- a/cgi-bin/ljlib.pl Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/ljlib.pl Wed Oct 21 17:30:30 2009 +0000
@@ -2317,7 +2317,7 @@ sub is_enabled {
my $conf = shift;
if ( $conf eq 'payments' ) {
my $remote = LJ::get_remote();
- return 1 if $remote && $remote->get_cap( 'beta_payments' );
+ return 1 if $remote && $remote->can_beta_payments;
}
return ! LJ::conf_test( $LJ::DISABLED{$conf}, @_ );
}
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/ljprotocol.pl
--- a/cgi-bin/ljprotocol.pl Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/ljprotocol.pl Wed Oct 21 17:30:30 2009 +0000
@@ -596,7 +596,7 @@ sub login
}
## tell some users they can hit the fast servers later.
- $res->{'fastserver'} = 1 if LJ::get_cap($u, "fastserver");
+ $res->{'fastserver'} = 1 if $u->can_use_fastlane;
## user info
$res->{'userid'} = $u->{'userid'};
@@ -1207,9 +1207,8 @@ sub postevent
if (LJ::Poll->contains_new_poll(\$event))
{
return fail($err,301,"Your account type doesn't permit creating
polls.")
- unless (LJ::get_cap($u, "makepoll")
- || ($uowner->is_community
- && LJ::get_cap($uowner, "makepoll")));
+ unless ( $u->can_create_polls
+ || ( $uowner->is_community && $uowner->can_create_polls )
);
my $error = "";
@polls = LJ::Poll->new_from_html(\$event, \$error, {
@@ -1536,7 +1535,7 @@ sub postevent
my @jobs; # jobs to add into TheSchwartz
# notify weblogs.com of post if necessary
- if ( LJ::is_enabled('weblogs_com') && $u->{'opt_weblogscom'} &&
LJ::get_cap($u, "weblogscom") &&
+ if ( LJ::is_enabled('weblogs_com') && $u->{'opt_weblogscom'} &&
$u->can_notify_weblogs &&
($security eq "public") && !$req->{'props'}->{'opt_backdated'} ) {
push @jobs,
TheSchwartz::Job->new_from_array("LJ::Worker::Ping::WeblogsCom", {
'user' => $u->{'user'},
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/talklib.pl
--- a/cgi-bin/talklib.pl Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/talklib.pl Wed Oct 21 17:30:30 2009 +0000
@@ -2436,7 +2436,7 @@ sub mail_comments {
# them, so it shouldn't matter.)
my $u = $comment->{u};
LJ::load_user_props($u, 'opt_getselfemail') if $u;
- if ($u && $u->{'opt_getselfemail'} && LJ::get_cap($u, 'getselfemail')
+ if ($u && $u->{'opt_getselfemail'} && $u->can_get_self_email
&& !$u->gets_notified(journal => $journalu, arg1 => $ditemid, arg2 =>
$comment->{talkid})) {
my $part;
diff -r d6762606a18d -r 6af3384bd954 cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl Wed Oct 21 17:24:56 2009 +0000
+++ b/cgi-bin/weblib.pl Wed Oct 21 17:30:30 2009 +0000
@@ -727,7 +727,7 @@ sub create_qr_div {
# userpic browse button
$qrhtml .= qq {
<input type="button" id="lj_userpicselect" value="Browse" />
- } if LJ::is_enabled('userpicselect') &&
$remote->get_cap('userpicselect');
+ } if LJ::is_enabled('userpicselect') &&
$remote->can_use_userpic_select;
$qrhtml .= LJ::help_icon_html("userpics", " ");
}
@@ -891,7 +891,7 @@ QQ
}
});
</script>
- } if LJ::is_enabled('userpicselect') &&
$remote->get_cap('userpicselect');
+ } if LJ::is_enabled('userpicselect') &&
$remote->can_use_userpic_select;
return $ret;
}
@@ -1191,7 +1191,7 @@ sub entry_form {
});
// ]]>
</script>
- } if LJ::is_enabled('userpicselect') &&
$remote->get_cap('userpicselect');
+ } if LJ::is_enabled('userpicselect') &&
$remote->can_use_userpic_select;
# libs for userpicselect
LJ::need_res(qw(
@@ -1208,7 +1208,7 @@ sub entry_form {
stc/ups.css
js/datasource.js
js/selectable_table.js
- )) if LJ::is_enabled('userpicselect') &&
$remote->get_cap('userpicselect');
+ )) if LJ::is_enabled('userpicselect') &&
$remote->can_use_userpic_select;
$out .= "<div id='userpic' style='display: none;'><p
id='userpic_preview'><a href='javascript:void(0);'
id='lj_userpicselect_img'><img src='' alt='selected userpic'
id='userpic_preview_image' /><span
id='lj_userpicselect_img_txt'>$userpic_link_text</span></a></p></div>";
$out .= "\n";
@@ -1303,7 +1303,7 @@ sub entry_form {
@pickws) . "\n";
$out .= "<a href='javascript:void(0);' id='lj_userpicselect'>
</a>";
# userpic browse button
- $$onload .= " insertViewThumbs();" if
LJ::is_enabled('userpicselect') && $remote->get_cap('userpicselect');
+ $$onload .= " insertViewThumbs();" if
LJ::is_enabled('userpicselect') && $remote->can_use_userpic_select;
$out .= LJ::help_icon_html("userpics", "", " ") . "\n";
$out .= "</p>\n\n";
@@ -2989,7 +2989,7 @@ sub rte_js_vars {
# of the poll button in the RTE.
# Also remove any RTE buttons that have been set to disabled.
my $canmakepoll = "true";
- $canmakepoll = "false" if ($remote && !LJ::get_cap($remote, 'makepoll'));
+ $canmakepoll = "false" if ($remote && ! $remote->can_create_polls );
$ret .= "<script type='text/javascript'>\n";
$ret .= " var RTEdisabled = new Array();\n";
my $rte_disabled = $LJ::DISABLED{rte_buttons} || {};
diff -r d6762606a18d -r 6af3384bd954 htdocs/customize/advanced/layeredit.bml
--- a/htdocs/customize/advanced/layeredit.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/customize/advanced/layeredit.bml Wed Oct 21 17:30:30 2009 +0000
@@ -44,7 +44,7 @@
# check priv and ownership
return $err->("You are not authorized to edit styles.")
- unless LJ::get_cap($u, "s2styles");
+ unless $u->can_create_s2_styles;
# at this point, they are authorized, allow viewing & editing
diff -r d6762606a18d -r 6af3384bd954 htdocs/customize/advanced/layers.bml
--- a/htdocs/customize/advanced/layers.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/customize/advanced/layers.bml Wed Oct 21 17:30:30 2009 +0000
@@ -62,11 +62,10 @@
my $pub = LJ::S2::get_public_layers();
my $ulay = LJ::S2::get_layers_of_user($u);
- my $has_priv = LJ::get_cap($u, 's2styles');
return $err->($remote->{user} eq $u->{user} ?
$ML{'.error.youcantuseadvanced'} :
$ML{'.error.usercantuseadvanced'} )
- unless $has_priv || $viewall;
+ unless $u->can_create_s2_styles || $viewall;
# start of output
$title = $ML{'.title'};
diff -r d6762606a18d -r 6af3384bd954 htdocs/customize/advanced/styles.bml
--- a/htdocs/customize/advanced/styles.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/customize/advanced/styles.bml Wed Oct 21 17:30:30 2009 +0000
@@ -48,11 +48,10 @@
return $err->($ML{'.error.cantbeauthenticated'})
unless $u;
- my $has_priv = LJ::get_cap($u, 's2styles');
return $err->($remote->{user} eq $u->{user} ?
$ML{'.error.youcantuseadvanced'} :
$ML{'.error.usercantuseadvanced'} )
- unless $has_priv || $viewall;
+ unless $u->can_create_s2_styles || $viewall;
my $no_layer_edit = LJ::run_hook("no_theme_or_layer_edit", $u);
return
$err->($ML{'/customize/advanced/index.bml.error.advanced.editing.denied'})
diff -r d6762606a18d -r 6af3384bd954 htdocs/directory.bml
--- a/htdocs/directory.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/directory.bml Wed Oct 21 17:30:30 2009 +0000
@@ -18,7 +18,7 @@ body<=
return "<?needlogin?>" unless $remote;
return LJ::CProd->inline($remote, inline => 'Directory') ||
BML::ml('cprod.directory.text3.v1')
- unless $remote->get_cap("directory");
+ unless $remote->can_use_directory;
my $ret = '';
diff -r d6762606a18d -r 6af3384bd954 htdocs/directorysearch.bml
--- a/htdocs/directorysearch.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/directorysearch.bml Wed Oct 21 17:30:30 2009 +0000
@@ -30,7 +30,7 @@ _code?>
return "<?needlogin?>" unless $remote;
return LJ::CProd->inline($remote, inline => 'Directory') ||
BML::ml('cprod.directory.text3.v1')
- unless $remote->get_cap("directory");
+ unless $remote->can_use_directory;
return "";
}
diff -r d6762606a18d -r 6af3384bd954 htdocs/editprivacy.bml
--- a/htdocs/editprivacy.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/editprivacy.bml Wed Oct 21 17:30:30 2009 +0000
@@ -16,9 +16,7 @@ body<=
return "This feature is currently disabled."
unless LJ::is_enabled('mass_privacy');
- unless ($u->get_cap('mass_privacy')) {
- return "<?standout $ML{'.unable'} standout?>";
- }
+ return "<?standout $ML{'.unable'} standout?>" unless
$u->can_use_mass_privacy;
my $mode = $POST{'mode'} || $GET{'mode'} || "init";
my $more_public = 0; # flag indiciating if security is becoming more public
diff -r d6762606a18d -r 6af3384bd954 htdocs/interests.bml
--- a/htdocs/interests.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/interests.bml Wed Oct 21 17:30:30 2009 +0000
@@ -131,7 +131,7 @@ body<=
if (!$did_post && $GET{'mode'} eq "findsim_do") {
return $ML{'error.tempdisabled'} unless
LJ::is_enabled('interests-findsim');
- return $ML{'.findsim_do.account.notallowed'} unless
LJ::get_cap($remote, "findsim");
+ return $ML{'.findsim_do.account.notallowed'} unless
$remote->can_find_similar;
my $ret = "";
my $u = LJ::load_user($GET{'user'});
@@ -525,7 +525,7 @@ body<=
$ret .= LJ::html_submit(undef, $ML{'.interested.btn.find'});
$ret .= "</form></td></tr>";
- if ( LJ::is_enabled('interests-findsim') && $remote &&
LJ::get_cap($remote, 'findsim') ) {
+ if ( LJ::is_enabled('interests-findsim') && $remote &&
$remote->can_find_similar ) {
$ret .= "<tr valign='top'><td>$ML{'.interests.findsim'}</td><td><form
method='get' action='interests'>";
$ret .= LJ::html_hidden('mode', 'findsim_do');
$ret .= LJ::html_text({name => 'user', value => $remote->{'user'},
size => 20}) . " ";
diff -r d6762606a18d -r 6af3384bd954 htdocs/manage/circle/edit.bml
--- a/htdocs/manage/circle/edit.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/manage/circle/edit.bml Wed Oct 21 17:30:30 2009 +0000
@@ -94,6 +94,7 @@ body<=
$ret .= "<td scope='col' abbr='" .
$other_u->display_username . "'>";
$ret .= LJ::html_hidden( "editfriend_edit_${uid}_user" =>
1 );
$ret .= $other_u->ljuser_display;
+ $ret .= "<br /><span style='font-size: smaller;'>" .
LJ::last_updated( $other_u ) . "</span>";
$ret .= "</td>";
# color
diff -r d6762606a18d -r 6af3384bd954 htdocs/manage/domain.bml
--- a/htdocs/manage/domain.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/manage/domain.bml Wed Oct 21 17:30:30 2009 +0000
@@ -49,7 +49,7 @@ body<=
my %uprop;
# journal domains
- my $dom_cap = LJ::get_cap($u, 'domainmap');
+ my $dom_cap = $u->can_map_domains;
if ( ( exists $POST{journaldomain} && $u->{journaldomain} ne
$POST{journaldomain} ) ||
( !$dom_cap && $POST{journaldomain_del} ) ) {
@@ -106,7 +106,7 @@ body<=
$ret .= "<form method='post' action='/manage/domain?authas=$authas'>\n";
$ret .= LJ::form_auth();
- my $has_cap = LJ::get_cap($u, 'domainmap');
+ my $has_cap = $u->can_map_domains;
my $has_dom = $u->{journaldomain} ? 1 : 0;
if ($LJ::OTHER_VHOSTS && ($has_cap || $has_dom)) {
$ret .= "<?h2 $ML{'.domainalias.head'} h2?><?p
$ML{'.domainalias.about'} p?>\n";
diff -r d6762606a18d -r 6af3384bd954 htdocs/manage/emailpost.bml
--- a/htdocs/manage/emailpost.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/manage/emailpost.bml Wed Oct 21 17:30:30 2009 +0000
@@ -364,7 +364,7 @@ body<=
$ret .= "<?p " . BML::ml('.intro', {'aopts' =>
"href='$LJ::SITEROOT/manage/emailpost?mode=help'"}) . " p?><br />";
- unless (LJ::get_cap($u, 'emailpost')) {
+ unless ( $u->can_emailpost ) {
$ret .= $ML{'.sorry.acct'};
return $ret;
}
diff -r d6762606a18d -r 6af3384bd954 htdocs/manage/moodthemes.bml
--- a/htdocs/manage/moodthemes.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/manage/moodthemes.bml Wed Oct 21 17:30:30 2009 +0000
@@ -394,7 +394,7 @@ body<=
my $moodtheme_upsell = LJ::run_hook("moodtheme_upsell");
- unless (LJ::get_cap($u, "moodthemecreate")) {
+ unless ( $u->can_create_moodthemes ) {
if ($moodtheme_upsell) {
$ret .= $moodtheme_upsell;
} else {
diff -r d6762606a18d -r 6af3384bd954 htdocs/manage/profile/index.bml
--- a/htdocs/manage/profile/index.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/manage/profile/index.bml Wed Oct 21 17:30:30 2009 +0000
@@ -324,7 +324,7 @@ body<=
# opt_whatemailshow
$ret .= "<tr><td class='field_name'> $ML{'.fn.emaildisplay'}</td><td>
";
my $cur = $u->opt_whatemailshow;
- my @vals = ( ($LJ::USER_EMAIL && LJ::get_cap($u, "useremail"))
+ my @vals = ( ( $LJ::USER_EMAIL && $u->can_have_email_alias )
? ("A" => BML::ml(".email.opt.actual"),
"D" => BML::ml(".email.opt.display"),
"L" => BML::ml(".email.opt.site", { sitenameshort =>
$LJ::SITENAMESHORT } ),
@@ -419,7 +419,7 @@ body<=
## TEXT MESSAGING
$ret .= "<a name='txtmsg'></a><div
class='section_head'>$ML{'.section.textmsg'}\n";
- unless (LJ::get_cap($u, "textmessaging")) {
+ unless ( $u->can_use_textmessaging ) {
my $inline;
if ($inline .= LJ::run_hook("cprod_inline", $u, 'TextMessaging')) {
$ret .= "</div>$inline";
@@ -427,7 +427,7 @@ body<=
$ret .= "</div>".BML::ml('cprod.textmessaging.text3.v1');
}
}
- if (LJ::get_cap($u, "textmessaging")) {
+ if ( $u->can_use_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');
diff -r d6762606a18d -r 6af3384bd954 htdocs/manage/subscriptions/user.bml
--- a/htdocs/manage/subscriptions/user.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/manage/subscriptions/user.bml Wed Oct 21 17:30:30 2009 +0000
@@ -47,7 +47,7 @@ body<=
event
=> "NewUserpic",
journal
=> $journal,
flags
=> LJ::Subscription::TRACKING,
- disabled
=> ! $remote->get_cap('track_user_newuserpic'),
+ disabled
=> ! $remote->can_track_new_userpic,
),
LJ::Subscription::Pending->new(
$remote,
diff -r d6762606a18d -r 6af3384bd954 htdocs/poll/create.bml
--- a/htdocs/poll/create.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/poll/create.bml Wed Oct 21 17:30:30 2009 +0000
@@ -66,7 +66,7 @@
return;
}
- my $remote_can_make_polls = LJ::get_cap($remote, "makepoll");
+ my $remote_can_make_polls = $remote->can_create_polls;
my $authas = $GET{'authas'} || $remote->{'user'};
my $u;
@@ -112,7 +112,7 @@
}
# does the remote or selected user have the 'makepoll' cap?
- unless ($remote_can_make_polls || LJ::get_cap($u, "makepoll")) {
+ unless ( $remote_can_make_polls || $u->can_create_polls ) {
$body .= "<?h1 $ML{'Sorry'} h1?><?p $ML{'.error.accttype2'} p?>";
return;
}
diff -r d6762606a18d -r 6af3384bd954 htdocs/syn/index.bml
--- a/htdocs/syn/index.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/syn/index.bml Wed Oct 21 17:30:30 2009 +0000
@@ -61,7 +61,7 @@ body<=
unless ($su) {
# check cap to create new feeds
return $error->($ML{'.error.nocreate'})
- unless LJ::get_cap($u, 'synd_create');
+ unless $u->can_create_feeds;
# if no account name, give them a proper entry form to pick
one, but don't reprompt
# for the url, just pass that through (we'll recheck it
anyway, though)
@@ -209,7 +209,7 @@ body<=
$ret .= LJ::html_hidden("userid", $u->{'userid'});
$ret .= "<?h1 $ML{'.add.byurl.title'} h1?><?p $ML{'.add.byurl.text'} p?>";
- unless (LJ::get_cap($u, "synd_create")) {
+ unless ( $u->can_create_feeds ) {
my $inline;
if ($inline .= LJ::run_hook("cprod_inline", $u, 'Syn')) {
$ret .= $inline;
diff -r d6762606a18d -r 6af3384bd954 htdocs/talkread.bml
--- a/htdocs/talkread.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/talkread.bml Wed Oct 21 17:30:30 2009 +0000
@@ -213,7 +213,7 @@ body<=
stc/lj_base.css
js/datasource.js
js/selectable_table.js
- )) if LJ::is_enabled('userpicselect') &&
$remote->get_cap('userpicselect');
+ )) if LJ::is_enabled('userpicselect') &&
$remote->can_use_userpic_select;
LJ::need_res(qw(
js/x_core.js
diff -r d6762606a18d -r 6af3384bd954 htdocs/tools/recent_email.bml
--- a/htdocs/tools/recent_email.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/tools/recent_email.bml Wed Oct 21 17:30:30 2009 +0000
@@ -40,7 +40,7 @@ body<=
} else {
# TODO: add a link to upgrading your account if you don't have the cap
return "Sorry, you are not able to view outgoing email."
- unless $u->get_cap("viewmailqueue");
+ unless $u->can_view_mailqueue;
return LJ::error_list("You must <a
href=\"$LJ::SITEROOT/register\">validate your email address</a> in order to
view your outgoing mail.")
unless $u->is_validated;
diff -r d6762606a18d -r 6af3384bd954 htdocs/tools/tellafriend.bml
--- a/htdocs/tools/tellafriend.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/tools/tellafriend.bml Wed Oct 21 17:30:30 2009 +0000
@@ -33,7 +33,7 @@
# Get sender's email address
my $u = LJ::load_userid($remote->{'userid'});
$u->{'emailpref'} = $u->email_raw;
- if ($LJ::USER_EMAIL && LJ::get_cap($u, "useremail")) {
+ if ( $LJ::USER_EMAIL && $u->can_have_email_alias ) {
$u->{'emailpref'} = $u->{'user'} . '@' . $LJ::USER_DOMAIN;
}
diff -r d6762606a18d -r 6af3384bd954 htdocs/tools/textmessage.bml
--- a/htdocs/tools/textmessage.bml Wed Oct 21 17:24:56 2009 +0000
+++ b/htdocs/tools/textmessage.bml Wed Oct 21 17:30:30 2009 +0000
@@ -45,7 +45,7 @@ body<=
$tminfo = LJ::TextMessage->tm_info($u);
}
- unless (LJ::get_cap($u, "textmessaging")) {
+ unless ( $u->can_use_textmessaging ) {
$ret .= "<?h1 $ML{'.error.unavailable.head'} h1?><?p
$ML{'.error.unavailable.notpermitted'} p?>";
return add_footer( $ret );
}
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog