tiki-faq_questions.php 3.64 KB
Newer Older
lrargerich's avatar
lrargerich committed
1
<?php
2
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
changi67's avatar
changi67 committed
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.
changi67's avatar
changi67 committed
6
// $Id$
7

8
$section = 'faqs';
9
require_once ('tiki-setup.php');
lrargerich's avatar
lrargerich committed
10

11 12
include_once ('lib/faqs/faqlib.php');

13 14
$access->check_feature('feature_faqs');
$access->check_permission('tiki_p_admin_faqs');
lrargerich's avatar
lrargerich committed
15

16
if (!isset($_REQUEST["faqId"])) {
17
	$smarty->assign('msg', tra("No questions group indicated"));
lrargerich's avatar
lrargerich committed
18

19
	$smarty->display("error.tpl");
20 21 22 23
	die;
}

$smarty->assign('faqId', $_REQUEST["faqId"]);
24
$faq_info = $tikilib->get_faq($_REQUEST["faqId"]);
25
$smarty->assign('faq_info', $faq_info);
lrargerich's avatar
lrargerich committed
26

27 28
if (!isset($_REQUEST["questionId"])) {
	$_REQUEST["questionId"] = 0;
lrargerich's avatar
lrargerich committed
29 30
}

31
$smarty->assign('questionId', $_REQUEST["questionId"]);
lrargerich's avatar
lrargerich committed
32

33 34
if ($_REQUEST["questionId"]) {
	$info = $faqlib->get_faq_question($_REQUEST["questionId"]);
lrargerich's avatar
lrargerich committed
35
} else {
36 37 38 39
	$info = array();

	$info["question"] = '';
	$info["answer"] = '';
lrargerich's avatar
lrargerich committed
40
}
41 42
// $smarty->assign('question',$info["question"]);  AWC moved this
// $smarty->assign('answer',$info["answer"]);      AWC moved this
43
if (isset($_REQUEST["remove"])) {
44 45
	$access->check_authenticity();
	$faqlib->remove_faq_question($_REQUEST["remove"]);
46
}
lrargerich's avatar
lrargerich committed
47

48 49
if (!isset($_REQUEST["filter"])) {
	$_REQUEST["filter"] = '';
lrargerich's avatar
lrargerich committed
50 51
}

52 53 54
$smarty->assign('filter', $_REQUEST["filter"]);

if (isset($_REQUEST["useq"])) {
55
	check_ticket('faq-questions');
56
	$quse = $faqlib->get_faq_question($_REQUEST["usequestionId"]);
lrargerich's avatar
lrargerich committed
57

58 59
	$faqlib->replace_faq_question($_REQUEST["faqId"], 0, $quse["question"], $quse["answer"]);
	$info = $faqlib->get_faq_question($_REQUEST["questionId"]); // AWC added
lrargerich's avatar
lrargerich committed
60 61
}

62
if (isset($_REQUEST["save"])) {
63
	check_ticket('faq-questions');
64 65 66 67 68 69 70
	$faqlib->replace_faq_question($_REQUEST["faqId"], $_REQUEST["questionId"], $_REQUEST["question"], $_REQUEST["answer"]);

	$info["question"] = '';
	$info["answer"] = '';
	//$smarty->assign('question',$info["question"]);  AWC moved this
	//$smarty->assign('answer',$info["answer"]);      AWC moved this
	$smarty->assign('questionId', 0);
lrargerich's avatar
lrargerich committed
71 72
}

73 74
$smarty->assign('question', $info["question"]); // moved from above
$smarty->assign('answer', $info["answer"]);     // moved from above
75

76
if (!isset($_REQUEST["sort_mode"])) {
niclone's avatar
niclone committed
77
	$sort_mode = 'position_asc,questionId_asc';
lrargerich's avatar
lrargerich committed
78
} else {
79 80
	$sort_mode = $_REQUEST["sort_mode"];
}
lrargerich's avatar
lrargerich committed
81

82 83
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
lrargerich's avatar
lrargerich committed
84
} else {
85
	$offset = $_REQUEST["offset"];
lrargerich's avatar
lrargerich committed
86 87
}

88 89 90 91
$smarty->assign_by_ref('offset', $offset);

if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
lrargerich's avatar
lrargerich committed
92
} else {
93
	$find = '';
lrargerich's avatar
lrargerich committed
94 95
}

96 97 98 99
$smarty->assign('find', $find);

if (isset($_REQUEST["remove_suggested"])) {
	$faqlib->remove_suggested_question($_REQUEST["remove_suggested"]);
lrargerich's avatar
lrargerich committed
100 101
}

102 103 104
if (isset($_REQUEST["approve_suggested"])) {
	$faqlib->approve_suggested_question($_REQUEST["approve_suggested"]);
}
lrargerich's avatar
lrargerich committed
105

106 107
$smarty->assign_by_ref('sort_mode', $sort_mode);
$channels = $faqlib->list_faq_questions($_REQUEST["faqId"], 0, -1, $sort_mode, $find);
niclone's avatar
niclone committed
108
$allq = $faqlib->list_all_faq_questions(0, -1, 'position_asc,questionId_asc', $_REQUEST["filter"]);
109
$smarty->assign_by_ref('allq', $allq["data"]);
lrargerich's avatar
lrargerich committed
110

111
$smarty->assign_by_ref('cant_pages', $channels["cant"]);
lrargerich's avatar
lrargerich committed
112

113
$smarty->assign_by_ref('channels', $channels["data"]);
lrargerich's avatar
lrargerich committed
114

115
$suggested = $faqlib->list_suggested_questions(0, -1, 'created_desc', '', $_REQUEST["faqId"]);
116
$smarty->assign_by_ref('suggested', $suggested["data"]);
lrargerich's avatar
lrargerich committed
117

118
include_once ('tiki-section_options.php');
119
ask_ticket('faq-questions');
mose's avatar
mose committed
120

121 122 123 124 125

global $wikilib; include_once('lib/wiki/wikilib.php');
$plugins = $wikilib->list_plugins(true, 'faqans');
$smarty->assign_by_ref('plugins', $plugins);

lrargerich's avatar
lrargerich committed
126
// Display the template
127
$smarty->assign('mid', 'tiki-faq_questions.tpl');
128
$smarty->display("tiki.tpl");