Index: trunk/extensions/EducationProgram/specials/SpecialEditInstitution.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | * @return string|true |
74 | 74 | */ |
75 | 75 | public function countryIsValid( $value, array $alldata = null ) { |
76 | | - $countries = array_keys( CountryNames::getNames( $this->getLang()->getCode() ) ); |
| 76 | + $countries = array_keys( CountryNames::getNames( $this->getLanguage()->getCode() ) ); |
77 | 77 | |
78 | 78 | if ( $this->isNew() ) { |
79 | 79 | array_unshift( $countries, '' ); |
Index: trunk/extensions/EducationProgram/specials/SpecialEPFormPage.php |
— | — | @@ -149,7 +149,8 @@ |
150 | 150 | static $isNew = null; |
151 | 151 | |
152 | 152 | if ( is_null( $isNew ) ) { |
153 | | - $isNew = $this->getRequest()->wasPosted() && $this->getUser()->matchEditToken( $this->getRequest()->getVal( 'newEditToken' ) ); |
| 153 | + $isNew = $this->getRequest()->wasPosted() && |
| 154 | + ( $this->getRequest()->getCheck( 'isnew' ) || $this->getRequest()->getCheck( 'wpisnew' ) ); |
154 | 155 | } |
155 | 156 | |
156 | 157 | return $isNew; |
— | — | @@ -163,7 +164,7 @@ |
164 | 165 | protected function showForm() { |
165 | 166 | $form = $this->getForm(); |
166 | 167 | |
167 | | - if ( $this->isNew() ) { |
| 168 | + if ( $this->getRequest()->wasPosted() && $this->getRequest()->getCheck( 'isnew' ) ) { |
168 | 169 | $form->prepareForm(); |
169 | 170 | $form->displayForm( Status::newGood() ); |
170 | 171 | } |
— | — | @@ -204,8 +205,17 @@ |
205 | 206 | * @return HTMLForm|null |
206 | 207 | */ |
207 | 208 | protected function getForm() { |
208 | | - $form = new HTMLForm( $this->getFormFields(), $this->getContext() ); |
| 209 | + $fields = $this->getFormFields(); |
209 | 210 | |
| 211 | + if ( $this->isNew() ) { |
| 212 | + $fields['isnew'] = array( |
| 213 | + 'type' => 'hidden', |
| 214 | + 'default' => 1 |
| 215 | + ); |
| 216 | + } |
| 217 | + |
| 218 | + $form = new HTMLForm( $fields, $this->getContext() ); |
| 219 | + |
210 | 220 | $form->setSubmitCallback( array( $this, 'handleSubmission' ) ); |
211 | 221 | $form->setSubmitText( wfMsg( 'educationprogram-org-submit' ) ); |
212 | 222 | |
— | — | @@ -239,12 +249,14 @@ |
240 | 250 | $fields = array(); |
241 | 251 | |
242 | 252 | $fields['id'] = array( 'type' => 'hidden' ); |
243 | | - |
| 253 | + |
| 254 | + $req = $this->getRequest(); |
| 255 | + |
244 | 256 | // This sort of sucks as well. Meh, HTMLForm is odd. |
245 | | - if ( $this->getRequest()->wasPosted() |
246 | | - && $this->getUser()->matchEditToken( $this->getRequest()->getVal( 'wpEditToken' ) ) |
247 | | - && $this->getRequest()->getCheck( 'wpitem-id' ) ) { |
248 | | - $fields['id']['default'] = $this->getRequest()->getInt( 'wpitem-id' ); |
| 257 | + if ( $req->wasPosted() |
| 258 | + && $this->getUser()->matchEditToken( $req->getVal( 'wpEditToken' ) ) |
| 259 | + && $req->getCheck( 'wpitem-id' ) ) { |
| 260 | + $fields['id']['default'] = $req->getInt( 'wpitem-id' ); |
249 | 261 | } |
250 | 262 | |
251 | 263 | return $fields; |
— | — | @@ -272,7 +284,7 @@ |
273 | 285 | $mappedFields = array(); |
274 | 286 | |
275 | 287 | foreach ( $fields as $name => $field ) { |
276 | | - if ( $this->isNew() ) { |
| 288 | + if ( $this->getRequest()->getCheck( 'isnew' ) ) { |
277 | 289 | // HTML form is being a huge pain in running the validation on post, |
278 | 290 | // so just remove it if when not appropriate. |
279 | 291 | unset( $field['validation-callback'] ); |
— | — | @@ -326,7 +338,7 @@ |
327 | 339 | $matches = array(); |
328 | 340 | |
329 | 341 | if ( preg_match( '/item-(.+)/', $name, $matches ) ) { |
330 | | - if ( $matches[1] === 'id' && $value === '' ) { |
| 342 | + if ( $matches[1] === 'id' && ( $value === '' || $value === '0' ) ) { |
331 | 343 | $value = null; |
332 | 344 | } |
333 | 345 | |
Index: trunk/extensions/EducationProgram/includes/EPOrg.php |
— | — | @@ -233,7 +233,7 @@ |
234 | 234 | 'submit' |
235 | 235 | ) ); |
236 | 236 | |
237 | | - $out->addHTML( Html::hidden( 'newEditToken', $context->getUser()->editToken() ) ); |
| 237 | + $out->addHTML( Html::hidden( 'isnew', 1 ) ); |
238 | 238 | |
239 | 239 | $out->addHTML( '</fieldset></form>' ); |
240 | 240 | |
Index: trunk/extensions/EducationProgram/includes/EPTerm.php |
— | — | @@ -229,7 +229,7 @@ |
230 | 230 | 'submit' |
231 | 231 | ) ); |
232 | 232 | |
233 | | - $out->addHTML( Html::hidden( 'newEditToken', $context->getUser()->editToken() ) ); |
| 233 | + $out->addHTML( Html::hidden( 'isnew', 1 ) ); |
234 | 234 | |
235 | 235 | $out->addHTML( '</fieldset></form>' ); |
236 | 236 | |
Index: trunk/extensions/EducationProgram/includes/EPCourse.php |
— | — | @@ -213,7 +213,7 @@ |
214 | 214 | 'submit' |
215 | 215 | ) ); |
216 | 216 | |
217 | | - $out->addHTML( Html::hidden( 'newEditToken', $context->getUser()->editToken() ) ); |
| 217 | + $out->addHTML( Html::hidden( 'isnew', 1 ) ); |
218 | 218 | |
219 | 219 | $out->addHTML( '</fieldset></form>' ); |
220 | 220 | |