1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8//this script may only be included - so its better to die if called directly.
9if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
10	header("location: index.php");
11	exit;
12}
13
14
15/**
16 * @return array
17 */
18function module_last_validated_faq_questions_info()
19{
20	return [
21		'name' => tra('Newest Validated FAQ Questions'),
22		'description' => tra('Displays the specified number of validated questions FAQs from newest to oldest.'),
23		'prefs' => ["feature_faqs"],
24		'params' => [
25			'faqId' => [
26				'name' => tra('FAQ identifier'),
27				'description' => tra('If set to a FAQ identifier, restricts the chosen questions to those in the identified FAQ.') . " " . tra('Example value: 13.') . " " . tra('Not set by default.'),
28				'profile_reference' => 'faq',
29				'filter' => 'int',
30			],
31			'truncate' => [
32				'name' => tra('Number of characters to display'),
33				'description' => tra('Number of characters to display'),
34				'filter' => 'int',
35			],
36		],
37		'common_params' => ['nonums', 'rows']
38	];
39}
40
41/**
42 * @param $mod_reference
43 * @param $module_params
44 */
45function module_last_validated_faq_questions($mod_reference, $module_params)
46{
47	$tikilib = TikiLib::lib('tiki');
48	$smarty = TikiLib::lib('smarty');
49	$faqlib = TikiLib::lib('faq');
50	$def = ['faqId' => 0, 'truncate' => 20];
51	$module_params = array_merge($def, $module_params);
52	$ranking = $faqlib->list_faq_questions($module_params['faqId'], 0, $mod_reference['rows'], 'created_desc', '');
53	$smarty->assign_by_ref('modLastValidatedFaqQuestions', $ranking['data']);
54	$smarty->assign_by_ref('trunc', $module_params['truncate']);
55}
56