Index: trunk/extensions/EducationProgram/specials/SpecialEnroll.php |
— | — | @@ -52,15 +52,20 @@ |
53 | 53 | } |
54 | 54 | elseif ( $term->getStatus() === 'current' ) { |
55 | 55 | $token = ''; |
| 56 | + $tokenIsValid = $term->getField( 'token' ) === ''; |
56 | 57 | |
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 | + } |
59 | 67 | } |
60 | | - elseif ( $this->getRequest()->wasPosted() && $this->getRequest()->getCheck( 'wptoken' ) ) { |
61 | | - $token = $this->getRequest()->getText( 'wptoken' ); |
62 | | - } |
63 | 68 | |
64 | | - if ( $term->getField( 'token' ) === $token ) { |
| 69 | + if ( $tokenIsValid ) { |
65 | 70 | $this->showEnrollmentView( $term ); |
66 | 71 | } |
67 | 72 | else { |
Index: trunk/extensions/EducationProgram/specials/SpecialEditTerm.php |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | 'options' => $courseOptions, |
43 | 43 | 'validation-callback' => function ( $value, array $alldata = null ) use ( $courseOptions ) { |
44 | 44 | return in_array( (int)$value, array_values( $courseOptions ) ) ? true : wfMsg( 'ep-term-invalid-course' ); |
45 | | - } , |
| 45 | + }, |
46 | 46 | ); |
47 | 47 | |
48 | 48 | $fields['token'] = array ( |
— | — | @@ -51,7 +51,8 @@ |
52 | 52 | 'required' => true, |
53 | 53 | 'size' => 20, |
54 | 54 | '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; |
56 | 57 | } , |
57 | 58 | ); |
58 | 59 | |