Passed
Push — master ( 3101ac...81e6e3 )
by Goffy
03:23
created

Registration::setVerifkeyEdit()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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\Forms\FormelementsHandler;
28
29
\defined('XOOPS_ROOT_PATH') || die('Restricted access');
30
31
/**
32
 * Class Object Registration
33
 */
34
class Registration extends \XoopsObject
35
{
36
    /**
37
     * @var int
38
     */
39
    private $start = 0;
40
41
    /**
42
     * @var int
43
     */
44
    private $limit = 0;
45
46
    /**
47
     * @var string
48
     */
49
    private $redir = 'list';
50
51
    /**
52
     * @var string
53
     */
54
    private $verifkeyEdit = '';
55
56
    /**
57
     * Constructor
58
     *
59
     * @param null
60
     */
61
    public function __construct()
62
    {
63
        $this->initVar('id', \XOBJ_DTYPE_INT);
64
        $this->initVar('evid', \XOBJ_DTYPE_INT);
65
        $this->initVar('salutation', \XOBJ_DTYPE_INT);
66
        $this->initVar('firstname', \XOBJ_DTYPE_TXTBOX);
67
        $this->initVar('lastname', \XOBJ_DTYPE_TXTBOX);
68
        $this->initVar('email', \XOBJ_DTYPE_TXTBOX);
69
        $this->initVar('email_send', \XOBJ_DTYPE_INT);
70
        $this->initVar('gdpr', \XOBJ_DTYPE_INT);
71
        $this->initVar('ip', \XOBJ_DTYPE_TXTBOX);
72
        $this->initVar('verifkey', \XOBJ_DTYPE_TXTBOX);
73
        $this->initVar('status', \XOBJ_DTYPE_INT);
74
        $this->initVar('financial', \XOBJ_DTYPE_INT);
75
        $this->initVar('paidamount', \XOBJ_DTYPE_FLOAT);
76
        $this->initVar('listwait', \XOBJ_DTYPE_INT);
77
        $this->initVar('datecreated', \XOBJ_DTYPE_INT);
78
        $this->initVar('submitter', \XOBJ_DTYPE_INT);
79
    }
80
81
    /**
82
     * @static function &getInstance
83
     *
84
     * @param null
85
     */
86
    public static function getInstance()
87
    {
88
        static $instance = false;
89
        if (!$instance) {
90
            $instance = new self();
91
        }
92
    }
93
94
    /**
95
     * The new inserted $Id
96
     * @return inserted id
0 ignored issues
show
Bug introduced by
The type XoopsModules\Wgevents\inserted 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...
97
     */
98
    public function getNewInsertedId()
99
    {
100
        return $GLOBALS['xoopsDB']->getInsertId();
101
    }
102
103
    /**
104
     * @public function getForm
105
     * @param bool $action
106
     * @param bool $test
107
     * @return \XoopsThemeForm
108
     */
109
    public function getForm($action = false, $test = false)
110
    {
111
        $helper = \XoopsModules\Wgevents\Helper::getInstance();
112
113
        $eventHandler = $helper->getHandler('Event');
114
        $questionHandler = $helper->getHandler('Question');
115
        $answerHandler = $helper->getHandler('Answer');
116
        $permissionsHandler = $helper->getHandler('Permission');
117
118
        if (!$action) {
119
            $action = $_SERVER['REQUEST_URI'];
120
        }
121
        $isAdmin = false;
122
        if (\is_object($GLOBALS['xoopsUser']) && \is_object($GLOBALS['xoopsUser']) && \is_object($GLOBALS['xoopsModule']) && \is_object($GLOBALS['xoopsModule'])) {
123
            $isAdmin = $GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid());
124
        }
125
        $answersExist = true;
126
        // Title
127
        if ($this->isNew()) {
128
            $title = $test ? \_MA_WGEVENTS_QUESTIONS_PREVIEW : \_MA_WGEVENTS_REGISTRATION_ADD;
129
            $answersExist = false;
130
        } else {
131
            $title =\_MA_WGEVENTS_REGISTRATION_EDIT;
132
        }
133
134
        $regEvid = $this->getVar('evid');
135
        $eventObj = $eventHandler->get($regEvid);
136
        $permRegistrationsApprove = $permissionsHandler->getPermRegistrationsApprove($eventObj->getVar('submitter'), $eventObj->getVar('status'));
137
        $eventFee = (float)$eventObj->getVar('fee');
138
        $eventRegisterMax = (int)$eventObj->getVar('register_max');
139
        $eventRegisterForceverif = (bool)$eventObj->getVar('register_forceverif');
140
141
        // Get Theme Form
142
        \xoops_load('XoopsFormLoader');
143
        $form = new \XoopsThemeForm($title, 'formRegistration', $action, 'post', true);
144
        $form->setExtra('enctype="multipart/form-data"');
145
        // Form Table events
146
        $form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_REGISTRATION_EVID, $eventObj->getVar('name')));
