1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Module: SmartFAQ |
5
|
|
|
* Author: The SmartFactory <www.smartfactory.ca> |
6
|
|
|
* Licence: GNU |
7
|
|
|
* @param $category |
8
|
|
|
* @param $item_id |
9
|
|
|
* @return mixed |
10
|
|
|
*/ |
11
|
|
|
function smartfaq_notify_iteminfo($category, $item_id) |
12
|
|
|
{ |
13
|
|
|
global $xoopsModule, $xoopsModuleConfig, $xoopsConfig; |
14
|
|
|
|
15
|
|
|
if (empty($xoopsModule) || 'smartfaq' !== $xoopsModule->getVar('dirname')) { |
16
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
17
|
|
|
$moduleHandler = xoops_getHandler('module'); |
18
|
|
|
$module = $moduleHandler->getByDirname('smartfaq'); |
19
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
20
|
|
|
$configHandler = xoops_getHandler('config'); |
21
|
|
|
$config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
|
|
|
|
22
|
|
|
} else { |
23
|
|
|
$module = $xoopsModule; |
24
|
|
|
$config = $xoopsModuleConfig; |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
if ('global' === $category) { |
28
|
|
|
$item['name'] = ''; |
|
|
|
|
29
|
|
|
$item['url'] = ''; |
30
|
|
|
|
31
|
|
|
return $item; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
global $xoopsDB; |
35
|
|
|
|
36
|
|
|
if ('category' === $category) { |
37
|
|
|
// Assume we have a valid category id |
38
|
|
|
$sql = 'SELECT name FROM ' . $xoopsDB->prefix('smartfaq_categories') . ' WHERE categoryid = ' . $item_id; |
39
|
|
|
$result = $xoopsDB->queryF($sql); // TODO: error check |
40
|
|
|
$result_array = $xoopsDB->fetchArray($result); |
41
|
|
|
$item['name'] = $result_array['name']; |
42
|
|
|
$item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/category.php?categoryid=' . $item_id; |
43
|
|
|
|
44
|
|
|
return $item; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
if ('faq' === $category) { |
48
|
|
|
// Assume we have a valid story id |
49
|
|
|
$sql = 'SELECT question FROM ' . $xoopsDB->prefix('smartfaq_faq') . ' WHERE faqid = ' . $item_id; |
50
|
|
|
$result = $xoopsDB->queryF($sql); // TODO: error check |
51
|
|
|
$result_array = $xoopsDB->fetchArray($result); |
52
|
|
|
$item['name'] = $result_array['question']; |
53
|
|
|
$item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/faq.php?faqid=' . $item_id; |
54
|
|
|
|
55
|
|
|
return $item; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|