1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Extcal; |
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
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
17
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
18
|
|
|
* @package extcal |
19
|
|
|
* @since |
20
|
|
|
* @author XOOPS Development Team, |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
//Kraven 30 |
24
|
|
|
|
25
|
|
|
require_once XOOPS_ROOT_PATH . '/kernel/object.php'; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Class LocationHandler. |
29
|
|
|
*/ |
30
|
|
|
class LocationHandler extends ExtcalPersistableObjectHandler |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* @param \XoopsDatabase|null $db |
34
|
|
|
*/ |
35
|
|
|
public function __construct(\XoopsDatabase $db = null) |
36
|
|
|
{ |
37
|
|
|
if (null === $db) { |
38
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
39
|
|
|
} |
40
|
|
|
parent::__construct($db, 'extcal_location', Location::class, 'id', 'nom'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param $locationId |
45
|
|
|
* @param bool $skipPerm |
46
|
|
|
* |
47
|
|
|
* @return bool |
48
|
|
|
*/ |
49
|
|
|
public function getLocation($locationId, $skipPerm = false) |
50
|
|
|
{ |
51
|
|
|
$user = $GLOBALS['xoopsUser']; |
52
|
|
|
|
53
|
|
|
$criteriaCompo = new \CriteriaCompo(); |
54
|
|
|
$criteriaCompo->add(new \Criteria('id', $locationId)); |
55
|
|
|
|
56
|
|
|
if (!$skipPerm) { |
57
|
|
|
$this->addCatPermCriteria($criteriaCompo, $user); |
58
|
|
|
} |
59
|
|
|
$ret = $this->getObjects($criteriaCompo); |
60
|
|
|
return $ret[0] ?? false; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param \CriteriaElement|null $criteria |
65
|
|
|
* @param null $fields |
|
|
|
|
66
|
|
|
* @param bool $asObject |
67
|
|
|
* @param bool $id_as_key |
68
|
|
|
* |
69
|
|
|
* @return array |
70
|
|
|
*/ |
71
|
|
|
public function &getAll( |
72
|
|
|
\CriteriaElement $criteria = null, |
73
|
|
|
$fields = null, |
74
|
|
|
$asObject = true, |
75
|
|
|
$id_as_key = true |
76
|
|
|
) //getAll($criteria = null, $asObject = false) |
77
|
|
|
{ |
78
|
|
|
$rst = $this->getObjects($criteria, $asObject); |
79
|
|
|
if ($asObject) { |
80
|
|
|
return $rst; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
$ret = $this->objectToArray($rst); |
84
|
|
|
|
85
|
|
|
return $ret; |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|