r113983 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113982‎ | r113983 | r113984 >
Date:00:41, 16 March 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
update last_active field on edits
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.hooks.php (modified) (history)
  • /trunk/extensions/EducationProgram/EducationProgram.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/EducationProgram.php
@@ -194,6 +194,7 @@
195195 $wgHooks['CanonicalNamespaces'][] = 'EPHooks::onCanonicalNamespaces';
196196 $wgHooks['TitleIsAlwaysKnown'][] = 'EPHooks::onTitleIsAlwaysKnown';
197197 $wgHooks['AbortMove'][] = 'EPHooks::onAbortMove';
 198+$wgHooks['NewRevisionFromEditComplete'][] = 'EPHooks::onNewRevisionFromEditComplete';
198199
199200 // Actions
200201 $wgActions['epremarticle'] = 'EPRemoveArticleAction';
Index: trunk/extensions/EducationProgram/specials/SpecialStudentActivity.php
@@ -167,7 +167,7 @@
168168 }
169169 break;
170170 case 'last_active':
171 - $value = htmlspecialchars( $this->getLanguage()->date( $value ) );
 171+ $value = htmlspecialchars( $this->getLanguage()->timeanddate( $value ) );
172172 break;
173173 case 'last_course':
174174 if ( array_key_exists( $value, $this->courseNames ) ) {
Index: trunk/extensions/EducationProgram/EducationProgram.hooks.php
@@ -381,5 +381,35 @@
382382
383383 return $allowed;
384384 }
 385+
 386+ /**
 387+ * Called when a revision was inserted due to an edit.
 388+ * @see https://www.mediawiki.org/wiki/Manual:Hooks/NewRevisionFromEditComplete
 389+ *
 390+ * @since 0.1
 391+ *
 392+ * @param weirdStuffButProbablyWikiPage $article
 393+ * @param Revision $rev
 394+ * @param integer $baseID
 395+ * @param User $user
 396+ *
 397+ * @return true
 398+ */
 399+ public static function onNewRevisionFromEditComplete( $article, Revision $rev, $baseID, User $user ) {
 400+ if ( $article->getTitle()->inNamespaces( NS_MAIN, NS_TALK ) ) {
 401+ $studentId = EPStudents::singleton()->selectFieldsRow( 'id', array( 'user_id' => $user->getId() ) );
 402+
 403+ if ( $studentId !== false ) {
 404+ $student = EPStudent::newFromUserId( $user->getId() );
 405+ $student->setFields( array(
 406+ 'id' => $studentId,
 407+ 'last_active' => wfTimestampNow()
 408+ ) );
 409+ $student->save();
 410+ }
 411+ }
 412+
 413+ return true;
 414+ }
385415
386416 }

Status & tagging log