r96017 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r96016‎ | r96017 | r96018 >
Date:17:40, 1 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on survey admin
Modified paths:
  • /trunk/extensions/Survey/api/ApiDeleteSurvey.php (modified) (history)
  • /trunk/extensions/Survey/resources/ext.survey.special.surveys.js (modified) (history)
  • /trunk/extensions/Survey/specials/SpecialSurvey.php (modified) (history)
  • /trunk/extensions/Survey/specials/SpecialSurveys.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Survey/specials/SpecialSurvey.php
@@ -46,12 +46,11 @@
4747 }
4848
4949 if ( $survey === false ) {
50 - $this->showNameError();
 50+ $survey = new Survey( null, $subPage );
5151 }
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' );
5655 }
5756 }
5857
@@ -132,11 +131,11 @@
133132 }
134133
135134 $question = new SurveyQuestion(
136 - $questionId,
 135+ $questionDbId,
137136 0,
138137 $wgRequest->getText( "survey-question-text-$questionId" ),
139138 $wgRequest->getInt( "survey-question-type-$questionId" ),
140 - $wgRequest->getCheck( "survey-question-required-$questionDbId" )
 139+ $wgRequest->getCheck( "survey-question-required-$questionId" )
141140 );
142141
143142 return $question;
@@ -172,20 +171,16 @@
173172
174173 $fields[] = array(
175174 'type' => 'text',
176 - //'options' => array(),
177 - 'default' => 'ohi',
 175+ 'default' => $survey->getName(),
178176 'label-message' => 'survey-special-label-name',
179 - 'required' => true,
180177 'id' => 'survey-name',
181178 'name' => 'survey-name',
182179 );
183180
184181 $fields[] = array(
185182 'type' => 'check',
186 - //'options' => array(),
187 - 'default' => 'there',
 183+ 'default' => $survey->isEnabled() ? '1' : '0',
188184 'label-message' => 'survey-special-label-enabled',
189 - 'required' => true,
190185 'id' => 'survey-enabled',
191186 'name' => 'survey-enabled',
192187 );
@@ -198,7 +193,6 @@
199194 'text' => $question->getText(),
200195 'type' => $question->getType(),
201196 'id' => $question->getId(),
202 - 'type' => $question->getType(),
203197 )
204198 );
205199 }
@@ -212,9 +206,7 @@
213207 $form = new HTMLForm( $fields );
214208 }
215209
216 -// $q = new SurveyQuestion( null, 5, 'foo bar', 0, false, array(), false );
217 -// var_dump($q->toUrlData());exit;
218 - $form->displayForm( '' );
 210+ $form->show();
219211 }
220212
221213 }
Index: trunk/extensions/Survey/specials/SpecialSurveys.php
@@ -162,7 +162,8 @@
163163 array(
164164 'href' => '#',
165165 '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' )
167168 ),
168169 wfMsg( 'surveys-special-delete' )
169170 ) .
Index: trunk/extensions/Survey/api/ApiDeleteSurvey.php
@@ -23,7 +23,7 @@
2424
2525 if ( !$wgUser->isAllowed( 'surveyadmin' ) || $wgUser->isBlocked() ) {
2626 $this->dieUsageMsg( array( 'badaccess-groups' ) );
27 - }
 27+ }
2828
2929 $params = $this->extractRequestParams();
3030
@@ -46,7 +46,7 @@
4747 }
4848
4949 public function getTokenSalt() {
50 - return '';
 50+ return 'deletesurvey';
5151 }
5252
5353 public function getAllowedParams() {
Index: trunk/extensions/Survey/resources/ext.survey.special.surveys.js
@@ -9,12 +9,13 @@
1010 (function( $ ) { $( document ).ready( function() {
1111
1212 function deleteSurvey( options, successCallback, failCallback ) {
13 - $.getJSON(
 13+ $.post(
1414 wgScriptPath + '/api.php',
1515 {
1616 'action': 'deletesurvey',
1717 'format': 'json',
18 - 'ids': options.id
 18+ 'ids': options.id,
 19+ 'token': options.token
1920 },
2021 function( data ) {
2122 if ( data.success ) {
@@ -32,7 +33,10 @@
3334
3435 if ( confirm( survey.msg( 'surveys-special-confirm-delete' ) ) ) {
3536 deleteSurvey(
36 - { id: $this.attr( 'data-survey-id' ) },
 37+ {
 38+ id: $this.attr( 'data-survey-id' ),
 39+ token: $this.attr( 'data-survey-token' )
 40+ },
3741 function() {
3842 $this.closest( 'tr' ).slideUp( 'slow', function() { $( this ).remove(); } );
3943 },

Status & tagging log