0 ignored issues
show
Bug introduced by
It seems like $eventObj->getVar('name') 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

146
        $form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_REGISTRATION_EVID, /** @scrutinizer ignore-type */ $eventObj->getVar('name')));
Loading history...
147
        $form->addElement(new \XoopsFormHidden('evid', $this->getVar('evid')));
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('evid') 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

147
        $form->addElement(new \XoopsFormHidden('evid', /** @scrutinizer ignore-type */ $this->getVar('evid')));
Loading history...
148
        // Form select regSalutation
149
        $regSalutationSelect = new \XoopsFormSelect(\_MA_WGEVENTS_REGISTRATION_SALUTATION, 'salutation', $this->getVar('salutation'));
150
        $regSalutationSelect->addOption(Constants::SALUTATION_NONE, ' ');
151
        $regSalutationSelect->addOption(Constants::SALUTATION_MEN, \_MA_WGEVENTS_REGISTRATION_SALUTATION_MEN);
152
        $regSalutationSelect->addOption(Constants::SALUTATION_WOMEN, \_MA_WGEVENTS_REGISTRATION_SALUTATION_WOMEN);
153
        $form->addElement($regSalutationSelect);
154
        // Form select regFirstname
155
        $regFirstname = new Forms\FormText(\_MA_WGEVENTS_REGISTRATION_FIRSTNAME, 'firstname', 50, 255, $this->getVar('firstname'));
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('firstname') 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

155
        $regFirstname = new Forms\FormText(\_MA_WGEVENTS_REGISTRATION_FIRSTNAME, 'firstname', 50, 255, /** @scrutinizer ignore-type */ $this->getVar('firstname'));
Loading history...
156
        $regFirstname->setPlaceholder(\_MA_WGEVENTS_REGISTRATION_FIRSTNAME_PLACEHOLDER);
157
        $form->addElement($regFirstname);
158
        // Form select regLastname
159
        $regLastname = new Forms\FormText(\_MA_WGEVENTS_REGISTRATION_LASTNAME, 'lastname', 50, 255, $this->getVar('lastname'));
160
        $regLastname->setPlaceholder(\_MA_WGEVENTS_REGISTRATION_LASTNAME_PLACEHOLDER);
161
        $form->addElement($regLastname, true);
162
        // Form select regEmail
163
        $regEmailTray = new Forms\FormElementTray(\_MA_WGEVENTS_REGISTRATION_EMAIL, '<br>');
164
        $regEmail = new Forms\FormText('', 'email', 50, 255, $this->getVar('email'));
165
        $regEmail->setPlaceholder(\_MA_WGEVENTS_REGISTRATION_EMAIL_PLACEHOLDER);
166
        if ($eventRegisterForceverif) {
167
            $regEmail->setDescription(_MA_WGEVENTS_EVENT_REGISTER_FORCEVERIF_INFO);
168
        }
169
        $regEmailTray->addElement($regEmail, $eventRegisterForceverif);
170
        // Form select regEmailSend
171
        $regEmailSend = $this->isNew() ? 1 : $this->getVar('email_send');
172
        $regEmailRadio = new \XoopsFormRadioYN(\_MA_WGEVENTS_REGISTRATION_EMAIL_CONFIRM, 'email_send', $regEmailSend);
