r113081 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113080‎ | r113081 | r113082 >
Date:20:42, 5 March 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPUtils.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialAmbassadorProfile.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialCAProfile.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialOAProfile.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialAmbassadorProfile.php
@@ -13,16 +13,50 @@
1414 */
1515 abstract class SpecialAmbassadorProfile extends FormSpecialPage {
1616
 17+ /**
 18+ * Returns the name of the ambassador class.
 19+ *
 20+ * @since 0.1
 21+ *
 22+ * @return string
 23+ */
1724 protected abstract function getClassName();
1825
1926 /**
 27+ * Returns if the user can access the page or not.
 28+ *
 29+ * @since 0.1
 30+ *
 31+ * @return boolean
 32+ */
 33+ protected abstract function userCanAccess();
 34+
 35+ /**
 36+ * Returns if the special page should be listed on Special:SpecialPages and similar interfaces.
 37+ *
 38+ * @since 0.1
 39+ *
 40+ * @return boolean
 41+ */
 42+ public function isListed() {
 43+ return $this->userCanAccess();
 44+ }
 45+
 46+ /**
2047 * Main method.
2148 *
2249 * @since 0.1
2350 *
2451 * @param string $subPage
 52+ *
 53+ * @return string
2554 */
2655 public function execute( $subPage ) {
 56+ if ( !$this->userCanAccess() ) {
 57+ $this->displayRestrictionError();
 58+ return '';
 59+ }
 60+
2761 if ( $this->getRequest()->getSessionData( 'epprofilesaved' ) ) {
2862 $messageKey = $this->getMsgPrefix() . 'profile-saved';
2963 $this->getOutput()->addHTML(
Index: trunk/extensions/EducationProgram/specials/SpecialOAProfile.php
@@ -19,7 +19,7 @@
2020 * @since 0.1
2121 */
2222 public function __construct() {
23 - parent::__construct( 'OnlineAmbassadorProfile', 'ep-online', false );
 23+ parent::__construct( 'OnlineAmbassadorProfile' );
2424 }
2525
2626 /**
@@ -43,4 +43,15 @@
4444 return 'EPOA';
4545 }
4646
 47+ /**
 48+ * (non-PHPdoc)
 49+ * @see SpecialAmbassadorProfile::userCanAccess()
 50+ */
 51+ protected function userCanAccess() {
 52+ $user = $this->getUser();
 53+ return $user->isAllowed( 'ep-online' )
 54+ || $user->isAllowed( 'ep-beonline' )
 55+ || EPOA::newFromUser( $user )->hasCourse();
 56+ }
 57+
4758 }
\ No newline at end of file
Index: trunk/extensions/EducationProgram/specials/SpecialCAProfile.php
@@ -19,7 +19,7 @@
2020 * @since 0.1
2121 */
2222 public function __construct() {
23 - parent::__construct( 'CampusAmbassadorProfile', 'ep-campus', false );
 23+ parent::__construct( 'CampusAmbassadorProfile' );
2424 }
2525
2626 /**
@@ -43,4 +43,15 @@
4444 return 'EPCA';
4545 }
4646
 47+ /**
 48+ * (non-PHPdoc)
 49+ * @see SpecialAmbassadorProfile::userCanAccess()
 50+ */
 51+ protected function userCanAccess() {
 52+ $user = $this->getUser();
 53+ return $user->isAllowed( 'ep-campus' )
 54+ || $user->isAllowed( 'ep-becampus' )
 55+ || EPCA::newFromUser( $user )->hasCourse();
 56+ }
 57+
4758 }
\ No newline at end of file
Index: trunk/extensions/EducationProgram/includes/EPUtils.php
@@ -208,11 +208,11 @@
209209 $items[wfMsg( 'ep-nav-mycourses' )] = SpecialPage::getTitleFor( 'MyCourses' );
210210 }
211211
212 - if ( $user->isAllowed( 'ep-online' ) && EPOA::newFromUser( $user )->hasCourse() ) {
 212+ if ( EPOA::newFromUser( $user )->hasCourse() ) {
213213 $items[wfMsg( 'ep-nav-oaprofile' )] = SpecialPage::getTitleFor( 'OnlineAmbassadorProfile' );
214214 }
215215
216 - if ( $user->isAllowed( 'ep-campus' ) && EPCA::newFromUser( $user )->hasCourse() ) {
 216+ if ( EPCA::newFromUser( $user )->hasCourse() ) {
217217 $items[wfMsg( 'ep-nav-caprofile' )] = SpecialPage::getTitleFor( 'CampusAmbassadorProfile' );
218218 }
219219

Sign-offs

UserFlagDate
Rob Schnautz (WMF)tested19:28, 7 March 2012

Status & tagging log