tiki-list_faqs.php 2.75 KB
Newer Older
lrargerich's avatar
lrargerich committed
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2015 by authors of the Tiki Wiki CMS Groupware Project
changi67's avatar
changi67 committed
6
// 
7 8
// 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.
9
// $Id$
changi67's avatar
changi67 committed
10

11
$section = 'faqs';
12
require_once ('tiki-setup.php');
13
$faqlib = TikiLib::lib('faq');
14
$auto_query_args = array('offset', 'find', 'sort_mode', 'faqId');
15 16
$access->check_feature('feature_faqs');
$access->check_permission('tiki_p_view_faqs');
gta74's avatar
gta74 committed
17
//get_strings tra('Admin FAQs')
18 19
if (!isset($_REQUEST["faqId"])) {
	$_REQUEST["faqId"] = 0;
lrargerich's avatar
lrargerich committed
20
}
21 22
$smarty->assign('faqId', $_REQUEST["faqId"]);
if ($_REQUEST["faqId"]) {
23
	$info = $faqlib->get_faq($_REQUEST["faqId"]);
lrargerich's avatar
lrargerich committed
24
} else {
25 26 27 28
	$info = array();
	$info["title"] = '';
	$info["description"] = '';
	$info["canSuggest"] = 'n';
lrargerich's avatar
lrargerich committed
29
}
30 31 32 33 34
$smarty->assign('title', $info["title"]);
$smarty->assign('description', $info["description"]);
$smarty->assign('canSuggest', $info["canSuggest"]);
if (isset($_REQUEST["remove"])) {
	if ($tiki_p_admin_faqs != 'y') {
35
		$smarty->assign('msg', tra("You do not have permission to use this feature"));
36
		$smarty->display("error.tpl");
37 38
		die;
	}
39 40
	$access->check_authenticity();
	$faqlib->remove_faq($_REQUEST["remove"]);
lrargerich's avatar
lrargerich committed
41
}
42
if (isset($_REQUEST["save"])) {
43
	check_ticket('list-faqs');
44
	$access->check_permission('tiki_p_admin_faqs');
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
	if (isset($_REQUEST["canSuggest"]) && $_REQUEST["canSuggest"] == 'on') {
		$canSuggest = 'y';
	} else {
		$canSuggest = 'n';
	}
	$fid = $faqlib->replace_faq($_REQUEST["faqId"], $_REQUEST["title"], $_REQUEST["description"], $canSuggest);
	$cat_type = 'faq';
	$cat_objid = $fid;
	$cat_desc = substr($_REQUEST["description"], 0, 200);
	$cat_name = $_REQUEST["title"];
	$cat_href = "tiki-view_faq.php?faqId=" . $cat_objid;
	include_once ("categorize.php");
	$smarty->assign('faqId', 0);
	$smarty->assign('title', '');
	$smarty->assign('description', '');
	$smarty->assign('canSuggest', '');
}
if (!isset($_REQUEST["sort_mode"])) {
63
	$sort_mode = 'title_asc';
lrargerich's avatar
lrargerich committed
64
} else {
65 66 67 68
	$sort_mode = $_REQUEST["sort_mode"];
}
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
lrargerich's avatar
lrargerich committed
69
} else {
70
	$offset = $_REQUEST["offset"];
lrargerich's avatar
lrargerich committed
71
}
72 73 74
$smarty->assign_by_ref('offset', $offset);
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
lrargerich's avatar
lrargerich committed
75
} else {
76
	$find = '';
lrargerich's avatar
lrargerich committed
77
}
78 79
$smarty->assign('find', $find);
$smarty->assign_by_ref('sort_mode', $sort_mode);
80
$channels = $faqlib->list_faqs($offset, $maxRecords, $sort_mode, $find);
81
$smarty->assign_by_ref('channels', $channels["data"]);
luciash's avatar
luciash committed
82
$smarty->assign_by_ref('cant', $channels["cant"]);
83
$cat_type = 'faq';
84
$cat_objid = $_REQUEST["faqId"];
85 86
include_once ("categorize_list.php");
include_once ('tiki-section_options.php');
87
ask_ticket('list-faqs');
lrargerich's avatar
lrargerich committed
88
// Display the template
89
$smarty->assign('mid', 'tiki-list_faqs.tpl');
90
$smarty->display("tiki.tpl");