0 ignored issues
show
Bug introduced by
It seems like $regEmailSend 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

172
        $regEmailRadio = new \XoopsFormRadioYN(\_MA_WGEVENTS_REGISTRATION_EMAIL_CONFIRM, 'email_send', /** @scrutinizer ignore-type */ $regEmailSend);
Loading history...
173
        $regEmailTray->addElement($regEmailRadio);
174
        $form->addElement($regEmailTray);
175
        // get all questions
176
        $crQuestion = new \CriteriaCompo();
177
        $crQuestion->add(new \Criteria('evid', $regEvid));
0 ignored issues
show
Bug introduced by
It seems like $regEvid 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

177
        $crQuestion->add(new \Criteria('evid', /** @scrutinizer ignore-type */ $regEvid));
Loading history...
178
        $crQuestion->setSort('weight ASC, id');
179
        $crQuestion->setOrder('DESC');
180
        $questionsCount = $questionHandler->getCount($crQuestion);
181
        if ($questionsCount > 0) {
182
            $questionsAll = $questionHandler->getAll($crQuestion);
183
            foreach (\array_keys($questionsAll) as $queId) {
184
                $formelementsHandler = new FormelementsHandler();
185
                $formelementsHandler->name = 'ans_id_' . $queId;
186
                $queType = (int)$questionsAll[$queId]->getVar('type');
187
                $addValue = (string)$questionsAll[$queId]->getVar('values');
188
                $formelementsHandler->type = $queType;
189
                $formelementsHandler->caption = $questionsAll[$queId]->getVar('caption');
190
                if ($answersExist) {
191
                    $value = '';
192
                    // get answers for this questions
193
                    $crAnswer = new \CriteriaCompo();
194
                    $crAnswer->add(new \Criteria('regid', $this->getVar('id')));
195
                    $crAnswer->add(new \Criteria('queid', $queId));
196
                    $answersCount = $answerHandler->getCount($crAnswer);
197
                    if ($answersCount > 0) {
198
                        $answersAll = $answerHandler->getAll($crAnswer);
199
                        foreach (\array_keys($answersAll) as $ansId) {
200
                            switch ($queType) {
201
                                case Constants::FIELD_DATE:
202
                                    $answerDateObj = \DateTime::createFromFormat(\_SHORTDATESTRING, $answersAll[$ansId]->getVar('text'));
203
                                    $value = $answerDateObj->getTimestamp();
204
                                    break;
205
                                case Constants::FIELD_COMBOBOX:
206
                                case Constants::FIELD_CHECKBOX:
207
                                    $ansText = $answersAll[$ansId]->getVar('text', 'n');
208
                                    $value = \unserialize($ansText);
209
                                    break;
210
                                case Constants::FIELD_SELECTBOX:
211
                                    $ansText = $answersAll[$ansId]->getVar('text', 'n');
212
                                    $value = (string)\unserialize($ansText);
213
                                    break;
214
                                case 0:
215
                                default:
216
                                    $value = $answersAll[$ansId]->getVar('text');
217
                                    break;
218
                            }
219
                        }
220
                    }
221
                    $formelementsHandler->value = $value;
222
                //} else {
223
                    //TODO
224
                }
225
                if (Constants::FIELD_RADIO == $queType ||
226
                    //Constants::FIELD_SELECTBOX == $queType ||
227
                    Constants::FIELD_CHECKBOX == $queType ||
228
                    Constants::FIELD_COMBOBOX == $queType) {
229
                        $formelementsHandler->optionsArr = \unserialize($addValue);
230
                }
231
                /**/
232
                $required = (bool)$questionsAll[$queId]->getVar('required');
233
                if (Constants::FIELD_SELECTBOX == $queType) {
234
                    //required selectboxes get a blank link in order to force user to input
235
                    $optionsSB = [];
236
                    if ($required) {
237
                        $optionsSB[''] = ' ';
238
                    }
239
                    foreach (\unserialize($addValue) as $optSB) {
240
                        $optionsSB[] = $optSB;
241
                    }
242
                    $formelementsHandler->optionsArr = $optionsSB;
243
                }
244
245
                if (Constants::FIELD_LABEL == $queType) {
246
                    $desc = \preg_replace('/\r\n|\r|\n/', '<br>', $questionsAll[$queId]->getVar('desc', 'e'));
247
                    $formelementsHandler->value = $desc;
248
                }
249
                $formelementsHandler->placeholder = $questionsAll[$queId]->getVar('placeholder');
250
                $formelementsHandler->desc = $questionsAll[$queId]->getVar('desc');
251
                $form->addElement($formelementsHandler->render(), $required);
252
                $form->addElement(new \XoopsFormHidden('type[' . $questionsAll[$queId]->getVar('id') . ']', $questionsAll[$queId]->getVar('type')));
253
                $form->addElement(new \XoopsFormHidden('ans_id[' . $questionsAll[$queId]->getVar('id') . ']', $questionsAll[$queId]->getVar('id')));
254
            }
255
            unset($questions);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $questions does not exist. Did you maybe mean $questionsAll?
Loading history...
256
        }
