Completed
Push — master ( d9c1b5...d598f1 )
by Michael
20s queued 11s
created

ro_regonlinehandler.php (19 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
use Xmf\Request;
4
5
require_once __DIR__ . '/../../mainfile.php';
6
require_once XOOPS_ROOT_PATH . '/header.php';
7
//XoopsMailer
8
require_once XOOPS_ROOT_PATH . '/class/xoopsmailer.php';
9
require_once XOOPS_ROOT_PATH . '/modules/apcal/language/' . $GLOBALS['xoopsConfig']['language'] . '/apcal_constants.php';
10
11
$xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" type="text/css" href="' . XOOPS_URL . '/modules/apcal/assets/css/apcal.css" />' . $xoopsTpl->get_template_vars('xoops_module_header'));
12
13
//read module preferences
14
require_once XOOPS_ROOT_PATH."/modules/apcal/class/APCal.php";
15
$cal = new APCal();
16
include_once XOOPS_ROOT_PATH.'/modules/apcal/include/read_configs.php';
17
18
//images
19
$roimageedit          = XOOPS_URL . '/modules/apcal/assets/images/regonline/edit.png';
20
$roimagedelete        = XOOPS_URL . '/modules/apcal/assets/images/regonline/delete.png';
21
$roimagesave          = XOOPS_URL . '/modules/apcal/assets/images/regonline/save.png';
22
$roimagesavemore      = XOOPS_URL . '/modules/apcal/assets/images/regonline/savemore.png';
23
$roimagecancel        = XOOPS_URL . '/modules/apcal/assets/images/regonline/cancel.png';
24
$roimagesend          = XOOPS_URL . '/modules/apcal/assets/images/regonline/sendmail.png';
25
$roimageprint         = XOOPS_URL . '/modules/apcal/assets/images/regonline/print.png';
26
$roimagestatusok      = XOOPS_URL . '/modules/apcal/assets/images/regonline/status_ok.png';
27
$roimagestatuslist    = XOOPS_URL . '/modules/apcal/assets/images/regonline/status_list.png';
28
$roimagestatuspending = XOOPS_URL . '/modules/apcal/assets/images/regonline/status_pend.png';
29
$roimagedownload      = XOOPS_URL . '/modules/apcal/assets/images/regonline/download.png';
30
31
$show_form_activate = false;
32
if (isset($_POST['form_activate'])) {
33
    if (!empty($_POST['eventid'])) {
34
        //called from edit an event (activate or edit regonline)
35
        $eventid   = Request::getInt('eventid', 0, 'POST');
36
        $url       = Request::getString('url', '', 'POST');
37
        $eventurl  = Request::getString('eventurl', '', 'POST');
38
        $event     = Request::getString('title', '', 'POST');
39
        $eventdate = Request::getString('eventdate', '', 'POST');
40
        $location  = Request::getString('location', '', 'POST');
41
42
        $show_form_activate = true;
43
    }
44
}
45
if (isset($_GET['op'])) {
46
    if ($_GET['op'] === 'show_form_activate') {
47
        //called after automatically redirect after add new event
48
        if (isset($_GET['eventid'])) {
49
            $eventid = $_GET['eventid'];
50
        }
51
        if (isset($_GET['eventurl'])) {
52
            $eventurl = $_GET['eventurl'] . '?smode=' . $_GET['smode'] . '&caldate=' . $_GET['caldate'];
53
        }
54
        if (isset($_GET['title'])) {
55
            $event = $_GET['title'];
56
        }
57
        if (isset($_GET['eventdate'])) {
58
            $eventdate = $_GET['eventdate'];
59
        }
60
61
        $show_form_activate = true;
62
    }
63
}
64
65
if ($show_form_activate) {
66
    $uid = $xoopsUser->getVar('uid');
67
68
    $email1 = '';
69
    $email2 = '';
70
    $email3 = '';
71
    $email4 = '';
72
    $email5 = '';
73
74
    //read data from apcal_ro_events
75
    $query    = 'SELECT '
76
        . $GLOBALS['xoopsDB']->prefix('apcal_ro_events')
77
        . '.* FROM '
78
        . $GLOBALS['xoopsDB']->prefix('apcal_ro_events')
79
        . ' WHERE (('
80
        . $GLOBALS['xoopsDB']->prefix('apcal_ro_events')
81
        . ".roe_eventid)=$eventid)";
82
    $res      = $GLOBALS['xoopsDB']->query($query);
83
    $num_rows = $GLOBALS['xoopsDB']->getRowsNum($res);
84
85
    if ($num_rows == 0) {
86
        //edit new item, make preselection
87
        $email1      = $xoopsUser->getVar('email');
88
        $datelimit   = $eventdate;
89
        $number      = 0;
90
        $waitinglist = 1;
91
        $needconfirm = 0;
92
        $typeedit    = 0; //new
93
    } else {
94
        while ($ro_result = $GLOBALS['xoopsDB']->fetchObject($res)) {
95
            $roeid       = $ro_result->roe_id;
96
            $number      = (int)$ro_result->roe_number;
97
            $datelimit   = (int)$ro_result->roe_datelimit;
98
            $waitinglist = ($number > 0) ? (int)$ro_result->roe_waitinglist : 0;
99
            $needconfirm = (int)$ro_result->roe_needconfirm;
100
            $typeedit    = 1; //edit
101
        }
102
    }
103
104
    //read data from apcal_ro_notify
105
    $query    = 'SELECT '
106
        . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify')
107
        . '.* FROM '
108
        . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify')
109
        . ' WHERE (('
110
        . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify')
111
        . ".ron_eventid)=$eventid)";
112
    $res      = $GLOBALS['xoopsDB']->query($query);
113
    $num_rows = $GLOBALS['xoopsDB']->getRowsNum($res);
114
115
    $i = 0;
116
    if ($num_rows == 0) {
117
        //no data, use email from actual user
118
    } else {
119
        while ($ron_result = $GLOBALS['xoopsDB']->fetchObject($res)) {
120
            ++$i;
121
            switch ($i) {
122
                case 1:
123
                    $email1 = $ron_result->ron_email;
124
                    break;
125
                case 2:
126
                    $email2 = $ron_result->ron_email;
127
                    break;
128
                case 3:
129
                    $email3 = $ron_result->ron_email;
130
                    break;
131
                case 4:
132
                    $email4 = $ron_result->ron_email;
133
                    break;
134
                case 5:
135
                    $email5 = $ron_result->ron_email;
136
                    break;
137
            }
138
        }
139
    }
140
141
    if ($datelimit > 0) {
142
        $datelimit = date('d.m.Y H:i:s', $datelimit);
143
    }
144
    if ($eventdate > 0) {
145
        $eventdate = date('d.m.Y H:i:s', $eventdate);
146
    }
147
148
    $ret = "
149
    <table border='0' width='100%'>
150
        <tr><td width='100%' class='itemHead'><span class='itemTitle'>" . _APCAL_RO_TITLE2 . "</span></td></tr>
151
        <tr><td width='100%'>
152
        <form class='apcalForm' method='post' id='RegOnlineForm' action='ro_regonlinehandler.php' name='roformactivate' style='margin:0px;'>
153
            <input type='hidden' name='eventid' value='$eventid' />
154
            <input type='hidden' name='uid' value='$uid' />
155
            <input type='hidden' name='eventurl' value='$eventurl' />
156
            <input type='hidden' name='url' value='$url' />
157
            <input type='hidden' name='typeedit' value='$typeedit' />
158
            <table>
159
                <tr>
160
                    <td class='even' width='300px'>" . _APCAL_RO_EVENT . ":</td>
161
                    <td class='odd'><input type='text' name='event' disabled='disabled' value='$event'  size='80' /></td>
162
                </tr>";
163
    $ret .= "
164
                <tr>
165
                    <td class='even' width='120px'>" . _APCAL_RO_DATE . ":</td>
166
                    <td class='odd'><input type='text' name='eventdate' disabled='disabled' value='$eventdate'  size='80' /></td>
167
                </tr>
168
                 <tr>
169
                    <td class='even' width='120px'>" . _APCAL_RO_LOCATION . ":</td>
170
                    <td class='odd'><input type='text' name='location' disabled='disabled' value='$location'  size='80' /></td>
171
                </tr>";
172
    $ret .= "
173
                <tr>
174
                    <td class='even' width='300px'>" . _APCAL_RO_QUANTITY . ":</td>
175
                    <td class='odd'><input type='text' name='number' value='$number' size='80' /></td>
176
                </tr>
177
                <tr>
178
                    <td class='even' width='300px'>" . _APCAL_RO_DATELIMIT . ":</td>
179
                    <td class='odd'><input type='text' name='datelimit' value='$datelimit' size='80' /></td>
180
                </tr>";
181
    $ret .= "
182
                    <tr>
183
                        <td class='even' width='300px'>" . _APCAL_RO_STATUS_ACT. ":</td>
184
                        <td class='odd'>
185
                            <input id='needconfirm1' type='radio' value='1'";
186
                            if ($needconfirm ==1) $ret .=" checked='checked'";
187
                            $ret .=" title='" . _APCAL_RO_STATUS_ACT . "' name='needconfirm' />
188
                            <label for='needconfirm1' name='xolb_needconfirm1'>"._APCAL_RO_RADIO_YES."</label>
189
                            <input id='needconfirm2' type='radio' value='0'";
190
                            if ($needconfirm == 0) $ret .=" checked='checked'";
191
                            $ret .=" title='" . _APCAL_RO_STATUS_ACT . "' name='needconfirm' />
192
                            <label for='needconfirm2' name='xolb_needconfirm2'>"._APCAL_RO_RADIO_NO."</label>
193
                        </td>
194
                    </tr>";
195
    $ret .= "
196
                    <tr>
197
                        <td class='even' width='300px'>" . _APCAL_RO_LIST_ACT . ":</td>
198
                        <td class='odd'>
199
                            <input id='waitinglist1' type='radio' value='1'";
200
                        if ($waitinglist == 1) $ret .=" checked='checked'";
201
                        $ret .=" title='" . _APCAL_RO_LIST_ACT . "' name='waitinglist' />
202
                        <label for='waitinglist1' name='xolb_waitinglist1'>"._APCAL_RO_RADIO_YES."</label>
203
                            <input id='waitinglist2' type='radio' value='0'";
204
                        if ($waitinglist == 0) $ret .=" checked='checked'";
205
                        $ret .=" title='" . _APCAL_RO_LIST_ACT . "' name='waitinglist' />
206
                        <label for='waitinglist2' name='xolb_waitinglist2'>"._APCAL_RO_RADIO_NO."</label>
207
                        </td>
208
                </tr>
209
                <tr>
210
                    <td class='even' width='300px'>" . _APCAL_RO_EMAIL_NOTIFY . ":</td>
211
                    <td class='odd'>
212
                        <table cellspacing='0' cellpading='0'>
213
                            <tr>
214
                                <td class='odd'><input type='text' name='email1' value='$email1' size='80' /></td>
215
                            </tr>
216
                            <tr>
217
                                <td class='odd'><input type='text' name='email2' value='$email2' size='80' /></td>
218
                            </tr>
219
                            <tr>
220
                                <td class='odd'><input type='text' name='email3' value='$email3' size='80' /></td>
221
                            </tr>
222
                            <tr>
223
                                <td class='odd'><input type='text' name='email4' value='$email4' size='80' /></td>
224
                            </tr>
225
                            <tr>
226
                                <td class='odd'><input type='text' name='email5' value='$email5' size='80' /></td>
227
                            </tr>
228
                        </table>
229
                    </td>
230
                </tr>
231
            </table>
232
            <br><br>
233
            <div align='center'>";
234
235
    if ($typeedit == 0) {
236
        $ret .= "<input type='image' src='$roimagesave' name='activate' alt='" . _APCAL_RO_BTN_CONF_SAVE . "' title='" . _APCAL_RO_BTN_CONF_SAVE . "' height='24px'/>";
237
    } else {
238
        $ret .= "<input type='image' src='$roimagesave' name='activate' alt='" . _APCAL_RO_BTN_CONF_EDIT . "' title='" . _APCAL_RO_BTN_CONF_EDIT . "' height='24px'/>";
239
    }
240
    $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
241
    $ret .= "<input type='image' src='$roimagedelete' name='deactivate' alt='" . _APCAL_RO_BTN_RO_DEACTIVATE . "' title='" . _APCAL_RO_BTN_RO_DEACTIVATE . "' height='24px'/>";
242
    $ret .= '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
243
    $ret .= "<input type='image' src='$roimagecancel' name='cancel' alt='" . _APCAL_RO_BTN_CANCEL . "' title='" . _APCAL_RO_BTN_CANCEL . "' height='24px'/>";
244
    $ret .= "</div>
245
        </form>
246
        </td></tr>
247
    </table>
248
    \n";
249
    echo $ret;
250
}
251
252
if (isset($_POST['activate_x'])) {
253
    if (!empty($_POST['eventid'])) {
254
        $uid         = Request::getInt('uid');
255
        $eventid     = Request::getInt('eventid');
256
        $eventurl    = Request::getString('eventurl', '');
257
        $datelimit   = Request::getString('datelimit', '');
258
        $number      = Request::getInt('number');
259
        $needconfirm = Request::getInt('needconfirm');
260
        $waitinglist = ($number > 0 ) ? Request::getInt('waitinglist') : 0;
261
        $email1      = Request::getString('email1', '');
262
        $email2      = Request::getString('email2', '');
263
        $email3      = Request::getString('email3', '');
264
        $email4      = Request::getString('email4', '');
265
        $email5      = Request::getString('email5', '');
266
        $typeedit    = Request::getInt('typeedit');
267
268
        if ($datelimit === '') {
269
            $datelimit = 0;
270
        } else {
271
            $datelimit = strtotime($datelimit);
272
        }
273
274
        //insert or update data in table apcal_ro_events
275
        if ($typeedit == 0) {
276
            $query = 'Insert into '
277
                     . $GLOBALS['xoopsDB']->prefix('apcal_ro_events')
278
                     . " (roe_submitter, roe_eventid, roe_datelimit, roe_number, roe_needconfirm, roe_waitinglist, roe_date_created) values ($uid, $eventid, $datelimit, $number, $needconfirm, $waitinglist, "
279
                     . time()
280
                     . ')';
281
        } else {
282
            $query = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('apcal_ro_events') . ' SET ';
283
            $query .= $GLOBALS['xoopsDB']->prefix('apcal_ro_events') . ".roe_submitter = $uid, ";
284
            $query .= $GLOBALS['xoopsDB']->prefix('apcal_ro_events') . ".roe_datelimit = $datelimit, ";
285
            $query .= $GLOBALS['xoopsDB']->prefix('apcal_ro_events') . ".roe_number = $number, ";
286
            $query .= $GLOBALS['xoopsDB']->prefix("apcal_ro_events") . ".roe_needconfirm = $needconfirm, ";
287
            $query .= $GLOBALS['xoopsDB']->prefix("apcal_ro_events") . ".roe_waitinglist = $waitinglist, ";
288
            $query .= $GLOBALS['xoopsDB']->prefix('apcal_ro_events') . '.roe_date_created = ' . time() . ' ';
289
            $query .= 'WHERE (((' . $GLOBALS['xoopsDB']->prefix('apcal_ro_events') . ".roe_eventid)=$eventid))";
290
        }
291
        $res = $GLOBALS['xoopsDB']->query($query);
292
        if (!$res) {
293
            redirect_header($eventurl, 3, _APCAL_RO_ERROR_RO_ACTIVATE);
294
        }
295
        
296
        $res = $GLOBALS['xoopsDB']->query($query);
297
        if (!$res) {
298
            redirect_header($eventurl, 3, _APCAL_RO_ERROR_RO_ACTIVATE);
299
        }
300
301
        //update data in table apcal_events
302
        $query = 'UPDATE '
303
                 . $GLOBALS['xoopsDB']->prefix('apcal_event')
304
                 . ' SET '
305
                 . $GLOBALS['xoopsDB']->prefix('apcal_event')
306
                 . '.extkey0 = 1 WHERE ((('
307
                 . $GLOBALS['xoopsDB']->prefix('apcal_event')
308
                 . ".id)=$eventid))";
309
        $res   = $GLOBALS['xoopsDB']->query($query);
310
        if (!$res) {
311
            //echo $query;
312
            redirect_header($eventurl, 3, _APCAL_RO_ERROR_RO_ACTIVATE);
313
        }
314
315
        //update date in apcal_ro_notify
316
        if ($typeedit == 1) {
317
            //delete old data in apcal_ro_notify
318
            $query = 'DELETE '
319
                     . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify')
320
                     . '.* FROM '
321
                     . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify')
322
                     . ' WHERE (('
323
                     . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify')
324
                     . ".ron_eventid)=$eventid)";
325
            $res   = $GLOBALS['xoopsDB']->query($query);
326
        }
327 View Code Duplication
        if ($email1 !== '') {
328
            $submitter = $xoopsUser->getVar('uid');
329
            $query     = 'Insert into ' . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify') . " (ron_eventid, ron_email, ron_submitter, ron_date_created) values ($eventid, '$email1', $submitter, ". time().")";
330
            $res       = $GLOBALS['xoopsDB']->query($query);
331
            if (!$res) {
332
                redirect_header($eventurl, 3, _APCAL_RO_ERROR_RO_ACTIVATE);
333
            }
334
        }
335 View Code Duplication
        if ($email2 !== '') {
336
            $query = 'Insert into ' . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify') . " (ron_eventid, ron_email, ron_submitter, ron_date_created) values ($eventid, '$email2', $submitter, ". time().")";
337
            $res   = $GLOBALS['xoopsDB']->query($query);
338
            if (!$res) {
339
                redirect_header($eventurl, 3, _APCAL_RO_ERROR_RO_ACTIVATE);
340
            }
341
        }
342 View Code Duplication
        if ($email3 !== '') {
343
            $query = 'Insert into ' . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify') . " (ron_eventid, ron_email, ron_submitter, ron_date_created) values ($eventid, '$email3', $submitter, ". time().")";
344
            $res   = $GLOBALS['xoopsDB']->query($query);
345
            if (!$res) {
346
                redirect_header($eventurl, 3, _APCAL_RO_ERROR_RO_ACTIVATE);
347
            }
348
        }
349 View Code Duplication
        if ($email4 !== '') {
350
            $query = 'Insert into ' . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify') . " (ron_eventid, ron_email, ron_submitter, ron_date_created) values ($eventid, '$email4', $submitter, ". time().")";
351
            $res   = $GLOBALS['xoopsDB']->query($query);
352
            if (!$res) {
353
                redirect_header($eventurl, 3, _APCAL_RO_ERROR_RO_ACTIVATE);
354
            }
355
        }
356 View Code Duplication
        if ($email5 !== '') {
357
            $query = 'Insert into ' . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify') . " (ron_eventid, ron_email, ron_submitter, ron_date_created) values ($eventid, '$email5', $submitter, ". time().")";
358
            $res   = $GLOBALS['xoopsDB']->query($query);
359
            if (!$res) {
360
                redirect_header($eventurl, 3, _APCAL_RO_ERROR_RO_ACTIVATE);
361
            }
362
        }
363
        redirect_header($eventurl, 3, _APCAL_RO_SUCCESS_RO_ACTIVATE);
364
    }
365
}
366
367
if (isset($_POST['deactivate_x'])) {
368
    if (!empty($_POST['eventid'])) {
369
        $eventid = Request::getInt('eventid');
370
        $url     = Request::getString('eventurl', '');
371
372
        //delete data in table apcal_ro_members
373
        $query = 'DELETE '
374
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
375
                 . '.* FROM '
376
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
377
                 . ' WHERE (('
378
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
379
                 . ".rom_eventid)=$eventid)";
380
        $res   = $GLOBALS['xoopsDB']->query($query);
381
        if (!$res) {
382
            redirect_header($url, 3, _APCAL_RO_ERROR_RO_DEACTIVATE);
383
        }
384
385
        //delete data in table apcal_ro_notify
386
        $query = 'DELETE '
387
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify')
388
                 . '.* FROM '
389
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify')
390
                 . ' WHERE (('
391
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify')
392
                 . ".ron_eventid)=$eventid)";
393
        $res   = $GLOBALS['xoopsDB']->query($query);
394
395
        //delete data in table apcal_ro_events
396
        $query = 'DELETE '
397
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_events')
398
                 . '.* FROM '
399
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_events')
400
                 . ' WHERE (('
401
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_events')
402
                 . ".roe_eventid)=$eventid)";
403
        $res   = $GLOBALS['xoopsDB']->query($query);
404
        if (!$res) {
405
            redirect_header($url, 3, _APCAL_RO_ERROR_RO_DEACTIVATE);
406
        }
407
408
        //update data in table apcal_event
409
        $query = 'UPDATE '
410
                 . $GLOBALS['xoopsDB']->prefix('apcal_event')
411
                 . ' SET '
412
                 . $GLOBALS['xoopsDB']->prefix('apcal_event')
413
                 . '.extkey0 = 0 WHERE ((('
414
                 . $GLOBALS['xoopsDB']->prefix('apcal_event')
415
                 . ".id)=$eventid))";
416
        $res   = $GLOBALS['xoopsDB']->query($query);
417
        if (!$res) {
418
            redirect_header($url, 3, _APCAL_RO_ERROR_RO_DEACTIVATE);
419
        } else {
420
            //Data were correctly deleted from DB;
421
            redirect_header($url, 3, _APCAL_RO_SUCCESS_RO_DEACTIVATE);
422
        }
423
    }
424
}
425
426
if (isset($_REQUEST['form_add'])) {
427
    if (!empty($_REQUEST['eventid'])) {
428
        $eventid   = Request::getInt('eventid');
429
        $eventurl  = Request::getString('eventurl', '');
430
        $summary   = Request::getString('summary', '');
431
        $date      = Request::getString('date');
432
        $eventdate = Request::getInt('eventdate');
433
        $location  = Request::getString('location', '');
434
        $title     = '';
435
        $ret       = '';
436
        $retList      = '';
437
        $classname = '';
438
        $event_uid = Request::getInt('event_uid');
439
        
440
        $firstname  = Request::getString('firstname', '');
441
        $lastname   = Request::getString('lastname', '');
442
        $email      = Request::getString('email', '');
443
        $extrainfo1 = Request::getString('extrainfo1', '');
444
        $extrainfo2 = Request::getString('extrainfo2', '');
445
        $extrainfo3 = Request::getString('extrainfo3', '');
446
        $extrainfo4 = Request::getString('extrainfo4', '');
447
        $extrainfo5 = Request::getString('extrainfo5', '');
448
449
        $eventdate = date('d.m.Y H:i:s', $eventdate);
450
451
        $title = $summary . ' (' . $eventdate . ' ' . $location . ')';
452
453 View Code Duplication
        if (!empty($_SERVER['HTTPS'])) {
454
            $url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
455
        } else {
456
            $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
457
        }
458
459
        $url .= '?form_add=1';
460
        $url .= "&eventid=$eventid";
461
        $url .= "&eventurl=$eventurl";
462
        $url .= "&summary=$summary";
463
        $url .= "&date=$date";
464
        $url .= "&eventdate=$eventdate";
465
        $url .= "&location=$location";
466
467
        //get username and email
468
        global $xoopsUser;
469
        if (!isset($xoopsUser) || !is_object($xoopsUser)) {
470
            $uname = '';
471
            $email = '';
472
            $uid   = 0;
473
        } else {
474
            $uname = $xoopsUser->getVar('uname');
475
            $email = $xoopsUser->getVar('email');
476
            $uid   = $xoopsUser->getVar('uid');
477
        }
478
479
        $ret = "
480
        <div class='row'>
481
            <div><span class='itemTitle'>" . _APCAL_RO_TITLE1 . "</span></div>
482
            <form class='apcalForm' method='post' id='RegOnlineForm' action='ro_regonlinehandler.php' name='roformaddmember' style='margin:0px;'>
483
                <input type='hidden' name='eventid' value='$eventid' />
484
                <input type='hidden' name='uid' value='$uid' />
485
                <input type='hidden' name='uname' value='$uname' />
486
                <input type='hidden' name='url' value='$url' />
487
                <input type='hidden' name='eventurl' value='$eventurl' />
488
                <input type='hidden' name='title' value='$title' />
489
                <input type='hidden' name='summary' value='$summary' />
490
                <input type='hidden' name='date' value='$date' />
491
                <input type='hidden' name='location' value='$location' />
492
                        <div class='col-xs-12 col-sm-4'>" . _APCAL_RO_EVENT . ":</div>
493
                        <div class='col-xs-12 col-sm-8'><input type='text' name='title' disabled='disabled' value='$summary' style='width:100%' /></div>
494
                        <div class='col-xs-12 col-sm-4'>" . _APCAL_RO_DATE . ":</div>
495
                        <div class='col-xs-12 col-sm-8'><input type='text' name='date' disabled='disabled' value='$date' style='width:100%' /></div>
496
                        <div class='col-xs-12 col-sm-4'>" . _APCAL_RO_LOCATION . ":</div>
497
                        <div class='col-xs-12 col-sm-8'><input type='text' name='location' disabled='disabled' value='$location' style='width:100%' /></div>
498
                        <div class='even col-xs-12 col-sm-4'>" . _APCAL_RO_FIRSTNAME . "*:</div>
499
                        <div class='odd col-xs-12 col-sm-8'><input type='text' name='firstname' value='$firstname' style='width:100%' /></div>
500
                        <div class='even col-xs-12 col-sm-4'>" . _APCAL_RO_LASTNAME . "*:</div>
501
                        <div class='odd col-xs-12 col-sm-8'><input type='text' name='lastname' value='$lastname' style='width:100%' /></div>
502
                        <div class='even col-xs-12 col-sm-4'>" . _APCAL_RO_EMAIL . ":</div>
503
                        <div class='odd col-xs-12 col-sm-8'>
504
                            <input type='text' name='email' value='$email' style='width:100%' />
505
                            <br>" . _APCAL_RO_SEND_CONF3 . "
506
                            <input type='radio' name='sendconf' value='yes' checked> " . _APCAL_RO_RADIO_YES . "
507
                            <input type='radio' name='sendconf' value='no'> " . _APCAL_RO_RADIO_NO . '
508
                        </div>
509
                    ';
510
        if ($cal->ro_extrainfo1 !== '') {
511
            $extrainfo1_obligatory = ($cal->ro_extrainfo1_obl > 0) ? '*' : '';
512
            $ret .= "
513
                        <div class='even col-xs-12 col-sm-4'>" . $cal->ro_extrainfo1 . "$extrainfo1_obligatory:</div>
514
                        <div class='odd col-xs-12 col-sm-8'><input type='text' name='extrainfo1' value='$extrainfo1' style='width:100%' /></div>
515
                    ";
516
        }
517
        if ($cal->ro_extrainfo2 !== '') {
518
            $extrainfo2_obligatory = ($cal->ro_extrainfo2_obl > 0) ? '*' : '';
519
            $ret .= "
520
                        <div class='even col-xs-12 col-sm-4'>" . $cal->ro_extrainfo2 . "$extrainfo2_obligatory:</div>
521
                        <div class='odd col-xs-12 col-sm-8'><input type='text' name='extrainfo2' value='$extrainfo2' style='width:100%' /></div>
522
                    ";
523
        }
524
        if ($cal->ro_extrainfo3 !== '') {
525
            $extrainfo3_obligatory = ($cal->ro_extrainfo3_obl > 0) ? '*' : '';
526
            $ret .= "
527
                        <div class='even col-xs-12 col-sm-4'>" . $cal->ro_extrainfo3 . "$extrainfo3_obligatory:</div>
528
                        <div class='odd col-xs-12 col-sm-8'><input type='text' name='extrainfo3' value='$extrainfo3' style='width:100%' /></div>
529
                    ";
530
        }
531
        if ($cal->ro_extrainfo4 !== '') {
532
            $extrainfo4_obligatory = ($cal->ro_extrainfo4_obl > 0) ? '*' : '';
533
            $ret .= "
534
                        <div class='even col-xs-12 col-sm-4'>" . $cal->ro_extrainfo4 . "$extrainfo4_obligatory:</div>
535
                        <div class='odd col-xs-12 col-sm-8'><input type='text' name='extrainfo4' value='$extrainfo4' style='width:100%' /></div>
536
                    ";
537
        }
538
        if ($cal->ro_extrainfo5 !== '') {
539
            $extrainfo5_obligatory = ($cal->ro_extrainfo5_obl > 0) ? '*' : '';
540
            $ret .= "
541
                        <div class='even col-xs-12 col-sm-4'>" . $cal->ro_extrainfo5 . "$extrainfo5_obligatory:</div>
542
                        <div class='odd col-xs-12 col-sm-8'><input type='text' name='extrainfo5' value='$extrainfo5' style='width:100%' /></div>
543
                    ";
544
        }
545
        
546
        if (($event_uid == $uid && $uid > 0) || //current user is event owner
547
            ($cal->isadmin == 1) || //current user is admin
548
            ($cal->ro_superedit == 1)) //current user can edit/delete registrations of other persons
0 ignored issues
show
The property ro_superedit does not seem to exist. Did you mean superedit?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
549
        {
550
            $ret .= "
551
                <div class='even col-xs-12 col-sm-4'>" . _APCAL_RO_STATUS . ":</div>
552
                <div class='odd col-xs-12 col-sm-8'>
553
                    <input id='status0' type='radio' value='0' checked='checked' title=" . _APCAL_RO_STATUS_OK . " name='status' />
554
                    <label for='status0' name='xolb_status0'>" . _APCAL_RO_STATUS_OK . "</label>&nbsp;&nbsp;
555
                    <input id='status1' type='radio' value='1' title=" . _APCAL_RO_STATUS_PENDING . " name='status' />
556
                    <label for='status1' name='xolb_status1'>" . _APCAL_RO_STATUS_PENDING . "</label>&nbsp;&nbsp;
557
                    <input id='status2' type='radio' value='2' title=" . _APCAL_RO_STATUS_LIST . " name='status' />
558
                    <label for='status2' name='xolb_status2'>" . _APCAL_RO_STATUS_LIST . "</label>
559
                </div>";
560
        } else {
561
            $ret .= "<input type='hidden' name='status' value='-1' size='100' />";
562
        }
563
        $ret .= '
564
                </div>
565
                * ' . _APCAL_RO_OBLIGATORY . "
566
                <br><br>
567
                <div align='center'>
568
                    <input type='image' src='$roimagesave' name='add_member' alt='" . _APCAL_RO_BTN_CONF_ADD . "' title='" . _APCAL_RO_BTN_CONF_ADD . "' height='24px'/>&nbsp;&nbsp;
569
                    <input type='image' src='$roimagesavemore' name='add_member_more' alt='" . _APCAL_RO_BTN_CONF_ADD_MORE . "' title='" . _APCAL_RO_BTN_CONF_ADD_MORE . "' height='24px'/>&nbsp;&nbsp;
570
                    <input type='image' src='$roimagecancel' name='cancel' alt='" . _APCAL_RO_BTN_CANCEL . "' title='" . _APCAL_RO_BTN_CANCEL . "' height='24px'/>
571
                </div>
572
            </form>
573
         </div>\n<br><br>";
574
575
        $retList = '';
576
        $query = "SELECT ".$GLOBALS['xoopsDB']->prefix("apcal_ro_members").".* ";
577
        $query .= "FROM ".$GLOBALS['xoopsDB']->prefix("apcal_ro_members");
578
        //replaced one line by goffy2
579
        //$query .= " WHERE (((rom_eventid)=$eventid) AND ((rom_submitter)=$uid))";
580
        $query .= " WHERE (((rom_eventid)=$eventid) AND ((rom_submitter)=$uid)";
581
        if ($uid==0) {
582
            $poster_ip = gethostbyaddr(getenv("REMOTE_ADDR"));
583
            if ($poster_ip=='') $poster_ip='x';
584
            $query .= " AND ((rom_poster_ip)='$poster_ip')";
585
        }
586
        $query .= ")";
587
        
588
        $res = $GLOBALS['xoopsDB']->query($query);
589
        $num_rows = $GLOBALS['xoopsDB']->getRowsNum($res);
590
591
592
        if ($num_rows > 0) {
593
            $retList .= "
594
                <table border='0' width='100%'>
595
                    <tr><td width='100%' class='itemHead'><span class='itemTitle'>" . _APCAL_RO_TITLE3 . "</span></td></tr>
596
                    <tr><td width='100%'>
597
                    <table class='ro_table' width='100%'>
598
                        <tr>
599
                            <th class='even'>" . _APCAL_RO_FIRSTNAME . "</th>
600
                            <th class='even'>" . _APCAL_RO_LASTNAME . "</th>
601
                            <th class='even'>" . _APCAL_RO_EMAIL . '</th>';
602
            if ($cal->ro_extrainfo1 !== '') {
603
                $retList .= "<th class='even'>" . $cal->ro_extrainfo1 . '</th>';
604
            }
605
            if ($cal->ro_extrainfo2 !== '') {
606
                $retList .= "<th class='even'>" . $cal->ro_extrainfo2 . '</th>';
607
            }
608
            if ($cal->ro_extrainfo3 !== '') {
609
                $retList .= "<th class='even'>" . $cal->ro_extrainfo3 . '</th>';
610
            }
611
            if ($cal->ro_extrainfo4 !== '') {
612
                $retList .= "<th class='even'>" . $cal->ro_extrainfo4 . '</th>';
613
            }
614
            if ($cal->ro_extrainfo5 !== '') {
615
                $retList .= "<th class='even'>" . $cal->ro_extrainfo5 . '</th>';
616
            }
617
            $retList .= "<th class='even'>"._APCAL_RO_STATUS."</th>";
618
            $retList .= "
619
                    <th class='even'>" . _APCAL_RO_ACTION . '</th>
620
                </tr>';
621
            while ($member = $GLOBALS['xoopsDB']->fetchObject($res)) {
622
                $romfirstname  = $member->rom_firstname;
623
                $romlastname   = $member->rom_lastname;
624
                $romemail      = $member->rom_email;
625
                $romextrainfo1 = $member->rom_extrainfo1;
626
                $romextrainfo2 = $member->rom_extrainfo2;
627
                $romextrainfo3 = $member->rom_extrainfo3;
628
                $romextrainfo4 = $member->rom_extrainfo4;
629
                $romextrainfo5 = $member->rom_extrainfo5;
630
                $rom_id        = $member->rom_id;
631
                $status        = (int)$member->rom_status;
632
633 View Code Duplication
                if ($line == 0) {
634
                    $classname = 'odd';
635
                    $line = 1;
636
                } else {
637
                    $classname = 'even';
638
                    $line = 0;
639
                }
640
                $unique_id = uniqid(mt_rand());
641
                $retList .= "
642
                    <form class='apcalForm' method='post' id='RegOnlineForm' action='ro_regonlinehandler.php' name='roformeditremovemember_" . $unique_id . "' style='margin:0px;'>
643
                        <input type='hidden' name='eventid' value='$eventid' />
644
                        <input type='hidden' name='uid' value='$uid' />
645
                        <input type='hidden' name='uname' value='$uname' />
646
                        <input type='hidden' name='url' value='$url' />
647
                        <input type='hidden' name='eventurl' value='$eventurl' />
648
                        <input type='hidden' name='summary' value='$summary' />
649
                        <input type='hidden' name='date' value='$date' />
650
                        <input type='hidden' name='eventdate' value='$eventdate' />
651
                        <input type='hidden' name='location' value='$location' />
652
                        <input type='hidden' name='rom_id' value='$rom_id' />
653
                        <input type='hidden' name='firstname' value='$romfirstname' />
654
                        <input type='hidden' name='lastname' value='$romlastname' />
655
                        <input type='hidden' name='email' value='$romemail' />
656
                        <input type='hidden' name='extrainfo1' value='$romextrainfo1' />
657
                        <input type='hidden' name='extrainfo2' value='$romextrainfo2' />
658
                        <input type='hidden' name='extrainfo3' value='$romextrainfo3' />
659
                        <input type='hidden' name='extrainfo4' value='$romextrainfo4' />
660
                        <input type='hidden' name='extrainfo5' value='$romextrainfo5' />
661
                        <input type='hidden' name='status' value='$status' />
662
                        <input type='hidden' name='num_members' value='$num_rows' />
663
                    ";
664
                $retList .= "<tr>
665
                            <td class='$classname'>$romfirstname</td>
666
                            <td class='$classname'>$romlastname</td>
667
                            <td class='$classname'>$romemail</td>";
668
                if ($cal->ro_extrainfo1 !== '') {
669
                    $retList .= "<td class='$classname'>$romextrainfo1</td>";
670
                }
671
                if ($cal->ro_extrainfo2 !== '') {
672
                    $retList .= "<td class='$classname'>$romextrainfo2</td>";
673
                }
674
                if ($cal->ro_extrainfo3 !== '') {
675
                    $retList .= "<td class='$classname'>$romextrainfo3</td>";
676
                }
677
                if ($cal->ro_extrainfo4 !== '') {
678
                    $retList .= "<td class='$classname'>$romextrainfo4</td>";
679
                }
680
                if ($cal->ro_extrainfo5 !== '') {
681
                    $retList .= "<td class='$classname'>$romextrainfo5</td>";
682
                }
683
                $retList .= "<td class='$classname'>";
684 View Code Duplication
                if (($event_uid == $uid && $uid > 0) || //current user is event owner
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
685
                    ($cal->isadmin == 1) || //current user is admin
686
                    ($cal->ro_superedit == 1)) //current user can edit/delete registrations of other persons
0 ignored issues
show
The property ro_superedit does not seem to exist. Did you mean superedit?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
687
                {
688
                    if ($status == 1) {
689
                        $retList .= "<input type='image' src='$roimagestatuspending' name='confirm_member' alt='"._APCAL_RO_STATUS_PENDING."' title='"._APCAL_RO_STATUS_PENDING."'  height='22px' />";
690
                    } else if ($status == 2){
691
                        $retList .= "<input type='image' src='$roimagestatuslist' name='confirm_member' alt='"._APCAL_RO_STATUS_LIST."' title='"._APCAL_RO_STATUS_LIST."'  height='22px' />";
692
                    } else {
693
                        $retList .= "<input type='image' src='$roimagestatusok' name='confirm_member' alt='"._APCAL_RO_STATUS_OK."' title='"._APCAL_RO_STATUS_OK."'  height='22px' />";
694
                    }
695
                } else {
696
                    if ($status == 1) {
697
                        $retList .= "<img type='image' src='$roimagestatuspending' name='confirm_member' alt='"._APCAL_RO_STATUS_PENDING."' title='"._APCAL_RO_STATUS_PENDING."'  height='22px' />";
698
                    } else if ($status == 2){
699
                        $retList .= "<img type='image' src='$roimagestatuslist' name='confirm_member' alt='"._APCAL_RO_STATUS_LIST."' title='"._APCAL_RO_STATUS_LIST."'  height='22px' />";
700
                    } else {
701
                        $retList .= "<img type='image' src='$roimagestatusok' name='confirm_member' alt='"._APCAL_RO_STATUS_OK."' title='"._APCAL_RO_STATUS_OK."'  height='22px' />";
702
                    }
703
                }
704
                $retList .= '</td>';
705
                $retList .= "
706
                            <td class='$classname'>
707
                                <input type='image' src='$roimageedit' name='form_edit' alt='" . _APCAL_RO_BTN_EDIT . "' title='" . _APCAL_RO_BTN_EDIT . "'  height='24px' />
708
                                <input type='image' src='$roimagedelete' name='remove_member' alt='" . _APCAL_RO_BTN_REMOVE . "' title='" . _APCAL_RO_BTN_REMOVE . "'  height='24px' />
709
                            </td>
710
                        </tr>";
711
            }
712
            $retList .= '</form></table></td></tr></table>';
713
            $retList .= "<p style='text-align:center;align:center;'>
714
        <form class='apcalForm' method='post' id='RegOnlineForm' action='ro_regonlinehandler.php' name='roformgoback' style='margin:0px;'>
715
            <input type='hidden' name='eventurl' value='$eventurl' />
716
            <div align='center'>
717
            <input type='image' src='$roimagecancel' name='goback' alt='" . _APCAL_RO_BTN_BACK . "' title='" . _APCAL_RO_BTN_BACK . "' height='24px'/>
718
            </div>
719
        </form></p>\n";
720
            $retList .= '<br><br>';
721
        }
722
        
723
724
        echo $retList . $ret;
725
    }
726
}
727
728
if (isset($_POST['add_member_x']) || isset($_POST['add_member_more_x'])) {
729
    if (!empty($_POST['eventid'])) {
730
        $uid        = Request::getInt('uid');
731
        $url        = Request::getString('url', '');
732
        $eventurl   = Request::getString('eventurl', '');
733
        $uname      = Request::getString('uname', '');
734
        $eventid    = Request::getInt('eventid');
735
        $firstname  = Request::getString('firstname', '');
736
        $lastname   = Request::getString('lastname', '');
737
        $email      = Request::getString('email', '');
738
        $extrainfo1 = Request::getString('extrainfo1', '-');
739
        $extrainfo2 = Request::getString('extrainfo2', '-');
740
        $extrainfo3 = Request::getString('extrainfo3', '-');
741
        $extrainfo4 = Request::getString('extrainfo4', '-');
742
        $extrainfo5 = Request::getString('extrainfo5', '-');
743
        $summary    = Request::getString('summary', '');
744
        $date       = Request::getString('date');
745
        $location   = Request::getString('location', '');
746
        $sendconf   = Request::getString('sendconf', '');
747
        $status     = Request::getInt('status');
748
        $eventdate  = Request::getString('eventdate', '');
749
750
        $url_redirect = "&firstname=".$firstname;
751
        $url_redirect .= "&lastname=".$lastname;
752
        $url_redirect .= "&email=".$email;
753
        $url_redirect .= "&extrainfo1=".$extrainfo1;
754
        $url_redirect .= "&extrainfo2=".$extrainfo2;
755
        $url_redirect .= "&extrainfo3=".$extrainfo3;
756
        $url_redirect .= "&extrainfo4=".$extrainfo4;
757
        $url_redirect .= "&extrainfo5=".$extrainfo5;
758
        
759
        if ($firstname=='') {
760
            redirect_header($url.$url_redirect, 3, str_replace('%s', _APCAL_RO_FIRSTNAME, _APCAL_RO_MISSING_ITEM));
761
        }
762
        if ($lastname=='') {
763
          redirect_header($url.$url_redirect, 3, str_replace('%s', _APCAL_RO_LASTNAME, _APCAL_RO_MISSING_ITEM));
764
        }
765
/*
766
        if ($email=='') {
767
          redirect_header($url.$url_redirect, 3, str_replace('%s', _APCAL_RO_EMAIL, _APCAL_RO_MISSING_ITEM));
768
        }*/
769 View Code Duplication
        if ($cal->ro_extrainfo1_obl > 0 && $extrainfo1=='') {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
770
            redirect_header($url . $url_redirect, 3, str_replace('%s', $cal->ro_extrainfo1, _APCAL_RO_MISSING_ITEM));
771
        }
772 View Code Duplication
        if ($cal->ro_extrainfo2_obl > 0 && $extrainfo2=='') {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
773
          redirect_header($url.$url_redirect, 3, str_replace('%s', $cal->ro_extrainfo2, _APCAL_RO_MISSING_ITEM));
774
        }
775 View Code Duplication
        if ($cal->ro_extrainfo3_obl > 0 && $extrainfo3=='') {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
776
          redirect_header($url.$url_redirect, 3, str_replace('%s', $cal->ro_extrainfo3, _APCAL_RO_MISSING_ITEM));
777
        }
778 View Code Duplication
        if ($cal->ro_extrainfo4_obl > 0 && $extrainfo4=='') {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
779
          redirect_header($url.$url_redirect, 3, str_replace('%s', $cal->ro_extrainfo4, _APCAL_RO_MISSING_ITEM));
780
        }
781 View Code Duplication
        if ($cal->ro_extrainfo5_obl > 0 && $extrainfo5=='') {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
782
            redirect_header($url.$url_redirect, 3, str_replace('%s', $cal->ro_extrainfo5, _APCAL_RO_MISSING_ITEM));
783
        }
784
785
        if ($email === '') {
786
            $email = '-';
787
        }
788
        if ($extrainfo1 == '') {
789
            $extrainfo1 = '-';
790
        }
791
        if ($extrainfo2 == '') {
792
            $extrainfo2 = '-';
793
        }
794
        if ($extrainfo3 == '') {
795
            $extrainfo3 = '-';
796
        }
797
        if ($extrainfo4 == '') {
798
            $extrainfo4 = '-';
799
        } 
800
        if ($extrainfo5 == '') {
801
            $extrainfo5 = '-';
802
        }
803
        
804
        //read data from apcal_ro_events
805
        $query    = 'SELECT '
806
                    . $GLOBALS['xoopsDB']->prefix('apcal_ro_events')
807
                    . '.roe_number, roe_datelimit, roe_needconfirm, roe_waitinglist FROM '
808
                    . $GLOBALS['xoopsDB']->prefix('apcal_ro_events')
809
                    . ' WHERE (('
810
                    . $GLOBALS['xoopsDB']->prefix('apcal_ro_events')
811
                    . ".roe_eventid)=$eventid)";
812
        $res      = $GLOBALS['xoopsDB']->query($query);
813
        $num_rows = $GLOBALS['xoopsDB']->getRowsNum($res);
814
        if ($num_rows == 0) {
815
            $number_allowed = 0;
816
            $datelimit      = 0;
817
            $needconfirm    = 0;
818
            $waitinglist    = 0;
819
        } else {
820
            while ($ro_result = $GLOBALS['xoopsDB']->fetchObject($res)) {
821
                $number_allowed = (int)$ro_result->roe_number;
822
                $datelimit      = $ro_result->roe_datelimit;
823
                $needconfirm    = (int)$ro_result->roe_needconfirm;
824
                $waitinglist    = (int)$ro_result->roe_waitinglist;
825
            }
826
        }
827
        //check limit date expired
828
        if ($datelimit > 0) {
829
            $datenow = strtotime(date('d.m.Y H:i:s'));
830
            if ($datelimit < $datenow) {
831
                redirect_header($url, 3, _APCAL_RO_ERROR_TIMEOUT);
832
            }
833
        }
834
        //check limit number registrations
835
        $waitinglist_used  = '';
836
        $waitinglist_used2 = '';
837
        if ($number_allowed > 0) {
838
            //get existing registrations
839
            $query    = 'SELECT '
840
                        . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
841
                        . '.rom_id FROM '
842
                        . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
843
                        . ' WHERE (('
844
                        . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
845
                        . ".rom_eventid)=$eventid)";
846
            $res          = $GLOBALS['xoopsDB']->query($query);
847
            $number_total = $GLOBALS['xoopsDB']->getRowsNum($res);
848
849
            if ($number_total >= $number_allowed) {
850
                if($waitinglist > 0 ) {
851
                    $waitinglist_used  =  _APCAL_RO_PUT_ON_WAITINGLIST;
852
                    $waitinglist_used2 =  _APCAL_RO_PUT_ON_WAITINGLIST2;
853
                } else {
854
                    redirect_header($url, 5, _APCAL_RO_ERROR_FULL);
855
                }
856
            }
857
        }
858
859
        $confirmto = $email;
860
        // check whether email is available and confirmation is selected
861
        if ($confirmto === '') {
862
            $confirmto = '-';
863
        }
864
        if ($sendconf === 'no') {
865
            $confirmto = '-';
866
        }
867
868
        $poster_ip = gethostbyaddr(getenv("REMOTE_ADDR"));
869
        if ($poster_ip=='') $poster_ip='-';
870
871
        if ($status == -1) {
872
            if ($number_total >= $number_allowed) {
873
                $status = 2;
874
            } else if ($needconfirm > 0) {
875
                $status = 1;
876
            } else {
877
                $status = 0;
878
            }
879
        }
880
881
        $query = 'Insert into '
882
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
883
                 . " (rom_submitter, rom_eventid, rom_firstname, rom_lastname, rom_email, rom_extrainfo1, rom_extrainfo2, rom_extrainfo3, rom_extrainfo4, rom_extrainfo5, rom_poster_ip, rom_status, rom_date_created) values ($uid, $eventid, '$firstname', '$lastname', '$email', '$extrainfo1', '$extrainfo2', '$extrainfo3', '$extrainfo4', '$extrainfo5', '$poster_ip', $status, "
884
                 . time()
885
                 . ' )';
886
        
887
        $res   = $GLOBALS['xoopsDB']->query($query);
888
        if (!$res) {
889
            redirect_header($url, 3, _APCAL_RO_ERROR_ADD); 
890
        } else {
891
            //send email of responsible persons
892
            $query    = 'SELECT ' . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify') . '.* ';
893
            $query    .= 'FROM ' . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify');
894
            $query    .= " WHERE (((ron_eventid)=$eventid))";
895
            $res      = $GLOBALS['xoopsDB']->query($query);
896
            $num_rows = $GLOBALS['xoopsDB']->getRowsNum($res);
897 View Code Duplication
            if ($num_rows == 0) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
898
                //nothing to do
899
            } else {
900
                while ($member = $GLOBALS['xoopsDB']->fetchObject($res)) {
901
                    $xoopsMailer = xoops_getMailer();
902
                    $xoopsMailer->useMail();
903
                    //set template path
904
                    if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/')) {
905
                        $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/mail_template/');
906
                    } else {
907
                        $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/mail_template/');
908
                    }
909
                    //set template name
910
                    $xoopsMailer->setTemplate('ro_notify_in.tpl');
911
                    //set sender
912
                    $xoopsMailer->setFromEmail($cal->ro_mail_sender);
913
                    //set name of sender
914
                    $xoopsMailer->setFromName($cal->ro_mail_sendername);
915
                    //set subject
916
                    $subject = _APCAL_RO_MAIL_SUBJ_ADD;
917
                    $xoopsMailer->setSubject($subject);
918
                    //assign vars in template
919
                    $xoopsMailer->assign('UNAME', $uname);
920
                    $xoopsMailer->assign('NAME', $firstname . ' ' . $lastname);
921
                    $xoopsMailer->assign('SUMMARY', $summary);
922
                    $xoopsMailer->assign('DATE', $date);
923
                    $xoopsMailer->assign('LOCATION', $location);
924
                    $xoopsMailer->assign('WAITINGLIST', $waitinglist_used2);
925
                    $xoopsMailer->assign('URL', $eventurl);
926
                    $xoopsMailer->assign('SIGNATURE', $cal->ro_mail_signature);
927
                    //set recipient
928
                    $recipient = $member->ron_email;
929
                    $xoopsMailer->setToEmails($recipient);
930
931
                    //execute sending
932
                    $xoopsMailer->send();
933
                    $xoopsMailer->reset();
934
                }
935
            }
936
937
            //confirmation mail to registered person
938 View Code Duplication
            if ($confirmto == '-') {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
939
                //echo "option not selected or no email-address available";
940
            } else {
941
                $xoopsMailer = xoops_getMailer();
942
                $xoopsMailer->useMail();
943
                //set template path
944
                if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/')) {
945
                    $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/mail_template/');
946
                } else {
947
                    $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/mail_template/');
948
                }
949
                //set template name
950
                $xoopsMailer->setTemplate('ro_confirm_in.tpl');
951
                //set sender
952
                $xoopsMailer->setFromEmail($cal->ro_mail_sender);
953
                //set sender name
954
                $xoopsMailer->setFromName($cal->ro_mail_sendername);
955
                //set subject
956
                $subject = _APCAL_RO_MAIL_SUBJ_ADD;
957
                $xoopsMailer->setSubject($subject);
958
                //assign vars
959
                $xoopsMailer->assign('NAME', $firstname . ' ' . $lastname);
960
                $xoopsMailer->assign('SUMMARY', $summary);
961
                $xoopsMailer->assign('DATE', $date);
962
                $xoopsMailer->assign('LOCATION', $location);
963
                $xoopsMailer->assign('WAITINGLIST', $waitinglist_used);
964
                $xoopsMailer->assign('URL', $eventurl);
965
                $xoopsMailer->assign('SIGNATURE', $cal->ro_mail_signature);
966
                //set recipient
967
                $xoopsMailer->setToEmails($confirmto);
968
969
                //execute sending
970
                $xoopsMailer->send();
971
                $xoopsMailer->reset();
972
            }
973
974
            if (isset($_POST['add_member_more_x'])) {
975
                redirect_header($url, 3, _APCAL_RO_SUCCESS_ADD);
976
            } else {
977
                redirect_header($eventurl, 3, _APCAL_RO_SUCCESS_ADD);
978
            }
979
        }
