r113382 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113381‎ | r113382 | r113383 >
Date:19:22, 8 March 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Modified paths:
  • /trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialMyCourses.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/actions/EPRemoveArticleAction.php
@@ -36,6 +36,7 @@
3737 'id',
3838 'course_id',
3939 'page_id',
 40+ 'page_title',
4041 ),
4142 array(
4243 'id' => $req->getInt( 'article-id' ),
Index: trunk/extensions/EducationProgram/specials/SpecialMyCourses.php
@@ -104,17 +104,11 @@
105105
106106 $this->displayRoleAssociation( 'EPStudent' );
107107
108 - if ( $this->getUser()->isAllowed( 'ep-instructor' ) ) {
109 - $this->displayRoleAssociation( 'EPInstructor' );
110 - }
111 -
112 - if ( $this->getUser()->isAllowed( 'ep-online' ) ) {
113 - $this->displayRoleAssociation( 'EPOA' );
114 - }
115 -
116 - if ( $this->getUser()->isAllowed( 'ep-campus' ) ) {
117 - $this->displayRoleAssociation( 'EPCA' );
118 - }
 108+ $this->displayRoleAssociation( 'EPInstructor' );
 109+
 110+ $this->displayRoleAssociation( 'EPOA' );
 111+
 112+ $this->displayRoleAssociation( 'EPCA' );
119113 }
120114
121115 /**
@@ -142,9 +136,25 @@
143137 * @param $class The name of the EPIRole implementing class
144138 */
145139 protected function displayRoleAssociation( $class ) {
146 - $userRole = $class::newFromUser( $this->getUser() );
 140+ $user = $this->getUser();
 141+ $userRole = $class::newFromUser( $user );
147142 $courses = $userRole->getCourses( array( 'id', 'name', 'org_id' ) );
148143
 144+ switch ( $class ) {
 145+ case 'EPStudent':
 146+ $isAllowed = true;
 147+ break;
 148+ case 'EPInstructor':
 149+ $isAllowed = $user->isAllowed( 'ep-beinstructor' ) || $user->isAllowed( 'ep-instructor' );
 150+ break;
 151+ case 'EPOA':
 152+ $isAllowed = $user->isAllowed( 'ep-beonline' ) || $user->isAllowed( 'ep-online' );
 153+ break;
 154+ case 'EPCA':
 155+ $isAllowed = $user->isAllowed( 'ep-becampus' ) || $user->isAllowed( 'ep-campus' );
 156+ break;
 157+ }
 158+
149159 if ( count( $courses ) > 0 ) {
150160 $message = wfMsgExt( 'ep-mycourses-courses-' . strtolower( $class ), 'parsemag', count( $courses ), $this->getUser()->getName() );
151161 $this->getOutput()->addElement( 'h2', array(), $message );
@@ -159,7 +169,7 @@
160170 $this->displayCoursePager( $courses, $class );
161171 }
162172 }
163 - else {
 173+ elseif ( $isAllowed ) {
164174 $this->getOutput()->addWikiMsg( 'ep-mycourses-nocourses-' . strtolower( $class ) );
165175 }
166176 }

Sign-offs

UserFlagDate
Rob Schnautz (WMF)tested15:20, 22 March 2012

Status & tagging log