257
        // Form checkbox regGdpr
258
        $valueGdpr = $permRegistrationsApprove ? 1 : '';
259
        $regGdpr = new \XoopsFormCheckBox(\_MA_WGEVENTS_REGISTRATION_GDPR, 'gdpr', $valueGdpr);
260
        $regGdpr->addOption(1, \_MA_WGEVENTS_REGISTRATION_GDPR_VALUE);
261
        $form->addElement($regGdpr, true);
262
        // Form Text Date Select regFinancial
263
        // Form Text Date Select regPaidamount
264
        $regFinancial = $this->isNew() ? Constants::FINANCIAL_UNPAID : $this->getVar('financial');
265
        $default0 = '0' . $helper->getConfig('sep_comma') . '00';
266
        $regPaidamount = $this->isNew() ? $default0 : Utility::FloatToString($this->getVar('paidamount'));
267
        if ($eventFee > 0 && $permRegistrationsApprove && !$test) {
268
            $regFinancialRadio = new \XoopsFormRadio(\_MA_WGEVENTS_REGISTRATION_FINANCIAL, 'financial', $regFinancial);
0 ignored issues
show
Bug introduced by
It seems like $regFinancial can also be of type array and array; however, parameter $value of XoopsFormRadio::__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

268
            $regFinancialRadio = new \XoopsFormRadio(\_MA_WGEVENTS_REGISTRATION_FINANCIAL, 'financial', /** @scrutinizer ignore-type */ $regFinancial);
Loading history...
269
            $regFinancialRadio->addOption(Constants::FINANCIAL_UNPAID, \_MA_WGEVENTS_REGISTRATION_FINANCIAL_UNPAID);
270
            $regFinancialRadio->addOption(Constants::FINANCIAL_PAID, \_MA_WGEVENTS_REGISTRATION_FINANCIAL_PAID);
271
            $form->addElement($regFinancialRadio, true);
272
            $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_REGISTRATION_PAIDAMOUNT, 'paidamount', 20, 150, $regPaidamount));
273
        } else {
274
            if (!$this->isNew() && $eventFee > 0  && $test) {
275
                $form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_REGISTRATION_FINANCIAL, Utility::getFinancialText($regFinancial)));
276
                $form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_REGISTRATION_PAIDAMOUNT, $regPaidamount));
277
            }
278
            $form->addElement(new \XoopsFormHidden('financial', $regFinancial));
279
            $form->addElement(new \XoopsFormHidden('paidamount', $regPaidamount));
280
        }
281
        // Form Radio Yes/No regListwait
282
        $regListwait = $this->isNew() ? 0 : (int)$this->getVar('listwait');
283
        if ($eventRegisterMax > 0 && $permRegistrationsApprove && !$test) {
284
            $form->addElement(new \XoopsFormRadioYN(\_MA_WGEVENTS_REGISTRATION_LISTWAIT, 'listwait', $regListwait));
285
        } else {
286
            if ($eventRegisterMax > 0 && $regListwait > 0 && $test) {
287
                $form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_REGISTRATION_LISTWAIT, \_YES));
288
            }
289
            $form->addElement(new \XoopsFormHidden('listwait', $regListwait));
290
        }
291
        // Form Text IP resIp
292
        $regIp = $_SERVER['REMOTE_ADDR'];
293
        // Form Text Select resStatus
294
        if ($this->isNew()) {
295
            $regStatus = Constants::STATUS_SUBMITTED;
296
            if ($permissionsHandler->getPermRegistrationsVerif()) {
297
                $regStatus = Constants::STATUS_VERIFIED;
298
            }
299
            if ($permRegistrationsApprove) {
300
                $regStatus = Constants::STATUS_APPROVED;
301
            }
302
        } else {
303
            $regStatus = $this->getVar('status');
304
        }
305
        // Form Text resVerifcode
306
        $resVerifkey = $this->getVar('verifkey');
307
        // Form Text Date Select regDatecreated
308
        $regDatecreated = $this->isNew() ? \time() : $this->getVar('datecreated');
309
        // Form Select User resSubmitter
310
        $regSubmitter = \is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() : 0;
311
        if ($permRegistrationsApprove && !$test) {
312
            $regStatusSelect = new \XoopsFormSelect(\_MA_WGEVENTS_STATUS, 'status', $regStatus);
313
            $regStatusSelect->addOption(Constants::STATUS_NONE, \_MA_WGEVENTS_STATUS_NONE);
314
            $regStatusSelect->addOption(Constants::STATUS_OFFLINE, \_MA_WGEVENTS_STATUS_OFFLINE);
315
            $regStatusSelect->addOption(Constants::STATUS_SUBMITTED, \_MA_WGEVENTS_STATUS_SUBMITTED);
316
            $regStatusSelect->addOption(Constants::STATUS_VERIFIED, \_MA_WGEVENTS_STATUS_VERIFIED);
317
            $regStatusSelect->addOption(Constants::STATUS_APPROVED, \_MA_WGEVENTS_STATUS_APPROVED);
318
            $form->addElement($regStatusSelect, true);
319
        } else {
320
            if (!$this->isNew() && !$test) {
321
                $form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_STATUS, Utility::getStatusText($regStatus)));
322
            }
323
            $form->addElement(new \XoopsFormHidden('status', $regStatus));
324
        }
325
        if ($isAdmin) {
326
            $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_REGISTRATION_IP, 'ip', 20, 150, $this->getVar('ip')));
0 ignored issues
show
Bug introduced by
It seems like $this->getVar('ip') 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

326
            $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_REGISTRATION_IP, 'ip', 20, 150, /** @scrutinizer ignore-type */ $this->getVar('ip')));
Loading history...
327
            $form->addElement(new \XoopsFormText(\_MA_WGEVENTS_REGISTRATION_VERIFKEY, 'verifkey', 20, 150, $resVerifkey));
328
            // Form Text Date Select queDatecreated
329
            $form->addElement(new \XoopsFormTextDateSelect(\_MA_WGEVENTS_DATECREATED, 'datecreated', '', $regDatecreated));
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

329
            $form->addElement(new \XoopsFormTextDateSelect(\_MA_WGEVENTS_DATECREATED, 'datecreated', /** @scrutinizer ignore-type */ '', $regDatecreated));
Loading history...
330
            $form->addElement(new \XoopsFormSelectUser(\_MA_WGEVENTS_SUBMITTER, 'submitter', false, $regSubmitter));
331
        } else {
332
            $form->addElement(new \XoopsFormHidden('ip', $regIp));
333
            $form->addElement(new \XoopsFormHidden('verifkey', $resVerifkey));
334
            $form->addElement(new \XoopsFormHidden('datecreated_int', \time()));
335
            $form->addElement(new \XoopsFormHidden('submitter', $regSubmitter));
336
            if (!$this->isNew() && !$test) {
337
                $form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_DATECREATED, \formatTimestamp($regDatecreated, 's')));
338
                $form->addElement(new \XoopsFormLabel(\_MA_WGEVENTS_SUBMITTER, \XoopsUser::getUnameFromId($regSubmitter)));
339
            }
340
        }
341
        // To Save
342
        $form->addElement(new \XoopsFormHidden('id', $this->getVar('id')));
343
        $form->addElement(new \XoopsFormHidden('op', 'save'));
344
        $form->addElement(new \XoopsFormHidden('start', $this->start));
345
        $form->addElement(new \XoopsFormHidden('limit', $this->limit));
346
        $form->addElement(new \XoopsFormHidden('redir', $this->redir));
347
        $form->addElement(new \XoopsFormHidden('verifkeyEdit', $this->verifkeyEdit));
348
        // button tray
349
        $buttonTray = new \XoopsFormElementTray('');
350
        $buttonBack = new Forms\FormButton('', 'cancel', \_CANCEL, 'button');
351
        $buttonBack->setExtra('onclick="history.go(-1);return true;"');
352
        $buttonBack->setClass('btn-danger');
353
        $buttonTray->addElement($buttonBack);
354
        if (!$test) {
355
            $buttonReset = new Forms\FormButton('', 'reset', \_RESET, 'reset');
356
            $buttonReset->setClass('btn-warning');
357
            $buttonTray->addElement($buttonReset);
358
            $buttonSubmit = new Forms\FormButton('', '_submit', \_MA_WGEVENTS_SAVE, 'submit');
359
            $buttonSubmit->setClass('btn-primary');
360
            $buttonTray->addElement($buttonSubmit);
361
        }
362
        $form->addElement($buttonTray);
363
        return $form;
364
    }
365
366
    /**
367
     * Get Values
368
     * @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...
369
     * @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...
370
     * @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...
371
     * @return array
372
     */
373
    public function getValuesRegistrations($keys = null, $format = null, $maxDepth = null)
374
    {
375
        $helper  = \XoopsModules\Wgevents\Helper::getInstance();
376
        $ret = $this->getValues($keys, $format, $maxDepth);
377
        $eventHandler = $helper->getHandler('Event');
378
        $eventObj = $eventHandler->get($this->getVar('evid'));
379
        $ret['eventname']        = $eventObj->getVar('name');
380
        $ret['salutation_text']  = Utility::getSalutationText($this->getVar('salutation'));
381
        $ret['status_text']      = Utility::getStatusText($this->getVar('status'));
382
        $ret['financial_text']   = Utility::getFinancialText($this->getVar('financial'));
383
        $ret['paidamount_text']  = Utility::FloatToString($this->getVar('paidamount'));
384
        $ret['listwait_text']    = (int)$this->getVar('listwait') > 0 ? \_YES : \_NO;
385
        $ret['datecreated_text'] = \formatTimestamp($this->getVar('datecreated'), 'm');
386
        $ret['submitter_text']   = \XoopsUser::getUnameFromId($this->getVar('submitter'));
387
        return $ret;
388
    }
389
390
    /**
391
     * Set start
392
     * @param $start
393
     * @return void
394
     */
395
    public function setStart($start)
396
    {
397
        $this->start = $start;
398
    }
399
400
    /**
401
     * Set start
402
     * @param $limit
403
     * @return void
404
     */
405
    public function setLimit($limit)
406
    {
407
        $this->limit = $limit;
408
    }
409
410
    /**
411
     * Set redir
412
     * @param $redir
413
     * @return void
414
     */
415
    public function setRedir($redir)
416
    {
417
        $this->redir = $redir;
418
    }
419
420
    /**
421
     * Set verifkeyEdit
422
     * @param $verifkey
423
     * @return void
424
     */
425
    public function setVerifkeyEdit($verifkey)
426
    {
427
        $this->verifkeyEdit = $verifkey;
428
    }
429
430
    /**
431
     * Returns an array representation of the object
432
     *
433
     * @return array
434
     */
435
    /*
436
    public function toArray()
437
    {
438
        $ret = [];
439
        $vars = $this->getVars();
440
        foreach (\array_keys($vars) as $var) {
441
            $ret[$var] = $this->getVar($var);
442
        }
443
        return $ret;
444
    }
445
    */
446
}
447