|
1
|
|
|
<?php namespace XoopsModules\Smartobject; |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* You may not change or alter any portion of this comment or credits |
|
5
|
|
|
* of supporting developers from this source code or any supporting source code |
|
6
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
7
|
|
|
* |
|
8
|
|
|
* This program is distributed in the hope that it will be useful, |
|
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @copyright XOOPS Project https://xoops.org/ |
|
15
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
|
16
|
|
|
* @package |
|
17
|
|
|
* @since |
|
18
|
|
|
* @author XOOPS Development Team |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
use XoopsModules\Smartobject; |
|
22
|
|
|
|
|
23
|
|
|
// defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
|
24
|
|
|
|
|
25
|
|
|
//require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobject.php'; |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class SmartobjectCustomtagHandler |
|
30
|
|
|
*/ |
|
31
|
|
|
class CustomtagHandler extends Smartobject\PersistableObjectHandler |
|
32
|
|
|
{ |
|
33
|
|
|
public $objects = false; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* SmartobjectCustomtagHandler constructor. |
|
37
|
|
|
* @param \XoopsDatabase $db |
|
38
|
|
|
*/ |
|
39
|
|
|
public function __construct(\XoopsDatabase $db) |
|
40
|
|
|
{ |
|
41
|
|
|
parent::__construct($db, Customtag::class, 'customtagid', 'name', 'description', 'smartobject'); |
|
42
|
|
|
$this->addPermission('view', _CO_SOBJECT_CUSTOMTAG_PERMISSION_VIEW, _CO_SOBJECT_CUSTOMTAG_PERMISSION_VIEW_DSC); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @return array|bool |
|
47
|
|
|
*/ |
|
48
|
|
|
public function getCustomtagsByName() |
|
49
|
|
|
{ |
|
50
|
|
|
if (!$this->objects) { |
|
51
|
|
|
global $xoopsConfig; |
|
52
|
|
|
|
|
53
|
|
|
$ret = []; |
|
54
|
|
|
|
|
55
|
|
|
$criteria = new \CriteriaCompo(); |
|
56
|
|
|
|
|
57
|
|
|
$criteria_language = new \CriteriaCompo(); |
|
58
|
|
|
$criteria_language->add(new \Criteria('language', $xoopsConfig['language'])); |
|
59
|
|
|
$criteria_language->add(new \Criteria('language', 'all'), 'OR'); |
|
60
|
|
|
$criteria->add($criteria_language); |
|
61
|
|
|
|
|
62
|
|
|
$smartobjectPermissionsHandler = new PermissionHandler($this); |
|
63
|
|
|
$granted_ids = $smartobjectPermissionsHandler->getGrantedItems('view'); |
|
64
|
|
|
|
|
65
|
|
|
if ($granted_ids && count($granted_ids) > 0) { |
|
|
|
|
|
|
66
|
|
|
$criteria->add(new \Criteria('customtagid', '(' . implode(', ', $granted_ids) . ')', 'IN')); |
|
67
|
|
|
$customtagsObj =& $this->getObjects($criteria, true); |
|
68
|
|
|
foreach ($customtagsObj as $customtagObj) { |
|
69
|
|
|
$ret[$customtagObj->getVar('name')] = $customtagObj; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
$this->objects = $ret; |
|
|
|
|
|
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
return $this->objects; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.