https://www.mediawiki.org/wiki/Special:Code/MediaWiki/113344
Revision: 113344
Author: jeroendedauw
Date: 2012-03-08 02:28:13 +0000 (Thu, 08 Mar 2012)
Log Message:
-----------
added logging of student article removal
Modified Paths:
--------------
trunk/extensions/EducationProgram/EducationProgram.i18n.php
trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php
trunk/extensions/EducationProgram/includes/EPArticle.php
trunk/extensions/EducationProgram/includes/EPOrg.php
Modified: trunk/extensions/EducationProgram/EducationProgram.i18n.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-03-08
02:03:12 UTC (rev 113343)
+++ trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-03-08
02:28:13 UTC (rev 113344)
@@ -119,6 +119,7 @@
'logentry-student-selfremove' => '$1 disenrolled from course $3',
'logentry-eparticle-add' => '$1 added article $4 to
{{GENDER:$2|his|her}} list of articles at course $3',
+ 'logentry-eparticle-remove' => '$1 removed article $4 from
{{GENDER:$2|his|her}} list of articles at course $3',
// Preferences
'prefs-education' => 'Education',
Modified: trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php
===================================================================
--- trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php
2012-03-08 02:03:12 UTC (rev 113343)
+++ trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php
2012-03-08 02:28:13 UTC (rev 113344)
@@ -31,13 +31,28 @@
$user = $this->getUser();
if ( $user->matchEditToken( $req->getText( 'token' ),
'remarticle' . $req->getInt( 'article-id' ) ) ) {
- $article = EPArticles::singleton()->selectRow( 'id',
array(
- 'id' => $req->getInt( 'article-id' ),
- 'user_id' => $user->getId(),
- ) );
+ $article = EPArticles::singleton()->selectRow(
+ array(
+ 'id',
+ 'course_id',
+ 'page_id',
+ ),
+ array(
+ 'id' => $req->getInt( 'article-id' ),
+ 'user_id' => $user->getId(),
+ )
+ );
if ( $article !== false && $article->remove() ) {
- // TODO: log
+ EPUtils::log( array(
+ 'type' => 'eparticle',
+ 'subtype' => 'remove',
+ 'user' => $this->getUser(),
+ 'title' =>
$article->getCourse()->getTitle(),
+ 'parameters' => array(
+ '4::articlename' =>
$article->getTitle()->getFullText(),
+ ),
+ ) );
}
}
Modified: trunk/extensions/EducationProgram/includes/EPArticle.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPArticle.php 2012-03-08
02:03:12 UTC (rev 113343)
+++ trunk/extensions/EducationProgram/includes/EPArticle.php 2012-03-08
02:28:13 UTC (rev 113344)
@@ -6,7 +6,7 @@
*
* @since 0.1
*
- * @file EPRevision.php
+ * @file EPArticle.php
* @ingroup EducationProgram
*
* @licence GNU GPL v3 or later
@@ -15,7 +15,7 @@
class EPArticle extends DBDataObject {
/**
- * Cached user object for this revision.
+ * Cached user object for this article.
*
* @since 0.1
* @var User|false
@@ -23,7 +23,7 @@
protected $user = false;
/**
- * Cached title object for this revision.
+ * Cached title object for this article.
*
* @since 0.1
* @var Title|false
@@ -31,6 +31,14 @@
protected $title = false;
/**
+ * Cached course object for this article.
+ *
+ * @since 0.1
+ * @var Course|false
+ */
+ protected $course = false;
+
+ /**
* Returns the user that is working on this article.
*
* @since 0.1
@@ -86,6 +94,27 @@
return $this->title;
}
+ /**
+ * Returns the course this article is linked to.
+ *
+ * @since 0.1
+ *
+ * @param array|string|null $fields
+ *
+ * @return EPCourse|false
+ */
+ public function getCourse( $fields = null ) {
+ if ( $this->course === false ) {
+ $course = EPCourses::singleton()->selectRow( $fields,
array( 'id' => $this->getField( 'course_id' ) ) );
+
+ if ( is_null( $fields ) ) {
+ $this->course = $course;
+ }
+ }
+
+ return $this->course === false ? $course : $this->course;
+ }
+
protected $canBecomeReviwer = array();
public function canBecomeReviewer( User $user ) {
Modified: trunk/extensions/EducationProgram/includes/EPOrg.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPOrg.php 2012-03-08
02:03:12 UTC (rev 113343)
+++ trunk/extensions/EducationProgram/includes/EPOrg.php 2012-03-08
02:28:13 UTC (rev 113344)
@@ -224,7 +224,7 @@
*
* @since 0.1
*
- * @param array|null $fields
+ * @param array|string|null $fields
*
* @return array of EPCourse
*/
@@ -237,7 +237,7 @@
}
}
- return $this->courses === false ? $courses : $courses;
+ return $this->courses === false ? $courses : $this->courses;
}
}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs