|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace XoopsModules\Rssfit\Plugins; |
|
6
|
|
|
|
|
7
|
|
|
/* |
|
8
|
|
|
* You may not change or alter any portion of this comment or credits |
|
9
|
|
|
* of supporting developers from this source code or any supporting source code |
|
10
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
11
|
|
|
* |
|
12
|
|
|
* This program is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
19
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
20
|
|
|
* @package RSSFit - Extendable XML news feed generator |
|
21
|
|
|
* @author NS Tai (aka tuff) <http://www.brandycoke.com> |
|
22
|
|
|
* @author XOOPS Development Team |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
/* |
|
26
|
|
|
* About this RSSFit plug-in |
|
27
|
|
|
* Author: tuff <http://www.brandycoke.com> |
|
28
|
|
|
* Requirements (Tested with): |
|
29
|
|
|
* Module: WF-Downloads <http://smartyfactory.ca> |
|
30
|
|
|
* Version: 3.1 |
|
31
|
|
|
* RSSFit verision: 1.21 |
|
32
|
|
|
* XOOPS version: 2.0.14 |
|
33
|
|
|
*/ |
|
34
|
|
|
|
|
35
|
|
|
if (!\defined('RSSFIT_ROOT_PATH')) { |
|
36
|
|
|
exit(); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Class Wfdownloads_podcast |
|
41
|
|
|
* @package XoopsModules\Rssfit\Plugins |
|
42
|
|
|
*/ |
|
43
|
|
|
class Wfdownloads_podcast extends \XoopsObject |
|
44
|
|
|
{ |
|
45
|
|
|
public $dirname = 'wfdownloads'; |
|
46
|
|
|
public $modname; |
|
47
|
|
|
public $module; |
|
48
|
|
|
public $grab; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @return \XoopsModule |
|
52
|
|
|
*/ |
|
53
|
|
|
public function loadModule():?\XoopsModule |
|
54
|
|
|
{ |
|
55
|
|
|
$mod = $GLOBALS['module_handler']->getByDirname($this->dirname); |
|
56
|
|
|
if (!$mod || !$mod->getVar('isactive') || $mod->getVar('version') < 310) { |
|
57
|
|
|
return null; |
|
58
|
|
|
} |
|
59
|
|
|
$this->modname = $mod->getVar('name'); |
|
60
|
|
|
$this->module = $mod; |
|
61
|
|
|
|
|
62
|
|
|
return $mod; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @return array |
|
67
|
|
|
*/ |
|
68
|
|
|
public function grabEntries(\XoopsMySQLDatabase $xoopsDB):?array |
|
69
|
|
|
{ |
|
70
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
71
|
|
|
$grouppermHandler = \xoops_getHandler('groupperm'); |
|
72
|
|
|
$ret = null; |
|
73
|
|
|
$i = 0; |
|
74
|
|
|
$sql = 'SELECT lid, cid, title, date, description, filetype, size FROM ' . $xoopsDB->prefix('wfdownloads_downloads') . ' WHERE status > 0 AND offline = 0 AND (expired > ' . \time() . ' OR expired = 0) AND published <= ' . \time() . ' ORDER BY date DESC'; |
|
75
|
|
|
$result = $xoopsDB->query($sql, $this->grab, 0); |
|
76
|
|
|
if ($result instanceof \mysqli_result) { |
|
77
|
|
|
$ret = []; |
|
78
|
|
|
/** @var \XoopsMemberHandler $memberHandler */ |
|
79
|
|
|
$memberHandler = \xoops_getHandler('member'); |
|
80
|
|
|
while (false !== ($row = $xoopsDB->fetchArray($result))) { |
|
81
|
|
|
if ((isset($perms[$row['cid']]) && true === $perms[$row['cid']]) |
|
|
|
|
|
|
82
|
|
|
|| $grouppermHandler->checkRight('WFDownCatPerm', $row['cid'], \is_object($GLOBALS['xoopsUser']) ? $memberHandler->getGroupsByUser($GLOBALS['xoopsUser']->getVar('uid')) : XOOPS_GROUP_ANONYMOUS, $this->module->getVar('mid'))) { |
|
|
|
|
|
|
83
|
|
|
$perms[$row['cid']] = true; |
|
84
|
|
|
$ret[$i]['title'] = $row['title']; |
|
85
|
|
|
$link = XOOPS_URL . '/modules/' . $this->dirname . '/singlefile.php?cid=' . $row['cid'] . '&lid=' . $row['lid']; |
|
86
|
|
|
$ret[$i]['link'] = $ret[$i]['guid'] = $link; |
|
87
|
|
|
$ret[$i]['timestamp'] = $row['date']; |
|
88
|
|
|
$ret[$i]['description'] = $myts->displayTarea($row['description']); |
|
89
|
|
|
$ret[$i]['category'] = $this->modname; |
|
90
|
|
|
$ret[$i]['domain'] = XOOPS_URL . '/modules/' . $this->dirname . '/'; |
|
91
|
|
|
// enclosure tag, a.k.a podcast |
|
92
|
|
|
$ret[$i]['extras']['enclosure']['attributes'] = [ |
|
93
|
|
|
'url' => XOOPS_URL . '/modules/' . $this->dirname . '/visit.php?cid=' . $row['cid'] . '&lid=' . $row['lid'], |
|
94
|
|
|
'length' => $row['size'], |
|
95
|
|
|
'type' => $row['filetype'], |
|
96
|
|
|
]; |
|
97
|
|
|
$i++; |
|
98
|
|
|
} else { |
|
99
|
|
|
$perms[$row['cid']] = false; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
return $ret; |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|