Passed
Push — master ( 9785ba...9eee91 )
by Goffy
03:23
created

Event::getDayname()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 25
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 6
eloc 22
c 2
b 0
f 0
nc 6
nop 2
dl 0
loc 25
rs 8.9457
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Wgevents;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
*/
14
15
/**
16
 * wgEvents module for xoops
17
 *
18
 * @copyright    2021 XOOPS Project (https://xoops.org)
19
 * @license      GPL 2.0 or later
20
 * @package      wgevents
21
 * @since        1.0.0
22
 * @min_xoops    2.5.11 Beta1
23
 * @author       Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com
24
 */
25
26
use XoopsModules\Wgevents;
27
use XoopsModules\Wgevents\ {
28
    Helper,
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, XoopsModules\Wgevents\Helper. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
29
    Utility,
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, XoopsModules\Wgevents\Utility. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
30
    Forms
31
};
32
33
34
\defined('XOOPS_ROOT_PATH') || die('Restricted access');
35
36
/**
37
 * Class Object Event
38
 */
39
class Event extends \XoopsObject
40
{
41
    /**
42
     * @var int
43
     */
44
    public $start = 0;
45
46
    /**
47
     * @var int
48
     */
49
    public $limit = 0;
50
51
    /**
52
     * @var int
53
     */
54
    public $idSource = 0;
55
56
    /**
57
     * @var string
58
     */
59
    public $cats = '';
60
61
    /**
62
     * Constructor
63
     *
64
     */
65
    public function __construct()
66
    {
67
        $this->initVar('id', \XOBJ_DTYPE_INT);
68
        $this->initVar('catid', \XOBJ_DTYPE_INT);
69
        $this->initVar('subcats', \XOBJ_DTYPE_OTHER);
70
        $this->initVar('name', \XOBJ_DTYPE_TXTBOX);
71
        $this->initVar('logo', \XOBJ_DTYPE_TXTBOX);
72
        $this->initVar('desc', \XOBJ_DTYPE_OTHER);
73
        $this->initVar('datefrom', \XOBJ_DTYPE_INT);
74
        $this->initVar('dateto', \XOBJ_DTYPE_INT);
75
        $this->initVar('allday', \XOBJ_DTYPE_INT);
76
        $this->initVar('contact', \XOBJ_DTYPE_TXTAREA);
77
        $this->initVar('email', \XOBJ_DTYPE_TXTBOX);
78
        $this->initVar('url', \XOBJ_DTYPE_TXTBOX);
79
        $this->initVar('location', \XOBJ_DTYPE_TXTAREA);
80
        $this->initVar('locgmlat', \XOBJ_DTYPE_FLOAT);
81
        $this->initVar('locgmlon', \XOBJ_DTYPE_FLOAT);
82
        $this->initVar('locgmzoom', \XOBJ_DTYPE_INT);
83
        $this->initVar('fee_type', \XOBJ_DTYPE_INT);
84
        $this->initVar('fee', \XOBJ_DTYPE_OTHER);
85
        $this->initVar('paymentinfo', \XOBJ_DTYPE_OTHER);
86
        $this->initVar('register_use', \XOBJ_DTYPE_INT);
87
        $this->initVar('register_from', \XOBJ_DTYPE_INT);
88
        $this->initVar('register_to', \XOBJ_DTYPE_INT);
89
        $this->initVar('register_max', \XOBJ_DTYPE_INT);
90
        $this->initVar('register_listwait', \XOBJ_DTYPE_INT);
91
        $this->initVar('register_autoaccept', \XOBJ_DTYPE_INT);
92
        $this->initVar('register_notify', \XOBJ_DTYPE_TXTAREA);
93
        $this->initVar('register_sendermail', \XOBJ_DTYPE_TXTBOX);
94
        $this->initVar('register_sendername', \XOBJ_DTYPE_TXTBOX);
95
        $this->initVar('register_signature', \XOBJ_DTYPE_TXTAREA);
96
        $this->initVar('register_forceverif', \XOBJ_DTYPE_INT);
97
        $this->initVar('status', \XOBJ_DTYPE_INT);
98
        $this->initVar('galid', \XOBJ_DTYPE_TXTBOX);
99
        $this->initVar('url_info', \XOBJ_DTYPE_TXTBOX);
100
        $this->initVar('url_registration', \XOBJ_DTYPE_TXTBOX);
101
        $this->initVar('identifier', \XOBJ_DTYPE_TXTBOX);
102
        $this->initVar('groups', \XOBJ_DTYPE_TXTBOX);
103
        $this->initVar('datecreated', \XOBJ_DTYPE_INT);
104
        $this->initVar('submitter', \XOBJ_DTYPE_INT);
105
    }
106
107
    /**
108
     * @static function &getInstance
109
     *
110
     */
111
    public static function getInstance()
112
    {
113
        static $instance = false;
114
        if (!$instance) {
115
            $instance = new self();
116
        }
117
    }
118
119
    /**
120
     * The new inserted $Id
121
     * @return int
122
     */
123
    public function getNewInsertedId()
124
    {
125
        return $GLOBALS['xoopsDB']->getInsertId();
126
    }
127
128
    /**
129
     * @public function getForm
130
     * @param bool $action
131
     * @return \XoopsThemeForm
132
     */
133
    public function getForm($action = false)
134
    {
135
        $helper = Helper::getInstance();
136
137
        $categoryHandler = $helper->getHandler('Category');
138
        $permissionsHandler = $helper->getHandler('Permission');
139
140
        $utility = new Utility();
141
142
        if (!$action) {
143
            $action = $_SERVER['REQUEST_URI'];
144
        }
145
        $isAdmin   = false;
146
        $userUid   = 0;
147
        $userEmail = '';
148
        $userName  = '';
149
        if (\is_object($GLOBALS['xoopsUser'])) {
150
            if (\is_object($GLOBALS['xoopsModule'])) {
151
                $isAdmin   = $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid());
152
            }
153
            $userUid   = $GLOBALS['xoopsUser']->uid();
154
            $userEmail = $GLOBALS['xoopsUser']->email();
155
            $userName  = ('' !== (string)$GLOBALS['xoopsUser']->name()) ? $GLOBALS['xoopsUser']->name() : $GLOBALS['xoopsUser']->uname();
156
        }
157
158
        $imgInfo = '<img class="wge-img-info" src="' . \WGEVENTS_ICONS_URL_24 . '/info.png" alt="img-info" title="%s">';
159
160
        // Title
161
        $title = $this->isNew() ? \_MA_WGEVENTS_EVENT_ADD : \_MA_WGEVENTS_EVENT_EDIT;
162
        if ($this->idSource > 0) {
163
            $this->unsetNew();
164
        }
165
        // Get Theme Form
166
        \xoops_load('XoopsFormLoader');
167
        $form = new \XoopsThemeForm($title, 'formEvent', $action, 'post', true);
168
        $form->setExtra('enctype="multipart/form-data"');
169
        // Form Text identifier
170
        if (!$this->isNew()) {
171
            if ($isAdmin) {
172
                $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_EVENT_IDENTIFIER, 'identifier', 50, 255, $this->getVar('identifier')));
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('identifier') can also be of type array and array; however, parameter $value of XoopsFormText::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

172
                $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_EVENT_IDENTIFIER, 'identifier', 50, 255, /** @scrutinizer ignore-type */ $this->getVar('identifier')));