980
    }
981
}
982
983
if (isset($_POST['confirm_member']) || isset($_POST['confirm_member_x'])){
984
985
    if (!empty($_POST['eventid'])){
986
        $uid       = Request::getInt('uid');
987
        $url       = Request::getString('url', '');
988
        $eventurl  = Request::getString('eventurl', '');
989
        $uname     = Request::getString('uname', '');
990
        $eventid   = Request::getInt('eventid');
991
        $firstname = Request::getString('firstname', '');
992
        $lastname  = Request::getString('lastname', '');
993
        $email     = Request::getString('email', '');
994
        $summary   = Request::getString('summary', '');
995
        $date      = Request::getString('date');
996
        $location  = Request::getString('location', '');
997
        $status    = Request::getInt('status');
998
        $rom_id    = Request::getInt('rom_id');
999
        $eventdate = Request::getString('eventdate', '');
1000
1001
        if ($email=='') $email='-';
1002
1003
        $confirmto = $email;
1004
1005
        if ($status == 0) {
1006
            $status = 1;
1007
            $roinfo = _APCAL_RO_STATUS_SUCCESS_CHANGE_PENDING;
1008
        } else {
1009
            $status = 0;
1010
            $roinfo = _APCAL_RO_STATUS_SUCCESS_CHANGE_OK;
1011
        }
1012
1013
        $query = "UPDATE `".$GLOBALS['xoopsDB']->prefix("apcal_ro_members")."` SET `rom_status` = '$status' WHERE `rom_id` = $rom_id;";
1014
        $res = $GLOBALS['xoopsDB']->query($query);
1015
        if(!$res) {
1016
            redirect_header($url, 3, _APCAL_RO_ERROR_STATUS_CONF);
1017
        } else {
1018
            //confirmation mail to registrated person
1019
            if ($confirmto=='-') {
1020
                //echo "option not selected or no email-address available";
1021
            } else {
1022
                $xoopsMailer =& xoops_getMailer();
1023
                $xoopsMailer->useMail();
1024
                //set template path
1025
                if( file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/'. $xoopsConfig['language'] .'/')) {
1026
                    $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/'. $xoopsConfig['language'] .'/mail_template/');
1027
                } else {
1028
                    $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/mail_template/');
1029
                }
1030
                //set template name 
1031
                $xoopsMailer->setTemplate('ro_confirm_status.tpl');
1032
                //set sender 
1033
                $xoopsMailer->setFromEmail($cal->ro_mail_sender);
1034
                //set sender name
1035
                $xoopsMailer->setFromName($cal->ro_mail_sendername);
1036
                //set subject
1037
                $subject = _APCAL_RO_MAIL_SUBJ_STATUS;
1038
                $xoopsMailer->setSubject($subject);
1039
                //assign vars
1040
                $xoopsMailer->assign("NAME", $firstname." ".$lastname);
1041
                $xoopsMailer->assign("SUMMARY", $summary);
1042
                $xoopsMailer->assign("DATE", $date);
1043
                $xoopsMailer->assign("LOCATION", $location);
1044
                $xoopsMailer->assign("URL", $eventurl);
1045
                $xoopsMailer->assign("SIGNATURE", $cal->ro_mail_signature);
1046
                $xoopsMailer->assign("INFOTEXT", $roinfo.".");
1047
                //set recipient
1048
                $xoopsMailer->setToEmails($confirmto);
1049
1050
                //execute sending
1051
                $xoopsMailer->send();
1052
                $xoopsMailer->reset();
1053
            }
1054
            redirect_header($url, 3, $roinfo);
1055
        }
1056
    }
1057
}
1058
1059
if (isset($_POST['remove_member']) || isset($_POST['remove_member_x'])) {
1060
    if (!empty($_POST['rom_id'])) {
1061
        $rom_id      = Request::getInt('rom_id');
1062
        $url         = Request::getString('url', '');
1063
        $eventurl    = Request::getString('eventurl', '');
1064
        $uid         = Request::getInt('uid');
1065
        $uname       = Request::getString('uname', '');
1066
        $eventid     = Request::getInt('eventid');
1067
        $title       = Request::getString('title', '');
1068
        $firstname   = Request::getString('firstname', '');
1069
        $lastname    = Request::getString('lastname', '');
1070
        $confirmto   = Request::getString('email', '');
1071
        $summary     = Request::getString('summary', '');
1072
        $date        = Request::getInt('date');
1073
        $location    = Request::getString('location', '');
1074
        $num_members = Request::getInt('num_members');
1075
        $eventdate   = Request::getString('eventdate', '');
1076
1077
        // check whether confirmation mail should be send
1078
        if ($confirmto === '') {
1079
            $confirmto = '-';
1080
        }
1081
1082
        $query = 'DELETE '
1083
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
1084
                 . '.* FROM '
1085
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
1086
                 . ' WHERE (('
1087
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
1088
                 . ".rom_id)=$rom_id)";
1089
1090
        $res = $GLOBALS['xoopsDB']->query($query);
1091
        if (!$res) {
1092
            redirect_header($url, 3, _APCAL_RO_ERROR_REMOVE);
1093
        } else {
1094
            //data was correctly deleted from DB;
1095
            //send mail to responsible person
1096
            $query = 'SELECT ' . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify') . '.* ';
1097
            $query .= 'FROM ' . $GLOBALS['xoopsDB']->prefix('apcal_ro_notify');
1098
            $query .= " WHERE (((ron_eventid)=$eventid))";
1099
1100
            $res      = $GLOBALS['xoopsDB']->query($query);
1101
            $num_rows = $GLOBALS['xoopsDB']->getRowsNum($res);
1102 View Code Duplication
            if ($num_rows == 0) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1103
                //nothing to do
1104
            } else {
1105
                while ($member = $GLOBALS['xoopsDB']->fetchObject($res)) {
1106
                    $xoopsMailer = xoops_getMailer();
1107
                    $xoopsMailer->useMail();
1108
                    //set template path
1109
                    if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/')) {
1110
                        $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/mail_template/');
1111
                    } else {
1112
                        $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/mail_template/');
1113
                    }
1114
                    //set template name
1115
                    $xoopsMailer->setTemplate('ro_notify_out.tpl');
1116
                    //set sender
1117
                    $xoopsMailer->setFromEmail($cal->ro_mail_sender);
1118
                    //set sender name
1119
                    $xoopsMailer->setFromName($cal->ro_mail_sendername);
1120
                    //set subject
1121
                    $subject = _APCAL_RO_MAIL_SUBJ_REMOVE;
1122
                    $xoopsMailer->setSubject($subject);
1123
                    //assign vars
1124
                    $xoopsMailer->assign('UNAME', $uname);
1125
                    $xoopsMailer->assign('NAME', $firstname . ' ' . $lastname);
1126
                    $xoopsMailer->assign('SUMMARY', $summary);
1127
                    $xoopsMailer->assign('DATE', $date);
1128
                    $xoopsMailer->assign('LOCATION', $location);
1129
                    $xoopsMailer->assign('URL', $eventurl);
1130
                    $xoopsMailer->assign('SIGNATURE', $cal->ro_mail_signature);
1131
                    //set recipient
1132
                    $recipient = $member->ron_email;
1133
                    $xoopsMailer->setToEmails($recipient);
1134
1135
                    //execute sending
1136
                    $xoopsMailer->send();
1137
                    $xoopsMailer->reset();
1138
                }
1139
            }
1140
1141
            //confirmation mail to registered person
1142
            if ($confirmto == '-') {
1143
                //echo "option not selected or no email-address available";
1144
            } else {
1145
                $xoopsMailer = xoops_getMailer();
1146
                $xoopsMailer->useMail();
1147
                //set template path
1148
                if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/')) {
1149
                    $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/mail_template/');
1150
                } else {
1151
                    $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/mail_template/');
1152
                }
1153
                //set template name
1154
                $xoopsMailer->setTemplate('ro_confirm_out.tpl');
1155
                //set sender
1156
                $sender = $cal->ro_mail_sender;
1157
                $xoopsMailer->setFromEmail($sender);
1158
                //set sender name
1159
                $xoopsMailer->setFromName($cal->ro_mail_sendername);
1160
                //set subject
1161
                $subject = _APCAL_RO_MAIL_SUBJ_REMOVE;
1162
                $xoopsMailer->setSubject($subject);
1163
                //assign vars
1164
                $xoopsMailer->assign('NAME', $firstname . ' ' . $lastname);
1165
                $xoopsMailer->assign('SUMMARY', $summary);
1166
                $xoopsMailer->assign('DATE', $date);
1167
                $xoopsMailer->assign('LOCATION', $location);
1168
                $xoopsMailer->assign('URL', $eventurl);
1169
                $xoopsMailer->assign('SIGNATURE', $cal->ro_mail_signature);
1170
                //set recipient
1171
                $xoopsMailer->setToEmails($confirmto);
1172
                //execute sending
1173
                $xoopsMailer->send();
1174
                $xoopsMailer->reset();
1175
            }
