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
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
14
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
15
|
|
|
* @author XOOPS Development Team |
16
|
|
|
* @param mixed $category |
17
|
|
|
* @param mixed $item_id |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @param $category |
22
|
|
|
* @param $item_id |
23
|
|
|
* |
24
|
|
|
* @return mixed |
25
|
|
|
*/ |
26
|
|
|
function lookup($category, $item_id) |
27
|
|
|
{ |
28
|
|
|
global $xoopsModule, $xoopsModuleConfig, $xoopsConfig; |
29
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
30
|
|
|
if (empty($xoopsModule) || $xoopsModule->getVar('dirname') !== $moduleDirName) { |
31
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
32
|
|
|
$moduleHandler = xoops_getHandler('module'); |
33
|
|
|
$module = $moduleHandler->getByDirname($moduleDirName); |
34
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
35
|
|
|
$configHandler = xoops_getHandler('config'); |
36
|
|
|
$config = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
|
|
|
|
37
|
|
|
} else { |
38
|
|
|
$module = $xoopsModule; |
39
|
|
|
$config = $xoopsModuleConfig; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
if ('global' === $category) { |
43
|
|
|
$item['name'] = ''; |
|
|
|
|
44
|
|
|
$item['url'] = ''; |
45
|
|
|
|
46
|
|
|
return $item; |
47
|
|
|
} |
48
|
|
|
$item_id = (int)$item_id; |
49
|
|
|
|
50
|
|
|
global $xoopsDB; |
51
|
|
|
if ('dog' === $category) { |
52
|
|
|
// Assume we have a valid forum id |
53
|
|
|
$sql = 'SELECT pname FROM ' . $GLOBALS['xoopsDB']->prefix('pedigree_registry') . ' WHERE id = ' . $item_id; |
54
|
|
|
if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
55
|
|
|
redirect_header('index.php', 2, _MD_ERRORFORUM); |
|
|
|
|
56
|
|
|
} |
57
|
|
|
$result_array = $GLOBALS['xoopsDB']->fetchArray($result); |
58
|
|
|
$item['name'] = $result_array['pname']; |
59
|
|
|
$item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/dog.php?id=' . $item_id; |
60
|
|
|
|
61
|
|
|
return $item; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
if ('thread' === $category) { |
65
|
|
|
// Assume we have a valid topid id |
66
|
|
|
$sql = 'SELECT t.topic_title,f.forum_id,f.forum_name FROM ' . $GLOBALS['xoopsDB']->prefix('bb_topics') . ' t, ' . $GLOBALS['xoopsDB']->prefix('bb_forums') . ' f WHERE t.forum_id = f.forum_id AND t.topic_id = ' . $item_id . ' LIMIT 1'; |
67
|
|
|
if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
68
|
|
|
redirect_header('index.php', 2, _MD_ERROROCCURED); |
|
|
|
|
69
|
|
|
} |
70
|
|
|
$result_array = $GLOBALS['xoopsDB']->fetchArray($result); |
71
|
|
|
$item['name'] = $result_array['topic_title']; |
72
|
|
|
$item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewtopic.php?forum=' . $result_array['forum_id'] . '&topic_id=' . $item_id; |
73
|
|
|
|
74
|
|
|
return $item; |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
if ('post' === $category) { |
78
|
|
|
// Assume we have a valid post id |
79
|
|
|
$sql = 'SELECT subject,topic_id,forum_id FROM ' . $GLOBALS['xoopsDB']->prefix('bb_posts') . ' WHERE post_id = ' . $item_id . ' LIMIT 1'; |
80
|
|
|
if (!$result = $GLOBALS['xoopsDB']->query($sql)) { |
81
|
|
|
redirect_header('index.php', 2, _MD_ERROROCCURED); |
82
|
|
|
} |
83
|
|
|
$result_array = $GLOBALS['xoopsDB']->fetchArray($result); |
84
|
|
|
$item['name'] = $result_array['subject']; |
85
|
|
|
$item['url'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/viewtopic.php?forum= ' . $result_array['forum_id'] . '&topic_id=' . $result_array['topic_id'] . '#forumpost' . $item_id; |
86
|
|
|
|
87
|
|
|
return $item; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|