Index: trunk/extensions/EducationProgram/specials/SpecialCourse.php |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | |
61 | 61 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-description' ) ) ); |
62 | 62 | |
63 | | - $out->addHTML( '<p>' . $this->getOutput()->parse( $course->getField( 'description' ) ) . '</p>' ); |
| 63 | + $out->addHTML( $this->getOutput()->parse( $course->getField( 'description' ) ) ); |
64 | 64 | |
65 | 65 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-terms' ) ) ); |
66 | 66 | |
Index: trunk/extensions/EducationProgram/specials/SpecialTerm.php |
— | — | @@ -55,8 +55,12 @@ |
56 | 56 | } |
57 | 57 | } |
58 | 58 | else { |
59 | | - $this->displayInfo( $term ); |
| 59 | + $this->displaySummary( $term ); |
60 | 60 | |
| 61 | + $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-term-description' ) ) ); |
| 62 | + |
| 63 | + $out->addHTML( $this->getOutput()->parse( $term->getField( 'description' ) ) ); |
| 64 | + |
61 | 65 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-term-students' ) ) ); |
62 | 66 | |
63 | 67 | // TODO: students |
— | — | @@ -65,16 +69,28 @@ |
66 | 70 | } |
67 | 71 | |
68 | 72 | /** |
69 | | - * Display the terms info. |
70 | | - * |
| 73 | + * Gets the summary data. |
| 74 | + * |
71 | 75 | * @since 0.1 |
72 | | - * |
| 76 | + * |
73 | 77 | * @param EPTerm $term |
| 78 | + * |
| 79 | + * @return array |
74 | 80 | */ |
75 | | - protected function displayInfo( EPTerm $term ) { |
76 | | - $out = $this->getOutput(); |
| 81 | + protected function getSummaryData( EPDBObject $term ) { |
| 82 | + $stats = array(); |
| 83 | + |
| 84 | + $stats['org'] = EPOrg::selectFieldsRow( 'name', array( 'id' => $term->getField( 'org_id' ) ) ); |
| 85 | + $stats['course'] = EPCourse::selectFieldsRow( 'name', array( 'id' => $term->getField( 'course_id' ) ) ); |
| 86 | + $stats['year'] = $term->getField( 'year' ); // TODO: how to properly i18n this? |
| 87 | + $stats['start'] = $this->getLanguage()->timeanddate( $term->getField( 'start' ), true ); |
| 88 | + $stats['end'] = $this->getLanguage()->timeanddate( $term->getField( 'end' ), true ); |
77 | 89 | |
| 90 | + if ( $term->useCanManage( $this->getUser() ) ) { |
| 91 | + $stats['token'] = $term->getField( 'token' ); |
| 92 | + } |
78 | 93 | |
| 94 | + return $stats; |
79 | 95 | } |
80 | 96 | |
81 | 97 | } |
Index: trunk/extensions/EducationProgram/includes/EPMentor.php |
— | — | @@ -97,7 +97,7 @@ |
98 | 98 | * @return boolean |
99 | 99 | */ |
100 | 100 | public function hasCourse( array $conditions = array() ) { |
101 | | - return true; |
| 101 | + return true; // TODO |
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
Index: trunk/extensions/EducationProgram/includes/EPTerm.php |
— | — | @@ -233,5 +233,30 @@ |
234 | 234 | $context->getOutput()->addWikiMsg( 'ep-terms-addcoursefirst' ); |
235 | 235 | } |
236 | 236 | } |
| 237 | + |
| 238 | + /** |
| 239 | + * Returns if the provided user can manage the term or not. |
| 240 | + * |
| 241 | + * @since 0.1 |
| 242 | + * |
| 243 | + * @param User $user |
| 244 | + * |
| 245 | + * @return boolean |
| 246 | + */ |
| 247 | + public function useCanManage( User $user ) { |
| 248 | + if ( $user->isAllowed( 'epadmin' ) ) { |
| 249 | + return true; |
| 250 | + } |
| 251 | + |
| 252 | + if ( $user->isAllowed( 'epmentor' ) ) { |
| 253 | + $mentor = EPMentor::selectRow( 'id', array( 'user_id' => $user->getId() ) ); |
| 254 | + |
| 255 | + if ( $mentor !== false ) { |
| 256 | + return $mentor->hasTerm( array( 'id' => $this->getId() ) ); |
| 257 | + } |
| 258 | + } |
| 259 | + |
| 260 | + return false; |
| 261 | + } |
237 | 262 | |
238 | 263 | } |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -177,6 +177,13 @@ |
178 | 178 | 'ep-term-students' => 'Students', |
179 | 179 | 'ep-term-none' => 'There is no term with id "$1". See [[Special:Terms|here]] for a list of terms.', |
180 | 180 | 'ep-term-create' => 'There is no term with id "$1", but you can create a new one.', |
| 181 | + 'specialterm-summary-org' => 'Institution', |
| 182 | + 'specialterm-summary-course' => 'Course', |
| 183 | + 'specialterm-summary-year' => 'Year', |
| 184 | + 'specialterm-summary-start' => 'Start', |
| 185 | + 'specialterm-summary-end' => 'End', |
| 186 | + 'ep-term-description' => 'description', |
| 187 | + 'specialterm-summary-token' => 'Enrollment token', |
181 | 188 | |
182 | 189 | // Navigation links |
183 | 190 | 'ep-nav-orgs' => 'Institution list', |