include/notification.inc.php
<?php
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* Wfdownloads module
*
* @copyright XOOPS Project (https://xoops.org)
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @package wfdownload
* @since 3.23
* @author Xoops Development Team
*
* @param $category
* @param $item_id
* @return null
*/
function wfdownloads_notify_iteminfo($category, $item_id)
{
global $xoopsModule, $xoopsModuleConfig;
if (empty($xoopsModule) || 'wfdownloads' !== $xoopsModule->dirname()) {
/** @var \XoopsModuleHandler $moduleHandler */
$moduleHandler = xoops_getHandler('module');
/** @var \XoopsModule $module */
$module = $moduleHandler->getByDirname('wfdownloads');
/** @var \XoopsConfigHandler $configHandler */
$configHandler = xoops_getHandler('config');
$config = $configHandler->getConfigsByCat(0, (int)$module->mid());
} else {
$module = $xoopsModule;
$config = $xoopsModuleConfig;
}
if ('global' === $category) {
$item['name'] = '';
$item['url'] = '';
return $item;
}
if ('category' === $category) {
// Assume we have a valid category id
$sql = 'SELECT title FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_cat') . " WHERE cid = '" . (int)$item_id . "'";
$result = $GLOBALS['xoopsDB']->query($sql); // TODO: error check
$result_array = $GLOBALS['xoopsDB']->fetchArray($result);
$item['name'] = $result_array['title'];
$item['url'] = WFDOWNLOADS_URL . '/viewcat.php?cid=' . (int)$item_id;
return $item;
}
if ('file' === $category) {
// Assume we have a valid file id
$sql = 'SELECT cid,title FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_downloads') . " WHERE lid = '" . (int)$item_id . "'";
$result = $GLOBALS['xoopsDB']->query($sql); // TODO: error check
$result_array = $GLOBALS['xoopsDB']->fetchArray($result);
$item['name'] = $result_array['title'];
$item['url'] = WFDOWNLOADS_URL . '/singlefile.php?cid=' . (int)$result_array['cid'] . '&lid=' . (int)$item_id;
return $item;
}
return null;
}