1176
            if ($num_members == 1) {
1177
                redirect_header($eventurl, 3, _APCAL_RO_SUCCESS_REMOVE);
1178
            } else {
1179
                redirect_header($url, 3, _APCAL_RO_SUCCESS_REMOVE);
1180
            }
1181
        }
1182
    }
1183
}
1184
1185
if (isset($_REQUEST['list'])) {
1186
    if (!empty($_REQUEST['eventid'])) {
1187
        $uid       = Request::getInt('uid');
1188
        $eventid   = Request::getInt('eventid');
1189
        $summary   = Request::getString('summary', '');
1190
        $date      = Request::getInt('date');
1191
        $location  = Request::getString('location', '');
1192
        $eventurl  = Request::getString('eventurl', '');
1193
        $event_uid = Request::getInt('event_uid');
1194
        $classname = '';
1195
1196 View Code Duplication
        if (!empty($_SERVER['HTTPS'])) {
1197
            $url = 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
1198
        } else {
1199
            $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
1200
        }
1201
1202
        if (!isset($xoopsUser) || !is_object($xoopsUser)) {
1203
            $current_uid = 0;
1204
            $current_uname = "";
1205
        } else {
1206
            $current_uid   = $xoopsUser->getVar('uid');
1207
            $current_uname = $xoopsUser->getVar('uname');
1208
        }
1209
1210
        $url .= '?list=1';
1211
        $url .= "&uid=$uid";
1212
        $url .= "&eventid=$eventid";
1213
        $url .= "&summary=$summary";
1214
        $url .= "&date=$date";
1215
        $url .= "&location=$location";
1216
        $url .= "&eventurl=$eventurl";
1217
1218
        $title = $summary . ' (' . $date . ' ' . $location . ')';
1219
        $query = 'SELECT '
1220
                 . $GLOBALS['xoopsDB']->prefix('users')
1221
                 . '.uname, '
1222
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
1223
                 . '.* FROM '
1224
                 . $GLOBALS['xoopsDB']->prefix('users')
1225
                 . ' INNER JOIN '
1226
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
1227
                 . ' ON '
1228
                 . $GLOBALS['xoopsDB']->prefix('users')
1229
                 . '.uid = '
1230
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
1231
                 . '.rom_submitter WHERE ((('
1232
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
1233
                 . ".rom_eventid)=$eventid)) ORDER BY "
1234
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
1235
                 . '.rom_date_created';
1236
1237
        $res      = $GLOBALS['xoopsDB']->query($query);
1238
        $num_rows = $GLOBALS['xoopsDB']->getRowsNum($res);
1239
1240
        if ($num_rows == 0) {
1241
            $ret = _APCAL_RO_NOMEMBERS;
1242
        } else {
1243
            $ret .= "
1244
           <table class='ro_table'>
1245
             <tr>
1246
               <th width='100px' class='listeheader'>" . _APCAL_RO_UNAME . "</th>
1247
               <th width='100px' class='listeheader'>" . _APCAL_RO_FIRSTNAME . "</th>
1248
               <th width='100px' class='listeheader'>" . _APCAL_RO_LASTNAME . "</th>
1249
               <th class='listeheader'>" . _APCAL_RO_EMAIL . '</th>';
1250
            if ($cal->ro_extrainfo1 !== '') {
1251
                $ret .= "<th class='listeheader'>" . $cal->ro_extrainfo1 . '</th>';
1252
            }
1253
            if ($cal->ro_extrainfo2 !== '') {
1254
                $ret .= "<th class='listeheader'>" . $cal->ro_extrainfo2 . '</th>';
1255
            }
1256
            if ($cal->ro_extrainfo3 !== '') {
1257
                $ret .= "<th class='listeheader'>" . $cal->ro_extrainfo3 . '</th>';
1258
            }
1259
            if ($cal->ro_extrainfo4 !== '') {
1260
                $ret .= "<th class='listeheader'>" . $cal->ro_extrainfo4 . '</th>';
1261
            }
1262
            if ($cal->ro_extrainfo5 !== '') {
1263
                $ret .= "<th class='listeheader'>" . $cal->ro_extrainfo5 . '</th>';
1264
            }
1265
            $ret .= "<th class='listeheader'>"._APCAL_RO_STATUS."</th>";
1266
            $ret .= "
1267
               <th class='listeheader'>" . _APCAL_RO_ACTION . '</th>
1268
             </tr>';
1269
            while ($member = $GLOBALS['xoopsDB']->fetchObject($res)) {
1270
                $rom_id     = $member->rom_id;
1271
                $uname      = $member->uname;
1272
                $firstname  = $member->rom_firstname;
1273
                $lastname   = $member->rom_lastname;
1274
                $email      = $member->rom_email;
1275
                $extrainfo1 = $member->rom_extrainfo1;
1276
                $extrainfo2 = $member->rom_extrainfo2;
1277
                $extrainfo3 = $member->rom_extrainfo3;
1278
                $extrainfo4 = $member->rom_extrainfo4;
1279
                $extrainfo5 = $member->rom_extrainfo5;
1280
                $status     = (int)$member->rom_status;
1281 View Code Duplication
                if ($line == 0) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1282
                    $classname = 'odd';
1283
                    $line      = 1;
1284
                } else {
1285
                    $classname = 'even';
1286
                    $line      = 0;
1287
                }
1288
                $ret .= "<tr>
1289
                    <td class='$classname'>$uname</td>
1290
                    <td class='$classname'>$firstname</td>
1291
                    <td class='$classname'>$lastname</td>
1292
                    <td class='$classname'>$email</td>";
1293
                if ($cal->ro_extrainfo1 !== '') {
1294
                    $ret .= "<td class='$classname'>$extrainfo1</td>";
1295
                }
1296
                if ($cal->ro_extrainfo2 !== '') {
1297
                    $ret .= "<td class='$classname'>$extrainfo2</td>";
1298
                }
1299
                if ($cal->ro_extrainfo3 !== '') {
1300
                    $ret .= "<td class='$classname'>$extrainfo3</td>";
1301
                }
1302
                if ($cal->ro_extrainfo4 !== '') {
1303
                    $ret .= "<td class='$classname'>$extrainfo4</td>";
1304
                }
1305
                if ($cal->ro_extrainfo5 !== '') {
1306
                    $ret .= "<td class='$classname'>$extrainfo5</td>";
1307
                }
1308
                $ret .= "<td class='$classname' style='text-align:center'>";
1309
                $unique_id = uniqid(mt_rand());
1310
                $ret .= "
1311
                    <form method='post' action='ro_regonlinehandler.php' name='roformlistconfirm_".$unique_id."' style='margin:0px;'>
1312
                      <input type='hidden' name='eventid' value='$eventid' />
1313
                      <input type='hidden' name='url' value='$url' />
1314
                      <input type='hidden' name='eventurl' value='$eventurl' />
1315
                      <input type='hidden' name='rom_id' value='$rom_id' />
1316
                      <input type='hidden' name='summary' value='$summary' />
1317
                      <input type='hidden' name='date' value='$date' />
1318
                      <input type='hidden' name='location' value='$location' />
1319
                      <input type='hidden' name='uid' value='$uid' />  
1320
                      <input type='hidden' name='firstname' value='$firstname' />
1321
                      <input type='hidden' name='lastname' value='$lastname' />
1322
                      <input type='hidden' name='email' value='$email' />
1323
                      <input type='hidden' name='uname' value='$uname' />
1324
                      <input type='hidden' name='current_uname' value='$current_uname' />              
1325
                      <input type='hidden' name='status' value='$status' />
1326
                      <div style='display:inline;'>";
1327 View Code Duplication
                        if (($event_uid == $current_uid && $current_uid > 0) || //current user is event owner
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1328
                            ($cal->isadmin == 1) || //current user is admin
1329
                            ($cal->ro_superedit == 1)) //current user can edit/delete registrations of other persons
0 ignored issues
show
The property ro_superedit does not seem to exist. Did you mean superedit?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1330
                        {
1331
                            if ($status == 1) {
1332
                                $ret .= "<input type='image' src='$roimagestatuspending' name='confirm_member' alt='"._APCAL_RO_STATUS_PENDING."' title='"._APCAL_RO_STATUS_PENDING."'  height='22px' />";
1333
                            } else if ($status == 2){
1334
                                $ret .= "<input type='image' src='$roimagestatuslist' name='confirm_member' alt='"._APCAL_RO_STATUS_LIST."' title='"._APCAL_RO_STATUS_LIST."'  height='22px' />";
1335
                            } else {
1336
                                $ret .= "<input type='image' src='$roimagestatusok' name='confirm_member' alt='"._APCAL_RO_STATUS_OK."' title='"._APCAL_RO_STATUS_OK."'  height='22px' />";
1337
                            }
1338
                        } else {
1339
                            if ($status == 1) {
1340
                                $ret .= "<img src='$roimagestatuspending' name='confirm_member' alt='"._APCAL_RO_STATUS_PENDING."' title='"._APCAL_RO_STATUS_PENDING."'  height='22px' />";
1341
                            } else if ($status == 2){
1342
                                $ret .= "<img src='$roimagestatuslist' name='confirm_member' alt='"._APCAL_RO_STATUS_LIST."' title='"._APCAL_RO_STATUS_LIST."'  height='22px' />";
1343
                            } else {
1344
                                $ret .= "<img src='$roimagestatusok' name='confirm_member' alt='"._APCAL_RO_STATUS_OK."' title='"._APCAL_RO_STATUS_OK."'  height='22px' />";
1345
                            }
1346
                        }
1347
1348
                        $ret .= "
1349
                      </div>
1350
                    </form>";
1351
                $ret .= "</td>";
1352
                $ret .= "<td class='$classname'>";
1353
                
1354
                $current_ip = gethostbyaddr(getenv("REMOTE_ADDR"));
1355
                if ($current_ip=='') $current_ip='-';
1356
                if (!isset($xoopsUser) || !is_object($xoopsUser)) {
1357
                    $current_uid = 0;
1358
                } else {
1359
                    $current_uid = $xoopsUser->getVar('uid');
1360
                }
1361
                if (($event_uid == $current_uid && $current_uid > 0) || //current user is event owner
1362
                    ($submitter == $current_uid && $current_uid > 0) || //current user made registration
1363
                    ($cal->isadmin == 1) || //current user is admin
1364
                    ($cal->superedit == 1) || //current user can edit/delete registrations of other persons
1365
                    ($submitter == $current_uid && $current_uid == 0 && $poster_ip == $current_ip)) //current user is guest, but ip is the same as guest who made registration 
1366
                    { //end added
1367
                        $unique_id = uniqid(mt_rand());
1368
                        $ret .= "
1369
                        <form class='apcalForm' method='post' id='RegOnlineForm' action='ro_regonlinehandler.php' name='roformlist_" . $unique_id . "' style='margin:0px;'>
1370
                            <input type='hidden' name='eventid' value='$eventid' />
1371
                            <input type='hidden' name='url' value='$url' />
1372
                            <input type='hidden' name='eventurl' value='$eventurl' />
1373
                            <input type='hidden' name='rom_id' value='$rom_id' />
1374
                            <input type='hidden' name='firstname' value='$firstname' />
1375
                            <input type='hidden' name='lastname' value='$lastname' />
1376
                            <input type='hidden' name='email' value='$email' />
1377
                            <input type='hidden' name='summary' value='$summary' />
1378
                            <input type='hidden' name='date' value='$date' />
1379
                            <input type='hidden' name='location' value='$location' />
1380
                            <input type='hidden' name='uname' value='$uname' />  
1381
                            <input type='hidden' name='uid' value='$uid' />              
1382
                            <input type='hidden' name='extrainfo1' value='$extrainfo1' />
1383
                            <input type='hidden' name='extrainfo2' value='$extrainfo2' />
1384
                            <input type='hidden' name='extrainfo3' value='$extrainfo3' />
1385
                            <input type='hidden' name='extrainfo4' value='$extrainfo4' />
1386
                            <input type='hidden' name='extrainfo5' value='$extrainfo5' />
1387
                            <input type='hidden' name='status' value='$status' />
1388
                            <input type='hidden' name='current_uname' value='$current_uname' />
1389
                            <input type='hidden' name='num_members' value='$num_rows' />
1390
                            <div style='display:inline;'>
1391
                                <input type='image' src='$roimageedit' name='form_edit' alt='" . _APCAL_RO_BTN_EDIT . "' title='" . _APCAL_RO_BTN_EDIT . "'  height='22px' />
1392
                                <input type='image' src='$roimagedelete' name='remove_member' alt='" . _APCAL_RO_BTN_REMOVE . "' title='" . _APCAL_RO_BTN_REMOVE . "'  height='22px' />
1393
                            </div>
1394
                        </form>";
1395
                    }
1396
                    $ret .= '
1397
                    </td>
1398
                </tr>';
1399
            }
1400
            $ret .= "</table>\n<br>";
1401
1402
            $ret .= "<div align='center'><a href='$eventurl' target='_self'><img src='$roimagecancel' name='goback' alt='" . _APCAL_RO_BTN_BACK . "' title='" . _APCAL_RO_BTN_BACK . "' style='height:24px;margin:0 10px;'/></a>";
1403
            if ($cal->enableprint) {
1404
                $ret .= "<a href='print.php?smode=ro_list&eventid=$eventid&summary=$summary&date=$date&location=$location' target='_blank'><img src='$roimageprint' name='print' alt='" . _APCAL_RO_PRINT_LIST . "' title='" . _APCAL_RO_PRINT_LIST . "' style='height:24px;margin:0 10px;'/></a>";
1405
                $ret .= "<a href='print.php?smode=ro_list&op=exportxls&eventid=$eventid&summary=$summary&date=$date&location=$location' target='_blank'><img src='$roimagedownload' name='download' alt='" . _DOWNLOAD . "' title='" . _DOWNLOAD . "' style='height:24px;margin:0 10px;'/></a>";
1406
            }
1407
            $ret .= "</div>\n";
1408
1409
            //show form for sending mail to all registered persons; only allowed for event owner or admins
1410
            if (($event_uid == $current_uid && $current_uid > 0) || //current user is event owner
1411
                ($cal->isadmin == 1) || //current user is admin
1412
                ($cal->superedit == 1) //current user can edit/delete registrations of other persons
1413
               )
1414
            {
1415
                $query = 'SELECT ' . $GLOBALS['xoopsDB']->prefix('users') . '.email ';
1416
                $query .= 'FROM ' . $GLOBALS['xoopsDB']->prefix('users');
1417
                $query .= ' WHERE (((' . $GLOBALS['xoopsDB']->prefix('users') . ".uid)=$uid))";
1418
1419
                $res = $GLOBALS['xoopsDB']->query($query);
1420
                $num_rows = $GLOBALS['xoopsDB']->getRowsNum($res);
1421
1422 View Code Duplication
                if ($num_rows == 0) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1423
                    $sender = '';
1424
                } else {
1425
                    while ($member = $GLOBALS['xoopsDB']->fetchObject($res)) {
1426
                        $sender = $member->email;
1427
                    }
1428
                }
1429
                $mailtext = _APCAL_RO_EVENT . ": $summary\n" . _APCAL_RO_DATE . ": $date\n" . _APCAL_RO_LOCATION . ": $location\n" . _APCAL_RO_LINK . ": $eventurl\n\n";
1430
                $ret .= "
1431
                    <br><br><br>
1432
                    <p class='listeheader'>" . _APCAL_RO_TITLE4 . "</p>
1433
                    <form class='apcalForm' method='post' id='RegOnlineForm' action='ro_regonlinehandler.php' name='roformsendmail' accept-charset='UTF-8'>
1434
                    <table border='0' width='100%'>
1435
                        <tr>
1436
                            <td class='even' width='100px'>" . _APCAL_RO_MAIL_SENDER . ":</td>
1437
                            <td class='odd'><input type='text' name='sender' size='70' value='$sender'></td>
1438
                        </tr>
1439
                        <tr>
1440
                            <td class='even' width='100px'>" . _APCAL_RO_MAIL_SUBJ . ":</td>
1441
                            <td class='odd'><input type='text' name='subject' size='70' value='" . _APCAL_RO_MAIL_SUBJ_TEXT . "'></td>
1442
                        </tr>
1443
                        <tr>
1444
                            <td class='even' width='200px'>" . _APCAL_RO_MAIL_BODY1 . ":<br><br><font size='1'>" . _APCAL_RO_MAIL_BODY2 . "</font></td>
1445
                            <td class='odd' height='200px' valign='top'>
1446
                            <textarea rows='25' name='mailtext' cols='95'>$mailtext</textarea></td>
1447
                      </tr>
1448
                    </table>
1449
                        <input type='hidden' name='url' value='$url' />
1450
                        <input type='hidden' name='eventurl' value='$eventurl' />
1451
                        <input type='hidden' name='eventid' value='$eventid' />
1452
                        <p style='text-align:center;align:center'><input type='image' src='$roimagesend' name='ro_notify_all' alt='" . _APCAL_RO_BTN_SEND . "' title='" . _APCAL_RO_BTN_SEND . "' height='24px'/></p>
1453
                    </form>
1454
                    \n";
1455
            }
1456
        }
