Index: trunk/extensions/EducationProgram/specials/SpecialEnroll.php |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | * |
35 | 35 | * @since 0.1 |
36 | 36 | * |
37 | | - * @param string $arg |
| 37 | + * @param string $subPage |
38 | 38 | */ |
39 | 39 | public function execute( $subPage ) { |
40 | 40 | parent::execute( $subPage ); |
— | — | @@ -63,22 +63,30 @@ |
64 | 64 | |
65 | 65 | if ( $this->getUser()->isLoggedIn() ) { |
66 | 66 | if ( $this->getUser()->isAllowed( 'epstudent' ) ) { |
67 | | - $this->showEnrollmentForm( $term ); |
| 67 | + $user = $this->getUser(); |
| 68 | + $hasFields = trim( $user->getRealName() ) !== '' || $user->getOption( 'gender' ) !== 'unknown'; |
| 69 | + |
| 70 | + if ( $hasFields ) { |
| 71 | + $this->showEnrollmentForm( $term ); |
| 72 | + } |
| 73 | + else { |
| 74 | + |
| 75 | + } |
68 | 76 | } |
69 | 77 | else { |
70 | 78 | $this->showWarning( wfMessage( 'ep-enroll-not-allowed' ) ); |
71 | 79 | } |
72 | 80 | } |
73 | 81 | else { |
74 | | - $this->showSignupLink( $term ); |
| 82 | + $this->showSignupLink(); |
75 | 83 | } |
76 | 84 | } |
77 | 85 | } |
78 | 86 | } |
79 | 87 | |
80 | 88 | /** |
| 89 | + * Set the page title. |
81 | 90 | * |
82 | | - * |
83 | 91 | * @since 0.1 |
84 | 92 | * |
85 | 93 | * @param EPTerm $term |
— | — | @@ -93,13 +101,11 @@ |
94 | 102 | } |
95 | 103 | |
96 | 104 | /** |
| 105 | + * Show links to signup. |
97 | 106 | * |
98 | | - * |
99 | | - * @param EPTerm $term |
100 | | - * |
101 | 107 | * @since 0.1 |
102 | 108 | */ |
103 | | - protected function showSignupLink( EPTerm $term ) { |
| 109 | + protected function showSignupLink() { |
104 | 110 | $out = $this->getOutput(); |
105 | 111 | |
106 | 112 | $out->addWikiMsg( 'ep-enroll-login-first' ); |
— | — | @@ -129,15 +135,30 @@ |
130 | 136 | |
131 | 137 | $out->addHTML( '</li></ul>' ); |
132 | 138 | } |
| 139 | + |
| 140 | + /** |
| 141 | + * Just enroll the user in the term. This is useful when |
| 142 | + * there are no things for the user to fill out in the |
| 143 | + * enrollment form, making that step not needed. |
| 144 | + * |
| 145 | + * @since 0.1 |
| 146 | + * |
| 147 | + * @param EPTerm $term |
| 148 | + */ |
| 149 | + protected function autoEnroll( EPTerm $term ) { |
| 150 | + // TODO |
| 151 | + } |
133 | 152 | |
134 | 153 | /** |
| 154 | + * Create and display the enrollment form. |
135 | 155 | * |
136 | | - * |
137 | 156 | * @since 0.1 |
138 | 157 | * |
139 | 158 | * @param EPTerm $term |
140 | 159 | */ |
141 | 160 | protected function showEnrollmentForm( EPTerm $term ) { |
| 161 | + $this->getOutput()->addWikiMsg( 'ep-enroll-header' ); |
| 162 | + |
142 | 163 | $form = new HTMLForm( $this->getFormFields(), $this->getContext() ); |
143 | 164 | |
144 | 165 | $form->setSubmitCallback( array( $this, 'handleSubmission' ) ); |
— | — | @@ -150,8 +171,8 @@ |
151 | 172 | } |
152 | 173 | |
153 | 174 | /** |
| 175 | + * Returns the definitions for the fields of the signup form. |
154 | 176 | * |
155 | | - * |
156 | 177 | * @since 0.1 |
157 | 178 | * |
158 | 179 | * @return array |
— | — | @@ -159,11 +180,41 @@ |
160 | 181 | protected function getFormFields() { |
161 | 182 | $fields = array(); |
162 | 183 | |
| 184 | + $user = $this->getUser(); |
| 185 | + |
163 | 186 | $fields['enroll'] = array( |
164 | 187 | 'type' => 'hidden', |
165 | 188 | 'default' => 1 |
166 | 189 | ); |
167 | 190 | |
| 191 | + if ( trim( $user->getRealName() ) === '' ) { |
| 192 | + $fields['realname'] = array( |
| 193 | + 'type' => 'text', |
| 194 | + 'default' => '', |
| 195 | + 'label-message' => 'ep-enroll-realname', |
| 196 | + 'required' => true, |
| 197 | + 'validation-callback' => function( $value, array $alldata = null ) { |
| 198 | + return strlen( $value ) < 2 ? wfMsgExt( 'ep-enroll-invalid-name', 'parsemag', 2 ) : true; |
| 199 | + } |
| 200 | + ); |
| 201 | + } |
| 202 | + |
| 203 | + if ( $user->getOption( 'gender' ) === 'unknown' ) { |
| 204 | + $fields['gender'] = array( |
| 205 | + 'type' => 'select', |
| 206 | + 'default' => 'unknown', |
| 207 | + 'label-message' => 'ep-enroll-gender', |
| 208 | + 'validation-callback' => function( $value, array $alldata = null ) { |
| 209 | + return strlen( $value ) < 2 ? wfMsg( 'ep-enroll-invalid-gender' ) : true; |
| 210 | + }, |
| 211 | + 'options' => array( |
| 212 | + wfMsg( 'gender-male' ) => 'male', |
| 213 | + wfMsg( 'gender-female' ) => 'female', |
| 214 | + wfMsg( 'gender-unknown' ) => 'unknown', |
| 215 | + ) |
| 216 | + ); |
| 217 | + } |
| 218 | + |
168 | 219 | return $fields; |
169 | 220 | } |
170 | 221 | |
Index: trunk/extensions/EducationProgram/includes/EPTermPager.php |
— | — | @@ -74,7 +74,7 @@ |
75 | 75 | ); |
76 | 76 | break; |
77 | 77 | case 'year': |
78 | | - $value = htmlspecialchars( $value ); |
| 78 | + $value = htmlspecialchars( $this->getLanguage()->formatNum( $value, true ) ); |
79 | 79 | break; |
80 | 80 | case 'start': case 'end': |
81 | 81 | $value = htmlspecialchars( $this->getLanguage()->date( $value ) ); |
Index: trunk/extensions/EducationProgram/EducationProgram.i18n.php |
— | — | @@ -265,6 +265,7 @@ |
266 | 266 | 'ep-enroll-no-token' => 'You need to provide the token needed to enroll for this term.', |
267 | 267 | 'ep-enroll-invalid-token' => 'The token you provided is invalid.', |
268 | 268 | 'ep-enroll-legend' => 'Enroll', |
| 269 | + 'ep-enroll-header' => 'In order to enroll for this course, all you need to do is fill out this form and click the submission button. After that you will be enrolled.', |
269 | 270 | |
270 | 271 | // Special:MyCourses |
271 | 272 | 'ep-mycourses-enrolled' => 'You have successfully enrolled for $1 at $2.', |