r108918 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108917‎ | r108918 | r108919 >
Date:16:54, 14 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
follow up to r108917, allow for not having a token
Modified paths:
  • /trunk/extensions/EducationProgram/specials/SpecialEditTerm.php (modified) (history)
  • /trunk/extensions/EducationProgram/specials/SpecialEnroll.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/specials/SpecialEnroll.php
@@ -52,15 +52,20 @@
5353 }
5454 elseif ( $term->getStatus() === 'current' ) {
5555 $token = '';
 56+ $tokenIsValid = $term->getField( 'token' ) === '';
5657
57 - if ( count( $args ) === 2 ) {
58 - $token = $args[1];
 58+ if ( !$tokenIsValid ) {
 59+ $tokenIsValid = $term->getField( 'token' ) === $token;
 60+
 61+ if ( count( $args ) === 2 ) {
 62+ $token = $args[1];
 63+ }
 64+ elseif ( $this->getRequest()->wasPosted() && $this->getRequest()->getCheck( 'wptoken' ) ) {
 65+ $token = $this->getRequest()->getText( 'wptoken' );
 66+ }
5967 }
60 - elseif ( $this->getRequest()->wasPosted() && $this->getRequest()->getCheck( 'wptoken' ) ) {
61 - $token = $this->getRequest()->getText( 'wptoken' );
62 - }
6368
64 - if ( $term->getField( 'token' ) === $token ) {
 69+ if ( $tokenIsValid ) {
6570 $this->showEnrollmentView( $term );
6671 }
6772 else {
Index: trunk/extensions/EducationProgram/specials/SpecialEditTerm.php
@@ -41,7 +41,7 @@
4242 'options' => $courseOptions,
4343 'validation-callback' => function ( $value, array $alldata = null ) use ( $courseOptions ) {
4444 return in_array( (int)$value, array_values( $courseOptions ) ) ? true : wfMsg( 'ep-term-invalid-course' );
45 - } ,
 45+ },
4646 );
4747
4848 $fields['token'] = array (
@@ -51,7 +51,8 @@
5252 'required' => true,
5353 'size' => 20,
5454 'validation-callback' => function ( $value, array $alldata = null ) {
55 - return strlen( $value ) < 2 ? wfMsgExt( 'ep-term-invalid-token', 'parsemag', 2 ) : true;
 55+ $strLen = strlen( $value );
 56+ return ( $strLen !== 0 && $strLen < 2 ) ? wfMsgExt( 'ep-term-invalid-token', 'parsemag', 2 ) : true;
5657 } ,
5758 );
5859

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r108917work on special:enrolljeroendedauw16:50, 14 January 2012

Status & tagging log