Issues (964)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  Header Injection
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

testdata/mymodule2/class/Testfields.php (19 issues)

1
<?php
2
3
namespace XoopsModules\Mymodule2;
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
 * My Module 2 module for xoops
17
 *
18
 * @copyright     2020 XOOPS Project (https://xooops.org)
19
 * @license        GPL 2.0 or later
20
 * @package        mymodule2
21
 * @since          1.0
22
 * @min_xoops      2.5.9
23
 * @author         TDM XOOPS - Email:<[email protected]> - Website:<http://xoops.org>
24
 */
25
26
use XoopsModules\Mymodule2;
27
28
defined('XOOPS_ROOT_PATH') || die('Restricted access');
29
30
/**
31
 * Class Object Testfields
32
 */
33
class Testfields extends \XoopsObject
34
{
35
	/**
36
	 * Constructor 
37
	 *
38
	 * @param null
39
	 */
40
	public function __construct()
41
	{
42
		$this->initVar('tf_id', XOBJ_DTYPE_INT);
43
		$this->initVar('tf_text', XOBJ_DTYPE_TXTBOX);
44
		$this->initVar('tf_textarea', XOBJ_DTYPE_TXTBOX);
45
		$this->initVar('tf_dhtml', XOBJ_DTYPE_TXTBOX);
46
		$this->initVar('tf_checkbox', XOBJ_DTYPE_INT);
47
		$this->initVar('tf_yesno', XOBJ_DTYPE_INT);
48
		$this->initVar('tf_selectbox', XOBJ_DTYPE_TXTBOX);
49
		$this->initVar('tf_user', XOBJ_DTYPE_INT);
50
		$this->initVar('tf_color', XOBJ_DTYPE_TXTBOX);
51
		$this->initVar('tf_imagelist', XOBJ_DTYPE_TXTBOX);
52
		$this->initVar('tf_urlfile', XOBJ_DTYPE_TXTBOX);
53
		$this->initVar('tf_uplimage', XOBJ_DTYPE_TXTBOX);
54
		$this->initVar('tf_uplfile', XOBJ_DTYPE_TXTBOX);
55
		$this->initVar('tf_textdateselect', XOBJ_DTYPE_TXTBOX);
56
		$this->initVar('tf_selectfile', XOBJ_DTYPE_TXTBOX);
57
		$this->initVar('tf_status', XOBJ_DTYPE_INT);
58
	}
59
60
	/**
61
	 * @static function &getInstance
62
	 *
63
	 * @param null
64
	 */
65
	public static function getInstance()
66
	{
67
		static $instance = false;
68
		if (!$instance) {
69
			$instance = new self();
70
		}
71
	}
72
73
	/**
74
	 * The new inserted $Id
75
	 * @return inserted id
0 ignored issues
show
The type XoopsModules\Mymodule2\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...
76
	 */
77
	public function getNewInsertedIdTestfields()
78
	{
79
		$newInsertedId = $GLOBALS['xoopsDB']->getInsertId();
80
		return $newInsertedId;
81
	}
82
83
	/**
84
	 * @public function getForm
85
	 * @param bool $action
86
	 * @return XoopsThemeForm
0 ignored issues
show
The type XoopsModules\Mymodule2\XoopsThemeForm was not found. Did you mean XoopsThemeForm? If so, make sure to prefix the type with \.
Loading history...
87
	 */
88
	public function getFormTestfields($action = false)
89
	{
90
		$helper = \XoopsModules\Mymodule2\Helper::getInstance();
91
		if (false === $action) {
92
			$action = $_SERVER['REQUEST_URI'];
93
		}
94
		// Permissions for uploader
95
		$grouppermHandler = xoops_getHandler('groupperm');
96
		$groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
97
		if ($GLOBALS['xoopsUser']) {
98
			if (!$GLOBALS['xoopsUser']->isAdmin($GLOBALS['xoopsModule']->mid())) {
99
				$permissionUpload = $grouppermHandler->checkRight('upload_groups', 32, $groups, $GLOBALS['xoopsModule']->getVar('mid')) ? true : false;
0 ignored issues
show
The method checkRight() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

99
				$permissionUpload = $grouppermHandler->/** @scrutinizer ignore-call */ checkRight('upload_groups', 32, $groups, $GLOBALS['xoopsModule']->getVar('mid')) ? true : false;
Loading history...
100
			} else {
101
				$permissionUpload = true;
102
			}
103
		} else {
104
			$permissionUpload = $grouppermHandler->checkRight('upload_groups', 32, $groups, $GLOBALS['xoopsModule']->getVar('mid')) ? true : false;
105
		}
106
		// Title
107
		$title = $this->isNew() ? sprintf(_AM_MYMODULE2_TESTFIELD_ADD) : sprintf(_AM_MYMODULE2_TESTFIELD_EDIT);
108
		// Get Theme Form
109
		xoops_load('XoopsFormLoader');
110
		$form = new \XoopsThemeForm($title, 'form', $action, 'post', true);
111
		$form->setExtra('enctype="multipart/form-data"');
112
		// Form Text TfText
113
		$form->addElement(new \XoopsFormText( _AM_MYMODULE2_TESTFIELD_TEXT, 'tf_text', 50, 255, $this->getVar('tf_text') ));
0 ignored issues
show
It seems like $this->getVar('tf_text') 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

113
		$form->addElement(new \XoopsFormText( _AM_MYMODULE2_TESTFIELD_TEXT, 'tf_text', 50, 255, /** @scrutinizer ignore-type */ $this->getVar('tf_text') ));
Loading history...
114
		// Form Text Area TfTextarea
115
		$form->addElement(new \XoopsFormTextArea( _AM_MYMODULE2_TESTFIELD_TEXTAREA, 'tf_textarea', $this->getVar('tf_textarea'), 4, 47 ));
0 ignored issues
show
It seems like $this->getVar('tf_textarea') 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

115
		$form->addElement(new \XoopsFormTextArea( _AM_MYMODULE2_TESTFIELD_TEXTAREA, 'tf_textarea', /** @scrutinizer ignore-type */ $this->getVar('tf_textarea'), 4, 47 ));
Loading history...
116
		// Form editor TfDhtml
117
		$editorConfigs = [];
118
		$editorConfigs['name'] = 'tf_dhtml';
119
		$editorConfigs['value'] = $this->getVar('tf_dhtml', 'e');
120
		$editorConfigs['rows'] = 5;
121
		$editorConfigs['cols'] = 40;
122
		$editorConfigs['width'] = '100%';
123
		$editorConfigs['height'] = '400px';
124
		$editorConfigs['editor'] = $helper->getConfig('editor_dhtml');
125
		$form->addElement(new \XoopsFormEditor( _AM_MYMODULE2_TESTFIELD_DHTML, 'tf_dhtml', $editorConfigs));
126
		// Form Check Box TfCheckbox
127
		$tfCheckbox = $this->isNew() ? 0 : $this->getVar('tf_checkbox');
128
		$checkTfCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_TESTFIELD_CHECKBOX, 'tf_checkbox', $tfCheckbox);
129
		$checkTfCheckbox->addOption(1, _AM_MYMODULE2_TESTFIELD_CHECKBOX);
130
		$form->addElement($checkTfCheckbox);
131
		// Form Radio Yes/No TfYesno
132
		$tfYesno = $this->isNew() ? 0 : $this->getVar('tf_yesno');
133
		$form->addElement(new \XoopsFormRadioYN( _AM_MYMODULE2_TESTFIELD_YESNO, 'tf_yesno', $tfYesno));
0 ignored issues
show
It seems like $tfYesno 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

133
		$form->addElement(new \XoopsFormRadioYN( _AM_MYMODULE2_TESTFIELD_YESNO, 'tf_yesno', /** @scrutinizer ignore-type */ $tfYesno));
Loading history...
134
		// Testfields handler
135
		$testfieldsHandler = $helper->getHandler('testfields');
136
		// Form Select Testfields
137
		$tfSelectboxSelect = new \XoopsFormSelect( _AM_MYMODULE2_TESTFIELD_SELECTBOX, 'tf_selectbox', $this->getVar('tf_selectbox'));
138
		$tfSelectboxSelect->addOption('Empty');
139
		$tfSelectboxSelect->addOptionArray($testfieldsHandler->getList());
0 ignored issues
show
The method getList() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsModuleHandler or XoopsImageHandler or XoopsRankHandler or XoopsCommentHandler or XoopsTplsetHandler or XoopsAvatarHandler or XoopsBlockHandler or XoopsImagesetHandler or XoopsPersistableObjectHandler or XoopsImagecategoryHandler. ( Ignorable by Annotation )

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

139
		$tfSelectboxSelect->addOptionArray($testfieldsHandler->/** @scrutinizer ignore-call */ getList());
Loading history...
140
		$form->addElement($tfSelectboxSelect);
141
		// Form Select User TfUser
142
		$form->addElement(new \XoopsFormSelectUser( _AM_MYMODULE2_TESTFIELD_USER, 'tf_user', false, $this->getVar('tf_user') ));
143
		// Form Color Picker TfColor
144
		$form->addElement(new \XoopsFormColorPicker( _AM_MYMODULE2_TESTFIELD_COLOR, 'tf_color', $this->getVar('tf_color') ), true);
0 ignored issues
show
It seems like $this->getVar('tf_color') can also be of type array and array; however, parameter $value of XoopsFormColorPicker::__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

144
		$form->addElement(new \XoopsFormColorPicker( _AM_MYMODULE2_TESTFIELD_COLOR, 'tf_color', /** @scrutinizer ignore-type */ $this->getVar('tf_color') ), true);
Loading history...
145
		// Form Frameworks Image Files TfImagelist
146
		$getTfImagelist = $this->getVar('tf_imagelist');
147
		$tfImagelist = $getTfImagelist ? $getTfImagelist : 'blank.gif';
148
		$imageDirectory = '/Frameworks/moduleclasses/icons/32';
149
		$imageTray = new \XoopsFormElementTray(_AM_MYMODULE2_TESTFIELD_IMAGELIST, '<br>' );
150
		$imageSelect = new \XoopsFormSelect( sprintf(_AM_MYMODULE2_TESTFIELD_IMAGELIST_UPLOADS, ".{$imageDirectory}/"), 'tf_imagelist', $tfImagelist, 5);
151
		$imageArray = \XoopsLists::getImgListAsArray( XOOPS_ROOT_PATH . $imageDirectory );
152
		foreach($imageArray as $image1) {
153
			$imageSelect->addOption("{$image1}", $image1);
154
		}
155
		$imageSelect->setExtra("onchange='showImgSelected(\"imglabel_tf_imagelist\", \"tf_imagelist\", \"".$imageDirectory."\", \"\", \"".XOOPS_URL."\")'");
156
		$imageTray->addElement($imageSelect, false);
157
		$imageTray->addElement(new \XoopsFormLabel('', "<br><img src='".XOOPS_URL."/".$imageDirectory."/".$tfImagelist."' name='imglabel_tf_imagelist' id='imglabel_tf_imagelist' alt='' style='max-width:100px' />"));
158
		// Form File
159
		$fileSelectTray = new \XoopsFormElementTray('', '<br>' );
160
		$fileSelectTray->addElement(new \XoopsFormFile( _AM_MYMODULE2_FORM_UPLOAD_NEW, 'tf_imagelist', $helper->getConfig('maxsize_image') ));
161
		$fileSelectTray->addElement(new \XoopsFormLabel(''));
162
		$imageTray->addElement($fileSelectTray);
163
		$form->addElement($imageTray);
164
		// Form Url Text File TfUrlfile
165
		$formUrlFile = new \XoopsFormElementTray(_AM_MYMODULE2_TESTFIELD_URLFILE, '<br><br>' );
166
		$formUrl = $this->isNew() ? '' : $this->getVar('tf_urlfile');
167
		$formText = new \XoopsFormText( _AM_MYMODULE2_TESTFIELD_URLFILE_UPLOADS, 'tf_urlfile', 75, 255, $formUrl );
168
		$formUrlFile->addElement($formText);
169
		$formUrlFile->addElement(new \XoopsFormFile( _AM_MYMODULE2_FORM_UPLOAD, 'tf_urlfile', $helper->getConfig('maxsize_file') ));
170
		$form->addElement($formUrlFile);
171
		// Form Image TfUplimage
172
		// Form Image TfUplimage: Select Uploaded Image 
173
		$getTfUplimage = $this->getVar('tf_uplimage');
174
		$tfUplimage = $getTfUplimage ? $getTfUplimage : 'blank.gif';
175
		$imageDirectory = '/uploads/mymodule2/images/testfields';
176
		$imageTray = new \XoopsFormElementTray(_AM_MYMODULE2_TESTFIELD_UPLIMAGE, '<br>' );
177
		$imageSelect = new \XoopsFormSelect( sprintf(_AM_MYMODULE2_TESTFIELD_UPLIMAGE_UPLOADS, ".{$imageDirectory}/"), 'tf_uplimage', $tfUplimage, 5);
178
		$imageArray = \XoopsLists::getImgListAsArray( XOOPS_ROOT_PATH . $imageDirectory );
179
		foreach($imageArray as $image1) {
180
			$imageSelect->addOption("{$image1}", $image1);
181
		}
182
		$imageSelect->setExtra("onchange='showImgSelected(\"imglabel_tf_uplimage\", \"tf_uplimage\", \"".$imageDirectory."\", \"\", \"".XOOPS_URL."\")'");
183
		$imageTray->addElement($imageSelect, false);
184
		$imageTray->addElement(new \XoopsFormLabel('', "<br><img src='".XOOPS_URL."/".$imageDirectory."/".$tfUplimage."' name='imglabel_tf_uplimage' id='imglabel_tf_uplimage' alt='' style='max-width:100px' />"));
185
		// Form Image TfUplimage: Upload new image
186
		if ($permissionUpload) {
187
			$maxsize = $helper->getConfig('maxsize_image');
188
			$imageTray->addElement(new \XoopsFormFile( '<br>' . _AM_MYMODULE2_FORM_UPLOAD_NEW, 'tf_uplimage', $maxsize ));
189
			$imageTray->addElement(new \XoopsFormLabel(_AM_MYMODULE2_FORM_UPLOAD_SIZE, ($maxsize / 1048576) . ' '  . _AM_MYMODULE2_FORM_UPLOAD_SIZE_MB));
190
			$imageTray->addElement(new \XoopsFormLabel(_AM_MYMODULE2_FORM_UPLOAD_IMG_WIDTH, $helper->getConfig('maxwidth_image') . ' px'));
191
			$imageTray->addElement(new \XoopsFormLabel(_AM_MYMODULE2_FORM_UPLOAD_IMG_HEIGHT, $helper->getConfig('maxheight_image') . ' px'));
192
		} else {
193
			$imageTray->addElement(new \XoopsFormHidden( 'tf_uplimage', $tfUplimage ));
194
		}
195
		$form->addElement($imageTray, );
196
		// Form File TfUplfile
197
		$tfUplfile = $this->isNew() ? '' : $this->getVar('tf_uplfile');
198
		if ($permissionUpload) {
199
			$fileUploadTray = new \XoopsFormElementTray(_AM_MYMODULE2_TESTFIELD_UPLFILE, '<br>' );
200
			$fileDirectory = '/uploads/mymodule2/files/testfields';
201
			if (!$this->isNew()) {
202
				$fileUploadTray->addElement(new \XoopsFormLabel(sprintf(_AM_MYMODULE2_TESTFIELD_UPLFILE_UPLOADS, ".{$fileDirectory}/"), $tfUplfile));
0 ignored issues
show
It seems like $tfUplfile 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

202
				$fileUploadTray->addElement(new \XoopsFormLabel(sprintf(_AM_MYMODULE2_TESTFIELD_UPLFILE_UPLOADS, ".{$fileDirectory}/"), /** @scrutinizer ignore-type */ $tfUplfile));
Loading history...
203
			}
204
			$maxsize = $helper->getConfig('maxsize_file');
205
			$fileUploadTray->addElement(new \XoopsFormFile( '', 'tf_uplfile', $maxsize ));
206
			$fileUploadTray->addElement(new \XoopsFormLabel(_AM_MYMODULE2_FORM_UPLOAD_SIZE, ($maxsize / 1048576) . ' '  . _AM_MYMODULE2_FORM_UPLOAD_SIZE_MB));
207
			$form->addElement($fileUploadTray, );
208
		} else {
209
			$form->addElement(new \XoopsFormHidden( 'tf_uplfile', $tfUplfile ));
0 ignored issues
show
It seems like $tfUplfile 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

209
			$form->addElement(new \XoopsFormHidden( 'tf_uplfile', /** @scrutinizer ignore-type */ $tfUplfile ));
Loading history...
210
		}
211
		// Form Text Date Select TfTextdateselect
212
		$tfTextdateselect = $this->isNew() ? 0 : $this->getVar('tf_textdateselect');
213
		$form->addElement(new \XoopsFormTextDateSelect( _AM_MYMODULE2_TESTFIELD_TEXTDATESELECT, 'tf_textdateselect', '', $tfTextdateselect ));
0 ignored issues
show
'' 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

213
		$form->addElement(new \XoopsFormTextDateSelect( _AM_MYMODULE2_TESTFIELD_TEXTDATESELECT, 'tf_textdateselect', /** @scrutinizer ignore-type */ '', $tfTextdateselect ));
Loading history...
214
		// Form File TfSelectfile
215
		// Form File TfSelectfile: Select Uploaded File 
216
		$getTfSelectfile = $this->getVar('tf_selectfile');
217
		$tfSelectfile = $getTfSelectfile ? $getTfSelectfile : 'blank.gif';
218
		$fileDirectory = '/uploads/mymodule2/files/testfields';
219
		$fileTray = new \XoopsFormElementTray(_AM_MYMODULE2_TESTFIELD_SELECTFILE, '<br>' );
220
		$fileSelect = new \XoopsFormSelect( sprintf(_AM_MYMODULE2_TESTFIELD_SELECTFILE_UPLOADS, ".{$fileDirectory}/"), 'tf_selectfile', $tfSelectfile, 5);
221
		$fileArray = \XoopsLists::getImgListAsArray( XOOPS_ROOT_PATH . $fileDirectory );
222
		foreach($fileArray as $file1) {
223
			$fileSelect->addOption("{$file1}", $file1);
224
		}
225
		$fileTray->addElement($fileSelect, false);
226
		// Form File TfSelectfile: Upload new file
227
		if ($permissionUpload) {
228
			$maxsize = $helper->getConfig('maxsize_file');
229
			$fileTray->addElement(new \XoopsFormFile( '<br>' . _AM_MYMODULE2_FORM_UPLOAD_NEW, 'tf_selectfile', $maxsize ));
230
			$fileTray->addElement(new \XoopsFormLabel(_AM_MYMODULE2_FORM_UPLOAD_SIZE, ($maxsize / 1048576) . ' '  . _AM_MYMODULE2_FORM_UPLOAD_SIZE_MB));
231
		} else {
232
			$fileTray->addElement(new \XoopsFormHidden( 'tf_selectfile', $tfSelectfile ));
233
		}
234
		$form->addElement($fileTray, );
235
		// Form Select Testfields
236
		$tfStatusSelect = new \XoopsFormSelect( _AM_MYMODULE2_TESTFIELD_STATUS, 'tf_status', $this->getVar('tf_status'));
237
		$tfStatusSelect->addOption(Constants::STATUS_NONE, _AM_MYMODULE2_STATUS_NONE);
238
		$tfStatusSelect->addOption(Constants::STATUS_OFFLINE, _AM_MYMODULE2_STATUS_OFFLINE);
239
		$tfStatusSelect->addOption(Constants::STATUS_SUBMITTED, _AM_MYMODULE2_STATUS_SUBMITTED);
240
		$tfStatusSelect->addOption(Constants::STATUS_APPROVED, _AM_MYMODULE2_STATUS_APPROVED);
241
		$form->addElement($tfStatusSelect);
242
		// Permissions
243
		$memberHandler = xoops_getHandler('member');
244
		$groupList = $memberHandler->getGroupList();
0 ignored issues
show
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

244
		/** @scrutinizer ignore-call */ 
245
  $groupList = $memberHandler->getGroupList();
Loading history...
245
		$grouppermHandler = xoops_getHandler('groupperm');
246
		$fullList[] = array_keys($groupList);
0 ignored issues
show
Comprehensibility Best Practice introduced by
$fullList was never initialized. Although not strictly required by PHP, it is generally a good practice to add $fullList = array(); before regardless.
Loading history...
247
		if (!$this->isNew()) {
248
			$groupsIdsApprove = $grouppermHandler->getGroupIds('mymodule2_approve_testfields', $this->getVar('tf_id'), $GLOBALS['xoopsModule']->getVar('mid'));
0 ignored issues
show
The method getGroupIds() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

248
			/** @scrutinizer ignore-call */ 
249
   $groupsIdsApprove = $grouppermHandler->getGroupIds('mymodule2_approve_testfields', $this->getVar('tf_id'), $GLOBALS['xoopsModule']->getVar('mid'));
Loading history...
249
			$groupsIdsApprove[] = array_values($groupsIdsApprove);
250
			$groupsCanApproveCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_APPROVE, 'groups_approve_testfields[]', $groupsIdsApprove);
251
			$groupsIdsSubmit = $grouppermHandler->getGroupIds('mymodule2_submit_testfields', $this->getVar('tf_id'), $GLOBALS['xoopsModule']->getVar('mid'));
252
			$groupsIdsSubmit[] = array_values($groupsIdsSubmit);
253
			$groupsCanSubmitCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_SUBMIT, 'groups_submit_testfields[]', $groupsIdsSubmit);
254
			$groupsIdsView = $grouppermHandler->getGroupIds('mymodule2_view_testfields', $this->getVar('tf_id'), $GLOBALS['xoopsModule']->getVar('mid'));
255
			$groupsIdsView[] = array_values($groupsIdsView);
256
			$groupsCanViewCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_VIEW, 'groups_view_testfields[]', $groupsIdsView);
257
		} else {
258
			$groupsCanApproveCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_APPROVE, 'groups_approve_testfields[]', $fullList);
259
			$groupsCanSubmitCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_SUBMIT, 'groups_submit_testfields[]', $fullList);
260
			$groupsCanViewCheckbox = new \XoopsFormCheckBox( _AM_MYMODULE2_PERMISSIONS_VIEW, 'groups_view_testfields[]', $fullList);
261
		}
262
		// To Approve
263
		$groupsCanApproveCheckbox->addOptionArray($groupList);
264
		$form->addElement($groupsCanApproveCheckbox);
265
		// To Submit
266
		$groupsCanSubmitCheckbox->addOptionArray($groupList);
267
		$form->addElement($groupsCanSubmitCheckbox);
268
		// To View
269
		$groupsCanViewCheckbox->addOptionArray($groupList);
270
		$form->addElement($groupsCanViewCheckbox);
271
		// To Save
272
		$form->addElement(new \XoopsFormHidden('op', 'save'));
273
		$form->addElement(new \XoopsFormButtonTray('', _SUBMIT, 'submit', '', false));
274
		return $form;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $form returns the type XoopsThemeForm which is incompatible with the documented return type XoopsModules\Mymodule2\XoopsThemeForm.
Loading history...
275
	}
276
277
	/**
278
	 * Get Values
279
	 * @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...
280
	 * @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...
281
	 * @param null$maxDepth 
282
	 * @return array
283
	 */
284
	public function getValuesTestfields($keys = null, $format = null, $maxDepth = null)
285
	{
286
		$helper = \XoopsModules\Mymodule2\Helper::getInstance();
0 ignored issues
show
The assignment to $helper is dead and can be removed.
Loading history...
287
		$ret = $this->getValues($keys, $format, $maxDepth);
288
		$ret['id'] = $this->getVar('tf_id');
289
		$ret['text'] = $this->getVar('tf_text');
290
		$ret['textarea'] = strip_tags($this->getVar('tf_textarea'));
0 ignored issues
show
It seems like $this->getVar('tf_textarea') can also be of type array and array; however, parameter $str of strip_tags() 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

290
		$ret['textarea'] = strip_tags(/** @scrutinizer ignore-type */ $this->getVar('tf_textarea'));
Loading history...
291
		$ret['dhtml'] = strip_tags($this->getVar('tf_dhtml'));
292
		$ret['checkbox'] = $this->getVar('tf_checkbox');
293
		$ret['yesno'] = $this->getVar('tf_yesno');
294
		$ret['yesno_text'] = (int)$this->getVar('tf_yesno') > 0 ? _YES : _NO;
295
		$ret['selectbox'] = $this->getVar('tf_selectbox');
296
		$ret['user'] = \XoopsUser::getUnameFromId($this->getVar('tf_user'));
297
		$ret['color'] = $this->getVar('tf_color');
298
		$ret['imagelist'] = $this->getVar('tf_imagelist');
299
		$ret['urlfile'] = $this->getVar('tf_urlfile');
300
		$ret['uplimage'] = $this->getVar('tf_uplimage');
301
		$ret['uplfile'] = $this->getVar('tf_uplfile');
302
		$ret['textdateselect'] = formatTimeStamp($this->getVar('tf_textdateselect'), 's');
303
		$ret['selectfile'] = $this->getVar('tf_selectfile');
304
		$ret['status'] = $this->getVar('tf_status');
305
		return $ret;
306
	}
307
308
	/**
309
	 * Returns an array representation of the object
310
	 *
311
	 * @return array
312
	 */
313
	public function toArrayTestfields()
314
	{
315
		$ret = [];
316
		$vars = $this->getVars();
317
		foreach(array_keys($vars) as $var) {
318
			$ret[$var] = $this->getVar('"{$var}"');
319
		}
320
		return $ret;
321
	}
322
}
323