|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Xoopstube; |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
You may not change or alter any portion of this comment or credits |
|
7
|
|
|
of supporting developers from this source code or any supporting source code |
|
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
9
|
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
|
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Xoopstube class |
|
17
|
|
|
* |
|
18
|
|
|
* @copyright The XUUPS Project https://sourceforge.net/projects/xuups/ |
|
19
|
|
|
* @license https://www.fsf.org/copyleft/gpl.html GNU public license |
|
20
|
|
|
* @package Xoopstube |
|
21
|
|
|
* @subpackage Utils |
|
22
|
|
|
* @since 1.0 |
|
23
|
|
|
* @author trabis <[email protected]> |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
/** @var Helper $this ->helper */ |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Class VideosHandler |
|
31
|
|
|
*/ |
|
32
|
|
|
class VideosHandler extends \XoopsPersistableObjectHandler |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* @var Helper |
|
36
|
|
|
* @access public |
|
37
|
|
|
*/ |
|
38
|
|
|
public $helper = null; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param null|\XoopsDatabase $db |
|
42
|
|
|
*/ |
|
43
|
|
|
public function __construct(\XoopsDatabase $db = null) |
|
44
|
|
|
{ |
|
45
|
|
|
parent::__construct($db, 'xoopstube_videos', Videos::class, 'lid', 'title'); |
|
46
|
|
|
$this->helper = Helper::getInstance(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Get criteria for active videos |
|
51
|
|
|
* |
|
52
|
|
|
* @return \CriteriaCompo |
|
53
|
|
|
*/ |
|
54
|
|
|
public function getActiveCriteria() |
|
55
|
|
|
{ |
|
56
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
57
|
|
|
$grouppermHandler = \xoops_getHandler('groupperm'); |
|
58
|
|
|
|
|
59
|
|
|
$criteria = new \CriteriaCompo(new \Criteria('offline', false)); |
|
|
|
|
|
|
60
|
|
|
$criteria->add(new \Criteria('published', 0, '>')); |
|
61
|
|
|
$criteria->add(new \Criteria('published', \time(), '<=')); |
|
62
|
|
|
$expiredCriteria = new \CriteriaCompo(new \Criteria('expired', 0)); |
|
63
|
|
|
$expiredCriteria->add(new \Criteria('expired', \time(), '>='), 'OR'); |
|
64
|
|
|
$criteria->add($expiredCriteria); |
|
65
|
|
|
// add criteria for categories that the user has permissions for |
|
66
|
|
|
$groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [0 => XOOPS_GROUP_ANONYMOUS]; |
|
67
|
|
|
$allowedDownCategoriesIds = $grouppermHandler->getItemIds('XTubeCatPerm', $groups, $this->helper->getModule()->mid()); |
|
68
|
|
|
$criteria->add(new \Criteria('cid', '(' . \implode(',', $allowedDownCategoriesIds) . ')', 'IN')); |
|
69
|
|
|
|
|
70
|
|
|
return $criteria; |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|