|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Lexikon\Form; |
|
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
|
|
|
* Module: lexikon |
|
17
|
|
|
* |
|
18
|
|
|
* @category Module |
|
19
|
|
|
* @package lexikon |
|
20
|
|
|
* @author XOOPS Development Team <[email protected]> - <https://xoops.org> |
|
21
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
22
|
|
|
* @license GPL 2.0 or later |
|
23
|
|
|
* @link https://xoops.org/ |
|
24
|
|
|
* @since 1.0.0 |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
use Xmf\Module\Helper\Permission; |
|
28
|
|
|
use XoopsFormButton; |
|
29
|
|
|
use XoopsFormCheckBox; |
|
30
|
|
|
use XoopsFormDhtmlTextArea; |
|
31
|
|
|
use XoopsFormEditor; |
|
32
|
|
|
use XoopsFormElementTray; |
|
33
|
|
|
use XoopsFormHidden; |
|
34
|
|
|
use XoopsFormLabel; |
|
35
|
|
|
use XoopsFormText; |
|
36
|
|
|
use XoopsModules\Lexikon\{ |
|
37
|
|
|
Helper |
|
38
|
|
|
}; |
|
39
|
|
|
use XoopsThemeForm; |
|
40
|
|
|
|
|
41
|
|
|
require_once \dirname(__DIR__, 2) . '/config/config.php'; |
|
42
|
|
|
|
|
43
|
|
|
$moduleDirName = \basename(\dirname(__DIR__, 2)); |
|
44
|
|
|
$permHelper = new \Xmf\Module\Helper\Permission($moduleDirName); |
|
45
|
|
|
|
|
46
|
|
|
$helper = Helper::getInstance(); |
|
47
|
|
|
|
|
48
|
|
|
\xoops_load('XoopsFormLoader'); |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Class LexikonCategoriesForm |
|
52
|
|
|
*/ |
|
53
|
|
|
class CategoriesForm extends XoopsThemeForm |
|
54
|
|
|
{ |
|
55
|
|
|
public $targetObject; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Constructor |
|
59
|
|
|
* |
|
60
|
|
|
* @param $target |
|
61
|
|
|
*/ |
|
62
|
|
|
public function __construct($target) |
|
63
|
|
|
{ |
|
64
|
|
|
global $helper; |
|
65
|
|
|
$this->targetObject = $target; |
|
66
|
|
|
|
|
67
|
|
|
$title = $this->targetObject->isNew() ? \sprintf(\_AM_LEXIKON_CATEGORIES_ADD) : \sprintf(\_AM_LEXIKON_CATEGORIES_EDIT); |
|
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('categoryID', $this->targetObject->getVar('categoryID')); |
|
74
|
|
|
$this->addElement($hidden); |
|
75
|
|
|
unset($hidden); |
|
76
|
|
|
|
|
77
|
|
|
// CategoryID |
|
78
|
|
|
$this->addElement(new XoopsFormLabel(\_AM_LEXIKON_CATEGORIES_CATEGORYID, $this->targetObject->getVar('categoryID'), 'categoryID')); |
|
79
|
|
|
// Name |
|
80
|
|
|
$this->addElement(new XoopsFormText(\_AM_LEXIKON_CATEGORIES_NAME, 'name', 50, 255, $this->targetObject->getVar('name')), false); |
|
81
|
|
|
// Description |
|
82
|
|
|
if (\class_exists('XoopsFormEditor')) { |
|
83
|
|
|
$editorOptions = []; |
|
84
|
|
|
$editorOptions['name'] = 'description'; |
|
85
|
|
|
$editorOptions['value'] = $this->targetObject->getVar('description', 'e'); |
|
86
|
|
|
$editorOptions['rows'] = 5; |
|
87
|
|
|
$editorOptions['cols'] = 40; |
|
88
|
|
|
$editorOptions['width'] = '100%'; |
|
89
|
|
|
$editorOptions['height'] = '400px'; |
|
90
|
|
|
//$editorOptions['editor'] = xoops_getModuleOption('lexikon_editor', 'lexikon'); |
|
91
|
|
|
//$this->addElement( new \XoopsFormEditor(\_AM_LEXIKON_CATEGORIES_DESCRIPTION, 'description', $editorOptions), false ); |
|
92
|
|
|
if ($helper->isUserAdmin()) { |
|
93
|
|
|
$descEditor = new XoopsFormEditor(\_AM_LEXIKON_CATEGORIES_DESCRIPTION, $helper->getConfig('lexikonEditorAdmin'), $editorOptions, $nohtml = false, $onfailure = 'textarea'); |
|
94
|
|
|
} else { |
|
95
|
|
|
$descEditor = new XoopsFormEditor(\_AM_LEXIKON_CATEGORIES_DESCRIPTION, $helper->getConfig('lexikonEditorUser'), $editorOptions, $nohtml = false, $onfailure = 'textarea'); |
|
96
|
|
|
} |
|
97
|
|
|
} else { |
|
98
|
|
|
$descEditor = new XoopsFormDhtmlTextArea(\_AM_LEXIKON_CATEGORIES_DESCRIPTION, 'description', $this->targetObject->getVar('description', 'e'), '100%', '100%'); |
|
|
|
|
|
|
99
|
|
|
} |
|
100
|
|
|
$this->addElement($descEditor); |
|
101
|
|
|
// Total |
|
102
|
|
|
$this->addElement(new XoopsFormText(\_AM_LEXIKON_CATEGORIES_TOTAL, 'total', 50, 255, $this->targetObject->getVar('total')), false); |
|
103
|
|
|
// Weight |
|
104
|
|
|
$this->addElement(new XoopsFormText(\_AM_LEXIKON_CATEGORIES_WEIGHT, 'weight', 50, 255, $this->targetObject->getVar('weight')), false); |
|
105
|
|
|
// Logourl |
|
106
|
|
|
$this->addElement(new XoopsFormText(\_AM_LEXIKON_CATEGORIES_LOGOURL, 'logourl', 50, 255, $this->targetObject->getVar('logourl')), false); |
|
107
|
|
|
|
|
108
|
|
|
//permissions |
|
109
|
|
|
/** @var \XoopsMemberHandler $memberHandler */ |
|
110
|
|
|
$memberHandler = \xoops_getHandler('member'); |
|
111
|
|
|
$groupList = $memberHandler->getGroupList(); |
|
112
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
113
|
|
|
$grouppermHandler = \xoops_getHandler('groupperm'); |
|
114
|
|
|
$fullList = \array_keys($groupList); |
|
|
|
|
|
|
115
|
|
|
|
|
116
|
|
|
//======================================================================== |
|
117
|
|
|
|
|
118
|
|
|
$mid = $GLOBALS['xoopsModule']->mid(); |
|
119
|
|
|
$groupIdAdmin = 0; |
|
120
|
|
|
$groupNameAdmin = ''; |
|
121
|
|
|
|
|
122
|
|
|
// create admin checkbox |
|
123
|
|
|
foreach ($groupList as $groupId => $groupName) { |
|
124
|
|
|
if (XOOPS_GROUP_ADMIN == $groupId) { |
|
125
|
|
|
$groupIdAdmin = $groupId; |
|
126
|
|
|
$groupNameAdmin = $groupName; |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
$selectPermAdmin = new XoopsFormCheckBox('', 'admin', XOOPS_GROUP_ADMIN); |
|
131
|
|
|
$selectPermAdmin->addOption($groupIdAdmin, $groupNameAdmin); |
|
132
|
|
|
$selectPermAdmin->setExtra("disabled='disabled'"); //comment it out, if you want to allow to remove permissions for the admin |
|
133
|
|
|
|
|
134
|
|
|
// ******************************************************** |
|
135
|
|
|
// permission view items |
|
136
|
|
|
$cat_gperms_read = $grouppermHandler->getGroupIds('lexikon_view', $this->targetObject->getVar('categoryID'), $mid); |
|
137
|
|
|
$arr_cat_gperms_read = $this->targetObject->isNew() ? '0' : $cat_gperms_read; |
|
138
|
|
|
|
|
139
|
|
|
$permsTray = new XoopsFormElementTray(\_AM_LEXIKON_PERMISSIONS_VIEW, ''); |
|
140
|
|
|
|
|
141
|
|
|
$selectAllReadCheckbox = new XoopsFormCheckBox('', 'adminbox1', 1); |
|
142
|
|
|
$selectAllReadCheckbox->addOption('allbox', \_AM_SYSTEM_ALL); |
|
143
|
|
|
$selectAllReadCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox1\" , \"groupsRead[]\");' "); |
|
144
|
|
|
$selectAllReadCheckbox->setClass('xo-checkall'); |
|
145
|
|
|
$permsTray->addElement($selectAllReadCheckbox); |
|
146
|
|
|
|
|
147
|
|
|
// checkbox webmaster |
|
148
|
|
|
$permsTray->addElement($selectPermAdmin, false); |
|
149
|
|
|
// checkboxes other groups |
|
150
|
|
|
//$selectPerm = new \XoopsFormCheckBox('', 'cat_gperms_read', $arr_cat_gperms_read); |
|
151
|
|
|
//$selectPerm = new \XoopsFormCheckBox('', 'groupsRead[]', $this->targetObject->getGroupsRead()); |
|
152
|
|
|
$selectPerm = new XoopsFormCheckBox('', 'groupsRead[]', $arr_cat_gperms_read); |
|
153
|
|
|
foreach ($groupList as $groupId => $groupName) { |
|
154
|
|
|
if (XOOPS_GROUP_ADMIN != $groupId) { |
|
155
|
|
|
$selectPerm->addOption($groupId, $groupName); |
|
156
|
|
|
} |
|
157
|
|
|
} |
|
158
|
|
|
$permsTray->addElement($selectPerm, false); |
|
159
|
|
|
$this->addElement($permsTray, false); |
|
160
|
|
|
unset($permsTray, $selectPerm); |
|
161
|
|
|
|
|
162
|
|
|
// ******************************************************** |
|
163
|
|
|
// permission submit item |
|
164
|
|
|
$cat_gperms_create = $grouppermHandler->getGroupIds('lexikon_submit', $this->targetObject->getVar('categoryID'), $mid); |
|
165
|
|
|
$arr_cat_gperms_create = $this->targetObject->isNew() ? '0' : $cat_gperms_create; |
|
166
|
|
|
|
|
167
|
|
|
$permsTray = new XoopsFormElementTray(\_AM_LEXIKON_PERMISSIONS_SUBMIT, ''); |
|
168
|
|
|
|
|
169
|
|
|
$selectAllSubmitCheckbox = new XoopsFormCheckBox('', 'adminbox2', 1); |
|
170
|
|
|
$selectAllSubmitCheckbox->addOption('allbox', \_AM_SYSTEM_ALL); |
|
171
|
|
|
$selectAllSubmitCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox2\" , \"groupsSubmit[]\");' "); |
|
172
|
|
|
$selectAllSubmitCheckbox->setClass('xo-checkall'); |
|
173
|
|
|
$permsTray->addElement($selectAllSubmitCheckbox); |
|
174
|
|
|
|
|
175
|
|
|
// checkbox webmaster |
|
176
|
|
|
$permsTray->addElement($selectPermAdmin, false); |
|
177
|
|
|
// checkboxes other groups |
|
178
|
|
|
//$selectPerm = new \XoopsFormCheckBox('', 'cat_gperms_create', $arr_cat_gperms_create); |
|
179
|
|
|
$selectPerm = new XoopsFormCheckBox('', 'groupsSubmit[]', $arr_cat_gperms_create); |
|
180
|
|
|
foreach ($groupList as $groupId => $groupName) { |
|
181
|
|
|
if (XOOPS_GROUP_ADMIN != $groupId) { |
|
182
|
|
|
$selectPerm->addOption($groupId, $groupName); |
|
183
|
|
|
} |
|
184
|
|
|
} |
|
185
|
|
|
$permsTray->addElement($selectPerm, false); |
|
186
|
|
|
$this->addElement($permsTray, false); |
|
187
|
|
|
unset($permsTray, $selectPerm); |
|
188
|
|
|
|
|
189
|
|
|
// ******************************************************** |
|
190
|
|
|
// permission approve items |
|
191
|
|
|
$cat_gperms_admin = $grouppermHandler->getGroupIds('lexikon_approve', $this->targetObject->getVar('categoryID'), $mid); |
|
192
|
|
|
$arr_cat_gperms_admin = $this->targetObject->isNew() ? '0' : $cat_gperms_admin; |
|
193
|
|
|
|
|
194
|
|
|
$permsTray = new XoopsFormElementTray(\_AM_LEXIKON_PERMISSIONS_APPROVE, ''); |
|
195
|
|
|
|
|
196
|
|
|
$selectAllModerateCheckbox = new XoopsFormCheckBox('', 'adminbox3', 1); |
|
197
|
|
|
$selectAllModerateCheckbox->addOption('allbox', \_AM_SYSTEM_ALL); |
|
198
|
|
|
$selectAllModerateCheckbox->setExtra(" onclick='xoopsCheckGroup(\"form\", \"adminbox3\" , \"groupsModeration[]\");' "); |
|
199
|
|
|
$selectAllModerateCheckbox->setClass('xo-checkall'); |
|
200
|
|
|
$permsTray->addElement($selectAllModerateCheckbox); |
|
201
|
|
|
|
|
202
|
|
|
// checkbox webmaster |
|
203
|
|
|
$permsTray->addElement($selectPermAdmin, false); |
|
204
|
|
|
// checkboxes other groups |
|
205
|
|
|
//$selectPerm = new \XoopsFormCheckBox('', 'cat_gperms_admin', $arr_cat_gperms_admin); |
|
206
|
|
|
$selectPerm = new XoopsFormCheckBox('', 'groupsModeration[]', $arr_cat_gperms_admin); |
|
207
|
|
|
foreach ($groupList as $groupId => $groupName) { |
|
208
|
|
|
if (XOOPS_GROUP_ADMIN != $groupId && XOOPS_GROUP_ANONYMOUS != $groupId) { |
|
209
|
|
|
$selectPerm->addOption($groupId, $groupName); |
|
210
|
|
|
} |
|
211
|
|
|
} |
|
212
|
|
|
$permsTray->addElement($selectPerm, false); |
|
213
|
|
|
$this->addElement($permsTray, false); |
|
214
|
|
|
unset($permsTray, $selectPerm); |
|
215
|
|
|
|
|
216
|
|
|
//========================================================================= |
|
217
|
|
|
$this->addElement(new XoopsFormHidden('op', 'save')); |
|
218
|
|
|
$this->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
219
|
|
|
} |
|
220
|
|
|
} |
|
221
|
|
|
|