Loading history...
173
            } else {
174
                $form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_EVENT_IDENTIFIER, $this->getVar('identifier')));
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('identifier') can also be of type array and array; however, parameter $value of XoopsFormLabel::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

174
                $form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_EVENT_IDENTIFIER, /** @scrutinizer ignore-type */ $this->getVar('identifier')));
Loading history...
175
                $form->addElement(new \XoopsFormHidden('identifier', (string)$this->getVar('identifier')));
176
            }
177
        }
178
        // Form Table categories
179
        $evCatidSelect = new \XoopsFormSelect(\_MA_WGEVENTS_EVENT_CATID, 'catid', $this->getVar('catid'));
180
        $evCatidSelect->addOptionArray($categoryHandler->getAllCatsOnline(Constants::CATEGORY_TYPE_MAIN));
181
        $form->addElement($evCatidSelect);
182
        // Form Table sub categories
183
        // count sub categories
184
        $catsSubOnline = $categoryHandler->getAllCatsOnline(Constants::CATEGORY_TYPE_SUB);
185
        if (\count($catsSubOnline) > 0) {
186
            $evSubCats = $this->isNew() ? [] : \unserialize($this->getVar('subcats'), ['allowed_classes' => false]);
187
            $evSubCatsSelect = new \XoopsFormCheckBox(\_MA_WGEVENTS_EVENT_SUBCATS, 'subcats', $evSubCats);
188
            $evSubCatsSelect->addOptionArray($catsSubOnline);
189
            $form->addElement($evSubCatsSelect);
190
        }
191
        // Form Text evName
192
        $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_EVENT_NAME, 'name', 50, 255, $this->getVar('name')), true);
193
        // Form Editor DhtmlTextArea evDesc
194
        $editorConfigs = [];
195
        if ($isAdmin) {
196
            $editor = $helper->getConfig('editor_admin');
197
        } else {
198
            $editor = $helper->getConfig('editor_user');
199
        }
200
        $editorConfigs['name'] = 'desc';
201
        $editorConfigs['value'] = $this->getVar('desc', 'e');
202
        $editorConfigs['rows'] = 5;
203
        $editorConfigs['cols'] = 40;
204
        $editorConfigs['width'] = '100%';
205
        $editorConfigs['height'] = '400px';
206
        $editorConfigs['editor'] = $editor;
207
        $form->addElement(new \XoopsFormEditor(\_MA_WGEVENTS_EVENT_DESC, 'desc', $editorConfigs));
208
        // Form Image evLogo
209
        // Form Image evLogo: Select Uploaded Image
210
        $getEvLogo = $this->getVar('logo');
211
        $evLogo = $getEvLogo ?: 'blank.gif';
212
        $imageDirectory = '/uploads/wgevents/events/logos/' . $userUid;
213
        $folderUid = \XOOPS_ROOT_PATH . $imageDirectory;
214
        if (!\file_exists($folderUid)) {
215
            $utility::createFolder($folderUid);
216
            \chmod($folderUid, 0777);
217
            $file = \WGEVENTS_PATH . '/assets/images/blank.gif';
218
            $dest = $folderUid . '/blank.gif';
219
            $utility::copyFile($file, $dest);
220
        }
221
        $imageTray = new Forms\FormElementTray(\_MA_WGEVENTS_EVENT_LOGO, '<br>');
222
        $imageSelect = new \XoopsFormSelect(\_MA_WGEVENTS_EVENT_LOGO_UPLOADS, 'logo', $evLogo, 5);
223
        $imageArray = \XoopsLists::getImgListAsArray(\XOOPS_ROOT_PATH . $imageDirectory);
224
        foreach ($imageArray as $image1) {
225
            $imageSelect->addOption(($image1), $image1);
226
        }
227
        $imageSelect->setExtra("onchange='showImgSelected(\"imglabel_logo\", \"logo\", \"" . $imageDirectory . '", "", "' . \XOOPS_URL . "\")'");
228
        $imageTray->addElement($imageSelect);
229
        $imageTray->addElement(new \XoopsFormLabel('', "<br><img src='" . \XOOPS_URL . '/' . $imageDirectory . '/' . $evLogo . "' id='imglabel_logo' alt='' style='max-width:100px' >"));
230
        // Form Image evLogo: Upload new image
231
        $maxsize = $helper->getConfig('maxsize_image');
232
        $imageTray->addElement(new \XoopsFormFile('<br>' . \_AM_WGEVENTS_FORM_UPLOAD_NEW, 'logo', $maxsize));
233
        $imageTray->addElement(new \XoopsFormLabel(\_AM_WGEVENTS_FORM_UPLOAD_SIZE, ($maxsize / 1048576) . ' ' . \_AM_WGEVENTS_FORM_UPLOAD_SIZE_MB));
234
        $imageTray->addElement(new \XoopsFormLabel(\_AM_WGEVENTS_FORM_UPLOAD_IMG_WIDTH, $helper->getConfig('maxwidth_image') . ' px'));
235
        $imageTray->addElement(new \XoopsFormLabel(\_AM_WGEVENTS_FORM_UPLOAD_IMG_HEIGHT, $helper->getConfig('maxheight_image') . ' px'));
236
        $form->addElement($imageTray);
237
        // Form Tray Datefrom
238
        $evDatefromTray = new Forms\FormElementTray(\_MA_WGEVENTS_EVENT_DATEFROM, '&nbsp;');
239
        // Text Date Select evDatefrom
240
        $evDatefrom = ($this->isNew() && 0 === (int)$this->getVar('datefrom')) ? \time() : $this->getVar('datefrom');
241
        $evDatefromTray->addElement(new \XoopsFormDateTime('', 'datefrom', '', $evDatefrom), true);
0 ignored issues
show
Bug introduced by
'' of type string is incompatible with the type integer expected by parameter $size of XoopsFormDateTime::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

241
        $evDatefromTray->addElement(new \XoopsFormDateTime('', 'datefrom', /** @scrutinizer ignore-type */ '', $evDatefrom), true);
Loading history...
242
        // Text Date Checkbox evAllday
243
        $evAllday = $this->isNew() ? 0 : (int)$this->getVar('allday');
244
        $checkAllday = new \XoopsFormCheckBox('', 'allday', $evAllday);
