|
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
|
|
|
* Wfdownloads module |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
16
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
17
|
|
|
* @package wfdownload |
|
18
|
|
|
* @since 3.23 |
|
19
|
|
|
* @author Xoops Development Team |
|
20
|
|
|
* |
|
21
|
|
|
* @param $category |
|
22
|
|
|
* @param $item_id |
|
23
|
|
|
* @return null |
|
24
|
|
|
*/ |
|
25
|
|
|
function wfdownloads_notify_iteminfo($category, $item_id) |
|
26
|
|
|
{ |
|
27
|
|
|
global $xoopsModule, $xoopsModuleConfig; |
|
28
|
|
|
|
|
29
|
|
|
if (empty($xoopsModule) || 'wfdownloads' !== $xoopsModule->dirname()) { |
|
30
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
|
31
|
|
|
$moduleHandler = xoops_getHandler('module'); |
|
32
|
|
|
/** @var \XoopsModule $module */ |
|
33
|
|
|
$module = $moduleHandler->getByDirname('wfdownloads'); |
|
34
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
|
35
|
|
|
$configHandler = xoops_getHandler('config'); |
|
36
|
|
|
$config = $configHandler->getConfigsByCat(0, (int)$module->mid()); |
|
|
|
|
|
|
37
|
|
|
} else { |
|
38
|
|
|
$module = $xoopsModule; |
|
|
|
|
|
|
39
|
|
|
$config = $xoopsModuleConfig; |
|
40
|
|
|
} |
|
41
|
|
|
if ('global' === $category) { |
|
42
|
|
|
$item['name'] = ''; |
|
|
|
|
|
|
43
|
|
|
$item['url'] = ''; |
|
44
|
|
|
|
|
45
|
|
|
return $item; |
|
46
|
|
|
} |
|
47
|
|
|
if ('category' === $category) { |
|
48
|
|
|
// Assume we have a valid category id |
|
49
|
|
|
$sql = 'SELECT title FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_cat') . " WHERE cid = '" . (int)$item_id . "'"; |
|
50
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); // TODO: error check |
|
51
|
|
|
$result_array = $GLOBALS['xoopsDB']->fetchArray($result); |
|
52
|
|
|
$item['name'] = $result_array['title']; |
|
53
|
|
|
$item['url'] = WFDOWNLOADS_URL . '/viewcat.php?cid=' . (int)$item_id; |
|
|
|
|
|
|
54
|
|
|
|
|
55
|
|
|
return $item; |
|
56
|
|
|
} |
|
57
|
|
|
if ('file' === $category) { |
|
58
|
|
|
// Assume we have a valid file id |
|
59
|
|
|
$sql = 'SELECT cid,title FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_downloads') . " WHERE lid = '" . (int)$item_id . "'"; |
|
60
|
|
|
$result = $GLOBALS['xoopsDB']->query($sql); // TODO: error check |
|
61
|
|
|
$result_array = $GLOBALS['xoopsDB']->fetchArray($result); |
|
62
|
|
|
$item['name'] = $result_array['title']; |
|
63
|
|
|
$item['url'] = WFDOWNLOADS_URL . '/singlefile.php?cid=' . (int)$result_array['cid'] . '&lid=' . (int)$item_id; |
|
64
|
|
|
|
|
65
|
|
|
return $item; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
return null; |
|
69
|
|
|
} |
|
70
|
|
|
|