r108753 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108752‎ | r108753 | r108754 >
Date:20:33, 12 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on special:term and student pager
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPStudent.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPStudentPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPTerm.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialTerm.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialTerm.php
@@ -71,7 +71,14 @@
7272
7373 $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-term-students' ) ) );
7474
75 - // TODO: students
 75+ $studentIds = array_map(
 76+ function( EPStudent $student ) {
 77+ return $student->getId();
 78+ },
 79+ $term->getStudents( 'id' )
 80+ );
 81+
 82+ EPStudent::displayPager( $this->getContext(), array( 'id' => $studentIds ) );
7683 }
7784 }
7885 }
Index: trunk/extensions/EducationProgram/includes/EPStudentPager.php
@@ -75,7 +75,7 @@
7676 $value = Linker::userLink( $value, $name ) . Linker::userToolLinks( $value, $name );
7777 break;
7878 case 'first_enroll': case 'last_active':
79 - htmlspecialchars( $this->getLanguage()->date( $value ) );
 79+ $value = htmlspecialchars( $this->getLanguage()->date( $value ) );
8080 break;
8181 case 'active_enroll':
8282 $value = wfMsgHtml( $value === '1' ? 'epstudentpager-yes' : 'epstudentpager-no' );
@@ -84,7 +84,7 @@
8585 $value = $this->getLanguage()->pipeList( array_map(
8686 function( EPCourse $course ) {
8787 return $course->getLink();
88 - } ,
 88+ },
8989 $this->currentObject->getCurrentCourses( 'name' )
9090 ) );
9191 break;
Index: trunk/extensions/EducationProgram/includes/EPStudent.php
@@ -99,7 +99,7 @@
100100 }
101101
102102 /**
103 - * Returns the orgs this mentor is part of.
 103+ * Returns the terms this student is enrolled in.
104104 * Caches the result when no conditions are provided and all fields are selected.
105105 *
106106 * @since 0.1
Index: trunk/extensions/EducationProgram/includes/EPTerm.php
@@ -31,6 +31,14 @@
3232 protected $org = false;
3333
3434 /**
 35+ * Cached array of the linked EPStudent objects.
 36+ *
 37+ * @since 0.1
 38+ * @var array|false
 39+ */
 40+ protected $students = false;
 41+
 42+ /**
3543 * Returns a list of statuses a term can have.
3644 * Keys are messages, values are identifiers.
3745 *
@@ -101,6 +109,60 @@
102110 }
103111
104112 /**
 113+ * Returns the students enrolled in this term.
 114+ *
 115+ * @since 0.1
 116+ *
 117+ * @param string|array|null $fields
 118+ * @param array $conditions
 119+ *
 120+ * @return array of EPStudent
 121+ */
 122+ protected function doGetStudents( $fields, array $conditions ) {
 123+ $conditions[] = array( array( 'ep_terms', 'id' ), $this->getId() );
 124+
 125+ return EPStudent::select(
 126+ $fields,
 127+ $conditions,
 128+ array(),
 129+ array(
 130+ 'ep_students_per_term' => array( 'INNER JOIN', array( array( array( 'ep_students_per_term', 'term_id' ), array( 'ep_terms', 'id' ) ) ) ),
 131+ 'ep_terms' => array( 'INNER JOIN', array( array( array( 'ep_students_per_term', 'term_id' ), array( 'ep_terms', 'id' ) ) ) )
 132+ )
 133+ );
 134+ }
 135+
 136+ /**
 137+ * Returns the students enrolled in this term.
 138+ * Caches the result when no conditions are provided and all fields are selected.
 139+ *
 140+ * @since 0.1
 141+ *
 142+ * @param string|array|null $fields
 143+ * @param array $conditions
 144+ *
 145+ * @return array of EPStudent
 146+ */
 147+ public function getStudents( $fields = null, array $conditions = array() ) {
 148+ if ( count( $conditions ) !== 0 ) {
 149+ return $this->doGetStudents( $fields, $conditions );
 150+ }
 151+
 152+ if ( $this->students === false ) {
 153+ $students = $this->doGetStudents( $fields, $conditions );
 154+
 155+ if ( is_null( $fields ) ) {
 156+ $this->students = $students;
 157+ }
 158+
 159+ return $students;
 160+ }
 161+ else {
 162+ return $this->students;
 163+ }
 164+ }
 165+
 166+ /**
105167 * (non-PHPdoc)
106168 * @see EPDBObject::loadSummaryFields()
107169 */

Status & tagging log