fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-12-07 01:52 pm

[dw-free] better organization of LJ functions

[commit: http://hg.dwscoalition.org/dw-free/rev/69d517428701]

http://bugs.dwscoalition.org/show_bug.cgi?id=3965

Move LJ::statushistory_add from ljlib.pl to LJ/User.pm. No changes in
package or implementation.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/LJ/User.pm
  • cgi-bin/ljlib.pl
--------------------------------------------------------------------------------
diff -r 904af5fb25f0 -r 69d517428701 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Wed Dec 07 21:50:46 2011 +0800
+++ b/cgi-bin/LJ/User.pm	Wed Dec 07 21:53:03 2011 +0800
@@ -7243,6 +7243,7 @@
 ###  4. Login, Session, and Rename Functions
 ###  5. Database and Memcache Functions
 ###  6. What the App Shows to Users
+###  9. Logging and Recording Actions
 ###  15. Email-Related Functions
 ###  16. Entry-Related Functions
 ###  19. OpenID and Identity Functions
@@ -8403,6 +8404,40 @@
 
 
 ########################################################################
+###  9. Logging and Recording Actions
+
+=head2 Logging and Recording Actions (LJ)
+=cut
+
+# <LJFUNC>
+# class: logging
+# name: LJ::statushistory_add
+# des: Adds a row to a user's statushistory
+# info: See the [dbtable[statushistory]] table.
+# returns: boolean; 1 on success, 0 on failure
+# args: userid, adminid, shtype, notes?
+# des-userid: The user being acted on.
+# des-adminid: The site admin doing the action.
+# des-shtype: The status history type code.
+# des-notes: Optional notes associated with this action.
+# </LJFUNC>
+sub statushistory_add {
+    my ( $userid, $actid, $shtype, $notes ) = @_;
+    my $dbh = LJ::get_db_writer();
+
+    $userid = LJ::want_userid( $userid ) + 0;
+    $actid  = LJ::want_userid( $actid ) + 0;
+
+    my $qshtype = $dbh->quote( $shtype );
+    my $qnotes  = $dbh->quote( $notes );
+
+    $dbh->do( "INSERT INTO statushistory (userid, adminid, shtype, notes) ".
+              "VALUES ($userid, $actid, $qshtype, $qnotes)" );
+    return $dbh->err ? 0 : 1;
+}
+
+
+########################################################################
 ###  15. Email-Related Functions
 
 =head2 Email-Related Functions (LJ)
diff -r 904af5fb25f0 -r 69d517428701 cgi-bin/ljlib.pl
--- a/cgi-bin/ljlib.pl	Wed Dec 07 21:50:46 2011 +0800
+++ b/cgi-bin/ljlib.pl	Wed Dec 07 21:53:03 2011 +0800
@@ -381,35 +381,6 @@
 
 
 # <LJFUNC>
-# class: logging
-# name: LJ::statushistory_add
-# des: Adds a row to a user's statushistory
-# info: See the [dbtable[statushistory]] table.
-# returns: boolean; 1 on success, 0 on failure
-# args: dbarg?, userid, adminid, shtype, notes?
-# des-userid: The user being acted on.
-# des-adminid: The site admin doing the action.
-# des-shtype: The status history type code.
-# des-notes: Optional notes associated with this action.
-# </LJFUNC>
-sub statushistory_add {
-    my $dbh = LJ::get_db_writer();
-
-    my $userid = shift;
-    $userid = LJ::want_userid($userid) + 0;
-
-    my $actid  = shift;
-    $actid = LJ::want_userid($actid) + 0;
-
-    my $qshtype = $dbh->quote(shift);
-    my $qnotes  = $dbh->quote(shift);
-
-    $dbh->do("INSERT INTO statushistory (userid, adminid, shtype, notes) ".
-             "VALUES ($userid, $actid, $qshtype, $qnotes)");
-    return $dbh->err ? 0 : 1;
-}
-
-# <LJFUNC>
 # name: LJ::is_valid_authaction
 # des: Validates a shared secret (authid/authcode pair)
 # info: See [func[LJ::register_authaction]].
--------------------------------------------------------------------------------