r107306 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107305‎ | r107306 | r107307 >
Date:23:26, 25 December 2011
Author:jeroendedauw
Status:deferred
Tags:educationprogram 
Comment:
added edit nav links
Modified paths:
  • /trunk/extensions/EducationProgram/EducationProgram.i18n.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialInstitution.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialTerm.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialInstitution.php
@@ -41,11 +41,11 @@
4242 else {
4343 $out->setPageTitle( wfMsgExt( 'ep-institution-title', 'parsemag', $this->subPage ) );
4444
45 - $this->displayNavigation();
46 -
4745 $org = EPOrg::selectRow( null, array( 'name' => $this->subPage ) );
4846
4947 if ( $org === false ) {
 48+ $this->displayNavigation();
 49+
5050 if ( $this->getUser()->isAllowed( 'epadmin' ) ) {
5151 $out->addWikiMsg( 'ep-institution-create', $this->subPage );
5252 EPOrg::displayAddNewControl( $this->getContext(), array( 'name' => $this->subPage ) );
@@ -55,6 +55,14 @@
5656 }
5757 }
5858 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+
5967 $this->displaySummary( $org );
6068
6169 $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-institution-courses' ) ) );
Index: trunk/extensions/EducationProgram/specials/SpecialCourse.php
@@ -41,11 +41,11 @@
4242 else {
4343 $out->setPageTitle( wfMsgExt( 'ep-course-title', 'parsemag', $this->subPage ) );
4444
45 - $this->displayNavigation();
46 -
4745 $course = EPCourse::selectRow( null, array( 'name' => $this->subPage ) );
4846
4947 if ( $course === false ) {
 48+ $this->displayNavigation();
 49+
5050 if ( $this->getUser()->isAllowed( 'epadmin' ) || $this->getUser()->isAllowed( 'epmentor' ) ) {
5151 $out->addWikiMsg( 'ep-course-create', $this->subPage );
5252 EPCourse::displayAddNewRegion( $this->getContext(), array( 'name' => $this->subPage ) );
@@ -55,6 +55,14 @@
5656 }
5757 }
5858 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+
5967 $this->displaySummary( $course );
6068
6169 $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-course-description' ) ) );
Index: trunk/extensions/EducationProgram/specials/SpecialTerm.php
@@ -40,12 +40,12 @@
4141 }
4242 else {
4343 $out->setPageTitle( wfMsgExt( 'ep-term-title', 'parsemag', $this->subPage ) );
44 -
45 - $this->displayNavigation();
4644
4745 $term = EPTerm::selectRow( null, array( 'id' => $this->subPage ) );
4846
4947 if ( $term === false ) {
 48+ $this->displayNavigation();
 49+
5050 if ( $this->getUser()->isAllowed( 'epadmin' ) || $this->getUser()->isAllowed( 'epmentor' ) ) {
5151 $out->addWikiMsg( 'ep-term-create', $this->subPage );
5252 EPTerm::displayAddNewRegion( $this->getContext(), array( 'id' => $this->subPage ) );
@@ -55,6 +55,14 @@
5656 }
5757 }
5858 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+
5967 $this->displaySummary( $term );
6068
6169 $out->addHTML( Html::element( 'h2', array(), wfMsg( 'ep-term-description' ) ) );
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -264,5 +264,30 @@
265265 $context->getOutput()->addWikiMsg( 'ep-courses-noresults' );
266266 }
267267 }
 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+ }
268293
269294 }
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php
@@ -162,6 +162,7 @@
163163 'specialinstitution-summary-name' => 'Name',
164164 'specialinstitution-summary-city' => 'City',
165165 'specialinstitution-summary-country' => 'Country',
 166+ 'ep-institution-nav-edit' => 'Edit this institution',
166167
167168 // Special:Course
168169 'ep-course-title' => 'Course: $1',
@@ -171,6 +172,7 @@
172173 'specialcourse-summary-name' => 'Name',
173174 'specialcourse-summary-org' => 'Institution',
174175 'ep-course-description' => 'Description',
 176+ 'ep-course-nav-edit' => 'Edit this course',
175177
176178 // Special:Term
177179 'ep-term-title' => 'Term: $1',
@@ -184,6 +186,7 @@
185187 'specialterm-summary-end' => 'End',
186188 'ep-term-description' => 'description',
187189 'specialterm-summary-token' => 'Enrollment token',
 190+ 'ep-term-nav-edit' => 'Edit this term',
188191
189192 // Navigation links
190193 'ep-nav-orgs' => 'Institution list',

Status & tagging log