245
        $checkAllday->addOption(1, \_MA_WGEVENTS_EVENT_ALLDAY);
246
        $checkAllday->setExtra(" onclick='toggleAllday()' ");
247
        $evDatefromTray->addElement($checkAllday);
248
        $form->addElement($evDatefromTray);
249
        // Form Text Date Select evDateto
250
        $evDateto = ($this->isNew() && 0 === (int)$this->getVar('dateto')) ? \time() : $this->getVar('dateto');
251
        $form->addElement(new \XoopsFormDateTime(\_MA_WGEVENTS_EVENT_DATETO, 'dateto', '', $evDateto));
252
        // Form Text evContact
253
        $form->addElement(new \XoopsFormTextArea(\_MA_WGEVENTS_EVENT_CONTACT, 'contact', $this->getVar('contact', 'e'), 4, 30));
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('contact', 'e') can also be of type array and array; however, parameter $value of XoopsFormTextArea::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

253
        $form->addElement(new \XoopsFormTextArea(\_MA_WGEVENTS_EVENT_CONTACT, 'contact', /** @scrutinizer ignore-type */ $this->getVar('contact', 'e'), 4, 30));
Loading history...
254
        // Form Text evEmail
255
        $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_EVENT_EMAIL, 'email', 50, 255, $this->getVar('email')));
256
        // Form Text evUrl
257
        $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_EVENT_URL, 'url', 50, 255, $this->getVar('url')));
258
        // Location
259
        // Form Editor TextArea evLocation
260
        $evLocation = $this->isNew() ? '' : $this->getVar('location', 'e');
261
        $form->addElement(new \XoopsFormTextArea(\_MA_WGEVENTS_EVENT_LOCATION, 'location', $evLocation, 4, 50));
262
263
        if ($helper->getConfig('use_gmaps')) {
264
            $gmapsTray = new Forms\FormElementTray('', '<br>');
265
            // Form Text evLocgmlat
266
            $evLocgmlat = $this->isNew() ? '0.00' : $this->getVar('locgmlat');
267
            $gmapsTray->addElement(new \XoopsFormText(\_MA_WGEVENTS_EVENT_LOCGMLAT, 'locgmlat', 20, 50, $evLocgmlat));
268
            // Form Text evLocgmlon
269
            $evLocgmlon = $this->isNew() ? '0.00' : $this->getVar('locgmlon');
270
            $gmapsTray->addElement(new \XoopsFormText(\_MA_WGEVENTS_EVENT_LOCGMLON, 'locgmlon', 20, 50, $evLocgmlon));
271
            // Form Text evLocgmzoom
272
            $evLocgmzoom = $this->isNew() ? '10' : $this->getVar('locgmzoom');
273
            $gmapsTray->addElement(new \XoopsFormText(\_MA_WGEVENTS_EVENT_LOCGMZOOM, 'locgmzoom', 5, 50, $evLocgmzoom));
274
            // Form label
275
            $locLabel = '<div class="row"><div class="col-sm-6">';
276
            $locLabel .= $gmapsTray->render();
277
            $locLabel .= '</div>';
278
            $locLabel .= '<div class="col-sm-6">';
279
            $locLabel .= "<button id='btnGetCoords' type='button' class='btn btn-primary' data-toggle='modal' data-target='#modalCoordsPicker'>" . \_MA_WGEVENTS_EVENT_GM_GETCOORDS . '</button>';
280
            $locLabel .= '</div></div>';
281
            $form->addElement(new \XoopsFormLabel('', $locLabel));
282
        }
283
        // Form Text evFee
284
        $default0 = '0' . $helper->getConfig('sep_comma') . '00';
285
        $evFeeArr = [];
286
        if ($this->isNew()) {
287
            $evFeeArr = [[$default0, '', 'placeholder' => \_MA_WGEVENTS_EVENT_FEE_DESC_PH]];
288
        } else {
289
            $evFee = \json_decode($this->getVar('fee'), true);
290
            foreach($evFee as $fee) {
291
                $evFeeArr[] = [Utility::FloatToString((float)$fee[0]), $fee[1], 'placeholder' => \_MA_WGEVENTS_EVENT_FEE_DESC_PH];
292
            }
293
            if (0 === \count($evFeeArr)) {
294
                $evFeeArr = [[$default0, '', 'placeholder' => \_MA_WGEVENTS_EVENT_FEE_DESC_PH]];
295
            }
296
        }
297
        $evFeeTray = new Forms\FormElementTray(\_MA_WGEVENTS_EVENT_FEE, '<br>');
298
        $evFeeType = $this->isNew() ? Constants::FEETYPE_DECLARED : (int)$this->getVar('fee_type');
299
        $evFeeTypeRadio = new \XoopsFormRadio('', 'fee_type', $evFeeType);
300
        $evFeeTypeRadio->addOption(Constants::FEETYPE_DECLARED, \_MA_WGEVENTS_EVENT_FEETYPE_DECLARED);
301
        $evFeeTypeRadio->addOption(Constants::FEETYPE_FREE, \_MA_WGEVENTS_EVENT_FEETYPE_FREE);
302
        $evFeeTypeRadio->addOption(Constants::FEETYPE_NONDECL, \_MA_WGEVENTS_EVENT_FEETYPE_NONDECL);
303
        $evFeeTypeRadio->setExtra(" onchange='toggleFeeFields()' ");
304
        $evFeeTray->addElement($evFeeTypeRadio);
305
        $evFeeGroup = new Forms\FormTextDouble('', 'fee', 0, 0, '');
306
        $evFeeGroup->setElements($evFeeArr);
307
        $evFeeGroup->setPlaceholder1(\_MA_WGEVENTS_EVENT_FEE_VAL_PH);
308
        $evFeeGroup->setPlaceholder2(\_MA_WGEVENTS_EVENT_FEE_DESC_PH);
309
        $evFeeGroup->setVisible(Constants::FEETYPE_DECLARED === $evFeeType);
310
        $evFeeTray->addElement($evFeeGroup);
311
        $form->addElement($evFeeTray);
312
        // Form TextArea evPaymentinfo
313
        $editorConfigs2 = [];
314
        $editorConfigs2['name'] = 'paymentinfo';
315
        $editorConfigs2['value'] = $this->getVar('paymentinfo', 'e');
316
        $editorConfigs2['rows'] = 5;
317
        $editorConfigs2['cols'] = 40;
318
        $editorConfigs2['width'] = '100%';
319
        $editorConfigs2['height'] = '400px';
320
        $editorConfigs2['editor'] = $editor;
321
        $form->addElement(new \XoopsFormEditor(\_MA_WGEVENTS_EVENT_PAYMENTINFO, 'paymentinfo', $editorConfigs2));
322
323
        // Start block registration options
324
        $evRegister_use = $this->isNew() ? 0 : $this->getVar('register_use');
325
        if ($helper->getConfig('use_register')) {
326
            // Form Radio Yes/No evRegister_use
327
            $evRegisterUseRadio = new \XoopsFormRadioYN(\_MA_WGEVENTS_EVENT_REGISTER_USE, 'register_use', $evRegister_use);
0 ignored issues
show
Bug introduced by
It seems like $evRegister_use can also be of type array and array; however, parameter $value of XoopsFormRadioYN::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

327
            $evRegisterUseRadio = new \XoopsFormRadioYN(\_MA_WGEVENTS_EVENT_REGISTER_USE, 'register_use', /** @scrutinizer ignore-type */ $evRegister_use);
Loading history...
328
            $evRegisterUseRadio->setExtra(" onclick='toggleRegistrationOpts()' ");
329
            $form->addElement($evRegisterUseRadio);
330
            $evReservUseTray = new \XoopsFormElementTray('', '<br>'); //double element tray is necessary for proper toggle
331
            $evRegisterOptsTray = new Forms\FormElementTray('', '<br>', 'registeropttray');
332
            $evRegisterOptsTray->setClass('col-xs-12 col-sm-5 col-lg-5');
333
            if (!$evRegister_use) {
334
                $evRegisterOptsTray->setHidden();
335
            }
336
            // Form Text Date Select evRegisterfrom
337
            $evRegisterfrom = $this->isNew() ? \time() : $this->getVar('register_from');
338
            $evRegisterOptsTray->addElement(new \XoopsFormDateTime(\_MA_WGEVENTS_EVENT_REGISTER_FROM, 'register_from', '', $evRegisterfrom));
339
            // Form Text Date Select evRegisterto
340
            $evRegisterto = $this->isNew() ? \time() : $this->getVar('register_to');
341
            $evRegisterOptsTray->addElement(new \XoopsFormDateTime(\_MA_WGEVENTS_EVENT_REGISTER_TO, 'register_to', '', $evRegisterto));
342
            // Form Text evRegisterMax
343
            $evRegisterMax = $this->isNew() ? 0 : $this->getVar('register_max');
344
            $captionRegisterMax = \_MA_WGEVENTS_EVENT_REGISTER_MAX . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_MAX_DESC);
345
            $evRegisterOptsTray->addElement(new \XoopsFormText($captionRegisterMax, 'register_max', 5, 50, $evRegisterMax));
346
            // Form Radio Yes/No evRegisterListwait
347
            $evRegisterListwait = $this->isNew() ? 0 : $this->getVar('register_listwait');
348
            $captionRegisterListwait = \_MA_WGEVENTS_EVENT_REGISTER_LISTWAIT . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_LISTWAIT_DESC);
349
            $evRegisterOptsTray->addElement(new \XoopsFormRadioYN($captionRegisterListwait, 'register_listwait', $evRegisterListwait));
350
            // Form Select User evRegisterAutoaccept
351
            $evRegisterAutoaccept = $this->isNew() ? 0 : $this->getVar('register_autoaccept');
352
            $captionRegisterAutoaccept = \_MA_WGEVENTS_EVENT_REGISTER_AUTOACCEPT . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_AUTOACCEPT_DESC);
353
            $evRegisterOptsTray->addElement(new \XoopsFormRadioYN($captionRegisterAutoaccept, 'register_autoaccept', $evRegisterAutoaccept));
354
            // Form Editor TextArea evRegisterNotify
355
            $evRegisterNotify = $this->isNew() ? $userEmail : $this->getVar('register_notify', 'e');
356
            $captionRegisterNotify = \_MA_WGEVENTS_EVENT_REGISTER_NOTIFY . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_NOTIFY_DESC);
357
            $evRegisterOptsTray->addElement(new \XoopsFormTextArea($captionRegisterNotify, 'register_notify', $evRegisterNotify, 4, 30));
358
            // Form Text evRegisterSendermail
359
            $evRegisterSendermail = $this->isNew() ? $userEmail : $this->getVar('register_sendermail');
360
            $captionRegisterSendermail = \_MA_WGEVENTS_EVENT_REGISTER_SENDERMAIL . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_SENDERMAIL_DESC);
361
            $evRegisterOptsTray->addElement(new \XoopsFormText($captionRegisterSendermail, 'register_sendermail', 35, 255, $evRegisterSendermail));
362
            // Form Text evRegisterSendername
363
            $evRegisterSendername = $this->isNew() ? $userName : $this->getVar('register_sendername');
364
            $captionRegisterSendername = \_MA_WGEVENTS_EVENT_REGISTER_SENDERNAME . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_SENDERNAME_DESC);
365
            $evRegisterOptsTray->addElement(new \XoopsFormText($captionRegisterSendername, 'register_sendername', 35, 255, $evRegisterSendername));
366
            // Form Editor TextArea evRegisterSignature
367
            $evRegisterSignature = $this->isNew() ? '' : $this->getVar('register_signature', 'e');
368
            $captionRegisterSignature = \_MA_WGEVENTS_EVENT_REGISTER_SIGNATURE . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_SIGNATURE_DESC);
369
            $evRegisterOptsTray->addElement(new \XoopsFormTextArea($captionRegisterSignature, 'register_signature', $evRegisterSignature, 4, 30));
370
            // Form Radio Yes/No evRegisterListwait
371
            $evRegisterForceverif = $this->isNew() ? 1 : $this->getVar('register_forceverif');
372
            $captionRegisterForceverif = \_MA_WGEVENTS_EVENT_REGISTER_FORCEVERIF . \sprintf($imgInfo, \_MA_WGEVENTS_EVENT_REGISTER_FORCEVERIF_DESC);
373
            $evRegisterOptsTray->addElement(new \XoopsFormRadioYN($captionRegisterForceverif, 'register_forceverif', $evRegisterForceverif));
374
375
            $evReservUseTray->addElement($evRegisterOptsTray);
376
            $form->addElement($evReservUseTray);
377
            //$form->addElement(new \XoopsFormLabel('', $evReservUseTray));
378
            // End block registration options
379
        }
380
        if ($helper->getConfig('use_urlregistration')) {
381
            // Form Text urlRegistration
382
            $evUrlregistration = $this->getVar('url_registration');
383
            $evUrlregText = new Forms\FormText(\_MA_WGEVENTS_EVENT_URL_REGISTRATION, 'url_registration', 50, 255, $evUrlregistration);
0 ignored issues
show
Bug introduced by
It seems like $evUrlregistration can also be of type array and array; however, parameter $value of XoopsModules\Wgevents\Fo...FormText::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

383
            $evUrlregText = new Forms\FormText(\_MA_WGEVENTS_EVENT_URL_REGISTRATION, 'url_registration', 50, 255, /** @scrutinizer ignore-type */ $evUrlregistration);
Loading history...
384
            $evUrlregText->setPlaceholder(\_MA_WGEVENTS_EVENT_URL_REGISTRATION_PH);
385
            if ($evRegister_use) {
386
                $evUrlregText->setExtra('disabled');
387
            }
388
            $form->addElement($evUrlregText);
389
        }
