XoopsModules25x /
tdmdownloads
| 1 | <?php |
||||||
| 2 | |||||||
| 3 | namespace XoopsModules\Tdmdownloads; |
||||||
| 4 | |||||||
| 5 | use XoopsModules\Tdmdownloads; |
||||||
| 6 | |||||||
| 7 | /** |
||||||
| 8 | * TDMDownload |
||||||
| 9 | * |
||||||
| 10 | * You may not change or alter any portion of this comment or credits |
||||||
| 11 | * of supporting developers from this source code or any supporting source code |
||||||
| 12 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||||||
| 13 | * This program is distributed in the hope that it will be useful, |
||||||
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
| 16 | * |
||||||
| 17 | * @copyright Gregory Mage (Aka Mage) |
||||||
| 18 | * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||||||
| 19 | * @author Gregory Mage (Aka Mage) |
||||||
| 20 | */ |
||||||
| 21 | defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
||||||
| 22 | |||||||
| 23 | /** |
||||||
| 24 | * Class Downloads |
||||||
| 25 | * @package XoopsModules\Tdmdownloads |
||||||
| 26 | */ |
||||||
| 27 | class Downloads extends \XoopsObject |
||||||
| 28 | { |
||||||
| 29 | // constructor |
||||||
| 30 | public function __construct() |
||||||
| 31 | { |
||||||
| 32 | $this->initVar('lid', XOBJ_DTYPE_INT, null, false, 11); |
||||||
| 33 | $this->initVar('cid', XOBJ_DTYPE_INT, null, false, 5); |
||||||
| 34 | $this->initVar('title', XOBJ_DTYPE_TXTBOX, null, false); |
||||||
| 35 | $this->initVar('url', XOBJ_DTYPE_TXTBOX, null, false); |
||||||
| 36 | $this->initVar('homepage', XOBJ_DTYPE_TXTBOX, null, false); |
||||||
| 37 | $this->initVar('version', XOBJ_DTYPE_TXTBOX, null, false); |
||||||
| 38 | $this->initVar('size', XOBJ_DTYPE_TXTBOX, null, false); |
||||||
| 39 | $this->initVar('platform', XOBJ_DTYPE_TXTBOX, null, false); |
||||||
| 40 | $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); |
||||||
| 41 | // Pour autoriser le html |
||||||
| 42 | $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
||||||
| 43 | $this->initVar('logourl', XOBJ_DTYPE_TXTBOX, null, false); |
||||||
| 44 | $this->initVar('submitter', XOBJ_DTYPE_INT, null, false, 11); |
||||||
| 45 | $this->initVar('status', XOBJ_DTYPE_INT, null, false, 2); |
||||||
| 46 | $this->initVar('date', XOBJ_DTYPE_INT, null, false, 10); |
||||||
| 47 | $this->initVar('hits', XOBJ_DTYPE_INT, null, false, 10); |
||||||
| 48 | $this->initVar('rating', XOBJ_DTYPE_OTHER, null, false, 10); |
||||||
| 49 | $this->initVar('votes', XOBJ_DTYPE_INT, null, false, 11); |
||||||
| 50 | $this->initVar('comments', XOBJ_DTYPE_INT, null, false, 11); |
||||||
| 51 | $this->initVar('top', XOBJ_DTYPE_INT, null, false, 2); |
||||||
| 52 | $this->initVar('paypal', XOBJ_DTYPE_TXTBOX, null, false); |
||||||
| 53 | |||||||
| 54 | //pour les jointures: |
||||||
| 55 | $this->initVar('cat_title', XOBJ_DTYPE_TXTBOX, null, false); |
||||||
| 56 | $this->initVar('cat_imgurl', XOBJ_DTYPE_TXTBOX, null, false); |
||||||
| 57 | } |
||||||
| 58 | |||||||
| 59 | /** |
||||||
| 60 | * @param null $db |
||||||
|
0 ignored issues
–
show
Documentation
Bug
introduced
by
Loading history...
|
|||||||
| 61 | * @return int |
||||||
| 62 | */ |
||||||
| 63 | public function getNewEnreg($db = null) |
||||||
| 64 | { |
||||||
| 65 | $newEnreg = 0; |
||||||
| 66 | /** @var \XoopsMySQLDatabase $db */ |
||||||
| 67 | if (null !== $db) { |
||||||
| 68 | $newEnreg = $db->getInsertId(); |
||||||
| 69 | } |
||||||
| 70 | |||||||
| 71 | return $newEnreg; |
||||||
| 72 | } |
||||||
| 73 | |||||||
| 74 | /** |
||||||
| 75 | * @param array $donnee |
||||||
| 76 | * @param bool $erreur |
||||||
| 77 | * @param bool $action |
||||||
| 78 | * @return \XoopsThemeForm |
||||||
| 79 | */ |
||||||
| 80 | public function getForm($donnee = [], $erreur = false, $action = false) |
||||||
| 81 | { |
||||||
| 82 | global $xoopsModule, $xoopsUser; |
||||||
| 83 | /** @var \XoopsModules\Tdmdownloads\Utility $utility */ |
||||||
| 84 | $utility = new \XoopsModules\Tdmdownloads\Utility(); |
||||||
| 85 | $moduleDirName = basename(dirname(__DIR__)); |
||||||
| 86 | if (false === $action) { |
||||||
| 87 | $action = $_SERVER['REQUEST_URI']; |
||||||
| 88 | } |
||||||
| 89 | //permission pour uploader |
||||||
| 90 | /** @var \XoopsGroupPermHandler $grouppermHandler */ |
||||||
| 91 | $grouppermHandler = xoops_getHandler('groupperm'); |
||||||
| 92 | $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
||||||
| 93 | if ($xoopsUser) { |
||||||
| 94 | $perm_upload = true; |
||||||
| 95 | if (!$xoopsUser->isAdmin($xoopsModule->mid())) { |
||||||
| 96 | $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')) ? true : false; |
||||||
| 97 | } |
||||||
| 98 | } else { |
||||||
| 99 | $perm_upload = $grouppermHandler->checkRight('tdmdownloads_ac', 32, $groups, $xoopsModule->getVar('mid')) ? true : false; |
||||||
| 100 | } |
||||||
| 101 | //nom du formulaire selon l'action (editer ou ajouter): |
||||||
| 102 | $title = $this->isNew() ? sprintf(_AM_TDMDOWNLOADS_FORMADD) : sprintf(_AM_TDMDOWNLOADS_FORMEDIT); |
||||||
| 103 | |||||||
| 104 | //création du formulaire |
||||||
| 105 | $form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
||||||
| 106 | $form->setExtra('enctype="multipart/form-data"'); |
||||||
| 107 | //titre |
||||||
| 108 | $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMTITLE, 'title', 50, 255, $this->getVar('title')), true); |
||||||
|
0 ignored issues
–
show
It seems like
$this->getVar('title') 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
Loading history...
|
|||||||
| 109 | // fichier |
||||||
| 110 | $fichier = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMFILE, '<br><br>'); |
||||||
| 111 | $url = $this->isNew() ? 'http://' : $this->getVar('url'); |
||||||
| 112 | $formurl = new \XoopsFormText(_AM_TDMDOWNLOADS_FORMURL, 'url', 75, 255, $url); |
||||||
| 113 | $fichier->addElement($formurl, false); |
||||||
| 114 | if (true === $perm_upload) { |
||||||
| 115 | $fichier->addElement(new \XoopsFormFile(_AM_TDMDOWNLOADS_FORMUPLOAD, 'attachedfile', $helper->getConfig('maxuploadsize')), false); |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 116 | } |
||||||
| 117 | $form->addElement($fichier); |
||||||
| 118 | |||||||
| 119 | //catégorie |
||||||
| 120 | /** @var \XoopsModules\Tdmdownloads\CategoryHandler $categoryHandler */ |
||||||
| 121 | $categoryHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Category'); |
||||||
| 122 | $categories = $utility->getItemIds('tdmdownloads_submit', $moduleDirName); |
||||||
| 123 | $criteria = new \CriteriaCompo(); |
||||||
| 124 | $criteria->setSort('cat_weight ASC, cat_title'); |
||||||
| 125 | $criteria->setOrder('ASC'); |
||||||
| 126 | if ($xoopsUser) { |
||||||
| 127 | if (!$xoopsUser->isAdmin($xoopsModule->mid())) { |
||||||
| 128 | $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); |
||||||
| 129 | } |
||||||
| 130 | } else { |
||||||
| 131 | $criteria->add(new \Criteria('cat_cid', '(' . implode(',', $categories) . ')', 'IN')); |
||||||
| 132 | } |
||||||
| 133 | $downloadscatArray = $categoryHandler->getAll($criteria); |
||||||
| 134 | if (0 === count($downloadscatArray)) { |
||||||
| 135 | redirect_header('index.php', 2, _NOPERM); |
||||||
| 136 | } |
||||||
| 137 | $mytree = new \XoopsModules\Tdmdownloads\Tree($downloadscatArray, 'cat_cid', 'cat_pid'); |
||||||
| 138 | $form->addElement($mytree->makeSelectElement('cid', 'cat_title', '--', $this->getVar('cid'), true, 0, '', _AM_TDMDOWNLOADS_FORMINCAT), true); |
||||||
|
0 ignored issues
–
show
It seems like
$this->getVar('cid') can also be of type array and array; however, parameter $selected of XoopsObjectTree::makeSelectElement() 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
Loading history...
|
|||||||
| 139 | |||||||
| 140 | //affichage des champs |
||||||
| 141 | /** @var \XoopsModules\Tdmdownloads\FieldHandler $fieldHandler */ |
||||||
| 142 | $fieldHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Field'); |
||||||
| 143 | $criteria = new \CriteriaCompo(); |
||||||
| 144 | $criteria->setSort('weight ASC, title'); |
||||||
| 145 | $criteria->setOrder('ASC'); |
||||||
| 146 | $downloads_field = $fieldHandler->getAll($criteria); |
||||||
| 147 | foreach (array_keys($downloads_field) as $i) { |
||||||
| 148 | if (1 == $downloads_field[$i]->getVar('status_def')) { |
||||||
| 149 | if (1 == $downloads_field[$i]->getVar('fid')) { |
||||||
| 150 | //page d'accueil |
||||||
| 151 | if (1 == $downloads_field[$i]->getVar('status')) { |
||||||
| 152 | $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMHOMEPAGE, 'homepage', 50, 255, $this->getVar('homepage'))); |
||||||
| 153 | } else { |
||||||
| 154 | $form->addElement(new \XoopsFormHidden('homepage', '')); |
||||||
| 155 | } |
||||||
| 156 | } |
||||||
| 157 | if (2 == $downloads_field[$i]->getVar('fid')) { |
||||||
| 158 | //version |
||||||
| 159 | if (1 == $downloads_field[$i]->getVar('status')) { |
||||||
| 160 | $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMVERSION, 'version', 10, 255, $this->getVar('version'))); |
||||||
| 161 | } else { |
||||||
| 162 | $form->addElement(new \XoopsFormHidden('version', '')); |
||||||
| 163 | } |
||||||
| 164 | } |
||||||
| 165 | if (3 == $downloads_field[$i]->getVar('fid')) { |
||||||
| 166 | //taille du fichier |
||||||
| 167 | if (1 == $downloads_field[$i]->getVar('status')) { |
||||||
| 168 | if ($this->isNew()) { |
||||||
| 169 | $size_value = $this->getVar('size'); |
||||||
| 170 | if (false === $erreur) { |
||||||
| 171 | $type_value = '[Ko]'; |
||||||
| 172 | } else { |
||||||
| 173 | $type_value = $donnee['type_size']; |
||||||
| 174 | } |
||||||
| 175 | } else { |
||||||
| 176 | $size_value_arr = explode(' ', $this->getVar('size')); |
||||||
|
0 ignored issues
–
show
It seems like
$this->getVar('size') can also be of type array and array; however, parameter $string of explode() 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
Loading history...
|
|||||||
| 177 | $size_value = $size_value_arr[0]; |
||||||
| 178 | if (false === $erreur) { |
||||||
| 179 | $type_value = $size_value_arr[1]; |
||||||
| 180 | } else { |
||||||
| 181 | $type_value = $donnee['type_size']; |
||||||
| 182 | } |
||||||
| 183 | } |
||||||
| 184 | $aff_size = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMSIZE, ''); |
||||||
| 185 | $aff_size->addElement(new \XoopsFormText('', 'size', 10, 255, $size_value)); |
||||||
| 186 | $type = new \XoopsFormSelect('', 'type_size', $type_value); |
||||||
| 187 | $type_arr = [ |
||||||
| 188 | _AM_TDMDOWNLOADS_BYTES => '[' . _AM_TDMDOWNLOADS_BYTES . ']', |
||||||
| 189 | _AM_TDMDOWNLOADS_KBYTES => '[' . _AM_TDMDOWNLOADS_KBYTES . ']', |
||||||
| 190 | _AM_TDMDOWNLOADS_MBYTES => '[' . _AM_TDMDOWNLOADS_MBYTES . ']', |
||||||
| 191 | _AM_TDMDOWNLOADS_GBYTES => '[' . _AM_TDMDOWNLOADS_GBYTES . ']', |
||||||
| 192 | _AM_TDMDOWNLOADS_TBYTES => '[' . _AM_TDMDOWNLOADS_TBYTES . ']', |
||||||
| 193 | ]; |
||||||
| 194 | $type->addOptionArray($type_arr); |
||||||
| 195 | $aff_size->addElement($type); |
||||||
| 196 | $form->addElement($aff_size); |
||||||
| 197 | } else { |
||||||
| 198 | $form->addElement(new \XoopsFormHidden('size', '')); |
||||||
| 199 | $form->addElement(new \XoopsFormHidden('type_size', '')); |
||||||
| 200 | } |
||||||
| 201 | } |
||||||
| 202 | if (4 == $downloads_field[$i]->getVar('fid')) { |
||||||
| 203 | //plateforme |
||||||
| 204 | if (1 == $downloads_field[$i]->getVar('status')) { |
||||||
| 205 | $platformselect = new \XoopsFormSelect(_AM_TDMDOWNLOADS_FORMPLATFORM, 'platform', explode('|', $this->getVar('platform')), 5, true); |
||||||
| 206 | $platform_array = explode('|', $helper->getConfig('platform')); |
||||||
| 207 | foreach ($platform_array as $platform) { |
||||||
| 208 | $platformselect->addOption((string)$platform, $platform); |
||||||
| 209 | } |
||||||
| 210 | $form->addElement($platformselect, false); |
||||||
| 211 | } else { |
||||||
| 212 | $form->addElement(new \XoopsFormHidden('platform', '')); |
||||||
| 213 | } |
||||||
| 214 | } |
||||||
| 215 | } else { |
||||||
| 216 | $contenu = ''; |
||||||
| 217 | $contenu_iddata = ''; |
||||||
| 218 | $nom_champ = 'champ' . $downloads_field[$i]->getVar('fid'); |
||||||
| 219 | /** @var \XoopsModules\Tdmdownloads\FielddataHandler $fielddataHandler */ |
||||||
| 220 | $fielddataHandler = \XoopsModules\Tdmdownloads\Helper::getInstance()->getHandler('Fielddata'); |
||||||
| 221 | $criteria = new \CriteriaCompo(); |
||||||
| 222 | $criteria->add(new \Criteria('lid', $this->getVar('lid'))); |
||||||
|
0 ignored issues
–
show
It seems like
$this->getVar('lid') 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
Loading history...
|
|||||||
| 223 | $criteria->add(new \Criteria('fid', $downloads_field[$i]->getVar('fid'))); |
||||||
| 224 | $downloadsfielddata = $fielddataHandler->getAll($criteria); |
||||||
| 225 | foreach (array_keys($downloadsfielddata) as $j) { |
||||||
| 226 | if (true === $erreur) { |
||||||
| 227 | $contenu = $donnee[$nom_champ]; |
||||||
| 228 | } else { |
||||||
| 229 | if (!$this->isNew()) { |
||||||
| 230 | $contenu = $downloadsfielddata[$j]->getVar('data'); |
||||||
| 231 | } |
||||||
| 232 | } |
||||||
| 233 | $contenu_iddata = $downloadsfielddata[$j]->getVar('iddata'); |
||||||
| 234 | } |
||||||
| 235 | $iddata = 'iddata' . $downloads_field[$i]->getVar('fid'); |
||||||
| 236 | if (!$this->isNew()) { |
||||||
| 237 | $form->addElement(new \XoopsFormHidden($iddata, $contenu_iddata)); |
||||||
| 238 | } |
||||||
| 239 | if (1 == $downloads_field[$i]->getVar('status')) { |
||||||
| 240 | $form->addElement(new \XoopsFormText($downloads_field[$i]->getVar('title'), $nom_champ, 50, 255, $contenu)); |
||||||
| 241 | } else { |
||||||
| 242 | $form->addElement(new \XoopsFormHidden($nom_champ, '')); |
||||||
| 243 | } |
||||||
| 244 | } |
||||||
| 245 | } |
||||||
| 246 | //description |
||||||
| 247 | $editor_configs = []; |
||||||
| 248 | $editor_configs['name'] = 'description'; |
||||||
| 249 | $editor_configs['value'] = $this->getVar('description', 'e'); |
||||||
| 250 | $editor_configs['rows'] = 20; |
||||||
| 251 | $editor_configs['cols'] = 100; |
||||||
| 252 | $editor_configs['width'] = '100%'; |
||||||
| 253 | $editor_configs['height'] = '400px'; |
||||||
| 254 | $editor_configs['editor'] = $helper->getConfig('editor'); |
||||||
| 255 | $form->addElement(new \XoopsFormEditor(_AM_TDMDOWNLOADS_FORMTEXTDOWNLOADS, 'description', $editor_configs), true); |
||||||
| 256 | //tag |
||||||
| 257 | $dir_tag_ok = false; |
||||||
| 258 | if (is_dir(dirname(__DIR__) . '/tag') || is_dir(dirname(dirname(__DIR__)) . '/tag')) { |
||||||
| 259 | $dir_tag_ok = true; |
||||||
| 260 | } |
||||||
| 261 | if ((1 == $helper->getConfig('usetag')) && $dir_tag_ok) { |
||||||
| 262 | $tagId = $this->isNew() ? 0 : $this->getVar('lid'); |
||||||
| 263 | if (true === $erreur) { |
||||||
| 264 | $tagId = $donnee['TAG']; |
||||||
| 265 | } |
||||||
| 266 | // require_once XOOPS_ROOT_PATH.'/modules/tag/class/formtag.php'; |
||||||
| 267 | $form->addElement(new \XoopsModules\Tag\FormTag('tag', 60, 255, $tagId, 0)); |
||||||
| 268 | } |
||||||
| 269 | |||||||
| 270 | //image |
||||||
| 271 | if ($helper->getConfig('useshots')) { |
||||||
| 272 | $uploaddir = XOOPS_ROOT_PATH . '/uploads/' . $moduleDirName . '/images/shots/' . $this->getVar('logourl'); |
||||||
| 273 | $downloadscat_img = $this->getVar('logourl') ?: 'blank.gif'; |
||||||
| 274 | if (!is_file($uploaddir)) { |
||||||
| 275 | $downloadscat_img = 'blank.gif'; |
||||||
| 276 | } |
||||||
| 277 | $uploadirectory = '/uploads/' . $moduleDirName . '/images/shots'; |
||||||
| 278 | $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG, '<br>'); |
||||||
| 279 | $imgpath = sprintf(_AM_TDMDOWNLOADS_FORMPATH, $uploadirectory); |
||||||
| 280 | $imageselect = new \XoopsFormSelect($imgpath, 'logo_img', $downloadscat_img); |
||||||
| 281 | $topics_array = \XoopsLists:: getImgListAsArray(XOOPS_ROOT_PATH . $uploadirectory); |
||||||
| 282 | foreach ($topics_array as $image) { |
||||||
| 283 | $imageselect->addOption((string)$image, $image); |
||||||
| 284 | } |
||||||
| 285 | $imageselect->setExtra("onchange='showImgSelected(\"image3\", \"logo_img\", \"" . $uploadirectory . '", "", "' . XOOPS_URL . "\")'"); |
||||||
| 286 | $imgtray->addElement($imageselect, false); |
||||||
| 287 | $imgtray->addElement(new \XoopsFormLabel('', "<br><img src='" . XOOPS_URL . '/' . $uploadirectory . '/' . $downloadscat_img . "' name='image3' id='image3' alt=''>")); |
||||||
| 288 | $fileseltray = new \XoopsFormElementTray('', '<br>'); |
||||||
| 289 | if (true === $perm_upload) { |
||||||
| 290 | $fileseltray->addElement(new \XoopsFormFile(_AM_TDMDOWNLOADS_FORMUPLOAD, 'attachedimage', $helper->getConfig('maxuploadsize')), false); |
||||||
| 291 | } |
||||||
| 292 | $imgtray->addElement($fileseltray); |
||||||
| 293 | $form->addElement($imgtray); |
||||||
| 294 | } |
||||||
| 295 | // pour changer de poster et pour ne pas mettre à jour la date: |
||||||
| 296 | |||||||
| 297 | if ($xoopsUser) { |
||||||
| 298 | if ($xoopsUser->isAdmin($xoopsModule->mid())) { |
||||||
| 299 | // auteur |
||||||
| 300 | if ($this->isNew()) { |
||||||
| 301 | $submitter = !empty($xoopsUser) ? $xoopsUser->getVar('uid') : 0; |
||||||
| 302 | $donnee['date_update'] = 0; |
||||||
| 303 | } else { |
||||||
| 304 | $submitter = $this->getVar('submitter'); |
||||||
| 305 | $v_date = $this->getVar('date'); |
||||||
| 306 | } |
||||||
| 307 | if (true === $erreur) { |
||||||
| 308 | $date_update = $donnee['date_update']; |
||||||
| 309 | $v_status = $donnee['status']; |
||||||
| 310 | $submitter = $donnee['submitter']; |
||||||
| 311 | } else { |
||||||
| 312 | $date_update = 'N'; |
||||||
| 313 | $v_status = 1; |
||||||
| 314 | } |
||||||
| 315 | $form->addElement(new \XoopsFormSelectUser(_AM_TDMDOWNLOADS_FORMSUBMITTER, 'submitter', true, $submitter, 1, false), true); |
||||||
| 316 | |||||||
| 317 | // date |
||||||
| 318 | if (!$this->isNew()) { |
||||||
| 319 | $selection_date = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMDATEUPDATE); |
||||||
| 320 | $date = new \XoopsFormRadio('', 'date_update', $date_update); |
||||||
| 321 | $options = [ |
||||||
| 322 | 'N' => _AM_TDMDOWNLOADS_FORMDATEUPDATE_NO . ' (' . formatTimestamp($v_date, 's') . ')', |
||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||
| 323 | 'Y' => _AM_TDMDOWNLOADS_FORMDATEUPDATE_YES, |
||||||
| 324 | ]; |
||||||
| 325 | $date->addOptionArray($options); |
||||||
| 326 | $selection_date->addElement($date); |
||||||
| 327 | $selection_date->addElement(new \XoopsFormTextDateSelect('', 'date', '', time())); |
||||||
|
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
Loading history...
|
|||||||
| 328 | $form->addElement($selection_date); |
||||||
| 329 | } |
||||||
| 330 | $status = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_FORMSTATUS, 'status', $v_status); |
||||||
| 331 | $status->addOption(1, _AM_TDMDOWNLOADS_FORMSTATUS_OK); |
||||||
| 332 | $form->addElement($status); |
||||||
| 333 | //permissions pour télécharger |
||||||
| 334 | if (2 == $helper->getConfig('permission_download')) { |
||||||
| 335 | $memberHandler = xoops_getHandler('member'); |
||||||
| 336 | $group_list = $memberHandler->getGroupList(); |
||||||
| 337 | $grouppermHandler = xoops_getHandler('groupperm'); |
||||||
| 338 | $full_list = array_keys($group_list); |
||||||
| 339 | global $xoopsModule; |
||||||
| 340 | if (!$this->isNew()) { |
||||||
| 341 | $item_ids_download = $grouppermHandler->getGroupIds('tdmdownloads_download_item', $this->getVar('lid'), $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
Loading history...
|
|||||||
| 342 | $item_ids_downloa = array_values($item_ids_download); |
||||||
| 343 | $item_news_can_download_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_FORMPERMDOWNLOAD, 'item_download[]', $item_ids_download); |
||||||
| 344 | } else { |
||||||
| 345 | $item_news_can_download_checkbox = new \XoopsFormCheckBox(_AM_TDMDOWNLOADS_FORMPERMDOWNLOAD, 'item_download[]', $full_list); |
||||||
| 346 | } |
||||||
| 347 | $item_news_can_download_checkbox->addOptionArray($group_list); |
||||||
| 348 | $form->addElement($item_news_can_download_checkbox); |
||||||
| 349 | } |
||||||
| 350 | } |
||||||
| 351 | } |
||||||
| 352 | //paypal |
||||||
| 353 | if (true === $helper->getConfig('use_paypal')) { |
||||||
| 354 | $form->addElement(new \XoopsFormText(_AM_TDMDOWNLOADS_FORMPAYPAL, 'paypal', 50, 255, $this->getVar('paypal')), false); |
||||||
| 355 | } else { |
||||||
| 356 | $form->addElement(new \XoopsFormHidden('paypal', '')); |
||||||
| 357 | } |
||||||
| 358 | // captcha |
||||||
| 359 | $form->addElement(new \XoopsFormCaptcha(), true); |
||||||
| 360 | // pour passer "lid" si on modifie la catégorie |
||||||
| 361 | if (!$this->isNew()) { |
||||||
| 362 | $form->addElement(new \XoopsFormHidden('lid', $this->getVar('lid'))); |
||||||
|
0 ignored issues
–
show
It seems like
$this->getVar('lid') 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
Loading history...
|
|||||||
| 363 | $form->addElement(new \XoopsFormHidden('downloads_modified', true)); |
||||||
|
0 ignored issues
–
show
true of type true is incompatible with the type string expected by parameter $value of XoopsFormHidden::__construct().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 364 | } |
||||||
| 365 | //pour enregistrer le formulaire |
||||||
| 366 | $form->addElement(new \XoopsFormHidden('op', 'save_downloads')); |
||||||
| 367 | //bouton d'envoi du formulaire |
||||||
| 368 | $form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
||||||
| 369 | |||||||
| 370 | return $form; |
||||||
| 371 | } |
||||||
| 372 | } |
||||||
| 373 |