r111196 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111195‎ | r111196 | r111197 >
Date:20:31, 10 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r111172; r111184
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/ViewCourseAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/actions/ViewOrgAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCoursePager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrg.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrgPager.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRevisionedObject.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRoleObject.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/actions/ViewCourseAction.php
@@ -71,7 +71,7 @@
7272 $stats['start'] = htmlspecialchars( $lang->timeanddate( $course->getField( 'start' ), true ) );
7373 $stats['end'] = htmlspecialchars( $lang->timeanddate( $course->getField( 'end' ), true ) );
7474
75 - $stats['students'] = htmlspecialchars( $lang->formatNum( $course->getField( 'students' ) ) );
 75+ $stats['students'] = htmlspecialchars( $lang->formatNum( $course->getField( 'student_count' ) ) );
7676
7777 $stats['status'] = htmlspecialchars( EPCourse::getStatusMessage( $course->getStatus() ) );
7878
Index: trunk/extensions/EducationProgram/actions/ViewOrgAction.php
@@ -58,14 +58,14 @@
5959
6060 $stats['status'] = wfMsgHtml( $org->getField( 'active' ) ? 'ep-institution-active' : 'ep-institution-inactive' );
6161
62 - $stats['courses'] = $this->getLanguage()->formatNum( $org->getField( 'courses' ) );
63 - $stats['students'] = $this->getLanguage()->formatNum( $org->getField( 'students' ) );
 62+ $stats['courses'] = $this->getLanguage()->formatNum( $org->getField( 'course_count' ) );
 63+ $stats['students'] = $this->getLanguage()->formatNum( $org->getField( 'student_count' ) );
6464
6565 foreach ( $stats as &$stat ) {
6666 $stat = htmlspecialchars( $stat );
6767 }
6868
69 - if ( $org->getField( 'courses' ) > 0 ) {
 69+ if ( $org->getField( 'course_count' ) > 0 ) {
7070 $stats['courses'] = Linker::linkKnown(
7171 SpecialPage::getTitleFor( 'Courses' ),
7272 $stats['courses'],
Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php
@@ -33,8 +33,8 @@
3434 'name',
3535 'city',
3636 'country',
37 - 'courses',
38 - 'students',
 37+ 'course_count',
 38+ 'student_count',
3939 'active',
4040 );
4141 }
@@ -68,13 +68,13 @@
6969 $countries = array_flip( EPUtils::getCountryOptions( $this->getLanguage()->getCode() ) );
7070 $value = htmlspecialchars( $countries[$value] );
7171 break;
72 - case 'courses': case 'students':
 72+ case 'course_count': case 'student_count':
7373 $rawValue = $value;
7474 $value = htmlspecialchars( $this->getLanguage()->formatNum( $value ) );
7575
76 - if ( $rawValue > 0 && $name === 'courses' ) {
 76+ if ( $rawValue > 0 && $name === 'course_count' ) {
7777 $value = Linker::linkKnown(
78 - SpecialPage::getTitleFor( $this->getLanguage()->ucfirst( $name ) ),
 78+ SpecialPage::getTitleFor( 'Courses' ),
7979 $value,
8080 array(),
8181 array( 'org_id' => $this->currentObject->getId() )
@@ -99,8 +99,8 @@
100100 'name',
101101 'city',
102102 'country',
103 - 'courses',
104 - 'students',
 103+ 'course_count',
 104+ 'student_count',
105105 'active',
106106 );
107107 }
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php
@@ -45,7 +45,7 @@
4646 'org_id',
4747 'term',
4848 'lang',
49 - 'students',
 49+ 'student_count',
5050 );
5151 }
5252
@@ -101,7 +101,7 @@
102102 break;
103103 case '_status':
104104 $value = htmlspecialchars( EPCourse::getStatusMessage( $this->currentObject->getStatus() ) );
105 - case 'students':
 105+ case 'student_count':
106106 $value = htmlspecialchars( $this->getLanguage()->formatNum( $value ) );
107107 break;
108108 }
@@ -117,10 +117,8 @@
118118 return array(
119119 'name',
120120 'term',
121 -// 'start',
122 -// 'end',
123121 'lang',
124 - 'students',
 122+ 'student_count',
125123 );
126124 }
127125
@@ -131,12 +129,8 @@
132130 public function getFieldNames() {
133131 $fields = parent::getFieldNames();
134132
135 -// if ( array_key_exists( 'mc_id', $this->conds ) && array_key_exists( 'org_id', $fields ) ) {
136 -// unset( $fields['org_id'] );
137 -// }
 133+ $fields = wfArrayInsertAfter( $fields, array( '_status' => 'status' ), 'student_count' );
138134
139 - $fields = wfArrayInsertAfter( $fields, array( '_status' => 'status' ), 'students' );
140 -
141135 return $fields;
142136 }
143137
Index: trunk/extensions/EducationProgram/includes/EPOrg.php
@@ -37,7 +37,7 @@
3838 'country' => 'str',
3939
4040 'active' => 'bool',
41 - 'courses' => 'int',
 41+ 'course_count' => 'int',
4242 'student_count' => 'int',
4343 'instructor_count' => 'int',
4444 'ca_count' => 'int',
@@ -56,7 +56,7 @@
5757 'country' => '',
5858
5959 'active' => false,
60 - 'courses' => 0,
 60+ 'course_count' => 0,
