[dw-free] strip unused functions from .pms in cgi-bin
[commit: http://hg.dwscoalition.org/dw-free/rev/28873ff272f6]
http://bugs.dwscoalition.org/show_bug.cgi?id=1379
Remove unused functions (round 3).
Patch by
denise.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=1379
Remove unused functions (round 3).
Patch by
Files modified:
- cgi-bin/LJ/Intercast/Handler/GetCommenterOptions.pm
- cgi-bin/customizelib.pl
- cgi-bin/ljlib.pl
- cgi-bin/supportlib.pl
--------------------------------------------------------------------------------
diff -r 65fdc23958c7 -r 28873ff272f6 cgi-bin/LJ/Intercast/Handler/GetCommenterOptions.pm
--- a/cgi-bin/LJ/Intercast/Handler/GetCommenterOptions.pm Tue Aug 04 20:40:23 2009 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-use strict;
-package LJ::Intercast::Handler::GetCommenterOptions;
-use base 'LJ::Intercast::Handler';
-
-sub handle {
- my ($class, $reqopts) = @_;
-
- my $retopts = [
- ['commenter_id',
- 'commenter_name'],
-
- [0, 'Allow comments'],
- [1, 'Disallow comments'],
- ];
-
- my %ret = (
- status => "OK",
- code => 0,
- total_items => 2,
- results => $retopts,
- );
-
- return JSON::objToJson(\%ret);
-}
-
-sub owns { $_[1] eq 'Member::getCommenterOptions' }
-
-1;
diff -r 65fdc23958c7 -r 28873ff272f6 cgi-bin/customizelib.pl
--- a/cgi-bin/customizelib.pl Tue Aug 04 20:40:23 2009 -0500
+++ b/cgi-bin/customizelib.pl Tue Aug 04 21:31:52 2009 -0500
@@ -55,81 +55,6 @@ sub s2_implicit_style_create
LJ::S2::set_style_layers($u, $u->prop('s2_style'), %style);
return 1;
-}
-
-# <LJFUNC>
-# name: LJ::cmize::s2_get_lang
-# des: Gets the lang code for the user's style
-# args: user, styleid
-# des-user: user to return the style lang code for
-# des-styleid: S2 style ID to return lang code for
-# returns: lang code if found, undef otherwise
-# </LJFUNC>
-sub s2_get_lang {
- my ($u, $styleid) = @_;
- my $pub = LJ::S2::get_public_layers();
- my $userlay = LJ::S2::get_layers_of_user($u);
-
- foreach ($userlay, $pub) {
- return $_->{$styleid}->{'langcode'} if
- $_->{$styleid} && $_->{$styleid}->{'langcode'};
- }
- return undef;
-}
-
-# <LJFUNC>
-# name: LJ::cmize::s2_custom_layer_list
-# des: custom layers will be shown in the "Custom Layers" and "Disabled Layers"
-# groups depending on the user's account status. if they don't have the
-# s2styles cap, then they will have all layers disabled, except for the one
-# they are currently using.
-# args: user, type, ptype
-# des-user: User whose layers to return
-# des-type: Type of layers to return
-# des-ptype: Parent type of layers to return (used to restrict layers to
-# children of the layer of that type in the user's current S2 style)
-# returns: A list of layer ids and names, suitable for [func[LJ::html_select]].
-# The list include separators labels for available layers and disabled
-# layers if appropriate.
-# </LJFUNC>
-sub s2_custom_layer_list {
- my ($u, $type, $ptype) = @_;
- my @layers = ();
-
- my $has_cap = LJ::get_cap($u, "s2styles");
- my $pub = LJ::S2::get_public_layers();
- my $userlay = LJ::S2::get_layers_of_user($u);
- my %style = LJ::S2::get_style($u, "verify");
-
- my @user = map { $_, $userlay->{$_}->{'name'} ? $userlay->{$_}->{'name'} : "\#$_" }
- sort { $userlay->{$a}->{'name'} cmp $userlay->{$b}->{'name'} || $a <=> $b }
- grep { /^\d+$/ && $userlay->{$_}->{'b2lid'} == $style{$ptype} &&
- $userlay->{$_}->{'type'} eq $type &&
- ($has_cap || $_ == $style{$type}) }
- keys %$userlay;
- if (@user) {
- push @layers, { value => "",
- text => "--- Custom Layers: ---",
- disabled => 1 }, @user;
- }
-
- unless ($has_cap) {
- my @disabled =
- map { { value => $_,
- text => $userlay->{$_}->{'name'} ? $userlay->{$_}->{'name'} : "\#$_",
- disabled => 1 } }
- sort { $userlay->{$a}->{'name'} cmp $userlay->{$b}->{'name'} ||
- $userlay->{$a}->{'s2lid'} <=> $userlay->{$b}->{'s2lid'} }
- grep { /^\d+$/ && $userlay->{$_}->{'b2lid'} == $style{$ptype} &&
- $userlay->{$_}->{'type'} eq $type && $_ != $style{$type} }
- keys %$userlay;
- if (@disabled) {
- push @layers, { value => "",
- text => "--- Disabled Layers: ---",
- disabled => 1 }, @disabled;
- }
- }
- return @layers;
}
# <LJFUNC>
@@ -191,155 +116,4 @@ sub get_moodtheme_select_list
return @themes;
}
-# <LJFUNC>
-# name: LJ::cmize::js_redirect
-# des: Function to determine the correct redirect when clicking on a tab link.
-# args: opts
-# des-opts: Hash of options
-# - getextra: extra arguments appended to the redirected URL
-# returns: Nothing
-# </LJFUNC>
-sub js_redirect
-{
- my $POST = shift;
- my %opts = @_;
-
- my %redirect = (
- "display_index" => "index",
- "display_style" => "style",
- "display_options" => "options",
- "display_advanced" => "advanced",
- );
-
- if ($POST->{"action:redir"} ne "" && $redirect{$POST->{"action:redir"}}) {
- BML::redirect("$LJ::SITEROOT/customize/$redirect{$POST->{'action:redir'}}$opts{getextra}");
- }
-}
-
-# <LJFUNC>
-# name: LJ::cmize::get_style_thumbnails
-# des: Get style thumbnail information from per-process caches,
-# or load if not available or cache is more than 5 minutes old.
-# returns: {style name => thumbnail URL} hash reference, or undef on failure.
-# </LJFUNC>
-sub get_style_thumbnails
-{
- my $now = time;
- return \%LJ::CACHE_STYLE_THUMBS if $LJ::CACHE_STYLE_THUMBS{'_loaded'} > $now - 300;
- %LJ::CACHE_STYLE_THUMBS = ();
-
- open (my $pfh, "$LJ::HOME/htdocs/img/stylepreview/pics.autogen.dat") or return undef;
- while (my $line = <$pfh>) {
- chomp $line;
- my ($style, $url) = split(/\t/, $line);
- $LJ::CACHE_STYLE_THUMBS{$style} = $url;
- }
- $LJ::CACHE_STYLE_THUMBS{'_loaded'} = $now;
- return \%LJ::CACHE_STYLE_THUMBS;
-}
-
-### HTML helper functions
-
-# <LJFUNC>
-# name: LJ::cmize::display_current_summary
-# des: HTML helper function: Returns a block of HTML that summarizes the
-# user's current display options.
-# args: user
-# des-user: user whose settings to display
-# returns: HTML wrapped inside a BML <?standout ... standout?> block.
-# </LJFUNC>
-sub display_current_summary
-{
- my $u = shift;
- my $ret;
- $ret .= "<?standout <strong>Current Display Summary</strong>";
-
- $ret .= "<table><tr>";
- my $style_settings = "None";
- if ($u->prop('stylesys') == 2) {
- my $ustyle = LJ::S2::load_user_styles($u);
- if (%$ustyle) {
- $style_settings = $ustyle->{$u->prop('s2_style')};
- }
- } else {
- confess 'S1 deprecated.';
- }
- $ret .= "<tr valign='top'><th>Name:</th><td>" . LJ::ehtml($style_settings) . "</td></tr>";
-
- my $style_type = $u->prop('stylesys') == 2 ? "Wizard" : "Template" ;
- $ret .= "<th valign='top'>Type:</th><td>$style_type</td></tr>";
-
- my $mood_settings = "None";
- my $dbr = LJ::get_db_reader();
- if ($u->prop('moodthemeid') > 0) {
- $mood_settings = $dbr->selectrow_array("SELECT name FROM moodthemes WHERE moodthemeid=?",
- undef, $u->prop('moodthemeid'));
- }
- $ret .= "<tr valign='top'><th>Mood Theme:</th><td>" . LJ::ehtml($mood_settings) . "</td></tr>";
-
- $ret .= "</table> standout?>";
- return $ret;
-}
-
-# <LJFUNC>
-# name: LJ::cmize::html_tablinks
-# des: HTML helper function: Common HTML for links on top of tabs.
-# args: page, getextra, opts*
-# des-page: name of the current page/tab
-# des-getextra: get parameters added to URLs for other pages/tabs
-# returns: HTML fragment
-# </LJFUNC>
-sub html_tablinks
-{
- my ($page, $getextra) = @_;
- my $ret;
-
- my %strings;
- my @tabs;
-
- %strings = (
- "index" => "Basics",
- "style" => "Look and Feel",
- "options" => "Custom Options",
- "advanced" => "Advanced",
- );
- @tabs = qw( index style options advanced );
-
- $ret .= "<ul id='Tabs'>";
- foreach my $tab (@tabs) {
- if ($page eq $tab) {
- $ret .= "<li class='SelectedTab'>$strings{$tab}</li>";
- } else {
- $ret .= "<li><a id='display_$tab' href='$tab$getextra'>$strings{$tab}</a></li>";
- }
- }
- $ret .= "</ul>";
- return $ret;
-}
-
-# <LJFUNC>
-# name: LJ::cmize::html_save
-# des: HTML helper function: Common HTML for the "save changes" button
-# in a tab.
-# args: opts
-# des-opts: hashref of options
-# - remove = add a "Remove changes" button
-# returns: HTML fragment
-# </LJFUNC>
-sub html_save
-{
- my $opts = shift;
- my $ret;
-
- $ret .= LJ::html_hidden({ 'name' => "action:redir", value => "", 'id' => "action:redir" });
- $ret .= "<div style='text-align: center'>";
- $ret .= LJ::html_submit('action:save', "Save Changes", { 'id' => "action:save" });
- $ret .= " " . LJ::html_submit('action:remove', "Remove Changes", {
- 'id' => "action:remove",
- 'onclick' => "return confirm('" . LJ::ejs("Are you sure you want to remove your changes?") . "')" }) if $opts->{remove};
- $ret .= "</div>";
-
- return $ret;
-}
-
1;
diff -r 65fdc23958c7 -r 28873ff272f6 cgi-bin/ljlib.pl
--- a/cgi-bin/ljlib.pl Tue Aug 04 20:40:23 2009 -0500
+++ b/cgi-bin/ljlib.pl Tue Aug 04 21:31:52 2009 -0500
@@ -1458,38 +1458,6 @@ sub get_cluster_description {
}
# <LJFUNC>
-# name: LJ::do_to_cluster
-# des: Given a subref, this function will pick a random cluster and run the subref,
-# passing it the cluster id. If the subref returns a 1, this function will exit
-# with a 1. Else, the function will call the subref again, with the next cluster.
-# args: subref
-# des-subref: Reference to a sub to call; @_ = (clusterid)
-# returns: 1 if the subref returned a 1 at some point, undef if it didn't ever return
-# success and we tried every cluster.
-# </LJFUNC>
-sub do_to_cluster {
- my $subref = shift;
-
- # start at some random point and iterate through the clusters one by one until
- # $subref returns a true value
- my $size = @LJ::CLUSTERS;
- my $start = int(rand() * $size);
- my $rval = undef;
- my $tries = $size > 15 ? 15 : $size;
- foreach (1..$tries) {
- # select at random
- my $idx = $start++ % $size;
-
- # get subref value
- $rval = $subref->($LJ::CLUSTERS[$idx]);
- last if $rval;
- }
-
- # return last rval
- return $rval;
-}
-
-# <LJFUNC>
# name: LJ::cmd_buffer_add
# des: Schedules some command to be run sometime in the future which would
# be too slow to do synchronously with the web request. An example
@@ -1645,20 +1613,6 @@ sub get_interest {
undef, $intid);
return wantarray() ? ($int, $intcount) : $int;
-}
-
-sub get_interest_id {
- my $int = shift
- or return undef;
-
- # FIXME: caching!
-
- my $dbr = LJ::get_db_reader();
- my ($intid, $intcount) = $dbr->selectrow_array
- ("SELECT intid, intcount FROM interests WHERE interest=?",
- undef, $int);
-
- return wantarray() ? ($intid, $intcount) : $intid;
}
# <LJFUNC>
@@ -1925,44 +1879,6 @@ sub color_todb
my $c = shift;
return undef unless $c =~ /^\#[0-9a-f]{6,6}$/i;
return hex(substr($c, 1, 6));
-}
-
-
-# <LJFUNC>
-# name: LJ::event_register
-# des: Logs a subscribable event, if anybody is subscribed to it.
-# args: dbarg?, dbc, etype, ejid, eiarg, duserid, diarg
-# des-dbc: Cluster master of event
-# des-etype: One character event type.
-# des-ejid: Journalid event occurred in.
-# des-eiarg: 4 byte numeric argument
-# des-duserid: Event doer's userid
-# des-diarg: Event's 4 byte numeric argument
-# returns: boolean; 1 on success; 0 on fail.
-# </LJFUNC>
-sub event_register
-{
- &nodb;
- my ($dbc, $etype, $ejid, $eiarg, $duserid, $diarg) = @_;
- my $dbr = LJ::get_db_reader();
-
- # see if any subscribers first of all (reads cheap; writes slow)
- return 0 unless $dbr;
- my $qetype = $dbr->quote($etype);
- my $qejid = $ejid+0;
- my $qeiarg = $eiarg+0;
- my $qduserid = $duserid+0;
- my $qdiarg = $diarg+0;
-
- my $has_sub = $dbr->selectrow_array("SELECT userid FROM subs WHERE etype=$qetype AND ".
- "ejournalid=$qejid AND eiarg=$qeiarg LIMIT 1");
- return 1 unless $has_sub;
-
- # so we're going to need to log this event
- return 0 unless $dbc;
- $dbc->do("INSERT INTO events (evtime, etype, ejournalid, eiarg, duserid, diarg) ".
- "VALUES (NOW(), $qetype, $qejid, $qeiarg, $qduserid, $qdiarg)");
- return $dbc->err ? 0 : 1;
}
# <LJFUNC>
@@ -2251,40 +2167,6 @@ sub alloc_global_counter
$dbh->do("INSERT IGNORE INTO counter (journalid, area, max) VALUES (?,?,?)",
undef, $uid, $dom, $newmax) or return LJ::errobj($dbh)->cond_throw;
return LJ::alloc_global_counter($dom, 1);
-}
-
-sub system_userid {
- return $LJ::CACHE_SYSTEM_ID if $LJ::CACHE_SYSTEM_ID;
- my $u = LJ::load_user("system")
- or die "No 'system' user available for LJ::system_userid()";
- return $LJ::CACHE_SYSTEM_ID = $u->{userid};
-}
-
-sub blobcache_replace {
- my ($key, $value) = @_;
-
- die "invalid key: $key" unless length $key;
-
- my $dbh = LJ::get_db_writer()
- or die "Unable to contact global master";
-
- return $dbh->do("REPLACE INTO blobcache SET bckey=?, dateupdate=NOW(), value=?",
- undef, $key, $value);
-}
-
-sub blobcache_get {
- my $key = shift;
-
- die "invalid key: $key" unless length $key;
-
- my $dbr = LJ::get_db_reader()
- or die "Unable to contact global reader";
-
- my ($value, $timeupdate) =
- $dbr->selectrow_array("SELECT value, UNIX_TIMESTAMP(dateupdate) FROM blobcache WHERE bckey=?",
- undef, $key);
-
- return wantarray() ? ($value, $timeupdate) : $value;
}
sub note_recent_action {
diff -r 65fdc23958c7 -r 28873ff272f6 cgi-bin/supportlib.pl
--- a/cgi-bin/supportlib.pl Tue Aug 04 20:40:23 2009 -0500
+++ b/cgi-bin/supportlib.pl Tue Aug 04 21:31:52 2009 -0500
@@ -98,17 +98,6 @@ sub get_cat_by_key
my ($cats, $cat) = @_;
foreach (keys %$cats) {
if ($cats->{$_}->{'catkey'} eq $cat) {
- return $cats->{$_};
- }
- }
- return undef;
-}
-
-sub get_cat_by_id
-{
- my ($cats, $id) = @_;
- foreach (keys %$cats) {
- if ($cats->{$_}->{'spcatid'} == $id) {
return $cats->{$_};
}
}
@@ -269,17 +258,6 @@ sub support_check_priv
return 1 if LJ::check_priv($remote, $priv, '') && $sp->{_cat}->{public_read};
return 1 if LJ::check_priv($remote, $priv, $sp->{_cat}->{catkey});
return 0;
-}
-
-# different calling convention than above. this matches LJ::check_priv
-sub category_check_priv
-{
- my ($remote, $priv, $cat) = @_;
-
- my $sp = get_cat_by_key(load_cats(), $cat)
- or return 0;
-
- return support_check_priv($sp, $remote, $priv);
}
# can they read internal comments? if they're a helper or have
@@ -874,179 +852,6 @@ sub mini_auth
return substr($sp->{'authcode'}, 0, 4);
}
-# <LJFUNC>
-# name: LJ::Support::get_support_by_daterange
-# des: Get all the [dbtable[support]] rows based on a date range.
-# args: date1, date2
-# des-date1: YYYY-MM-DD of beginning date of range
-# des-date2: YYYY-MM-DD of ending date of range
-# returns: HashRef of support rows by support id
-# </LJFUNC>
-sub get_support_by_daterange {
- my ($date1, $date2) = @_;
-
- # Build the query out based on the dates specified
- my $time1 = LJ::mysqldate_to_time($date1);
- my $time2 = LJ::mysqldate_to_time($date2) + $SECONDS_IN_DAY;
-
- # Convert from times to IDs because support.timecreate isn't indexed
- my ($start_id, $end_id) = LJ::DB::time_range_to_ids
- (table => 'support',
- roles => ['slow'],
- idcol => 'spid',
- timecol => 'timecreate',
- starttime => $time1,
- endtime => $time2,
- );
-
- # Generate the SQL. Include time fields to be safe
- my $sql = "SELECT * FROM support "
- . "WHERE spid >= ? AND spid <= ? "
- . " AND timecreate >= ? AND timecreate < ?";
-
- # Get the results from the database
- my $dbh = LJ::Support::slow_query_dbh()
- or return "Database unavailable";
- my $sth = $dbh->prepare($sql);
- $sth->execute($start_id, $end_id, $time1, $time2);
- die $dbh->errstr if $dbh->err;
- $sth->{mysql_use_result} = 1;
-
- # Loop over the results, generating a hash by Support ID
- my %result_hash = ();
- while (my $row = $sth->fetchrow_hashref) {
- $result_hash{$row->{spid}} = $row;
- }
-
- return \%result_hash;
-}
-
-# <LJFUNC>
-# name: LJ::Support::get_support_by_ids
-# des: Get all the [dbtable[support]] rows based on a list of Support IDs
-# args: support_ids_ref
-# des-support_ids_ref: ArrayRef of Support IDs.
-# returns: ArrayRef of support rows
-# </LJFUNC>
-sub get_support_by_ids {
- my ($support_ids_ref) = @_;
- my %result_hash = ();
- return \%result_hash unless @$support_ids_ref;
-
- # Build the query out based on the dates specified
- my $support_ids_bind = join ',', map { '?' } @$support_ids_ref;
- my $sql = "SELECT * FROM support "
- . "WHERE spid IN ($support_ids_bind)";
-
- # Get the results from the database
- my $dbh = LJ::Support::slow_query_dbh()
- or return "Database unavailable";
- my $sth = $dbh->prepare($sql);
- $sth->execute(@$support_ids_ref);
- die $dbh->errstr if $dbh->err;
- $sth->{mysql_use_result} = 1;
-
- # Loop over the results, generating a hash by Support ID
- while (my $row = $sth->fetchrow_hashref) {
- $result_hash{$row->{spid}} = $row;
- }
-
- return \%result_hash;
-}
-
-# <LJFUNC>
-# name: LJ::Support::get_supportlogs
-# des: Get all the [dbtable[supportlog]] rows for a list of Support IDs.
-# args: support_ids_ref
-# des-support_ids_ref: ArrayRef of Support IDs.
-# returns: HashRef of supportlog rows by support id.
-# </LJFUNC>
-sub get_supportlogs {
- my $support_ids_ref = shift;
- my %result_hash = ();
- return \%result_hash unless @$support_ids_ref;
-
- # Build the query out based on the dates specified
- my $spid_bind = join ',', map { '?' } @$support_ids_ref;
- my $sql = "SELECT * FROM supportlog WHERE spid IN ($spid_bind) ";
-
- # Get the results from the database
- my $dbh = LJ::Support::slow_query_dbh()
- or return "Database unavailable";
- my $sth = $dbh->prepare($sql);
- $sth->execute(@$support_ids_ref);
- die $dbh->errstr if $dbh->err;
- $sth->{mysql_use_result} = 1;
-
- # Loop over the results, generating a hash by Support ID
- while (my $row = $sth->fetchrow_hashref) {
- push @{$result_hash{$row->{spid}}}, $row;
- }
-
- return \%result_hash;
-}
-
-# <LJFUNC>
-# name: LJ::Support::get_touch_supportlogs_by_user_and_date
-# des: Get all touch (non-req) supportlogs based on User ID and Date Range.
-# args: userid, date1, date2
-# des-userid: User ID to filter on, or Undef for all users.
-# des-date1: YYYY-MM-DD of beginning date of range
-# des-date2: YYYY-MM-DD of ending date of range
-# returns: Support HashRef of Support Logs Array, sorted by log time.
-# </LJFUNC>
-sub get_touch_supportlogs_by_user_and_date {
- my ($userid, $date1, $date2) = @_;
-
- # Build the query out based on the dates specified
- my $time1 = LJ::mysqldate_to_time($date1);
- my $time2 = LJ::mysqldate_to_time($date2) + $SECONDS_IN_DAY;
-
- # Convert from times to IDs because supportlog.timelogged isn't indexed
- my ($start_id, $end_id) = LJ::DB::time_range_to_ids
- (table => 'supportlog',
- roles => \@LJ::SUPPORT_SLOW_ROLES,
- idcol => 'splid',
- timecol => 'timelogged',
- starttime => $time1,
- endtime => $time2,
- );
-
- # Generate the SQL. Include time fields to be safe
- my $sql = "SELECT * FROM supportlog"
- . " WHERE type <> 'req' "
- . " AND splid >= ? AND splid <= ?"
- . " AND timelogged >= ? AND timelogged < ?"
- . ($userid ? " AND userid = ?" : '');
-
- # Get the results from the database
- my $dbh = LJ::Support::slow_query_dbh()
- or return "Database unavailable";
- my $sth = $dbh->prepare($sql);
- my @parms = ($start_id, $end_id, $time1, $time2);
- push @parms, $userid if $userid;
- $sth->execute(@parms);
- die $dbh->errstr if $dbh->err;
- $sth->{mysql_use_result} = 1;
-
- # Store the query results in an array
- my @results;
- while (my $row = $sth->fetchrow_hashref) {
- push @results, $row;
- }
-
- # Sort logs by time
- @results = sort {$a->{timelogged} <=> $b->{timelogged}} @results;
-
- # Loop over the results, generating an array that's hashed by Support ID
- my %result_hash = ();
- foreach my $row (@results) {
- push @{$result_hash{$row->{spid}}}, $row;
- }
-
- return \%result_hash;
-}
-
sub support_notify {
my $params = shift;
my $sclient = LJ::theschwartz() or
--------------------------------------------------------------------------------
