Index: trunk/extensions/EducationProgram/includes/EPArticleTable.php |
— | — | @@ -518,9 +518,9 @@ |
519 | 519 | */ |
520 | 520 | protected function doBatchLookups() { |
521 | 521 | $userIds = array(); |
| 522 | + $field = $this->table->getPrefixedField( 'org_id' ); |
522 | 523 | |
523 | 524 | while( $student = $this->mResult->fetchObject() ) { |
524 | | - $field = EPStudents::singleton()->getPrefixedField( 'user_id' ); |
525 | 525 | $userIds[] = $student->$field; |
526 | 526 | $this->articles[$student->$field] = array(); |
527 | 527 | } |
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php |
— | — | @@ -20,6 +20,15 @@ |
21 | 21 | * @var boolean |
22 | 22 | */ |
23 | 23 | protected $readOnlyMode; |
| 24 | + |
| 25 | + /** |
| 26 | + * List of org names, looked up in batch before the rows are displayed. |
| 27 | + * org id => org name |
| 28 | + * |
| 29 | + * @since 0.1 |
| 30 | + * @var array |
| 31 | + */ |
| 32 | + protected $orgNames; |
24 | 33 | |
25 | 34 | /** |
26 | 35 | * Constructor. |
— | — | @@ -72,15 +81,11 @@ |
73 | 82 | public function getFormattedValue( $name, $value ) { |
74 | 83 | switch ( $name ) { |
75 | 84 | case 'name': |
76 | | - $value = EPCourses::singleton()->getLinkFor( $value ); |
| 85 | + $value = $this->table->getLinkFor( $value ); |
77 | 86 | break; |
78 | 87 | case 'org_id': |
79 | | - $org = EPOrgs::singleton()->selectRow( 'name', array( 'id' => $value ) ); |
80 | | - |
81 | | - // This should not happen. A course should always have an org. |
82 | | - // But if something gets messed up somehow, just display the ID rather then throwing a fatal. |
83 | | - if ( $org !== false ) { |
84 | | - $value = $org->getLink(); |
| 88 | + if ( array_key_exists( $value, $this->orgNames ) ) { |
| 89 | + $value = EPOrgs::singleton()->getLinkFor( $this->orgNames[$value] ); |
85 | 90 | } |
86 | 91 | break; |
87 | 92 | case 'term': |
— | — | @@ -268,4 +273,22 @@ |
269 | 274 | return !$this->readOnlyMode; |
270 | 275 | } |
271 | 276 | |
| 277 | + /** |
| 278 | + * (non-PHPdoc) |
| 279 | + * @see IndexPager::doBatchLookups() |
| 280 | + */ |
| 281 | + protected function doBatchLookups() { |
| 282 | + $orgIds = array(); |
| 283 | + $field = $this->table->getPrefixedField( 'org_id' ); |
| 284 | + |
| 285 | + while( $course = $this->mResult->fetchObject() ) { |
| 286 | + $orgIds[] = $course->$field; |
| 287 | + } |
| 288 | + |
| 289 | + $this->orgNames = EPOrgs::singleton()->selectFields( |
| 290 | + array( 'id', 'name' ), |
| 291 | + array( 'id' => $orgIds ) |
| 292 | + ); |
| 293 | + } |
| 294 | + |
272 | 295 | } |