|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
You may not change or alter any portion of this comment or credits |
|
4
|
|
|
of supporting developers from this source code or any supporting source code |
|
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
|
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* My Module module for xoops |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright 2020 XOOPS Project (https://xooops.org) |
|
16
|
|
|
* @license GPL 2.0 or later |
|
17
|
|
|
* @package mymodule |
|
18
|
|
|
* @since 1.0 |
|
19
|
|
|
* @min_xoops 2.5.9 |
|
20
|
|
|
* @author TDM XOOPS - Email:<[email protected]> - Website:<http://xoops.org> |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* comment callback functions |
|
25
|
|
|
* |
|
26
|
|
|
* @param $category |
|
27
|
|
|
* @param $item_id |
|
28
|
|
|
* @return array item|null |
|
29
|
|
|
*/ |
|
30
|
|
|
function mymodule_notify_iteminfo($category, $item_id) |
|
31
|
|
|
{ |
|
32
|
|
|
global $xoopsModule, $xoopsModuleConfig, $xoopsDB; |
|
33
|
|
|
// |
|
34
|
|
|
if (empty($xoopsModule) || $xoopsModule->getVar('dirname') != 'mymodule') |
|
35
|
|
|
{ |
|
36
|
|
|
$moduleHandler = xoops_getHandler('module'); |
|
37
|
|
|
$module = $moduleHandler->getByDirname('mymodule'); |
|
|
|
|
|
|
38
|
|
|
$configHandler = xoops_getHandler('config'); |
|
39
|
|
|
$config =& $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
|
|
|
|
|
|
40
|
|
|
} else { |
|
41
|
|
|
$module = $xoopsModule; |
|
|
|
|
|
|
42
|
|
|
$config = $xoopsModuleConfig; |
|
43
|
|
|
} |
|
44
|
|
|
// |
|
45
|
|
|
switch($category) { |
|
46
|
|
|
case 'global': |
|
47
|
|
|
$item['name'] = ''; |
|
|
|
|
|
|
48
|
|
|
$item['url'] = ''; |
|
49
|
|
|
return $item; |
|
50
|
|
|
break; |
|
|
|
|
|
|
51
|
|
|
case 'category': |
|
52
|
|
|
// Assume we have a valid category id |
|
53
|
|
|
$sql = 'SELECT art_title FROM ' . $xoopsDB->prefix('mymodule_articles') . ' WHERE art_id = '. $item_id; |
|
54
|
|
|
$result = $xoopsDB->query($sql); // TODO: error check |
|
55
|
|
|
$result_array = $xoopsDB->fetchArray($result); |
|
56
|
|
|
$item['name'] = $result_array['art_title']; |
|
57
|
|
|
$item['url'] = MYMODULE_URL . '/articles.php?art_id=' . $item_id; |
|
58
|
|
|
return $item; |
|
59
|
|
|
break; |
|
60
|
|
|
case 'article': |
|
61
|
|
|
// Assume we have a valid link id |
|
62
|
|
|
$sql = 'SELECT art_id, art_title FROM '.$xoopsDB->prefix('mymodule_articles') . ' WHERE art_id = ' . $item_id; |
|
63
|
|
|
$result = $xoopsDB->query($sql); // TODO: error check |
|
64
|
|
|
$result_array = $xoopsDB->fetchArray($result); |
|
65
|
|
|
$item['name'] = $result_array['art_title']; |
|
66
|
|
|
$item['url'] = MYMODULE_URL . '/single.php?cid=' . $result_array['cid'] . '&art_id=' . $item_id; |
|
67
|
|
|
return $item; |
|
68
|
|
|
break; |
|
69
|
|
|
} |
|
70
|
|
|
return null; |
|
71
|
|
|
} |