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

Revision: 114462
Author:   jeroendedauw
Date:     2012-03-23 22:51:22 +0000 (Fri, 23 Mar 2012)
Log Message:
-----------
fix enlistment issue

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

Modified: trunk/extensions/EducationProgram/includes/EPCourse.php
===================================================================
--- trunk/extensions/EducationProgram/includes/EPCourse.php     2012-03-23 
22:28:47 UTC (rev 114461)
+++ trunk/extensions/EducationProgram/includes/EPCourse.php     2012-03-23 
22:51:22 UTC (rev 114462)
@@ -466,10 +466,25 @@
                                $this->$classField = array();
                        }
                        else {
-                               $this->$classField = 
$tableName::singleton()->select(
+                               $table = $tableName::singleton();
+
+                               $this->$classField = $table->select(
                                        null,
                                        array( 'user_id' => $userIds )
                                );
+
+                               // At this point we will have all users that 
actually have an entry in the role table.
+                               // But it's possible they do not have such an 
entry, so create new objects for those.
+
+                               $addedIds = array();
+
+                               foreach ( $this->$classField as /* EPRole */ 
$userInRole ) {
+                                       $addedIds[] = $userInRole->getField( 
'user_id' );
+                               }
+
+                               foreach ( array_diff( $userIds, $addedIds ) as 
$remainingId ) {
+                                       array_push( $this->$classField, 
$table->newFromArray( array( 'user_id' => $remainingId ) ) );
+                               }
                        }
                }
 


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

Reply via email to