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 http://sourceforge.net/projects/xuups/ |
19
|
|
|
* @license http://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
|
|
|
use XoopsModules\Xoopstube\{ |
27
|
|
|
Helper |
|
|
|
|
28
|
|
|
}; |
29
|
|
|
|
30
|
|
|
/** @var Helper $this ->helper */ |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Class VideosHandler |
34
|
|
|
*/ |
35
|
|
|
class VideosHandler extends \XoopsPersistableObjectHandler |
36
|
|
|
{ |
37
|
|
|
/** |
38
|
|
|
* @var Helper |
39
|
|
|
* @access public |
40
|
|
|
*/ |
41
|
|
|
public $helper = null; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param null|\XoopsDatabase $db |
45
|
|
|
*/ |
46
|
|
|
public function __construct(\XoopsDatabase $db = null) |
47
|
|
|
{ |
48
|
|
|
parent::__construct($db, 'xoopstube_videos', Videos::class, 'lid', 'title'); |
49
|
|
|
$this->helper = Helper::getInstance(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Get criteria for active videos |
54
|
|
|
* |
55
|
|
|
* @return \CriteriaCompo |
56
|
|
|
*/ |
57
|
|
|
public function getActiveCriteria() |
58
|
|
|
{ |
59
|
|
|
$grouppermHandler = \xoops_getHandler('groupperm'); |
60
|
|
|
|
61
|
|
|
$criteria = new \CriteriaCompo(new \Criteria('offline', false)); |
|
|
|
|
62
|
|
|
$criteria->add(new \Criteria('published', 0, '>')); |
63
|
|
|
$criteria->add(new \Criteria('published', \time(), '<=')); |
64
|
|
|
$expiredCriteria = new \CriteriaCompo(new \Criteria('expired', 0)); |
65
|
|
|
$expiredCriteria->add(new \Criteria('expired', \time(), '>='), 'OR'); |
66
|
|
|
$criteria->add($expiredCriteria); |
67
|
|
|
// add criteria for categories that the user has permissions for |
68
|
|
|
$groups = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [0 => XOOPS_GROUP_ANONYMOUS]; |
69
|
|
|
$allowedDownCategoriesIds = $grouppermHandler->getItemIds('XTubeCatPerm', $groups, $this->helper->getModule()->mid()); |
|
|
|
|
70
|
|
|
$criteria->add(new \Criteria('cid', '(' . \implode(',', $allowedDownCategoriesIds) . ')', 'IN')); |
71
|
|
|
|
72
|
|
|
return $criteria; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: