Index: trunk/extensions/Survey/specials/SpecialSurvey.php |
— | — | @@ -46,12 +46,11 @@ |
47 | 47 | } |
48 | 48 | |
49 | 49 | if ( $survey === false ) { |
50 | | - $this->showNameError(); |
| 50 | + $survey = new Survey( null, $subPage ); |
51 | 51 | } |
52 | | - else { |
53 | | - $this->showSurvey( $survey ); |
54 | | - $this->addModules( 'ext.survey.special.survey' ); |
55 | | - } |
| 52 | + |
| 53 | + $this->showSurvey( $survey ); |
| 54 | + $this->addModules( 'ext.survey.special.survey' ); |
56 | 55 | } |
57 | 56 | } |
58 | 57 | |
— | — | @@ -132,11 +131,11 @@ |
133 | 132 | } |
134 | 133 | |
135 | 134 | $question = new SurveyQuestion( |
136 | | - $questionId, |
| 135 | + $questionDbId, |
137 | 136 | 0, |
138 | 137 | $wgRequest->getText( "survey-question-text-$questionId" ), |
139 | 138 | $wgRequest->getInt( "survey-question-type-$questionId" ), |
140 | | - $wgRequest->getCheck( "survey-question-required-$questionDbId" ) |
| 139 | + $wgRequest->getCheck( "survey-question-required-$questionId" ) |
141 | 140 | ); |
142 | 141 | |
143 | 142 | return $question; |
— | — | @@ -172,20 +171,16 @@ |
173 | 172 | |
174 | 173 | $fields[] = array( |
175 | 174 | 'type' => 'text', |
176 | | - //'options' => array(), |
177 | | - 'default' => 'ohi', |
| 175 | + 'default' => $survey->getName(), |
178 | 176 | 'label-message' => 'survey-special-label-name', |
179 | | - 'required' => true, |
180 | 177 | 'id' => 'survey-name', |
181 | 178 | 'name' => 'survey-name', |
182 | 179 | ); |
183 | 180 | |
184 | 181 | $fields[] = array( |
185 | 182 | 'type' => 'check', |
186 | | - //'options' => array(), |
187 | | - 'default' => 'there', |
| 183 | + 'default' => $survey->isEnabled() ? '1' : '0', |
188 | 184 | 'label-message' => 'survey-special-label-enabled', |
189 | | - 'required' => true, |
190 | 185 | 'id' => 'survey-enabled', |
191 | 186 | 'name' => 'survey-enabled', |
192 | 187 | ); |
— | — | @@ -198,7 +193,6 @@ |
199 | 194 | 'text' => $question->getText(), |
200 | 195 | 'type' => $question->getType(), |
201 | 196 | 'id' => $question->getId(), |
202 | | - 'type' => $question->getType(), |
203 | 197 | ) |
204 | 198 | ); |
205 | 199 | } |
— | — | @@ -212,9 +206,7 @@ |
213 | 207 | $form = new HTMLForm( $fields ); |
214 | 208 | } |
215 | 209 | |
216 | | -// $q = new SurveyQuestion( null, 5, 'foo bar', 0, false, array(), false ); |
217 | | -// var_dump($q->toUrlData());exit; |
218 | | - $form->displayForm( '' ); |
| 210 | + $form->show(); |
219 | 211 | } |
220 | 212 | |
221 | 213 | } |
Index: trunk/extensions/Survey/specials/SpecialSurveys.php |
— | — | @@ -162,7 +162,8 @@ |
163 | 163 | array( |
164 | 164 | 'href' => '#', |
165 | 165 | 'class' => 'survey-delete', |
166 | | - 'data-survey-id' => $survey->survey_id |
| 166 | + 'data-survey-id' => $survey->survey_id, |
| 167 | + 'data-survey-token' => $GLOBALS['wgUser']->editToken( 'deletesurvey' ) |
167 | 168 | ), |
168 | 169 | wfMsg( 'surveys-special-delete' ) |
169 | 170 | ) . |
Index: trunk/extensions/Survey/api/ApiDeleteSurvey.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | |
25 | 25 | if ( !$wgUser->isAllowed( 'surveyadmin' ) || $wgUser->isBlocked() ) { |
26 | 26 | $this->dieUsageMsg( array( 'badaccess-groups' ) ); |
27 | | - } |
| 27 | + } |
28 | 28 | |
29 | 29 | $params = $this->extractRequestParams(); |
30 | 30 | |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | } |
48 | 48 | |
49 | 49 | public function getTokenSalt() { |
50 | | - return ''; |
| 50 | + return 'deletesurvey'; |
51 | 51 | } |
52 | 52 | |
53 | 53 | public function getAllowedParams() { |
Index: trunk/extensions/Survey/resources/ext.survey.special.surveys.js |
— | — | @@ -9,12 +9,13 @@ |
10 | 10 | (function( $ ) { $( document ).ready( function() { |
11 | 11 | |
12 | 12 | function deleteSurvey( options, successCallback, failCallback ) { |
13 | | - $.getJSON( |
| 13 | + $.post( |
14 | 14 | wgScriptPath + '/api.php', |
15 | 15 | { |
16 | 16 | 'action': 'deletesurvey', |
17 | 17 | 'format': 'json', |
18 | | - 'ids': options.id |
| 18 | + 'ids': options.id, |
| 19 | + 'token': options.token |
19 | 20 | }, |
20 | 21 | function( data ) { |
21 | 22 | if ( data.success ) { |
— | — | @@ -32,7 +33,10 @@ |
33 | 34 | |
34 | 35 | if ( confirm( survey.msg( 'surveys-special-confirm-delete' ) ) ) { |
35 | 36 | deleteSurvey( |
36 | | - { id: $this.attr( 'data-survey-id' ) }, |
| 37 | + { |
| 38 | + id: $this.attr( 'data-survey-id' ), |
| 39 | + token: $this.attr( 'data-survey-token' ) |
| 40 | + }, |
37 | 41 | function() { |
38 | 42 | $this.closest( 'tr' ).slideUp( 'slow', function() { $( this ).remove(); } ); |
39 | 43 | }, |