6161 'student_count' => 0,
6262 'instructor_count' => 0,
6363 'ca_count' => 0,
@@ -71,7 +71,7 @@
7272 public static function getSummaryFields() {
7373 return array(
7474 'active',
75 - 'courses',
 75+ 'course_count',
7676 'student_count',
7777 'instructor_count',
7878 'ca_count',
@@ -85,7 +85,7 @@
8686 */
8787 public function loadSummaryFields( $summaryFields = null ) {
8888 if ( is_null( $summaryFields ) ) {
89 - $summaryFields = array( 'courses', 'active', 'student_count', 'instructor_count', 'oa_count', 'ca_count' );
 89+ $summaryFields = array( 'course_count', 'active', 'student_count', 'instructor_count', 'oa_count', 'ca_count' );
9090 }
9191 else {
9292 $summaryFields = (array)$summaryFields;
@@ -93,8 +93,8 @@
9494
9595 $fields = array();
9696
97 - if ( in_array( 'courses', $summaryFields ) ) {
98 - $fields['courses'] = EPCourse::count( array( 'org_id' => $this->getId() ) );
 97+ if ( in_array( 'course_count', $summaryFields ) ) {
 98+ $fields['course_count'] = EPCourse::count( array( 'org_id' => $this->getId() ) );
9999 }
100100
101101 $dbr = wfGetDB( DB_SLAVE );
@@ -111,7 +111,7 @@
112112
113113 foreach ( array( 'student_count', 'instructor_count', 'oa_count', 'ca_count' ) as $field ) {
114114 $fields[$field] = EPCourse::rawSelect(
115 - 'SUM(' . $dbr->addQuotes( $field ) . ') AS sum',
 115+ array( 'SUM(' . $dbr->addQuotes( $field ) . ') AS sum' ),
116116 EPCourse::getPrefixedValues( array(
117117 'org_id' => $this->getId()
118118 ) )
Index: trunk/extensions/EducationProgram/includes/EPRoleObject.php
@@ -239,7 +239,7 @@
240240 return EPUtils::getCoursesForUser(
241241 $fields,
242242 $this->getField( 'user_id' ),
243 - $this->getRoleName( getRoleId ),
 243+ EPUtils::getRoleId( $this->getRoleName() ),
244244 $conditions
245245 );
246246 }
Index: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php
@@ -139,19 +139,18 @@
140140 static::setReadDb( DB_MASTER );
141141 $originalObject = static::selectRow( null, array( 'id' => $this->getId() ) );
142142 static::setReadDb( DB_SLAVE );
143 - }
144143
145 - if ( $originalObject === false ) {
146 - return false;
 144+ if ( $originalObject === false ) {
 145+ return false;
 146+ }
147147 }
148148
149149 $success = true;
150150
151151 if ( $this->inSummaryMode || $this->fieldsChanged( $originalObject, true ) ) {
152 -
153152 $success = parent::saveExisting();
154153
155 - if ( $success ) {
 154+ if ( $success && !$this->inSummaryMode ) {
156155 $this->onUpdated( $originalObject );
157156 }
158157 }
@@ -160,17 +159,16 @@
161160 }
162161
163162 /**
 163+ * Gets called after an existing object was updated in the database.
 164+ * Unless the class is in summary mode @see $this->inSummaryMode
164165 *
165 - *
166166 * @since 0.1
167167 *
168168 * @param EPRevisionedObject $originalObject
169169 */
170170 protected function onUpdated( EPRevisionedObject $originalObject ) {
171 - if ( !$this->inSummaryMode ) {
172 - $this->storeRevision( $originalObject );
173 - $this->log( 'update' );
174 - }
 171+ $this->storeRevision( $originalObject );
 172+ $this->log( 'update' );
175173 }
176174
177175 /**
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -205,7 +205,7 @@
206206 $success = parent::insert();
207207
208208 if ( $success && $this->updateSummaries ) {
209 - EPOrg::updateSummaryFields( array( 'courses', 'active' ), array( 'id' => $this->getField( 'org_id' ) ) );
 209+ EPOrg::updateSummaryFields( array( 'course_count', 'active' ), array( 'id' => $this->getField( 'org_id' ) ) );
210210 }
211211
212212 return $success;
@@ -582,6 +582,9 @@
583583 case 'campus':
584584 return $this->getCampusAmbassadors();
585585 break;
 586+ case 'student':
 587+ return $this->getStudents();
 588+ break;
586589 }
587590
588591 throw new MWException( 'Invalid role name: ' . $roleName );
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -211,8 +211,8 @@
212212 'eporgpager-header-city' => 'City',
213213 'eporgpager-header-country' => 'Country',
214214 'eporgpager-filter-country' => 'Country',
215 - 'eporgpager-header-courses' => 'Courses',
216 - 'eporgpager-header-students' => 'Students',
 215+ 'eporgpager-header-course-count' => 'Courses',
 216+ 'eporgpager-header-student-count' => 'Students',
217217 'eporgpager-header-active' => 'Active',
218218 'eporgpager-filter-active' => 'Active courses',
219219 'eporgpager-yes' => 'Yes',
@@ -233,7 +233,7 @@
234234 'epcoursepager-header-org-id' => 'Institution',
235235 'epcoursepager-header-end' => 'End',
236236 'epcoursepager-header-status' => 'Status',
237 - 'epcoursepager-header-students' => 'Students',
 237+ 'epcoursepager-header-student-count' => 'Students',
238238 'epcoursepager-header-lang' => 'Language',
239239 'epcoursepager-filter-term' => 'Term',
240240 'epcoursepager-filter-lang' => 'Language',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111172schema changesjeroendedauw18:07, 10 February 2012
r111184Follow up to r111172;jeroendedauw19:21, 10 February 2012

Status & tagging log