tiki-admin_survey_questions.php 3.12 KB
Newer Older
lrargerich's avatar
lrargerich committed
1
<?php
2
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
3
// 
4 5
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6
// $Id$
changi67's avatar
changi67 committed
7

8 9
require_once ('tiki-setup.php');
include_once ('lib/surveys/surveylib.php');
changi67's avatar
changi67 committed
10
$auto_query_args = array(
11 12 13 14 15 16
	'surveyId',
	'questionId',
	'offset',
	'find',
	'sort_mode',
	'maxRecords'
changi67's avatar
changi67 committed
17
);
18 19
$access->check_feature('feature_surveys');

20
if (!isset($_REQUEST["surveyId"])) {
21 22 23
	$smarty->assign('msg', tra("No survey indicated"));
	$smarty->display("error.tpl");
	die;
lrargerich's avatar
lrargerich committed
24
}
25
$smarty->assign('surveyId', $_REQUEST["surveyId"]);
26 27
$tikilib->get_perm_object($_REQUEST['surveyId'], 'survey');

28 29
$access->check_permission('tiki_p_admin_surveys');

30 31 32
$survey_info = $srvlib->get_survey($_REQUEST["surveyId"]);
$smarty->assign('survey_info', $survey_info);
if (!isset($_REQUEST["questionId"])) {
33
	$_REQUEST["questionId"] = 0;
lrargerich's avatar
lrargerich committed
34
}
35 36
$smarty->assign('questionId', $_REQUEST["questionId"]);
if ($_REQUEST["questionId"]) {
37
	$info = $srvlib->get_survey_question($_REQUEST["questionId"]);
lrargerich's avatar
lrargerich committed
38
} else {
39 40 41 42 43 44 45 46
	$info = array();
	$info["question"] = '';
	$info["type"] = '';
	$info["position"] = '';
	$info["options"] = '';
	$info["mandatory"] = '';
	$info["min_answers"] = '';
	$info["max_answers"] = '';
lrargerich's avatar
lrargerich committed
47
}
48
$smarty->assign_by_ref('info', $info);
49
if (isset($_REQUEST["remove"])) {
50 51
	$access->check_authenticity();
	$srvlib->remove_survey_question($_REQUEST["remove"]);
lrargerich's avatar
lrargerich committed
52
}
53
if (isset($_REQUEST["save"])) {
54 55 56 57 58 59 60 61 62 63 64
	check_ticket('admin-survey-questions');
	$srvlib->replace_survey_question($_REQUEST["questionId"], $_REQUEST["question"], $_REQUEST["type"], $_REQUEST["surveyId"], $_REQUEST["position"], $_REQUEST["options"], isset($_REQUEST["mandatory"]) ? 'y' : 'n', $_REQUEST["min_answers"], $_REQUEST["max_answers"]);
	$info["question"] = '';
	$info["type"] = '';
	$info["position"] = '';
	$info["options"] = '';
	$info["mandatory"] = '';
	$info["min_answers"] = '';
	$info["max_answers"] = '';
	$smarty->assign('questionId', 0);
	$smarty->assign('info', $info);
65 66
}
if (!isset($_REQUEST["sort_mode"])) {
67
	$sort_mode = 'position_asc';
lrargerich's avatar
lrargerich committed
68
} else {
69
	$sort_mode = $_REQUEST["sort_mode"];
70 71
}
if (!isset($_REQUEST["offset"])) {
72
	$offset = 0;
lrargerich's avatar
lrargerich committed
73
} else {
74
	$offset = $_REQUEST["offset"];
lrargerich's avatar
lrargerich committed
75
}
76 77
$smarty->assign_by_ref('offset', $offset);
if (isset($_REQUEST["find"])) {
78
	$find = $_REQUEST["find"];
lrargerich's avatar
lrargerich committed
79
} else {
80
	$find = '';
lrargerich's avatar
lrargerich committed
81
}
82 83 84
$smarty->assign('find', $find);
$smarty->assign_by_ref('sort_mode', $sort_mode);
$channels = $srvlib->list_survey_questions($_REQUEST["surveyId"], $offset, $maxRecords, $sort_mode, $find);
85
if (empty($info["position"])) {
86
	$info["position"] = $channels["cant"] + 1;
87
}
88
$smarty->assign_by_ref('cant_pages', $channels["cant"]);
89
$smarty->assign_by_ref('channels', $channels["data"]);
lrargerich's avatar
lrargerich committed
90
// Fill array with possible number of questions per page
91
$positions = array();
92
for ($i = 1; $i < 100; $i++) $positions[] = $i;
93
$smarty->assign('positions', $positions);
94
ask_ticket('admin-survey-questions');
95 96
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
lrargerich's avatar
lrargerich committed
97
// Display the template
98
$smarty->assign('mid', 'tiki-admin_survey_questions.tpl');
99
$smarty->display("tiki.tpl");