390
        // Form Select evGalid
391
        if ($helper->getConfig('use_wggallery') && \class_exists('WggalleryCorePreload')) {
392
            $helperGallery = \XoopsModules\Wggallery\Helper::getInstance();
0 ignored issues
show
Bug introduced by
The type XoopsModules\Wggallery\Helper was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
393
            $albumsHandler = $helperGallery->getHandler('Albums');
394
            $evGalidSelect = new \XoopsFormSelect(\_MA_WGEVENTS_EVENT_GALID, 'galid', $this->getVar('galid'));
395
            $evGalidSelect->addOption(0, ' ');
396
            $evGalidSelect->addOptionArray($albumsHandler->getList());
397
            $form->addElement($evGalidSelect);
398
        }
399
        // Form Select evGroups
400
        if ($helper->getConfig('use_groups')) {
401
            if ($this->isNew()) {
402
                $groups = ['00000'];
403
            } else {
404
                $groups = \explode('|', $this->getVar('groups'));
405
            }
406
            $evGroupsSelect = new \XoopsFormSelect(\_MA_WGEVENTS_EVENT_GROUPS, 'groups', $groups, 5, true);
407
            $evGroupsSelect->addOption('00000', \_MA_WGEVENTS_EVENT_GROUPS_ALL);
408
            // Get groups
409
            $memberHandler = \xoops_getHandler('member');
410
            $xoopsGroups = $memberHandler->getGroupList();
0 ignored issues
show
Bug introduced by
The method getGroupList() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

410
            /** @scrutinizer ignore-call */ 
411
            $xoopsGroups = $memberHandler->getGroupList();
Loading history...
411
            foreach ($xoopsGroups as $key => $group) {
412
                if (3 !== (int)$key) {
413
                    $evGroupsSelect->addOption(substr('00000' . $key,  -5), $group);
414
                }
415
            }
416
            $form->addElement($evGroupsSelect, true);
417
        } else {
418
            $form->addElement(new \XoopsFormHidden('groups', '00000'));
419
        }
420
        // Form Select Status evStatus
421
        // Form Text Date Select evDatecreated
422
        // Form Select User evSubmitter
423
        $permEventsApprove = $permissionsHandler->getPermEventsApprove();
424
        $permEventsApproveAuto = $permissionsHandler->getPermEventsApproveAuto();
425
        if ($this->isNew()) {
426
            $evStatus = $permEventsApproveAuto ? Constants::STATUS_APPROVED : Constants::STATUS_SUBMITTED;
427
        } else {
428
            $evStatus = $this->getVar('status');
429
        }
430
        $evDatecreated = $this->isNew() ? \time() : (int)$this->getVar('datecreated');
431
        $evSubmitter = $this->isNew() ? $userUid : (int)$this->getVar('submitter');
432
        if ($isAdmin) {
433
            $evStatusSelect = new \XoopsFormSelect(\_MA_WGEVENTS_STATUS, 'status', $evStatus);
434
            $evStatusSelect->addOption(Constants::STATUS_NONE, \_MA_WGEVENTS_STATUS_NONE);
435
            $evStatusSelect->addOption(Constants::STATUS_OFFLINE, \_MA_WGEVENTS_STATUS_OFFLINE);
436
            $evStatusSelect->addOption(Constants::STATUS_SUBMITTED, \_MA_WGEVENTS_STATUS_SUBMITTED);
437
            $evStatusSelect->addOption(Constants::STATUS_APPROVED, \_MA_WGEVENTS_STATUS_APPROVED);
438
            $evStatusSelect->addOption(Constants::STATUS_LOCKED, \_MA_WGEVENTS_STATUS_LOCKED);
439
            $evStatusSelect->addOption(Constants::STATUS_CANCELED, \_MA_WGEVENTS_STATUS_CANCELED);
440
            $form->addElement($evStatusSelect, true);
441
            $form->addElement(new \XoopsFormTextDateSelect(\_MA_WGEVENTS_DATECREATED, 'datecreated', '', $evDatecreated));
0 ignored issues
show
Bug introduced by
'' of type string is incompatible with the type integer expected by parameter $size of XoopsFormTextDateSelect::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

441
            $form->addElement(new \XoopsFormTextDateSelect(\_MA_WGEVENTS_DATECREATED, 'datecreated', /** @scrutinizer ignore-type */ '', $evDatecreated));
Loading history...
442
            $form->addElement(new \XoopsFormSelectUser(\_MA_WGEVENTS_SUBMITTER, 'submitter', false, $evSubmitter));
443
        } else {
444
            $form->addElement(new \XoopsFormHidden('status', $evStatus));
445
            $form->addElement(new \XoopsFormHidden('datecreated_int', $evDatecreated));
446
            $form->addElement(new \XoopsFormHidden('submitter', $evSubmitter));
447
            if (!$this->isNew() && $permEventsApprove) {
448
                $evStatusSelect = new \XoopsFormSelect(\_MA_WGEVENTS_STATUS, 'status', $evStatus);
449
                $evStatusSelect->addOption(Constants::STATUS_NONE, \_MA_WGEVENTS_STATUS_NONE);
450
                $evStatusSelect->addOption(Constants::STATUS_OFFLINE, \_MA_WGEVENTS_STATUS_OFFLINE);
451
                $evStatusSelect->addOption(Constants::STATUS_SUBMITTED, \_MA_WGEVENTS_STATUS_SUBMITTED);
452
                $evStatusSelect->addOption(Constants::STATUS_APPROVED, \_MA_WGEVENTS_STATUS_APPROVED);
453
                $form->addElement($evStatusSelect, true);
454
                $form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_DATECREATED, \formatTimestamp($evDatecreated, 's')));
455
                $form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_SUBMITTER, \XoopsUser::getUnameFromId($evSubmitter)));
456
            }
457
        }
458
        if ($this->idSource > 0 && $helper->getConfig('use_register')) {
459
            $form->addElement(new \XoopsFormRadioYN(\_MA_WGEVENTS_EVENT_CLONE_QUESTION, 'clone_question', 1));
460
            $form->addElement(new \XoopsFormHidden('id_source', $this->idSource));
461
        }
462
        if (!$this->isNew() && 0 === $this->idSource) {
463
            $informModif = new \XoopsFormRadioYN(\_MA_WGEVENTS_EVENT_INFORM_MODIF, 'informModif', 0);
464
            $informModif->setDescription(\_MA_WGEVENTS_EVENT_INFORM_MODIF_DESC);
465
            $form->addElement($informModif);
466
        }
467
        // To Save
468
        $form->addElement(new \XoopsFormHidden('op', 'save'));
469
        $form->addElement(new \XoopsFormHidden('start', $this->start));
470
        $form->addElement(new \XoopsFormHidden('limit', $this->limit));
471
        $form->addElement(new \XoopsFormHidden('cats', $this->cats));
472
        // button tray
473
        $buttonTray = new \XoopsFormElementTray('');
474
        $buttonBack = new Forms\FormButton('', 'confirm_back', \_CANCEL, 'button');
475
        $buttonBack->setExtra('onclick="history.go(-1);return true;"');
476
        $buttonBack->setClass('btn-danger');
477
        $buttonTray->addElement($buttonBack);
478
479
        $buttonReset = new Forms\FormButton('', 'reset', \_RESET, 'reset');
480
        $buttonReset->setClass('btn-warning');
481
        $buttonTray->addElement($buttonReset);
482
483
        $buttonSubmit = new Forms\FormButton('', '_submit', \_MA_WGEVENTS_SAVE, 'submit');
484
        $buttonSubmit->setClass('btn-primary');
485
        $buttonTray->addElement($buttonSubmit);
486
487
        $buttonNext = new Forms\FormButton('', 'continue_questions', \_MA_WGEVENTS_CONTINUE_QUESTIONY, 'submit');
488
        $buttonNext->setClass('btn-primary');
489
        if (!$evRegister_use) {
490
            $buttonNext->setHidden();
491
        }
492
        $buttonTray->addElement($buttonNext);
493
        $form->addElement($buttonTray);
494
495
        return $form;
496
    }
497
498
    /**
499
     * @public function getFormContactAll
500
     * @param string $mailFrom
501
     * @param string $mailSubject
502
     * @param string $mailBody
503
     * @param int    $mailCopy
504
     * @param bool   $action
505
     * @return \XoopsThemeForm
506
     */
507
    public function getFormContactAll($mailFrom, $mailSubject, $mailBody = '', $mailCopy = 1, $action = false)
508
    {
509
        $helper = \XoopsModules\Wgevents\Helper::getInstance();
510
        $registrationHandler = $helper->getHandler('Registration');
511
        if (!$action) {
512
            $action = $_SERVER['REQUEST_URI'];
513
        }
514
        // Get Theme Form
515
        \xoops_load('XoopsFormLoader');
516
        $form = new \XoopsThemeForm(\_MA_WGEVENTS_CONTACT_ALL, 'formContactAll', $action, 'post', true);
517
        $form->setExtra('enctype="multipart/form-data"');
518
        // Form Text mailFrom
519
        $emailTray = new Forms\FormElementTray(\_MA_WGEVENTS_CONTACT_MAILFROM, '<br>');
520
        $email = new Forms\FormText('', 'mail_from', 50, 255, $mailFrom);
521
        $email->setPlaceholder(\_MA_WGEVENTS_REGISTRATION_EMAIL_PLACEHOLDER);
522
        $emailTray->addElement($email, true);
523
        // Form select mailCopy
524
        $emailRadio = new \XoopsFormRadioYN(\_MA_WGEVENTS_CONTACT_MAILCOPY, 'mail_copy', $mailCopy);
525
        $emailTray->addElement($emailRadio);
526
        $form->addElement($emailTray);
527
        // Form Editor TextArea mailTo
528
        $crRegistration = new \CriteriaCompo();
529
        $crRegistration->add(new \Criteria('evid', $this->getVar('id')));
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('id') can also be of type array and array; however, parameter $value of Criteria::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

529
        $crRegistration->add(new \Criteria('evid', /** @scrutinizer ignore-type */ $this->getVar('id')));
Loading history...
530
        $numberRegCurr = $registrationHandler->getCount($crRegistration);
531
        $mailToArr = [];
532
        $mailTo = '';
533
        if ($numberRegCurr > 0) {
534
            $registrationsAll = $registrationHandler->getAll($crRegistration);
535
            foreach (\array_keys($registrationsAll) as $i) {
536
                $mailToArr[$registrationsAll[$i]->getVar('email')] = $registrationsAll[$i]->getVar('email');
537
            }
538
        }
539
        foreach ($mailToArr as $mail) {
540
            $mailTo .= $mail . PHP_EOL;
541
        }
542
        $mailToTextarea = new \XoopsFormTextArea(\_MA_WGEVENTS_CONTACT_MAILTO, 'mail_to', $mailTo, 5, 47);
543
        $mailToTextarea->setExtra(" disabled='disabled'");
544
        $form->addElement($mailToTextarea);
545
        // From Text Subject
546
        $subject = \sprintf(\_MA_WGEVENTS_CONTACT_ALL_MAILSUBJECT_TEXT, $mailSubject);
547
        $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_CONTACT_MAILSUBJECT, 'mail_subject', 50, 255, $subject), true);
548
        // Form Editor DhtmlTextArea mailBody
549
        $editorConfigs = [];
550
        $editor = $helper->getConfig('editor_user');
551
        $editorConfigs['name'] = 'mail_body';
552
        $editorConfigs['value'] = $mailBody;
553
        $editorConfigs['rows'] = 10;
554
        $editorConfigs['cols'] = 40;
555
        $editorConfigs['width'] = '100%';
556
        $editorConfigs['height'] = '400px';
557
        $editorConfigs['editor'] = $editor;
558
        $form->addElement(new \XoopsFormEditor(\_MA_WGEVENTS_CONTACT_MAILBODY, 'mail_body', $editorConfigs));
559
        // To Save
560
        $form->addElement(new \XoopsFormHidden('evid', $this->getVar('id')));
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('id') can also be of type array and array; however, parameter $value of XoopsFormHidden::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

560
        $form->addElement(new \XoopsFormHidden('evid', /** @scrutinizer ignore-type */ $this->getVar('id')));
Loading history...
561
        $form->addElement(new \XoopsFormHidden('op', 'exec_contactall'));
562
        $form->addElement(new \XoopsFormButtonTray('', \_MA_WGEVENTS_SEND_ALL, 'submit', '', false));
563
        $form->addElement(new \XoopsFormButton(\_MA_WGEVENTS_CONTACT_ALL_TEST, 'exec_contactall_test', \sprintf(\_MA_WGEVENTS_CONTACT_ALL_TEST_BTN , $mailFrom), 'submit'));
564
        return $form;
565
    }
566
567
    /**
568
     * Get Values
569
     * @param null $keys
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $keys is correct as it would always require null to be passed?
Loading history...
570
     * @param null $format
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $format is correct as it would always require null to be passed?
Loading history...
571
     * @param null $maxDepth
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $maxDepth is correct as it would always require null to be passed?
Loading history...
572
     * @return array
573
     */
574
    public function getValuesEvents($keys = null, $format = null, $maxDepth = null)
