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
|
|
|
use XoopsModules\Extcal\{Helper |
|
|
|
|
24
|
|
|
}; |
25
|
|
|
|
26
|
|
|
// // require_once __DIR__ . '/ExtcalPersistableObjectHandler.php'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Class EventNotMemberHandler. |
30
|
|
|
*/ |
31
|
|
|
class EventNotMemberHandler extends ExtcalPersistableObjectHandler |
32
|
|
|
{ |
33
|
|
|
/** |
34
|
|
|
* @param \XoopsDatabase|null $db |
35
|
|
|
*/ |
36
|
|
|
public function __construct(\XoopsDatabase $db = null) |
37
|
|
|
{ |
38
|
|
|
if (null === $db) { |
39
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
40
|
|
|
} |
41
|
|
|
parent::__construct($db, 'extcal_eventnotmember', EventNotMember::class, ['event_id', 'uid']); |
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param $varArr |
46
|
|
|
*/ |
47
|
|
|
public function createEventNotMember($varArr) |
48
|
|
|
{ |
49
|
|
|
$eventnotmember = $this->create(); |
50
|
|
|
$eventnotmember->setVars($varArr); |
51
|
|
|
|
52
|
|
|
if ($this->insert($eventnotmember, true)) { |
53
|
|
|
$eventmemberHandler = Helper::getInstance()->getHandler(\_EXTCAL_CLN_MEMBER); |
54
|
|
|
$eventmemberHandler->deleteById([$varArr['event_id'], $varArr['uid']]); |
|
|
|
|
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param $id |
60
|
|
|
* |
61
|
|
|
* @return bool |
62
|
|
|
*/ |
63
|
|
|
public function deleteEventNotMember($id) |
64
|
|
|
{ |
65
|
|
|
return $this->deleteById($id, true); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param $eventId |
70
|
|
|
* |
71
|
|
|
* @return mixed |
72
|
|
|
*/ |
73
|
|
|
public function getMembers($eventId) |
74
|
|
|
{ |
75
|
|
|
/** @var \XoopsMemberHandler $memberHandler */ |
76
|
|
|
$memberHandler = \xoops_getHandler('member'); |
77
|
|
|
$eventNotMember = $this->getObjects(new \Criteria('event_id', $eventId)); |
78
|
|
|
$count = \count($eventNotMember); |
79
|
|
|
if ($count > 0) { |
80
|
|
|
$in = '(' . $eventNotMember[0]->getVar('uid'); |
81
|
|
|
\array_shift($eventNotMember); |
82
|
|
|
foreach ($eventNotMember as $member) { |
83
|
|
|
$in .= ',' . $member->getVar('uid'); |
84
|
|
|
} |
85
|
|
|
$in .= ')'; |
86
|
|
|
$criteria = new \Criteria('uid', $in, 'IN'); |
87
|
|
|
} else { |
88
|
|
|
$criteria = new \Criteria('uid', '(0)', 'IN'); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
return $memberHandler->getUsers($criteria, true); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param $eventId |
96
|
|
|
* |
97
|
|
|
* @return int|array |
98
|
|
|
*/ |
99
|
|
|
public function getNbMember($eventId) |
100
|
|
|
{ |
101
|
|
|
$criteria = new \Criteria('event_id', $eventId); |
102
|
|
|
|
103
|
|
|
return $this->getCount($criteria); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
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: