1 | <?php |
||||||
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 https://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 | Helper, |
||||||
22 | Perm |
||||||
23 | }; |
||||||
24 | use Xmf\Request; |
||||||
25 | |||||||
26 | require_once __DIR__ . '/header.php'; |
||||||
27 | require_once __DIR__ . '/include/constantes.php'; |
||||||
28 | $params = ['view' => _EXTCAL_NAV_NEW_EVENT, 'file' => _EXTCAL_FILE_NEW_EVENT]; |
||||||
29 | $GLOBALS['xoopsOption']['template_main'] = 'extcal_event.tpl'; |
||||||
30 | |||||||
31 | /** @var Helper $helper */ |
||||||
32 | $helper = Helper::getInstance(); |
||||||
33 | |||||||
34 | require_once XOOPS_ROOT_PATH . '/include/comment_view.php'; |
||||||
35 | |||||||
36 | if (!isset($_GET['event'])) { |
||||||
37 | $eventId = 0; |
||||||
38 | } else { |
||||||
39 | $eventId = Request::getInt('event', 0, 'GET'); |
||||||
40 | } |
||||||
41 | $eventHandler = Helper::getInstance()->getHandler(_EXTCAL_CLN_EVENT); |
||||||
42 | $fileHandler = Helper::getInstance()->getHandler(_EXTCAL_CLN_FILE); |
||||||
43 | $eventMemberHandler = Helper::getInstance()->getHandler(_EXTCAL_CLN_MEMBER); |
||||||
44 | $eventNotMemberHandler = Helper::getInstance()->getHandler(_EXTCAL_CLN_NOT_MEMBER); |
||||||
45 | $permHandler = Perm::getHandler(); |
||||||
46 | $myts = \MyTextSanitizer::getInstance(); // MyTextSanitizer object |
||||||
47 | |||||||
48 | if (!function_exists('clear_unicodeslashes')) { |
||||||
49 | /** |
||||||
50 | * @param $text |
||||||
51 | * |
||||||
52 | * @return mixed |
||||||
53 | */ |
||||||
54 | function clear_unicodeslashes($text) |
||||||
55 | { |
||||||
56 | $text = str_replace(["\\'"], "'", $text); |
||||||
57 | $text = str_replace(["\\\\\\'"], "'", $text); |
||||||
58 | $text = str_replace(['\\"'], '"', $text); |
||||||
59 | |||||||
60 | return $text; |
||||||
61 | } |
||||||
62 | } |
||||||
63 | |||||||
64 | // Retriving event |
||||||
65 | $eventObj = $eventHandler->getEvent($eventId); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
66 | |||||||
67 | if (!$eventObj) { |
||||||
68 | redirect_header('index.php', 3, ''); |
||||||
69 | } |
||||||
70 | |||||||
71 | $event = $eventHandler->objectToArray($eventObj, ['cat_id', 'event_submitter']); |
||||||
0 ignored issues
–
show
The method
objectToArray() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
72 | $eventHandler->serverTimeToUserTime($event); |
||||||
0 ignored issues
–
show
The method
serverTimeToUserTime() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
73 | |||||||
74 | // Adding formated date for start and end event |
||||||
75 | $eventHandler->formatEventDate($event, $helper->getConfig('event_date_event')); |
||||||
0 ignored issues
–
show
The method
formatEventDate() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
76 | |||||||
77 | // Assigning event to the template |
||||||
78 | $xoopsTpl->assign('event', $event); |
||||||
79 | $xoopsTpl->assign('event_desc', html_entity_decode($myts->displayTarea(clear_unicodeslashes($event['event_desc']), 1, 1, 1, 1, 1))); |
||||||
80 | $xoopsTpl->assign('event_address', html_entity_decode($myts->displayTarea(clear_unicodeslashes($event['event_address']), 1, 1, 1, 1, 1))); |
||||||
81 | |||||||
82 | // Title of the page |
||||||
83 | $xoopsTpl->assign('xoops_pagetitle', $event['event_title']); |
||||||
84 | |||||||
85 | // $lang = array( |
||||||
86 | // 'start' => _MD_EXTCAL_START, 'end' => _MD_EXTCAL_END, 'contact_info' => _MD_EXTCAL_CONTACT_INFO, 'email' => _MD_EXTCAL_EMAIL, 'url' => _MD_EXTCAL_URL, 'whos_going' => _MD_EXTCAL_WHOS_GOING, 'whosnot_going' => _MD_EXTCAL_WHOSNOT_GOING, 'reccur_rule' => _MD_EXTCAL_RECCUR_RULE, 'posted_by' => _MD_EXTCAL_POSTED_BY, 'on' => _MD_EXTCAL_ON |
||||||
87 | // ); |
||||||
88 | // // Assigning language data to the template |
||||||
89 | // $xoopsTpl->assign('lang', $lang); |
||||||
90 | |||||||
91 | // Getting event attachement |
||||||
92 | $eventFiles = $fileHandler->objectToArray($fileHandler->getEventFiles($eventId)); |
||||||
0 ignored issues
–
show
The method
getEventFiles() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
93 | $fileHandler->formatFilesSize($eventFiles); |
||||||
0 ignored issues
–
show
The method
formatFilesSize() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
94 | $xoopsTpl->assign('event_attachement', $eventFiles); |
||||||
95 | |||||||
96 | // Token to disallow direct posting on membre/nonmember page |
||||||
97 | $xoopsTpl->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML()); |
||||||
98 | |||||||
99 | // Location |
||||||
100 | $locationHandler = $helper->getHandler(_EXTCAL_CLN_LOCATION); |
||||||
101 | $locationObj = $locationHandler->get($event['event_location']); |
||||||
102 | //$location = $locationHandler->objectToArray($locationObj); |
||||||
103 | $location = $locationObj->vars; |
||||||
104 | $xoopsTpl->assign('location', $location); |
||||||
105 | |||||||
106 | // $t =print_r($locationObj->vars,true); |
||||||
107 | // echo "<hr>location {$event['event_location']}<hr><pre>{$t}</pre><hr>"; |
||||||
108 | |||||||
109 | // ### For Who's Going function ### |
||||||
110 | |||||||
111 | // If the who's goging function is enabled |
||||||
112 | if ($helper->getConfig('whos_going')) { |
||||||
113 | // Retriving member's for this event |
||||||
114 | $members = $eventMemberHandler->getMembers($eventId); |
||||||
0 ignored issues
–
show
The method
getMembers() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
115 | |||||||
116 | // Initializing variable |
||||||
117 | $eventmember['member']['show_button'] = false; |
||||||
118 | |||||||
119 | $nbUser = 0; |
||||||
120 | // Making a list with members and counting regitered user's |
||||||
121 | foreach ($members as $k => $v) { |
||||||
122 | ++$nbUser; |
||||||
123 | $eventmember['member']['userList'][] = ['uid' => $k, 'uname' => $v->getVar('uname')]; |
||||||
124 | } |
||||||
125 | $eventmember['member']['nbUser'] = $nbUser; |
||||||
126 | |||||||
127 | // If the user is logged |
||||||
128 | if ($xoopsUser) { |
||||||
129 | // Initializing variable |
||||||
130 | $eventmember['member']['show_button'] = true; |
||||||
131 | $eventmember['member']['button_disabled'] = ''; |
||||||
132 | |||||||
133 | // If the user is already restired to this event |
||||||
134 | if (array_key_exists($xoopsUser->getVar('uid'), $members)) { |
||||||
0 ignored issues
–
show
It seems like
$members can also be of type null ; however, parameter $search of array_key_exists() does only seem to accept array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
135 | $eventmember['member']['button_text'] = _MD_EXTCAL_REMOVE_ME; |
||||||
136 | $eventmember['member']['joinevent_mode'] = 'remove'; |
||||||
137 | } else { |
||||||
138 | $eventmember['member']['button_text'] = _MD_EXTCAL_ADD_ME; |
||||||
139 | $eventmember['member']['joinevent_mode'] = 'add'; |
||||||
140 | |||||||
141 | // If this event is full |
||||||
142 | if (0 != $event['event_nbmember'] |
||||||
143 | && $eventMemberHandler->getNbMember($eventId) >= $event['event_nbmember']) { |
||||||
0 ignored issues
–
show
The method
getNbMember() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
144 | $eventmember['member']['disabled'] = ' disabled="disabled"'; |
||||||
145 | } |
||||||
146 | } |
||||||
147 | } |
||||||
148 | } |
||||||
149 | |||||||
150 | // ### For Who's not Going function ### |
||||||
151 | |||||||
152 | // If the who's not goging function is enabled |
||||||
153 | if ($helper->getConfig('whosnot_going')) { |
||||||
154 | // Retriving not member's for this event |
||||||
155 | $notmembers = $eventNotMemberHandler->getMembers($eventId); |
||||||
156 | |||||||
157 | // Initializing variable |
||||||
158 | $eventmember['notmember']['show_button'] = false; |
||||||
159 | |||||||
160 | $nbUser = 0; |
||||||
161 | // Making a list with not members |
||||||
162 | foreach ($notmembers as $k => $v) { |
||||||
163 | ++$nbUser; |
||||||
164 | $eventmember['notmember']['userList'][] = ['uid' => $k, 'uname' => $v->getVar('uname')]; |
||||||
165 | } |
||||||
166 | $eventmember['notmember']['nbUser'] = $nbUser; |
||||||
167 | |||||||
168 | // If the user is logged |
||||||
169 | if ($xoopsUser) { |
||||||
170 | // Initializing variable |
||||||
171 | $eventmember['notmember']['show_button'] = true; |
||||||
172 | $eventmember['notmember']['button_disabled'] = ''; |
||||||
173 | |||||||
174 | // If the user is already restired to this event |
||||||
175 | if (array_key_exists($xoopsUser->getVar('uid'), $notmembers)) { |
||||||
176 | $eventmember['notmember']['button_text'] = _MD_EXTCAL_REMOVE_ME; |
||||||
177 | $eventmember['notmember']['joinevent_mode'] = 'remove'; |
||||||
178 | } else { |
||||||
179 | $eventmember['notmember']['button_text'] = _MD_EXTCAL_ADD_ME; |
||||||
180 | $eventmember['notmember']['joinevent_mode'] = 'add'; |
||||||
181 | } |
||||||
182 | } |
||||||
183 | } |
||||||
184 | |||||||
185 | // If who's going or not going function is enabled |
||||||
186 | if ($helper->getConfig('whos_going') || $helper->getConfig('whosnot_going')) { |
||||||
187 | $xoopsTpl->assign('eventmember', $eventmember); |
||||||
188 | } |
||||||
189 | |||||||
190 | // Checking user perm |
||||||
191 | if ($xoopsUser) { |
||||||
192 | $xoopsTpl->assign('isAdmin', $xoopsUser->isAdmin()); |
||||||
193 | $canEdit = $permHandler->isAllowed($xoopsUser, 'extcal_cat_edit', $event['cat']['cat_id']) |
||||||
194 | && $xoopsUser->getVar('uid') == $event['user']['uid']; |
||||||
195 | $xoopsTpl->assign('canEdit', $canEdit); |
||||||
196 | } else { |
||||||
197 | $xoopsTpl->assign('isAdmin', false); |
||||||
198 | $xoopsTpl->assign('canEdit', false); |
||||||
199 | } |
||||||
200 | |||||||
201 | $xoopsTpl->assign('whosGoing', $helper->getConfig('whos_going')); |
||||||
202 | $xoopsTpl->assign('whosNotGoing', $helper->getConfig('whosnot_going')); |
||||||
203 | |||||||
204 | //------------- |
||||||
205 | $xoopsTpl->assign('params', $params); |
||||||
206 | $tNavBar = getNavBarTabs($params['view']); |
||||||
207 | $xoopsTpl->assign('tNavBar', $tNavBar); |
||||||
208 | //--------------------- |
||||||
209 | |||||||
210 | /* |
||||||
211 | // TZV // |
||||||
212 | // mb missing for xBootstrap templates by Tzvook |
||||||
213 | $lang = ['start' => _MD_EXTCAL_START, |
||||||
214 | 'end' => _MD_EXTCAL_END, |
||||||
215 | 'calmonth' => _MD_EXTCAL_NAV_CALMONTH, |
||||||
216 | 'calweek' => _MD_EXTCAL_NAV_CALWEEK, |
||||||
217 | 'year' => _MD_EXTCAL_NAV_YEAR, |
||||||
218 | 'month' => _MD_EXTCAL_NAV_MONTH, |
||||||
219 | 'week' => _MD_EXTCAL_NAV_WEEK, |
||||||
220 | 'day' => _MD_EXTCAL_NAV_DAY, |
||||||
221 | 'agendaweek' => _MD_EXTCAL_NAV_AGENDA_WEEK, |
||||||
222 | 'agendaday' => _MD_EXTCAL_NAV_AGENDA_DAY, |
||||||
223 | 'search' => _MD_EXTCAL_NAV_SEARCH, |
||||||
224 | 'newevent' => _MD_EXTCAL_NAV_NEW_EVENT, |
||||||
225 | ]; |
||||||
226 | |||||||
227 | // Assigning language data to the template |
||||||
228 | $xoopsTpl->assign('lang', $lang); |
||||||
229 | $xoopsTpl->assign('view', 'event'); |
||||||
230 | |||||||
231 | */ |
||||||
232 | |||||||
233 | /* test modofication status JJD |
||||||
234 | $k = 'status'; |
||||||
235 | $isStatus = _EXTCAL_STATUS_DESINSCRIPTION; |
||||||
236 | $xfStatus = new \XoopsFormSelect('', $k, $isStatus, 1, false) ; |
||||||
237 | $tStatus = array(_EXTCAL_STATUS_NONE => _MD_EXTCAL_LIB_NONE, |
||||||
238 | _EXTCAL_STATUS_COME => _MD_EXTCAL_LIB_COME, |
||||||
239 | _EXTCAL_STATUS_NOTCOME => _MD_EXTCAL_LIB_NOTCOME); |
||||||
240 | |||||||
241 | $xfStatus->addOptionArray($tStatus); |
||||||
242 | $xoopsTpl->assign('status', $xfStatus->render()); |
||||||
243 | */ |
||||||
244 | |||||||
245 | /** @var xos_opal_Theme $xoTheme */ |
||||||
246 | $xoTheme->addScript('browse.php?modules/extcal/assets/js/highslide.js'); |
||||||
247 | $xoTheme->addStylesheet('browse.php?modules/extcal/assets/js/highslide.css'); |
||||||
248 | |||||||
249 | //function XoopsFormDhtmlTextArea($caption, $name, $value = "", $rows = 5, $cols = 50, $hiddentext = "xoopsHiddenText", $options = []); |
||||||
250 | |||||||
251 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||||||
252 |