575
    {
576
        $helper  = \XoopsModules\Wgevents\Helper::getInstance();
577
        $utility = new \XoopsModules\Wgevents\Utility();
578
        $ret = $this->getValues($keys, $format, $maxDepth);
579
        $adminMaxchar    = $helper->getConfig('admin_maxchar');
580
        $userMaxchar     = $helper->getConfig('user_maxchar');
581
        $eventDayname    = $helper->getConfig('event_dayname');
582
        $categoryHandler = $helper->getHandler('Category');
583
        $eventHandler    = $helper->getHandler('Event');
584
        $catId           = (int)$this->getVar('catid');
585
        $categoryObj     = $categoryHandler->get($catId);
586
        $catName         = '';
587
        $catLogo         = '';
588
        if (\is_object($categoryObj)) {
589
            $catName = $categoryObj->getVar('name');
590
            if ('blank.gif' !== (string)$categoryObj->getVar('logo')) {
591
                $catLogo = $categoryObj->getVar('logo');
592
            }
593
        }
594
        $ret['catname'] = $catName;
595
        $ret['catlogo'] = $catLogo;
596
        $subcatsArr = [];
597
        $subcats = \unserialize($this->getVar('subcats'), ['allowed_classes' => false]);
598
        if (\is_array($subcats) && \count($subcats) > 0) {
599
            foreach ($subcats as $subcat) {
600
                $subcategoryObj = $categoryHandler->get($subcat);
601
                // do not repeat main cat in sub cats even if it is checked there once more
602
                if (\is_object($subcategoryObj) && $catId !== (int)$subcat) {
603
                    //if (\is_object($subcategoryObj)) {
604
                    $subcatsArr[$subcat]['id'] = $subcat;
605
                    $subcatsArr[$subcat]['name'] = $subcategoryObj->getVar('name');
606
                    $subcatsArr[$subcat]['logo'] = $subcat;
607
                    if ('blank.gif' !== (string)$subcategoryObj->getVar('logo')) {
608
                        $subcatsArr[$subcat]['logo'] = $subcategoryObj->getVar('logo');
609
                    }
610
                }
611
            }
612
        }
613
        $ret['subcats_arr']      = $subcatsArr;
614
        $ret['name_clean']       = \htmlspecialchars($this->getVar('name'), ENT_QUOTES | ENT_HTML5);
615
        $ret['desc_text']        = $this->getVar('desc', 'e');
616
        $ret['desc_short_admin'] = $utility::truncateHtml($ret['desc_text'], $adminMaxchar);
617
        $ret['desc_short_user']  = $utility::truncateHtml($ret['desc_text'], $userMaxchar);
618
        $ret['logoExist']        = ('blank.gif' !== (string)$this->getVar('logo') && 'blank.png' !== (string)$this->getVar('logo'));
619
        $evAllday                = (int)$this->getVar('allday');
620
        $ret['allday_single']    = 0;
621
        if ($evAllday > 0) {
622
            $datefrom_text = \formatTimestamp($this->getVar('datefrom'), 's');
623
            $dateto_text   = \formatTimestamp($this->getVar('dateto'), 's');
624
            $ret['datefrom_text'] = $datefrom_text . ' ' . \_MA_WGEVENTS_EVENT_ALLDAY;
625
            if ($datefrom_text === $dateto_text) {
626
                //single allday
627
                $ret['allday_single'] = 1;
628
                $ret['dateto_text']   = ' ';
629
            } else {
630
                $ret['dateto_text']   = $dateto_text . ' ' . \_MA_WGEVENTS_EVENT_ALLDAY;
631
            }
632
        } else {
633
            $ret['datefrom_text']    = \formatTimestamp($this->getVar('datefrom'), 'm');
634
            $ret['dateto_text']      = \formatTimestamp($this->getVar('dateto'), 'm');
635
        }
636
        $ret['datefromto_text']  = $eventHandler->getDateFromToText($this->getVar('datefrom'), $this->getVar('dateto'), $evAllday);
637
        $ret['datefrom_dayname'] = $this->getDayname($eventDayname, \formatTimestamp($this->getVar('datefrom'), 'w'));
638
        $ret['dateto_dayname']   = $this->getDayname($eventDayname, \formatTimestamp($this->getVar('dateto'), 'w'));
639
        $evLocation              = $this->getVar('location', 'e');
640
        $ret['location_text']    = $evLocation;
641
        if ($evLocation) {
642
            $loc   = preg_split("/\r\n|\n|\r/", $evLocation);
643
            $ret['location_text_user']  = \implode('<br>', $loc);
644
        }
645
        $evContact               = $this->getVar('contact', 'e');
646
        $ret['contact_text']     = $evContact;
647
        if ($evContact) {
648
            $contactLines   = preg_split("/\r\n|\n|\r/", $evContact);
649
            $ret['contact_text_user']  = \implode('<br>', $contactLines);
650
        }
651
        $evFeeType = $this->getVar('fee_type');
652
        $evFeeText = '';
653
        $evFeeShow = false;
654
        switch ($evFeeType) {
655
            case Constants::FEETYPE_DECLARED:
656
            default:
657
                $feetypeText = \_MA_WGEVENTS_EVENT_FEETYPE_DECLARED;
658
                $evFee = \json_decode($this->getVar('fee'), true);
659
                foreach($evFee as $fee) {
660
                    $evFeeText .= Utility::FloatToString((float)$fee[0]) . ' ' . $fee[1] . '<br>';
661
                }
662
                $evFeeShow = true;
663
                break;
664
            case Constants::FEETYPE_FREE:
665
                $feetypeText = \_MA_WGEVENTS_EVENT_FEETYPE_FREE;
666
                $evFeeText   = \_MA_WGEVENTS_EVENT_FEETYPE_FREE;
667
                $evFeeShow   = true;
668
                break;
669
            case Constants::FEETYPE_NONDECL:
670
                $feetypeText = \_MA_WGEVENTS_EVENT_FEETYPE_NONDECL;
671
                break;
672
        }
673
        $ret['feetype_text']          = $feetypeText;
674
        $ret['fee_text']              = $evFeeText;
675
        $ret['fee_show']              = $evFeeShow;
676
        $ret['paymentinfo_text']      = \nl2br($this->getVar('paymentinfo', 'e'));
677
        $ret['register_use_text']     = (int)$this->getVar('register_use') > 0 ? \_YES : \_NO;
678
        $ret['register_from_text']    = '';
679
        $ret['register_from_dayname'] = '';
680
        if ($this->getVar('register_from') > 0) {
681
            $ret['register_from_text'] = \formatTimestamp($this->getVar('register_from'), 'm');
682
            $ret['register_from_dayname'] = $this->getDayname($eventDayname, \formatTimestamp($this->getVar('register_from'), 'w'));
683
        }
684
        $ret['register_to_text']    = '';
685
        $ret['register_to_dayname'] = '';
686
        if ($this->getVar('register_to') > 0) {
687
            $ret['register_to_text']       = \formatTimestamp($this->getVar('register_to'), 'm');
688
            $ret['register_to_dayname']   = $this->getDayname($eventDayname, \formatTimestamp($this->getVar('register_to'), 'w'));
689
        }
690
        $regMax = $this->getVar('register_max');
691
        $ret['register_max_text']        = $regMax > 0 ? $this->getVar('register_max') : \_MA_WGEVENTS_EVENT_REGISTER_MAX_UNLIMITED;
692
        $ret['register_listwait_text']   = (int)$this->getVar('register_listwait') > 0 ? \_YES : \_NO;
693
        $ret['register_autoaccept_text'] = (int)$this->getVar('register_autoaccept') > 0 ? \_YES : \_NO;
694
        $evRegisterNotify                = $this->getVar('register_notify', 'e');
695
        $ret['register_notify_text']     = $evRegisterNotify;
696
        if ($evRegisterNotify) {
697
            $notifyEmails   = \preg_split("/\r\n|\n|\r/", $evRegisterNotify);
698
            $ret['register_notify_user']  = \implode('<br>', $notifyEmails);
699
        }
700
        $ret['register_forceverif_text'] = (int)$this->getVar('register_forceverif') > 0 ? \_YES : \_NO;
701
        $evGalid                         = (int)$this->getVar('galid');
702
        if ($evGalid > 0 && $helper->getConfig('use_wggallery') && \class_exists('WggalleryCorePreload')) {
703
            $helperGallery = \XoopsModules\Wggallery\Helper::getInstance();
704
            $albumsHandler = $helperGallery->getHandler('Albums');
705
            $albumObj = $albumsHandler->get($evGalid);
706
            if (\is_object($albumObj)) {
707
                $ret['gallery_name'] = $albumObj->getVar('alb_name');
708
                $albLink = \XOOPS_URL . '/modules/wggallery/gallery.php?op=show&amp;alb_id=' . $evGalid;
709
                $albLink .= '&amp;alb_pid=' .$albumObj->getVar('alb_pid');
710
                $ret['gallery_link'] = $albLink;
711
            } else {
712
                $evGalid = 0;
713
            }
714
        }
715
        $ret['gallery_id'] = $evGalid;
716
        $evGroups                        = $this->getVar('groups', 'e');
717
        $groups_text                     = '';
718
        if (0 === (int)$evGroups) {
719
            $groups_text = \_MA_WGEVENTS_EVENT_GROUPS_ALL;
720
        } else {
721
            // Get groups
722
            $groups_text .= '<ul>';
723
            $memberHandler = \xoops_getHandler('member');
724
            $xoopsGroups  = $memberHandler->getGroupList();
725
            $groups   = explode('|', $evGroups);
726
            foreach ($groups as $group) {
727
                $groups_text .= '<li>' . $xoopsGroups[(int)$group] .  '</li>' ;
728
            }
729
            $groups_text .= '</ul>';
730
        }
731
        $ret['groups_text']      = $groups_text;
732
        $ret['status_text']      = Utility::getStatusText($this->getVar('status'));
733
        $ret['datecreated_text'] = \formatTimestamp($this->getVar('datecreated'), 's');
734
        $ret['submitter_text']   = \XoopsUser::getUnameFromId($this->getVar('submitter'));
735
        return $ret;
736
    }
