Index: trunk/extensions/EducationProgram/specials/SpecialInstitution.php |
— | — | @@ -41,11 +41,11 @@ |
42 | 42 | else { |
43 | 43 | $out->setPageTitle( wfMsgExt( 'ep-institution-title', 'parsemag', $this->subPage ) ); |
44 | 44 | |
45 | | - $this->displayNavigation(); |
46 | | - |
47 | 45 | $org = EPOrg::selectRow( null, array( 'name' => $this->subPage ) ); |
48 | 46 | |
49 | 47 | if ( $org === false ) { |
| 48 | + $this->displayNavigation(); |
| 49 | + |
50 | 50 | if ( $this->getUser()->isAllowed( 'epadmin' ) ) { |
51 | 51 | $out->addWikiMsg( 'ep-institution-create', $this->subPage ); |
52 | 52 | EPOrg::displayAddNewControl( $this->getContext(), array( 'name' => $this->subPage ) ); |
— | — | @@ -55,6 +55,14 @@ |
56 | 56 | } |
57 | 57 | } |
58 | 58 | else { |
| 59 | + $links = array(); |
| 60 | + |
| 61 | + if ( $this->getUser()->isAllowed( 'epadmin' ) ) { |
| 62 | + $links[wfMsg( 'ep-institution-nav-edit' )] = SpecialPage::getTitleFor( 'EditInstitution', $this->subPage ); |
| 63 | + } |
| 64 | + |
| 65 | + $this->displayNavigation( $links ); |
| 66 | + |
59 | 67 | $this->displaySummary( $org ); |
60 | 68 | |
61 | 69 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-institution-courses' ) ) ); |
Index: trunk/extensions/EducationProgram/specials/SpecialCourse.php |
— | — | @@ -41,11 +41,11 @@ |
42 | 42 | else { |
43 | 43 | $out->setPageTitle( wfMsgExt( 'ep-course-title', 'parsemag', $this->subPage ) ); |
44 | 44 | |
45 | | - $this->displayNavigation(); |
46 | | - |
47 | 45 | $course = EPCourse::selectRow( null, array( 'name' => $this->subPage ) ); |
48 | 46 | |
49 | 47 | if ( $course === false ) { |
| 48 | + $this->displayNavigation(); |
| 49 | + |
50 | 50 | if ( $this->getUser()->isAllowed( 'epadmin' ) || $this->getUser()->isAllowed( 'epmentor' ) ) { |
51 | 51 | $out->addWikiMsg( 'ep-course-create', $this->subPage ); |
52 | 52 | EPCourse::displayAddNewRegion( $this->getContext(), array( 'name' => $this->subPage ) ); |
— | — | @@ -55,6 +55,14 @@ |
56 | 56 | } |
57 | 57 | } |
58 | 58 | else { |
| 59 | + $links = array(); |
| 60 | + |
| 61 | + if ( $course->useCanManage( $this->getUser() ) ) { |
| 62 | + $links[wfMsg( 'ep-course-nav-edit' )] = SpecialPage::getTitleFor( 'EditCourse', $this->subPage ); |
| 63 | + } |
| 64 | + |
| 65 | + $this->displayNavigation( $links ); |
| 66 | + |
59 | 67 | $this->displaySummary( $course ); |
60 | 68 | |
61 | 69 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-description' ) ) ); |
Index: trunk/extensions/EducationProgram/specials/SpecialTerm.php |
— | — | @@ -40,12 +40,12 @@ |
41 | 41 | } |
42 | 42 | else { |
43 | 43 | $out->setPageTitle( wfMsgExt( 'ep-term-title', 'parsemag', $this->subPage ) ); |
44 | | - |
45 | | - $this->displayNavigation(); |
46 | 44 | |
47 | 45 | $term = EPTerm::selectRow( null, array( 'id' => $this->subPage ) ); |
48 | 46 | |
49 | 47 | if ( $term === false ) { |
| 48 | + $this->displayNavigation(); |
| 49 | + |
50 | 50 | if ( $this->getUser()->isAllowed( 'epadmin' ) || $this->getUser()->isAllowed( 'epmentor' ) ) { |
51 | 51 | $out->addWikiMsg( 'ep-term-create', $this->subPage ); |
52 | 52 | EPTerm::displayAddNewRegion( $this->getContext(), array( 'id' => $this->subPage ) ); |
— | — | @@ -55,6 +55,14 @@ |
56 | 56 | } |
57 | 57 | } |
58 | 58 | else { |
| 59 | + $links = array(); |
| 60 | + |
| 61 | + if ( $term->useCanManage( $this->getUser() ) ) { |
| 62 | + $links[wfMsg( 'ep-term-nav-edit' )] = SpecialPage::getTitleFor( 'EditTerm', $this->subPage ); |
| 63 | + } |
| 64 | + |
| 65 | + $this->displayNavigation( $links ); |
| 66 | + |
59 | 67 | $this->displaySummary( $term ); |
60 | 68 | |
61 | 69 | $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-term-description' ) ) ); |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -264,5 +264,30 @@ |
265 | 265 | $context->getOutput()->addWikiMsg( 'ep-courses-noresults' ); |
266 | 266 | } |
267 | 267 | } |
| 268 | + |
| 269 | + /** |
| 270 | + * Returns if the provided user can manage the course or not. |
| 271 | + * |
| 272 | + * @since 0.1 |
| 273 | + * |
| 274 | + * @param User $user |
| 275 | + * |
| 276 | + * @return boolean |
| 277 | + */ |
| 278 | + public function useCanManage( User $user ) { |
| 279 | + if ( $user->isAllowed( 'epadmin' ) ) { |
| 280 | + return true; |
| 281 | + } |
| 282 | + |
| 283 | + if ( $user->isAllowed( 'epmentor' ) ) { |
| 284 | + $mentor = EPMentor::selectRow( 'id', array( 'user_id' => $user->getId() ) ); |
| 285 | + |
| 286 | + if ( $mentor !== false ) { |
| 287 | + return $mentor->hasCourse( array( 'id' => $this->getId() ) ); |
| 288 | + } |
| 289 | + } |
| 290 | + |
| 291 | + return false; |
| 292 | + } |
268 | 293 | |
269 | 294 | } |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -162,6 +162,7 @@ |
163 | 163 | 'specialinstitution-summary-name' => 'Name', |
164 | 164 | 'specialinstitution-summary-city' => 'City', |
165 | 165 | 'specialinstitution-summary-country' => 'Country', |
| 166 | + 'ep-institution-nav-edit' => 'Edit this institution', |
166 | 167 | |
167 | 168 | // Special:Course |
168 | 169 | 'ep-course-title' => 'Course: $1', |
— | — | @@ -171,6 +172,7 @@ |
172 | 173 | 'specialcourse-summary-name' => 'Name', |
173 | 174 | 'specialcourse-summary-org' => 'Institution', |
174 | 175 | 'ep-course-description' => 'Description', |
| 176 | + 'ep-course-nav-edit' => 'Edit this course', |
175 | 177 | |
176 | 178 | // Special:Term |
177 | 179 | 'ep-term-title' => 'Term: $1', |
— | — | @@ -184,6 +186,7 @@ |
185 | 187 | 'specialterm-summary-end' => 'End', |
186 | 188 | 'ep-term-description' => 'description', |
187 | 189 | 'specialterm-summary-token' => 'Enrollment token', |
| 190 | + 'ep-term-nav-edit' => 'Edit this term', |
188 | 191 | |
189 | 192 | // Navigation links |
190 | 193 | 'ep-nav-orgs' => 'Institution list', |