XoopsModules25x /
xoopstube
| 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 |
||||||
|
0 ignored issues
–
show
|
|||||||
| 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)); |
||||||
|
0 ignored issues
–
show
false of type false is incompatible with the type string expected by parameter $value of Criteria::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 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()); |
||||||
|
0 ignored issues
–
show
The method
getItemIds() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 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:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare 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.phpHowever, as
OtherDir/Foo.phpdoes 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: