* @version 1.0 * @since 03 Nov 2013 13:29:40 */ require_once dirname(__FILE__) . '/../_config.inc.php'; $auth->requireLogin(); require_once 'models/Question.inc.php'; switch (getFormData('op')) { case 'parse' : // Test this with: http://d./io/questions.php?op=parse&question_text=Do+you+enjoy+filling+surveys%3F+A)+Yes+or+maybe+B)+No+C)+Other echo Question::getParsedJSON(getFormData('question_text')); break; case 'json' : $questions = Question::getListBySurvey(getFormData('survey_id'), getFormData('rank')); // Bounce the user if they don't have permission to read the specified records. Question::requireAllow('read', $questions); echo json_encode($questions); break; case 'save_rank' : // Bounce the user if they don't have permission to update the specified records. // Test with: http://d./io/questions.php?op=save_rank&survey_id=1&newrank%5B0%5D%5B0%5D%5Bquestion_id%5D=3&newrank%5B0%5D%5B1%5D%5Bquestion_id%5D=4&newrank%5B0%5D%5B2%5D%5Bquestion_id%5D=5&newrank%5B0%5D%5B3%5D%5Bquestion_id%5D=6&newrank%5B0%5D%5B4%5D%5Bquestion_id%5D=2&newrank%5B0%5D%5B5%5D%5Bquestion_id%5D=7&newrank%5B0%5D%5B6%5D%5Bquestion_id%5D=8&newrank%5B0%5D%5B7%5D%5Bquestion_id%5D=9&newrank%5B0%5D%5B8%5D%5Bquestion_id%5D=10&newrank%5B0%5D%5B9%5D%5Bquestion_id%5D=11&newrank%5B0%5D%5B10%5D%5Bquestion_id%5D=12 $item_rows = Question::get(array('survey_id' => getFormData('survey_id')), Model::INNUMERABLE); Question::requireAllow('update', $item_rows); if (true === Question::updateRank(getFormData('survey_id'), getFormData('newrank'))) { echo 'ok'; } else { echo 'fail'; } break; } $app->stop();