|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Contact; |
|
4
|
|
|
|
|
5
|
|
|
use XoopsObject; |
|
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
|
|
|
* Contact module |
|
19
|
|
|
* |
|
20
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
21
|
|
|
* @license https://www.fsf.org/copyleft/gpl.html GNU public license |
|
22
|
|
|
* @author Kazumi Ono (aka Onokazu) |
|
23
|
|
|
* @author Trabis <[email protected]> |
|
24
|
|
|
* @author Hossein Azizabadi (AKA Voltan) |
|
25
|
|
|
* @author Mirza (AKA Bleekk) |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class contact |
|
30
|
|
|
*/ |
|
31
|
|
|
class Contact extends XoopsObject |
|
32
|
|
|
{ |
|
33
|
|
|
private $db; |
|
34
|
|
|
private $table; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* contact constructor. |
|
38
|
|
|
*/ |
|
39
|
|
|
public function __construct() |
|
40
|
|
|
{ |
|
41
|
|
|
// parent::__construct(); |
|
42
|
|
|
$this->initVar('contact_id', \XOBJ_DTYPE_INT, null, false, 11); |
|
43
|
|
|
$this->initVar('contact_uid', \XOBJ_DTYPE_INT, null, false, 11); |
|
44
|
|
|
$this->initVar('contact_cid', \XOBJ_DTYPE_INT, null, false, 11); |
|
45
|
|
|
$this->initVar('contact_name', \XOBJ_DTYPE_TXTBOX, null, false); |
|
46
|
|
|
$this->initVar('contact_subject', \XOBJ_DTYPE_TXTBOX, null, false); |
|
47
|
|
|
$this->initVar('contact_mail', \XOBJ_DTYPE_EMAIL, null, false); |
|
48
|
|
|
$this->initVar('contact_url', \XOBJ_DTYPE_TXTBOX, null, false); |
|
49
|
|
|
$this->initVar('contact_create', \XOBJ_DTYPE_INT, null, false); |
|
50
|
|
|
$this->initVar('contact_icq', \XOBJ_DTYPE_TXTBOX, null, false); |
|
51
|
|
|
$this->initVar('contact_skype', \XOBJ_DTYPE_TXTBOX, null, false); |
|
52
|
|
|
$this->initVar('contact_company', \XOBJ_DTYPE_TXTBOX, null, false); |
|
53
|
|
|
$this->initVar('contact_location', \XOBJ_DTYPE_TXTBOX, null, false); |
|
54
|
|
|
$this->initVar('contact_phone', \XOBJ_DTYPE_TXTBOX, null, false); |
|
55
|
|
|
$this->initVar('contact_department', \XOBJ_DTYPE_TXTBOX, null, false); |
|
56
|
|
|
$this->initVar('contact_ip', \XOBJ_DTYPE_TXTBOX, null, false); |
|
57
|
|
|
$this->initVar('contact_message', \XOBJ_DTYPE_TXTAREA, null, false); |
|
58
|
|
|
$this->initVar('contact_address', \XOBJ_DTYPE_TXTAREA, null, false); |
|
59
|
|
|
$this->initVar('contact_reply', \XOBJ_DTYPE_INT, null, false, 1); |
|
60
|
|
|
$this->initVar('contact_platform', \XOBJ_DTYPE_ENUM, null, false, '', '', ['Android', 'Ios', 'Web']); |
|
|
|
|
|
|
61
|
|
|
$this->initVar('contact_type', \XOBJ_DTYPE_ENUM, null, false, '', '', ['Contact', 'Phone', 'Mail']); |
|
62
|
|
|
|
|
63
|
|
|
$this->db = $GLOBALS ['xoopsDB']; |
|
64
|
|
|
$this->table = $this->db->prefix('contact'); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @return \XoopsThemeForm |
|
69
|
|
|
*/ |
|
70
|
|
|
public function contactReplyForm(): \XoopsThemeForm |
|
71
|
|
|
{ |
|
72
|
|
|
// global $xoopsConfig; |
|
73
|
|
|
$form = new \XoopsThemeForm(_AM_CONTACT_REPLY, 'doreply', 'main.php', 'post', true); |
|
74
|
|
|
$form->setExtra('enctype="multipart/form-data"'); |
|
75
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'doreply')); |
|
76
|
|
|
$form->addElement(new \XoopsFormHidden('contact_id', $this->getVar('contact_id', 'e'))); |
|
|
|
|
|
|
77
|
|
|
$form->addElement(new \XoopsFormHidden('contact_uid', $this->getVar('contact_uid', 'e'))); |
|
78
|
|
|
$form->addElement(new \XoopsFormLabel(_AM_CONTACT_FROM, '', '')); |
|
79
|
|
|
$form->addElement(new \XoopsFormText(_AM_CONTACT_NAMEFROM, 'contact_name', 50, 255, \XoopsUser::getUnameFromId($GLOBALS['xoopsUser']->uid())), true); |
|
80
|
|
|
$form->addElement(new \XoopsFormText(_AM_CONTACT_MAILFROM, 'contact_mail', 50, 255, $GLOBALS['xoopsUser']->getVar('email')), true); |
|
81
|
|
|
$form->addElement(new \XoopsFormLabel(_AM_CONTACT_TO, '', '')); |
|
82
|
|
|
$form->addElement(new \XoopsFormText(_AM_CONTACT_NAMETO, 'contact_nameto', 50, 255, $this->getVar('contact_name')), true); |
|
|
|
|
|
|
83
|
|
|
$form->addElement(new \XoopsFormText(_AM_CONTACT_MAILTO, 'contact_mailto', 50, 255, $this->getVar('contact_mail')), true); |
|
84
|
|
|
$form->addElement(new \XoopsFormText(_AM_CONTACT_SUBJECT, 'contact_subject', 50, 255, _RE . $this->getVar('contact_subject')), true); |
|
85
|
|
|
$form->addElement(new \XoopsFormTextArea(_AM_CONTACT_MESSAGE, 'contact_message', '', 5, 60), true); |
|
86
|
|
|
$form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
87
|
|
|
|
|
88
|
|
|
return $form; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* Returns an array representation of the object |
|
93
|
|
|
* |
|
94
|
|
|
* @return array |
|
95
|
|
|
**/ |
|
96
|
|
|
public function toArray() |
|
97
|
|
|
{ |
|
98
|
|
|
$ret = []; |
|
99
|
|
|
$vars = &$this->getVars(); |
|
100
|
|
|
foreach (\array_keys($vars) as $i) { |
|
101
|
|
|
$ret [$i] = $this->getVar($i); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
return $ret; |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
|