|
1
|
|
|
<?php namespace XoopsModules\Extcal; |
|
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 {@link https://xoops.org/ XOOPS Project} |
|
15
|
|
|
* @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
|
16
|
|
|
* @package extcal |
|
17
|
|
|
* @since |
|
18
|
|
|
* @author XOOPS Development Team, |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
//Kraven 30 |
|
22
|
|
|
// defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
|
23
|
|
|
|
|
24
|
|
|
require_once XOOPS_ROOT_PATH . '/kernel/object.php'; |
|
|
|
|
|
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Class LocationHandler. |
|
28
|
|
|
*/ |
|
29
|
|
|
class LocationHandler extends ExtcalPersistableObjectHandler |
|
30
|
|
|
{ |
|
31
|
|
|
/** |
|
32
|
|
|
* @param \XoopsDatabase|null $db |
|
33
|
|
|
*/ |
|
34
|
|
|
public function __construct(\XoopsDatabase $db = null) |
|
|
|
|
|
|
35
|
|
|
{ |
|
36
|
|
|
parent::__construct($db, 'extcal_location', Location::class, 'id', 'nom'); |
|
|
|
|
|
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param $locationId |
|
41
|
|
|
* @param bool $skipPerm |
|
42
|
|
|
* |
|
43
|
|
|
* @return bool |
|
44
|
|
|
*/ |
|
45
|
|
|
public function getLocation($locationId, $skipPerm = false) |
|
46
|
|
|
{ |
|
47
|
|
|
$user = $GLOBALS['xoopsUser']; |
|
48
|
|
|
|
|
49
|
|
|
$criteriaCompo = new \CriteriaCompo(); |
|
|
|
|
|
|
50
|
|
|
$criteriaCompo->add(new \Criteria('id', $locationId)); |
|
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
if (!$skipPerm) { |
|
53
|
|
|
$this->addCatPermCriteria($criteriaCompo, $user); |
|
54
|
|
|
} |
|
55
|
|
|
$ret = $this->getObjects($criteriaCompo); |
|
56
|
|
|
if (isset($ret[0])) { |
|
57
|
|
|
return $ret[0]; |
|
58
|
|
|
} else { |
|
59
|
|
|
return false; |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @param \CriteriaElement $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
|
|
|
} else { |
|
82
|
|
|
return $this->objectToArray($rst); |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|