1457
        echo $ret;
1458
    }
1459
}
1460
1461
if (isset($_POST['sendmail_member']) || isset($_POST['sendmail_member_x'])) {
1462
    if (!empty($_REQUEST['eventid'])){
1463
1464
        $uid       = Request::getInt('uid');
1465
        $event_uid = Request::getInt('event_uid');
1466
        $eventid   = Request::getInt('eventid');
1467
        $summary   = Request::getString('summary', '');
1468
        $date      = Request::getInt('date');
1469
        $location  = Request::getString('location', '');
1470
        $eventurl  = Request::getString('eventurl', '');
1471
        $email     = Request::getString('email', '');
1472
        $firstname = Request::getString('firstname', '');
1473
        $lastname  = Request::getString('lastname', '');
1474
        $classname ='';
1475
1476 View Code Duplication
        if( ! empty( $_SERVER['HTTPS'] ) ) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1477
            $url = "https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ;
1478
        } else {
1479
            $url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ;
1480
        }
1481
1482
        $url .= "?list=1";
1483
        $url .= "&uid=$uid";
1484
        $url .= "&eventid=$eventid";
1485
        $url .= "&summary=$summary";
1486
        $url .= "&date=$date";
1487
        $url .= "&location=$location";
1488
        $url .= "&eventurl=$eventurl";
1489
1490
        //show form for sending mail to registered persons
1491
        $unique_id = uniqid(mt_rand());
1492
1493
        $query = "SELECT ".$GLOBALS['xoopsDB']->prefix("users").".email ";
1494
        $query .= "FROM ".$GLOBALS['xoopsDB']->prefix("users");
1495
        $query .= " WHERE (((".$GLOBALS['xoopsDB']->prefix("users").".uid)=$uid))";
1496
1497
        $res = $GLOBALS['xoopsDB']->query($query);
1498
        $num_rows = $GLOBALS['xoopsDB']->getRowsNum($res);
1499
1500 View Code Duplication
        if( $num_rows == 0 ) $sender= "" ;
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1501
        else while( $member = $GLOBALS['xoopsDB']->fetchObject($res) ) {
1502
            $sender=$member->email;
1503
        }
1504
        $mailtext = _APCAL_RO_EVENT.": $summary\n"._APCAL_RO_DATE.": $date\n"._APCAL_RO_LOCATION.": $location\n"._APCAL_RO_LINK.": $eventurl\n\n";
1505
        $mailtext .= "Hallo $firstname $lastname\n\n";
1506
        $ret .= "
1507
    <br /><br /><br />
1508
    <table border='1' cellpadding='0' cellspacing='0' width='100%'>
1509
      <tr>
1510
        <td class='listeheader'>"._APCAL_RO_TITLE4."</td>
1511
      </tr>
1512
    </table>
1513
    <form method='post' action='ro_regonlinehandler.php' name='roformsendmail".$unique_id."' accept-charset='UTF-8'>
1514
    <table border='1' width='100%'>
1515
      <tr>
1516
        <td class='even' width='100px'>"._APCAL_RO_MAIL_SENDER.":</td>
1517
        <td class='odd'><input type='text' name='sender' size='70' value='$sender'></td>
1518
      </tr>
1519
      <tr>
1520
        <td class='even' width='100px'>"._APCAL_RO_MAIL_RECEPIENT.":</td>
1521
        <td class='odd'><input type='text' name='email' size='70' value='$email'></td>
1522
      </tr>
1523
      <tr>
1524
        <td class='even' width='100px'>"._APCAL_RO_MAIL_SUBJ.":</td>
1525
        <td class='odd'><input type='text' name='subject' size='70' value='"._APCAL_RO_MAIL_SUBJ_TEXT."'></td>
1526
      </tr>
1527
      <tr>
1528
        <td class='even' width='200px'>"._APCAL_RO_MAIL_BODY1.":<br/><br/><font size='1'>"._APCAL_RO_MAIL_BODY2."</font></td>
1529
        <td class='odd' height='200px' valign='top'>
1530
        <textarea rows='25' name='mailtext' cols='95'>$mailtext</textarea></td>
1531
      </tr>
1532
    </table>
1533
        <input type='hidden' name='url' value='$url' />
1534
        <input type='hidden' name='eventurl' value='$eventurl' />
1535
        <input type='hidden' name='eventid' value='$eventid' />
1536
        <p style='text-align:center;align:center'>
1537
        <input type='image' src='$roimagesend' name='ro_notify_one' alt='"._APCAL_RO_BTN_SEND."' title='"._APCAL_RO_BTN_SEND."' height='32px'/>
1538
        <input type='image' src='$roimagecancel' name='goback' alt='"._APCAL_RO_BTN_BACK."' title='"._APCAL_RO_BTN_BACK."' height='32px'/>
1539
        </p>
1540
    </form>
1541
    \n";
1542
1543
1544
        echo $ret;
1545
    }
