Passed
Pull Request — master (#81)
by Michael
02:53
created

class/Form/FriendrequestForm.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace XoopsModules\Yogurt\Form;
6
7
/*
8
 You may not change or alter any portion of this comment or credits
9
 of supporting developers from this source code or any supporting source code
10
 which is considered copyrighted (c) material of the original comment or credit authors.
11
12
 This program is distributed in the hope that it will be useful,
13
 but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
*/
16
17
/**
18
 * Module: Yogurt
19
 *
20
 * @category        Module
21
 * @package         yogurt
22
 * @author          XOOPS Development Team <https://xoops.org>
23
 * @copyright       {@link https://xoops.org/ XOOPS Project}
24
 * @license         GPL 2.0 or later
25
 * @link            https://xoops.org/
26
 * @since           1.0.0
27
 */
28
29
use Xmf\Module\Helper\Permission;
30
use XoopsFormButton;
31
use XoopsFormHidden;
32
use XoopsFormLabel;
33
use XoopsFormSelectUser;
34
use XoopsFormTextDateSelect;
35
use XoopsModules\Yogurt;
36
use XoopsThemeForm;
37
38
require_once \dirname(__DIR__, 2) . '/include/common.php';
39
40
$moduleDirName = \basename(\dirname(__DIR__, 2));
41
//$helper = Yogurt\Helper::getInstance();
42
$permHelper = new Permission();
43
44
\xoops_load('XoopsFormLoader');
45
46
/**
47
 * Class FriendrequestForm
48
 */
49
class FriendrequestForm extends XoopsThemeForm
50
{
51
    public $targetObject;
52
53
    public $helper;
54
55
    /**
56
     * Constructor
57
     *
58
     * @param $target
59
     */
60
    public function __construct($target)
61
    {
62
        $this->helper       = $target->helper;
63
        $this->targetObject = $target;
64
65
        $title = $this->targetObject->isNew() ? \sprintf(\AM_YOGURT_FRIENDREQUEST_ADD) : \sprintf(
66
            \AM_YOGURT_FRIENDREQUEST_EDIT
67
        );
68
        parent::__construct($title, 'form', \xoops_getenv('SCRIPT_NAME'), 'post', true);
69
        $this->setExtra('enctype="multipart/form-data"');
70
71
        //include ID field, it's needed so the module knows if it is a new form or an edited form
72
73
        $hidden = new XoopsFormHidden(
74
            'friendreq_id', $this->targetObject->getVar(
75
            'friendreq_id'
76
        )
77
        );
78
        $this->addElement($hidden);
79
        unset($hidden);
80
81
        // Friendpet_id
82
        $this->addElement(
83
            new XoopsFormLabel(
84
                \AM_YOGURT_FRIENDREQUEST_FRIENDPET_ID, $this->targetObject->getVar(
85
                'friendreq_id'
86
            ), 'friendreq_id'
87
            )
88
        );
89
        // Inviting by Friend_uid
90
        $this->addElement(
91
            new XoopsFormSelectUser(
92
                \AM_YOGURT_FRIENDREQUEST_FRIENDREQUESTER_UID, 'friendrequester_uid', false, $this->targetObject->getVar(
93
                'friendrequester_uid'
94
            ), 1, false
95
            ),
96
            false
97
        );
98
        // Invited Friend_uid
99
        $this->addElement(
100
            new XoopsFormSelectUser(
101
                \AM_YOGURT_FRIENDREQUEST_FRIENDREQUESTTO_UID, 'friendrequestto_uid', false, $this->targetObject->getVar(
102
                'friendrequestto_uid'
103
            ), 1, false
104
            ),
105
            false
106
        );
107
108
        // Date_created
109
        $this->addElement(
110
            new \XoopsFormTextDateSelect(
111
                \AM_YOGURT_FRIENDREQUEST_DATE_CREATED, 'date_created', 0, formatTimestamp($this->targetObject->getVar('date_created'), 's')
0 ignored issues
show
formatTimestamp($this->t...r('date_created'), 's') of type string is incompatible with the type integer expected by parameter $value 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

111
                \AM_YOGURT_FRIENDREQUEST_DATE_CREATED, 'date_created', 0, /** @scrutinizer ignore-type */ formatTimestamp($this->targetObject->getVar('date_created'), 's')
Loading history...
112
            )
113
        );
114
115
        $this->addElement(new XoopsFormHidden('op', 'save'));
116
        $this->addElement(new XoopsFormButton('', 'submit', \_SUBMIT, 'submit'));
117
    }
118
}
119