https://www.mediawiki.org/wiki/Special:Code/MediaWiki/112802

Revision: 112802
Author:   jeroendedauw
Date:     2012-03-01 13:20:59 +0000 (Thu, 01 Mar 2012)
Log Message:
-----------
added missing message and fixed removal of article association on disenroll

Modified Paths:
--------------
    trunk/extensions/EducationProgram/EducationProgram.i18n.php
    trunk/extensions/EducationProgram/includes/EPCourse.php

Modified: trunk/extensions/EducationProgram/EducationProgram.i18n.php
===================================================================
--- trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-03-01 
13:14:48 UTC (rev 112801)
+++ trunk/extensions/EducationProgram/EducationProgram.i18n.php 2012-03-01 
13:20:59 UTC (rev 112802)
@@ -595,7 +595,7 @@
        'ep-mycourses-course-title' => 'My courses: $1 at $2',
        'specialmycourses-summary-name' => 'Course name',
        'specialmycourses-summary-org' => 'Institution name',
-    'ep-mycourses-not-a-student' => 'You are not enrolled in any 
[[Special:Courses|courses]].',
+    'ep-mycourses-nocourses-epstudent' => 'You are not enrolled in any 
[[Special:Courses|courses]].',
        'ep-mycourses-enrollment' => 'Courses I am enrolled in',
        'ep-mycourses-login-first' => 'You need to login before you can view 
your courses.',
        'ep-mycourses-courses-epoa' => '{{PLURAL:$1|Course|Courses}} I am 
{{GENDER:$1|Online Ambassador}} for',

Modified: trunk/extensions/EducationProgram/includes/EPCourse.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPCourse.php     2012-03-01 
13:14:48 UTC (rev 112801)
+++ trunk/extensions/EducationProgram/includes/EPCourse.php     2012-03-01 
13:20:59 UTC (rev 112802)
@@ -617,8 +617,6 @@
         * @return boolean Success indicator
         */
        public function unenlistUsers( $sadUsers, $role, $save = true, 
EPRevisionAction $revAction = null ) {
-               $removedUsers = array();
-               $remaimingUsers = array();
                $sadUsers = (array)$sadUsers;
 
                $roleMap = array(
@@ -630,18 +628,21 @@
 
                $field = $roleMap[$role];
                
-               foreach ( $this->getField( $field ) as $userId ) {
-                       if ( in_array( $userId, $sadUsers ) ) {
-                               $removedUsers[] = $userId;
-                       }
-                       else {
-                               $remaimingUsers[] = $userId;
-                       }
-               }
+               $removedUsers = array_intersect( $sadUsers, $this->getField( 
$field ) );
 
                if ( count( $removedUsers ) > 0 ) {
-                       $this->setField( $field, $remaimingUsers );
+                       $this->setField( $field, array_diff( $this->getField( 
$field ), $sadUsers ) );
 
+                       if ( $role === 'student' ) {
+                               // Get rid of the articles asscoaite 
associations with the student.
+                               // No revisioning is implemented here, so this 
cannot be undone.
+                               // Might want to add revisioning or just add a 
'deleted' flag at some point.
+                               EPArticles::singleton()->delete( array(
+                                       'course_id' => $this->getId(),
+                                       'user_id' => $removedUsers,
+                               ) );
+                       }
+
                        $success = true;
 
                        if ( $save ) {


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to