1546
}
1547
1548
if (isset($_POST['form_edit']) || isset($_POST['form_edit_x'])) {
1549
    if (!empty($_POST['rom_id'])) {
1550
        $rom_id     = Request::getInt('rom_id');
1551
        $uid        = Request::getInt('uid');
1552
        $url        = Request::getString('url', '');
1553
        $eventurl   = Request::getString('eventurl', '');
1554
        $uname      = Request::getString('uname', '');
1555
        $eventid    = Request::getInt('eventid');
1556
        $firstname  = Request::getString('firstname', '');
1557
        $lastname   = Request::getString('lastname', '');
1558
        $email      = Request::getString('email', '');
1559
        $extrainfo1 = Request::getString('extrainfo1', '');
1560
        $extrainfo2 = Request::getString('extrainfo2', '');
1561
        $extrainfo3 = Request::getString('extrainfo3', '');
1562
        $extrainfo4 = Request::getString('extrainfo4', '');
1563
        $extrainfo5 = Request::getString('extrainfo5', '');
1564
        $summary    = Request::getString('summary', '');
1565
        $date       = Request::getInt('date');
1566
        $location   = Request::getString('location', '');
1567
        $sendconf   = Request::getInt('sendconf');
1568
        $status     = Request::getInt('status');
1569
1570
        $ret  = '';
1571
        $retList = '';
1572
1573
        $ret = "
1574
        <table border='0' width='100%'>
1575
            <tr><td width='100%' class='itemHead'><span class='itemTitle'>" . _APCAL_RO_TITLE5 . "</span></td></tr>
1576
            <tr><td width='100%'>
1577
            <form class='apcalForm' method='post' id='RegOnlineForm' action='ro_regonlinehandler.php' name='roformeditmember' style='margin:0px;'>
1578
                <input type='hidden' name='url' value='$url' />
1579
                <input type='hidden' name='rom_id' value='$rom_id' />
1580
1581
                <table>
1582
                    <tr>
1583
                        <td class='even' width='120px'>" . _APCAL_RO_FIRSTNAME . "*:</td>
1584
                        <td class='odd'><input type='text' name='firstname' value='$firstname' size='100' /></td>
1585
                    </tr>
1586
                    <tr>
1587
                        <td class='even' width='120px'>" . _APCAL_RO_LASTNAME . "*:</td>
1588
                        <td class='odd'><input type='text' name='lastname' value='$lastname' size='100' /></td>
1589
                    </tr>
1590
                    <tr>
1591
                        <td class='even' width='120px'>" . _APCAL_RO_EMAIL . ":</td>
1592
                        <td class='odd'><input type='text' name='email' value='$email' size='100' /></td>
1593
                    </tr>";
1594
        if ($cal->ro_extrainfo1 !== '') {
1595
            $ret .= "
1596
                    <tr>
1597
                        <td class='even' width='120px'>" . $cal->ro_extrainfo1 . ":</td>
1598
                        <td class='odd'><input type='text' name='extrainfo1' value='$extrainfo1' size='100' /></td>
1599
                    </tr>";
1600
        }
1601
        if ($cal->ro_extrainfo2 !== '') {
1602
            $ret .= "
1603
                    <tr>
1604
                        <td class='even' width='120px'>" . $cal->ro_extrainfo2 . ":</td>
1605
                        <td class='odd'><input type='text' name='extrainfo2' value='$extrainfo2' size='100' /></td>
1606
                    </tr>";
1607
        }
1608
        if ($cal->ro_extrainfo3 !== '') {
1609
            $ret .= "
1610
                    <tr>
1611
                        <td class='even' width='120px'>" . $cal->ro_extrainfo3 . ":</td>
1612
                        <td class='odd'><input type='text' name='extrainfo3' value='$extrainfo3' size='100' /></td>
1613
                    </tr>";
1614
        }
1615
        if ($cal->ro_extrainfo4 !== '') {
1616
            $ret .= "
1617
                    <tr>
1618
                        <td class='even' width='120px'>" . $cal->ro_extrainfo4 . ":</td>
1619
                        <td class='odd'><input type='text' name='extrainfo4' value='$extrainfo4' size='100' /></td>
1620
                    </tr>";
1621
        }
1622
        if ($cal->ro_extrainfo5 !== '') {
1623
            $ret .= "
1624
                    <tr>
1625
                        <td class='even' width='120px'>" . $cal->ro_extrainfo5 . ":</td>
1626
                        <td class='odd'><input type='text' name='extrainfo5' value='$extrainfo5' size='100' /></td>
1627
                    </tr>";
1628
        }
1629
        if (($event_uid == $uid && $uid > 0) || //current user is event owner
1630
            ($cal->isadmin == 1) || //current user is admin
1631
            ($cal->ro_superedit == 1)) //current user can edit/delete registrations of other persons
0 ignored issues
show
The property ro_superedit does not seem to exist. Did you mean superedit?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
1632
        {
1633
            $ret .= "
1634
          <tr>
1635
            <td class='even' width='120px'>"._APCAL_RO_STATUS.":</td>
1636
            <td class='odd'>
1637
              <input id='status0' type='radio' value='0'";
1638
            if ($status == 0 ) $ret .=" checked='checked'";
1639
            $ret .=" title="._APCAL_RO_STATUS_OK." name='status' />
1640
              <label for='status0' name='xolb_status0'>"._APCAL_RO_STATUS_OK."</label>&nbsp;&nbsp;
1641
              <input id='status1' type='radio' value='1'";
1642
            if ($status == 1) $ret .=" checked='checked'";
1643
            $ret .=" title="._APCAL_RO_STATUS_PENDING." name='status' />
1644
              <label for='status1' name='xolb_status1'>"._APCAL_RO_STATUS_PENDING."</label>&nbsp;&nbsp;
1645
              <input id='status2' type='radio' value='2'";
1646
            if ($status == 2) $ret .=" checked='checked'";
1647
            $ret .=" title="._APCAL_RO_STATUS_LIST." name='status' />
1648
              <label for='status2' name='xolb_status2'>"._APCAL_RO_STATUS_LIST."</label>
1649
            </td>
1650
          </tr>";
1651
        } else {
1652
            $ret .= "<input type='hidden' name='status' value='$status' size='100' />";
1653
        }
1654
        $ret .= '
1655
                </table>
1656
                * ' . _APCAL_RO_OBLIGATORY . "
1657
                <br><br>
1658
                <div align='center'>
1659
                    <input type='image' src='$roimagesave' name='edit_member' alt='" . _APCAL_RO_BTN_CONF_EDIT . "' title='" . _APCAL_RO_BTN_CONF_EDIT . "' height='24px'/>
1660
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
1661
                    <input type='image' src='$roimagecancel' name='cancel' alt='" . _APCAL_RO_BTN_CANCEL . "' title='" . _APCAL_RO_BTN_CANCEL . "' height='24px'/>
1662
                </div>
1663
            </form>
1664
            </td></tr>
1665
        </table>\n<br><br>";
1666
1667
        echo $ret;
1668
    }
1669
}
1670
1671
if (isset($_POST['edit_member']) || isset($_POST['edit_member_x'])) {
1672
    if (!empty($_POST['rom_id'])) {
1673
        $rom_id     = Request::getInt('rom_id');
1674
        $uid        = Request::getInt('uid');
1675
        $url        = Request::getString('url', '');
1676
        $eventurl   = Request::getString('eventurl', '');
1677
        $uname      = Request::getString('uname', '');
1678
        $eventid    = Request::getInt('eventid');
1679
        $firstname  = Request::getString('firstname', '');
1680
        $lastname   = Request::getString('lastname', '');
1681
        $email      = Request::getString('email', '');
1682
        $extrainfo1 = Request::getString('extrainfo1', '');
1683
        $extrainfo2 = Request::getString('extrainfo2', '');
1684
        $extrainfo3 = Request::getString('extrainfo3', '');
1685
        $extrainfo4 = Request::getString('extrainfo4', '');
1686
        $extrainfo5 = Request::getString('extrainfo5', '');
1687
        $summary    = Request::getString('summary', '');
1688
        $date       = Request::getInt('date');
1689
        $location   = Request::getString('location', '');
1690
        $sendconf   = Request::getInt('sendconf');
1691
        $status     = Request::getInt('status');
1692
1693
        if ($firstname === '') {
1694
            $firstname = '-';
1695
        }
1696
        if ($lastname === '') {
1697
            $lastname = '-';
1698
        }
1699
        if ($email === '') {
1700
            $email = '-';
1701
        }
1702
        if ($extrainfo1 === '') {
1703
            $extrainfo1 = '-';
1704
        }
1705
        if ($extrainfo2 === '') {
1706
            $extrainfo2 = '-';
1707
        }
1708
        if ($extrainfo3 === '') {
1709
            $extrainfo3 = '-';
1710
        }
1711
        if ($extrainfo4 === '') {
1712
            $extrainfo4 = '-';
1713
        }
1714
        if ($extrainfo5 === '') {
1715
            $extrainfo5 = '-';
1716
        }
1717
1718
        $query = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix('apcal_ro_members') . ' SET ';
1719
        $query .= $GLOBALS['xoopsDB']->prefix('apcal_ro_members') . ".rom_firstname = '$firstname', ";
1720
        $query .= $GLOBALS['xoopsDB']->prefix('apcal_ro_members') . ".rom_lastname = '$lastname', ";
1721
        $query .= $GLOBALS['xoopsDB']->prefix('apcal_ro_members') . ".rom_email = '$email', ";
1722
        $query .= $GLOBALS['xoopsDB']->prefix('apcal_ro_members') . ".rom_extrainfo1 = '$extrainfo1', ";
1723
        $query .= $GLOBALS['xoopsDB']->prefix('apcal_ro_members') . ".rom_extrainfo2 = '$extrainfo2', ";
1724
        $query .= $GLOBALS['xoopsDB']->prefix('apcal_ro_members') . ".rom_extrainfo3 = '$extrainfo3', ";
1725
        $query .= $GLOBALS['xoopsDB']->prefix('apcal_ro_members') . ".rom_extrainfo4 = '$extrainfo4', ";
1726
        $query .= $GLOBALS['xoopsDB']->prefix('apcal_ro_members') . ".rom_extrainfo5 = '$extrainfo5', ";
1727
        $query .= $GLOBALS['xoopsDB']->prefix("apcal_ro_members") . ".rom_status = $status ";
1728
        $query .= 'WHERE (((' . $GLOBALS['xoopsDB']->prefix('apcal_ro_members') . ".rom_id)=$rom_id))";
1729
1730
        $res = $GLOBALS['xoopsDB']->query($query);
1731
        if (!$res) {
1732
            redirect_header($url, 3, _APCAL_RO_ERROR_EDIT);
1733
        } else {
1734
            redirect_header($url, 3, _APCAL_RO_SUCCESS_EDIT);
1735
        }
1736
    }
1737
}
1738
1739
if (isset($_POST['cancel']) || isset($_POST['cancel_x'])) {
1740 View Code Duplication
    if (!empty($_POST['eventurl'])) {
1741
        $url = Request::getString('eventurl', '');
1742
        redirect_header($url, 1, _APCAL_RO_CANCEL);
1743
    }
1744 View Code Duplication
    if (!empty($_POST['url'])) {
1745
        $url = Request::getString('url', '');
1746
        redirect_header($url, 1, _APCAL_RO_CANCEL);
1747
    }
1748
}
1749
if (isset($_POST['goback']) || isset($_POST['goback_x'])) {
1750 View Code Duplication
    if (!empty($_POST['eventurl'])) {
1751
        $url = Request::getString('eventurl', '');
1752
        redirect_header($url, 0, _APCAL_RO_BACK);
1753
    }
1754
}
1755
1756
if (isset($_POST['ro_notify_all']) || isset($_POST['ro_notify_all_x'])) {
1757
    if (!empty($_POST['url'])) {
1758
        $url      = Request::getString('url', '');
1759
        $eventurl = Request::getString('eventurl', '');
1760
        $eventid  = Request::getInt('eventid');
1761
        $sender   = Request::getString('sender', '');
1762
        $subject  = Request::getString('subject', '');
1763
        $mailtext = Request::getString('mailtext', '');
1764
        $counter  = 0;
1765
1766
        //$subject = utf8_encode($subject);
1767
        //$mailtext = utf8_encode($mailtext);
1768
1769
        $query = 'SELECT '
1770
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
1771
                 . '.rom_email, rom_firstname, rom_lastname FROM '
1772
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
1773
                 . ' WHERE ((('
1774
                 . $GLOBALS['xoopsDB']->prefix('apcal_ro_members')
1775
                 . ".rom_eventid)=$eventid) AND not(rom_email is null))";
1776
1777
        $res      = $GLOBALS['xoopsDB']->query($query);
1778
        $num_rows = $GLOBALS['xoopsDB']->getRowsNum($res);
1779
1780
        if ($num_rows == 0) {
1781
            //no action
1782
        } else {
1783
            while ($member = $GLOBALS['xoopsDB']->fetchObject($res)) {
1784
                $recipient = $member->rom_email;
1785
                $firstname = $member->rom_firstname;
1786
                $lastname  = $member->rom_lastname;
1787
1788 View Code Duplication
                if ($recipient != '-') {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
1789
                    ++$counter;
1790
1791
                    $xoopsMailer = xoops_getMailer();
1792
                    $xoopsMailer->useMail();
1793
                    //set template path
1794
                    if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/')) {
1795
                        $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/' . $xoopsConfig['language'] . '/mail_template/');
1796
                    } else {
1797
                        $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/mail_template/');
1798
                    }
1799
                    //set template name
1800
                    $xoopsMailer->setTemplate('ro_notify_all.tpl');
1801
                    //set sender
1802
                    $xoopsMailer->setFromEmail($sender); //take email from inputbox
1803
                    //set sender name
1804
                    $xoopsMailer->setFromName($cal->ro_mail_sendername);
1805
                    //set subject
1806
                    $xoopsMailer->setSubject($subject);
1807
                    //assign vars
1808
                    $xoopsMailer->assign('MAILTEXT', $mailtext);
1809
                    $xoopsMailer->assign('NAME', $firstname . ' ' . $lastname);
1810
                    $xoopsMailer->assign('SUMMARY', $summary);
1811
                    $xoopsMailer->assign('DATE', $date);
1812
                    $xoopsMailer->assign('LOCATION', $location);
1813
                    $xoopsMailer->assign('URL', $eventurl);
1814
                    $xoopsMailer->assign('SIGNATURE', $cal->ro_mail_signature);
1815
                    //set recipient
1816
                    $xoopsMailer->setToEmails($recipient);
1817
1818
                    //execute sending
1819
                    $xoopsMailer->send();
1820
                    $xoopsMailer->reset();
1821
                }
1822
            }
1823
        }
1824
1825
        redirect_header($url, 3, $counter . _APCAL_RO_MAILSENT);
1826
    }
1827
}
1828
1829
if (isset($_POST['ro_notify_one']) || isset($_POST['ro_notify_one_x'])) {
1830
1831
    if (!empty($_POST['url'])){
1832
1833
        $url      = Request::getString('url', '');
1834
        $eventurl = Request::getString('eventurl', '');
1835
        $eventid  = Request::getInt('eventid');
1836
        $sender   = Request::getString('sender', '');
1837
        $email    = Request::getString('email', '');
1838
        $subject  = Request::getString('subject', '');
1839
        $mailtext = Request::getString('mailtext', '');
1840
        $counter=1;
1841
1842
        //$subject = utf8_encode($subject);
1843
        //$mailtext = utf8_encode($mailtext);
1844
        $recipient=$email;
1845
1846
        $xoopsMailer =& xoops_getMailer();
1847
        $xoopsMailer->useMail();
1848
        //set template path
1849
        if( file_exists(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/'. $xoopsConfig['language'] .'/')) {
1850
            $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/'. $xoopsConfig['language'] .'/mail_template/');
1851
        } else {
1852
            $xoopsMailer->setTemplateDir(XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/language/english/mail_template/');
1853
        }
1854
        //set template name
1855
        $xoopsMailer->setTemplate('ro_notify_all.tpl');
1856
        //set sender
1857
        $xoopsMailer->setFromEmail($sender); //take email from inputbox
1858
        //set sender name
1859
        $xoopsMailer->setFromName($cal->ro_mail_sendername);
1860
        //set subject
1861
        $xoopsMailer->setSubject($subject);
1862
        //assign vars
1863
        $xoopsMailer->assign("MAILTEXT", $mailtext);
1864
        //set recipient
1865
        $xoopsMailer->setToEmails($recipient);
1866
1867
        //execute sending
1868
        $xoopsMailer->send();
1869
        $xoopsMailer->reset();
1870
1871
        redirect_header($url, 3, $counter._APCAL_RO_MAILSENT) ;
1872
1873
    }
1874
}
1875
1876
require XOOPS_ROOT_PATH . '/footer.php';
1877