Index: trunk/extensions/EducationProgram/actions/ViewCourseAction.php |
— | — | @@ -71,7 +71,7 @@ |
72 | 72 | $stats['start'] = htmlspecialchars( $lang->timeanddate( $course->getField( 'start' ), true ) ); |
73 | 73 | $stats['end'] = htmlspecialchars( $lang->timeanddate( $course->getField( 'end' ), true ) ); |
74 | 74 | |
75 | | - $stats['students'] = htmlspecialchars( $lang->formatNum( $course->getField( 'students' ) ) ); |
| 75 | + $stats['students'] = htmlspecialchars( $lang->formatNum( $course->getField( 'student_count' ) ) ); |
76 | 76 | |
77 | 77 | $stats['status'] = htmlspecialchars( EPCourse::getStatusMessage( $course->getStatus() ) ); |
78 | 78 | |
Index: trunk/extensions/EducationProgram/actions/ViewOrgAction.php |
— | — | @@ -58,14 +58,14 @@ |
59 | 59 | |
60 | 60 | $stats['status'] = wfMsgHtml( $org->getField( 'active' ) ? 'ep-institution-active' : 'ep-institution-inactive' ); |
61 | 61 | |
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' ) ); |
64 | 64 | |
65 | 65 | foreach ( $stats as &$stat ) { |
66 | 66 | $stat = htmlspecialchars( $stat ); |
67 | 67 | } |
68 | 68 | |
69 | | - if ( $org->getField( 'courses' ) > 0 ) { |
| 69 | + if ( $org->getField( 'course_count' ) > 0 ) { |
70 | 70 | $stats['courses'] = Linker::linkKnown( |
71 | 71 | SpecialPage::getTitleFor( 'Courses' ), |
72 | 72 | $stats['courses'], |
Index: trunk/extensions/EducationProgram/includes/EPOrgPager.php |
— | — | @@ -33,8 +33,8 @@ |
34 | 34 | 'name', |
35 | 35 | 'city', |
36 | 36 | 'country', |
37 | | - 'courses', |
38 | | - 'students', |
| 37 | + 'course_count', |
| 38 | + 'student_count', |
39 | 39 | 'active', |
40 | 40 | ); |
41 | 41 | } |
— | — | @@ -68,13 +68,13 @@ |
69 | 69 | $countries = array_flip( EPUtils::getCountryOptions( $this->getLanguage()->getCode() ) ); |
70 | 70 | $value = htmlspecialchars( $countries[$value] ); |
71 | 71 | break; |
72 | | - case 'courses': case 'students': |
| 72 | + case 'course_count': case 'student_count': |
73 | 73 | $rawValue = $value; |
74 | 74 | $value = htmlspecialchars( $this->getLanguage()->formatNum( $value ) ); |
75 | 75 | |
76 | | - if ( $rawValue > 0 && $name === 'courses' ) { |
| 76 | + if ( $rawValue > 0 && $name === 'course_count' ) { |
77 | 77 | $value = Linker::linkKnown( |
78 | | - SpecialPage::getTitleFor( $this->getLanguage()->ucfirst( $name ) ), |
| 78 | + SpecialPage::getTitleFor( 'Courses' ), |
79 | 79 | $value, |
80 | 80 | array(), |
81 | 81 | array( 'org_id' => $this->currentObject->getId() ) |
— | — | @@ -99,8 +99,8 @@ |
100 | 100 | 'name', |
101 | 101 | 'city', |
102 | 102 | 'country', |
103 | | - 'courses', |
104 | | - 'students', |
| 103 | + 'course_count', |
| 104 | + 'student_count', |
105 | 105 | 'active', |
106 | 106 | ); |
107 | 107 | } |
Index: trunk/extensions/EducationProgram/includes/EPCoursePager.php |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | 'org_id', |
47 | 47 | 'term', |
48 | 48 | 'lang', |
49 | | - 'students', |
| 49 | + 'student_count', |
50 | 50 | ); |
51 | 51 | } |
52 | 52 | |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | break; |
103 | 103 | case '_status': |
104 | 104 | $value = htmlspecialchars( EPCourse::getStatusMessage( $this->currentObject->getStatus() ) ); |
105 | | - case 'students': |
| 105 | + case 'student_count': |
106 | 106 | $value = htmlspecialchars( $this->getLanguage()->formatNum( $value ) ); |
107 | 107 | break; |
108 | 108 | } |
— | — | @@ -117,10 +117,8 @@ |
118 | 118 | return array( |
119 | 119 | 'name', |
120 | 120 | 'term', |
121 | | -// 'start', |
122 | | -// 'end', |
123 | 121 | 'lang', |
124 | | - 'students', |
| 122 | + 'student_count', |
125 | 123 | ); |
126 | 124 | } |
127 | 125 | |
— | — | @@ -131,12 +129,8 @@ |
132 | 130 | public function getFieldNames() { |
133 | 131 | $fields = parent::getFieldNames(); |
134 | 132 | |
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' ); |
138 | 134 | |
139 | | - $fields = wfArrayInsertAfter( $fields, array( '_status' => 'status' ), 'students' ); |
140 | | - |
141 | 135 | return $fields; |
142 | 136 | } |
143 | 137 | |
Index: trunk/extensions/EducationProgram/includes/EPOrg.php |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | 'country' => 'str', |
39 | 39 | |
40 | 40 | 'active' => 'bool', |
41 | | - 'courses' => 'int', |
| 41 | + 'course_count' => 'int', |
42 | 42 | 'student_count' => 'int', |
43 | 43 | 'instructor_count' => 'int', |
44 | 44 | 'ca_count' => 'int', |
— | — | @@ -56,7 +56,7 @@ |
57 | 57 | 'country' => '', |
58 | 58 | |
59 | 59 | 'active' => false, |
60 | | - 'courses' => 0, |
| 60 | + 'course_count' => 0, |
61 | 61 | 'student_count' => 0, |
62 | 62 | 'instructor_count' => 0, |
63 | 63 | 'ca_count' => 0, |
— | — | @@ -71,7 +71,7 @@ |
72 | 72 | public static function getSummaryFields() { |
73 | 73 | return array( |
74 | 74 | 'active', |
75 | | - 'courses', |
| 75 | + 'course_count', |
76 | 76 | 'student_count', |
77 | 77 | 'instructor_count', |
78 | 78 | 'ca_count', |
— | — | @@ -85,7 +85,7 @@ |
86 | 86 | */ |
87 | 87 | public function loadSummaryFields( $summaryFields = null ) { |
88 | 88 | 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' ); |
90 | 90 | } |
91 | 91 | else { |
92 | 92 | $summaryFields = (array)$summaryFields; |
— | — | @@ -93,8 +93,8 @@ |
94 | 94 | |
95 | 95 | $fields = array(); |
96 | 96 | |
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() ) ); |
99 | 99 | } |
100 | 100 | |
101 | 101 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | |
113 | 113 | foreach ( array( 'student_count', 'instructor_count', 'oa_count', 'ca_count' ) as $field ) { |
114 | 114 | $fields[$field] = EPCourse::rawSelect( |
115 | | - 'SUM(' . $dbr->addQuotes( $field ) . ') AS sum', |
| 115 | + array( 'SUM(' . $dbr->addQuotes( $field ) . ') AS sum' ), |
116 | 116 | EPCourse::getPrefixedValues( array( |
117 | 117 | 'org_id' => $this->getId() |
118 | 118 | ) ) |
Index: trunk/extensions/EducationProgram/includes/EPRoleObject.php |
— | — | @@ -239,7 +239,7 @@ |
240 | 240 | return EPUtils::getCoursesForUser( |
241 | 241 | $fields, |
242 | 242 | $this->getField( 'user_id' ), |
243 | | - $this->getRoleName( getRoleId ), |
| 243 | + EPUtils::getRoleId( $this->getRoleName() ), |
244 | 244 | $conditions |
245 | 245 | ); |
246 | 246 | } |
Index: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php |
— | — | @@ -139,19 +139,18 @@ |
140 | 140 | static::setReadDb( DB_MASTER ); |
141 | 141 | $originalObject = static::selectRow( null, array( 'id' => $this->getId() ) ); |
142 | 142 | static::setReadDb( DB_SLAVE ); |
143 | | - } |
144 | 143 | |
145 | | - if ( $originalObject === false ) { |
146 | | - return false; |
| 144 | + if ( $originalObject === false ) { |
| 145 | + return false; |
| 146 | + } |
147 | 147 | } |
148 | 148 | |
149 | 149 | $success = true; |
150 | 150 | |
151 | 151 | if ( $this->inSummaryMode || $this->fieldsChanged( $originalObject, true ) ) { |
152 | | - |
153 | 152 | $success = parent::saveExisting(); |
154 | 153 | |
155 | | - if ( $success ) { |
| 154 | + if ( $success && !$this->inSummaryMode ) { |
156 | 155 | $this->onUpdated( $originalObject ); |
157 | 156 | } |
158 | 157 | } |
— | — | @@ -160,17 +159,16 @@ |
161 | 160 | } |
162 | 161 | |
163 | 162 | /** |
| 163 | + * Gets called after an existing object was updated in the database. |
| 164 | + * Unless the class is in summary mode @see $this->inSummaryMode |
164 | 165 | * |
165 | | - * |
166 | 166 | * @since 0.1 |
167 | 167 | * |
168 | 168 | * @param EPRevisionedObject $originalObject |
169 | 169 | */ |
170 | 170 | 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' ); |
175 | 173 | } |
176 | 174 | |
177 | 175 | /** |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -205,7 +205,7 @@ |
206 | 206 | $success = parent::insert(); |
207 | 207 | |
208 | 208 | 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' ) ) ); |
210 | 210 | } |
211 | 211 | |
212 | 212 | return $success; |
— | — | @@ -582,6 +582,9 @@ |
583 | 583 | case 'campus': |
584 | 584 | return $this->getCampusAmbassadors(); |
585 | 585 | break; |
| 586 | + case 'student': |
| 587 | + return $this->getStudents(); |
| 588 | + break; |
586 | 589 | } |
587 | 590 | |
588 | 591 | throw new MWException( 'Invalid role name: ' . $roleName ); |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -211,8 +211,8 @@ |
212 | 212 | 'eporgpager-header-city' => 'City', |
213 | 213 | 'eporgpager-header-country' => 'Country', |
214 | 214 | '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', |
217 | 217 | 'eporgpager-header-active' => 'Active', |
218 | 218 | 'eporgpager-filter-active' => 'Active courses', |
219 | 219 | 'eporgpager-yes' => 'Yes', |
— | — | @@ -233,7 +233,7 @@ |
234 | 234 | 'epcoursepager-header-org-id' => 'Institution', |
235 | 235 | 'epcoursepager-header-end' => 'End', |
236 | 236 | 'epcoursepager-header-status' => 'Status', |
237 | | - 'epcoursepager-header-students' => 'Students', |
| 237 | + 'epcoursepager-header-student-count' => 'Students', |
238 | 238 | 'epcoursepager-header-lang' => 'Language', |
239 | 239 | 'epcoursepager-filter-term' => 'Term', |
240 | 240 | 'epcoursepager-filter-lang' => 'Language', |