737
738
    /** function to get day name
739
     * @param $eventDayname (= module preference 'event_dayname')
0 ignored issues
show
Documentation Bug introduced by
The doc comment (= at position 1 could not be parsed: Unknown type name '=' at position 1 in (=.
Loading history...
740
     * @param $day          (= weekday of date)
741
     * @return string
742
     */
743
    private function getDayname ($eventDayname, $day) {
744
        switch ($eventDayname) {
745
            case 0:
746
            default:
747
                $ret = '';
748
                break;
749
            case Constants::DAYNAME_SHORT:
750
                $daynames_short = [\_MA_WGEVENTS_CAL_MIN_SUNDAY, \_MA_WGEVENTS_CAL_MIN_MONDAY, \_MA_WGEVENTS_CAL_MIN_TUESDAY, \_MA_WGEVENTS_CAL_MIN_WEDNESDAY, \_MA_WGEVENTS_CAL_MIN_THURSDAY, \_MA_WGEVENTS_CAL_MIN_FRIDAY, \_MA_WGEVENTS_CAL_MIN_SATURDAY];
751
                $ret = $daynames_short[$day] . ' ';
752
                break;
753
            case Constants::DAYNAME_SHORTDOT:
754
                $daynames_short = [\_MA_WGEVENTS_CAL_MIN_SUNDAY, \_MA_WGEVENTS_CAL_MIN_MONDAY, \_MA_WGEVENTS_CAL_MIN_TUESDAY, \_MA_WGEVENTS_CAL_MIN_WEDNESDAY, \_MA_WGEVENTS_CAL_MIN_THURSDAY, \_MA_WGEVENTS_CAL_MIN_FRIDAY, \_MA_WGEVENTS_CAL_MIN_SATURDAY];
755
                $ret = $daynames_short[$day] . '. ';
756
                break;
757
            case Constants::DAYNAME_SHORTCOMMA:
758
                $daynames_short = [\_MA_WGEVENTS_CAL_MIN_SUNDAY, \_MA_WGEVENTS_CAL_MIN_MONDAY, \_MA_WGEVENTS_CAL_MIN_TUESDAY, \_MA_WGEVENTS_CAL_MIN_WEDNESDAY, \_MA_WGEVENTS_CAL_MIN_THURSDAY, \_MA_WGEVENTS_CAL_MIN_FRIDAY, \_MA_WGEVENTS_CAL_MIN_SATURDAY];
759
                $ret = $daynames_short[$day] . ', ';
760
                break;
761
            case Constants::DAYNAME_LONG:
762
                $daynames_long = [\_MA_WGEVENTS_CAL_SUNDAY, \_MA_WGEVENTS_CAL_MONDAY, \_MA_WGEVENTS_CAL_TUESDAY, \_MA_WGEVENTS_CAL_WEDNESDAY, \_MA_WGEVENTS_CAL_THURSDAY, \_MA_WGEVENTS_CAL_FRIDAY, \_MA_WGEVENTS_CAL_SATURDAY];
763
                $ret = $daynames_long[$day] . ' ';
764
                break;
765
        }
766
767
        return $ret;
768
    }
769
770
    /**
771
     * Returns an array representation of the object
772
     *
773
     * @return array
774
     */
775
    /*
776
    public function toArray()
777
    {
778
        $ret = [];
779
        $vars = $this->getVars();
780
        foreach (\array_keys($vars) as $var) {
781
            $ret[$var] = $this->getVar($var);
782
        }
783
        return $ret;
784
    }
785
    */
786
}
787