|
1
|
|
|
<?php namespace XoopsModules\Extcal; |
|
2
|
|
|
/* |
|
3
|
|
|
* You may not change or alter any portion of this comment or credits |
|
4
|
|
|
* of supporting developers from this source code or any supporting source code |
|
5
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
6
|
|
|
* |
|
7
|
|
|
* This program is distributed in the hope that it will be useful, |
|
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
14
|
|
|
* @license {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
|
15
|
|
|
* @package extcal |
|
16
|
|
|
* @since |
|
17
|
|
|
* @author XOOPS Development Team, |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
use XoopsModules\Extcal; |
|
21
|
|
|
|
|
22
|
|
|
// defined('XOOPS_ROOT_PATH') || exit('Restricted access.'); |
|
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
// // require_once __DIR__ . '/ExtcalPersistableObjectHandler.php'; |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Class EventNotMemberHandler. |
|
29
|
|
|
*/ |
|
30
|
|
View Code Duplication |
class EventNotMemberHandler extends ExtcalPersistableObjectHandler |
|
|
|
|
|
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* @param $db |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct(\XoopsDatabase $db) |
|
36
|
|
|
{ |
|
37
|
|
|
parent::__construct($db, 'extcal_eventnotmember', EventNotMember::class, ['event_id', 'uid']); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param $varArr |
|
42
|
|
|
*/ |
|
43
|
|
|
public function createEventNotMember($varArr) |
|
44
|
|
|
{ |
|
45
|
|
|
$eventnotmember = $this->create(); |
|
46
|
|
|
$eventnotmember->setVars($varArr); |
|
47
|
|
|
|
|
48
|
|
|
if ($this->insert($eventnotmember, true)) { |
|
49
|
|
|
$eventMemberHandler = Extcal\Helper::getInstance()->getHandler(_EXTCAL_CLN_MEMBER); |
|
50
|
|
|
$eventMemberHandler->deleteById([$varArr['event_id'], $varArr['uid']]); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param $id |
|
56
|
|
|
* |
|
57
|
|
|
* @return bool |
|
58
|
|
|
*/ |
|
59
|
|
|
public function deleteEventNotMember($id) |
|
60
|
|
|
{ |
|
61
|
|
|
return $this->deleteById($id, true); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param $eventId |
|
66
|
|
|
* |
|
67
|
|
|
* @return mixed |
|
68
|
|
|
*/ |
|
69
|
|
|
public function getMembers($eventId) |
|
70
|
|
|
{ |
|
71
|
|
|
$memberHandler = xoops_getHandler('member'); |
|
72
|
|
|
$eventNotMember = $this->getObjects( new \Criteria('event_id', $eventId)); |
|
73
|
|
|
$count = count($eventNotMember); |
|
74
|
|
|
if ($count > 0) { |
|
75
|
|
|
$in = '(' . $eventNotMember[0]->getVar('uid'); |
|
76
|
|
|
array_shift($eventNotMember); |
|
77
|
|
|
foreach ($eventNotMember as $member) { |
|
78
|
|
|
$in .= ',' . $member->getVar('uid'); |
|
79
|
|
|
} |
|
80
|
|
|
$in .= ')'; |
|
81
|
|
|
$criteria = new \Criteria('uid', $in, 'IN'); |
|
82
|
|
|
} else { |
|
83
|
|
|
$criteria = new \Criteria('uid', '(0)', 'IN'); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
return $memberHandler->getUsers($criteria, true); |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param $eventId |
|
91
|
|
|
* |
|
92
|
|
|
* @return int |
|
|
|
|
|
|
93
|
|
|
*/ |
|
94
|
|
|
public function getNbMember($eventId) |
|
95
|
|
|
{ |
|
96
|
|
|
$criteria = new \Criteria('event_id', $eventId); |
|
97
|
|
|
|
|
98
|
|
|
return $this->getCount($criteria); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.