1
|
|
|
<?php declare(strict_types=1); |
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 XOOPS Project (https://xoops.org) |
14
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
15
|
|
|
* @author XOOPS Development Team |
16
|
|
|
* @author Pascal Le Boustouller: original author ([email protected]) |
17
|
|
|
* @author Luc Bizet (www.frxoops.org) |
18
|
|
|
* @author jlm69 (www.jlmzone.com) |
19
|
|
|
* @author mamba (www.xoops.org) |
20
|
|
|
* @param mixed $category |
21
|
|
|
* @param mixed $item_id |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @param $category |
26
|
|
|
* @param $item_id |
27
|
|
|
* |
28
|
|
|
* @return array|void |
29
|
|
|
*/ |
30
|
|
|
function adslight_notify_iteminfo( |
31
|
|
|
$category, |
32
|
|
|
$item_id |
33
|
|
|
) { |
34
|
|
|
global $xoopsDB; |
35
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
36
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
37
|
|
|
$moduleHandler = xoops_getHandler('module'); |
38
|
|
|
$module = $moduleHandler->getByDirname($moduleDirName); |
|
|
|
|
39
|
|
|
if ('global' === $category) { |
40
|
|
|
$item['name'] = ''; |
|
|
|
|
41
|
|
|
$item['url'] = ''; |
42
|
|
|
|
43
|
|
|
return $item; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
$item_id = (int)$item_id; |
47
|
|
|
if ('category' === $category) { |
48
|
|
|
// Assume we have a valid topid id |
49
|
|
|
$sql = 'SELECT SQL_CACHE title FROM ' . $xoopsDB->prefix('adslight_categories') . " WHERE cid ={$item_id} LIMIT 1"; |
50
|
|
|
|
51
|
|
|
$result = $xoopsDB->query($sql); |
52
|
|
|
if (!$xoopsDB->isResultSet($result)) { |
53
|
|
|
\trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR); |
54
|
|
|
} |
55
|
|
|
if ($xoopsDB->isResultSet($result)) { |
56
|
|
|
$result_array = $xoopsDB->fetchArray($result); |
57
|
|
|
$item['name'] = $result_array['title']; |
58
|
|
|
$item['url'] = XOOPS_URL . '/modules/adslight/index.php?pa=adsview&cid=' . $item_id; |
59
|
|
|
|
60
|
|
|
return $item; |
61
|
|
|
} |
62
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
63
|
|
|
$moduleHandler = xoops_getHandler('module'); |
64
|
|
|
/** @var \XoopsModule $myModule */ |
65
|
|
|
$myModule = $moduleHandler->getByDirname('adslight'); |
66
|
|
|
$myModule->setErrors('Could not query the database.'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
if ('listing' === $category) { |
70
|
|
|
// Assume we have a valid post id |
71
|
|
|
$sql = 'SELECT title FROM ' . $xoopsDB->prefix('adslight_listing') . " WHERE lid={$item_id} LIMIT 1"; |
72
|
|
|
$result = $xoopsDB->query($sql); |
73
|
|
|
if (!$xoopsDB->isResultSet($result)) { |
74
|
|
|
\trigger_error("Query Failed! SQL: $sql- Error: " . $xoopsDB->error(), E_USER_ERROR); |
75
|
|
|
} |
76
|
|
|
$result_array = $xoopsDB->fetchArray($result); |
77
|
|
|
$item['name'] = $result_array['title']; |
78
|
|
|
// $item['catname'] = $result_array['cat.title']; |
79
|
|
|
$item['url'] = XOOPS_URL . '/modules/adslight/viewads.php?lid= ' . $item_id; |
80
|
|
|
|
81
|
|
|
return $item; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|