summaryrefslogtreecommitdiff
path: root/includes/RecentChange.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/RecentChange.php')
-rw-r--r--includes/RecentChange.php72
1 files changed, 51 insertions, 21 deletions
diff --git a/includes/RecentChange.php b/includes/RecentChange.php
index fced4343..79f32d0c 100644
--- a/includes/RecentChange.php
+++ b/includes/RecentChange.php
@@ -80,6 +80,31 @@ class RecentChange
return NULL;
}
}
+
+ /**
+ * Find the first recent change matching some specific conditions
+ *
+ * @param array $conds Array of conditions
+ * @param mixed $fname Override the method name in profiling/logs
+ * @return RecentChange
+ */
+ public static function newFromConds( $conds, $fname = false ) {
+ if( $fname === false )
+ $fname = __METHOD__;
+ $dbr = wfGetDB( DB_SLAVE );
+ $res = $dbr->select(
+ 'recentchanges',
+ '*',
+ $conds,
+ $fname
+ );
+ if( $res instanceof ResultWrapper && $res->numRows() > 0 ) {
+ $row = $res->fetchObject();
+ $res->free();
+ return self::newFromRow( $row );
+ }
+ return null;
+ }
# Accessors
@@ -195,10 +220,11 @@ class RecentChange
global $wgUseEnotif;
if( $wgUseEnotif ) {
# this would be better as an extension hook
+ global $wgUser;
include_once( "UserMailer.php" );
$enotif = new EmailNotification();
$title = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] );
- $enotif->notifyOnPageChange( $title,
+ $enotif->notifyOnPageChange( $wgUser, $title,
$this->mAttribs['rc_timestamp'],
$this->mAttribs['rc_comment'],
$this->mAttribs['rc_minor'],
@@ -209,24 +235,30 @@ class RecentChange
wfRunHooks( 'RecentChange_save', array( &$this ) );
}
- # Marks a certain row as patrolled
- function markPatrolled( $rcid )
- {
- $fname = 'RecentChange::markPatrolled';
-
+ /**
+ * Mark a given change as patrolled
+ *
+ * @param mixed $change RecentChange or corresponding rc_id
+ */
+ public static function markPatrolled( $change ) {
+ $rcid = $change instanceof RecentChange
+ ? $change->mAttribs['rc_id']
+ : $change;
$dbw = wfGetDB( DB_MASTER );
-
- $dbw->update( 'recentchanges',
- array( /* SET */
+ $dbw->update(
+ 'recentchanges',
+ array(
'rc_patrolled' => 1
- ), array( /* WHERE */
+ ),
+ array(
'rc_id' => $rcid
- ), $fname
+ ),
+ __METHOD__
);
}
# Makes an entry in the database corresponding to an edit
- /*static*/ function notifyEdit( $timestamp, &$title, $minor, &$user, $comment,
+ public static function notifyEdit( $timestamp, &$title, $minor, &$user, $comment,
$oldId, $lastTimestamp, $bot = "default", $ip = '', $oldSize = 0, $newSize = 0,
$newId = 0)
{
@@ -280,10 +312,8 @@ class RecentChange
* Makes an entry in the database corresponding to page creation
* Note: the title object must be loaded with the new id using resetArticleID()
* @todo Document parameters and return
- * @public
- * @static
*/
- public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot = "default",
+ public static function notifyNew( $timestamp, &$title, $minor, &$user, $comment, $bot = 'default',
$ip='', $size = 0, $newId = 0 )
{
if ( !$ip ) {
@@ -292,7 +322,7 @@ class RecentChange
$ip = '';
}
}
- if ( $bot == 'default' ) {
+ if ( $bot === 'default' ) {
$bot = $user->isAllowed( 'bot' );
}
@@ -331,7 +361,7 @@ class RecentChange
}
# Makes an entry in the database corresponding to a rename
- /*static*/ function notifyMove( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='', $overRedir = false )
+ public static function notifyMove( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='', $overRedir = false )
{
if ( !$ip ) {
$ip = wfGetIP();
@@ -372,17 +402,17 @@ class RecentChange
$rc->save();
}
- /* static */ function notifyMoveToNew( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='' ) {
+ public static function notifyMoveToNew( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='' ) {
RecentChange::notifyMove( $timestamp, $oldTitle, $newTitle, $user, $comment, $ip, false );
}
- /* static */ function notifyMoveOverRedirect( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='' ) {
+ public static function notifyMoveOverRedirect( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='' ) {
RecentChange::notifyMove( $timestamp, $oldTitle, $newTitle, $user, $comment, $ip, true );
}
# A log entry is different to an edit in that previous revisions are
# not kept
- /*static*/ function notifyLog( $timestamp, &$title, &$user, $comment, $ip='',
+ public static function notifyLog( $timestamp, &$title, &$user, $comment, $ip='',
$type, $action, $target, $logComment, $params )
{
if ( !$ip ) {
@@ -595,4 +625,4 @@ class RecentChange
}
}
}
-?>
+