@@ -40,204 +40,204 @@ |
||
| 40 | 40 | exit(); |
| 41 | 41 | } |
| 42 | 42 | switch($op) { |
| 43 | - case 'form': |
|
| 44 | - default: |
|
| 45 | - // Navigation |
|
| 46 | - $navigation = _MA_MYMODULE2_SUBMIT_PROPOSER; |
|
| 47 | - $GLOBALS['xoopsTpl']->assign('navigation', $navigation); |
|
| 48 | - // Title of page |
|
| 49 | - $title = _MA_MYMODULE2_SUBMIT_PROPOSER . ' - '; |
|
| 50 | - $title .= $GLOBALS['xoopsModule']->name(); |
|
| 51 | - $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title); |
|
| 52 | - // Description |
|
| 53 | - $GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags(_MA_MYMODULE2_SUBMIT_PROPOSER)); |
|
| 54 | - // Form Create |
|
| 55 | - $testfieldsObj = $testfieldsHandler->create(); |
|
| 56 | - $form = $testfieldsObj->getFormTestfields(); |
|
| 57 | - $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
| 43 | + case 'form': |
|
| 44 | + default: |
|
| 45 | + // Navigation |
|
| 46 | + $navigation = _MA_MYMODULE2_SUBMIT_PROPOSER; |
|
| 47 | + $GLOBALS['xoopsTpl']->assign('navigation', $navigation); |
|
| 48 | + // Title of page |
|
| 49 | + $title = _MA_MYMODULE2_SUBMIT_PROPOSER . ' - '; |
|
| 50 | + $title .= $GLOBALS['xoopsModule']->name(); |
|
| 51 | + $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title); |
|
| 52 | + // Description |
|
| 53 | + $GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags(_MA_MYMODULE2_SUBMIT_PROPOSER)); |
|
| 54 | + // Form Create |
|
| 55 | + $testfieldsObj = $testfieldsHandler->create(); |
|
| 56 | + $form = $testfieldsObj->getFormTestfields(); |
|
| 57 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
| 58 | 58 | |
| 59 | - break; |
|
| 60 | - case 'save': |
|
| 61 | - // Security Check |
|
| 62 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 63 | - redirect_header('testfields.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 64 | - } |
|
| 65 | - $testfieldsObj = $testfieldsHandler->create(); |
|
| 66 | - $testfieldsObj->setVar('tf_text', Request::getString('tf_text', '')); |
|
| 67 | - $testfieldsObj->setVar('tf_textarea', Request::getString('tf_textarea', '')); |
|
| 68 | - $testfieldsObj->setVar('tf_dhtml', Request::getString('tf_dhtml', '')); |
|
| 69 | - $testfieldsObj->setVar('tf_checkbox', Request::getInt('tf_checkbox', 0)); |
|
| 70 | - $testfieldsObj->setVar('tf_yesno', Request::getInt('tf_yesno', 0)); |
|
| 71 | - $testfieldsObj->setVar('tf_selectbox', Request::getString('tf_selectbox', '')); |
|
| 72 | - $testfieldsObj->setVar('tf_user', Request::getInt('tf_user', 0)); |
|
| 73 | - $testfieldsObj->setVar('tf_color', Request::getString('tf_color', '')); |
|
| 74 | - // Set Var tf_imagelist |
|
| 75 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 76 | - $uploader = new \XoopsMediaUploader(XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32', |
|
| 77 | - $helper->getConfig('mimetypes_image'), |
|
| 78 | - $helper->getConfig('maxsize_image'), null, null); |
|
| 79 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
|
| 80 | - //$uploader->setPrefix(tf_imagelist_); |
|
| 81 | - //$uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
|
| 82 | - if (!$uploader->upload()) { |
|
| 83 | - $errors = $uploader->getErrors(); |
|
| 84 | - redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 85 | - } else { |
|
| 86 | - $testfieldsObj->setVar('tf_imagelist', $uploader->getSavedFileName()); |
|
| 87 | - } |
|
| 88 | - } else { |
|
| 89 | - $testfieldsObj->setVar('tf_imagelist', Request::getString('tf_imagelist')); |
|
| 90 | - } |
|
| 91 | - $testfieldsObj->setVar('tf_urlfile', formatUrl($_REQUEST['tf_urlfile'])); |
|
| 92 | - // Set Var tf_urlfile |
|
| 93 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 94 | - $filename = $_FILES['tf_urlfile']['name']; |
|
| 95 | - $imgNameDef = Request::getString('tf_text'); |
|
| 96 | - $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/testfields/', |
|
| 97 | - $helper->getConfig('mimetypes_file'), |
|
| 98 | - $helper->getConfig('maxsize_file'), null, null); |
|
| 99 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][1])) { |
|
| 100 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 101 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 102 | - $uploader->setPrefix($imgName); |
|
| 103 | - $uploader->fetchMedia($_POST['xoops_upload_file'][1]); |
|
| 104 | - if (!$uploader->upload()) { |
|
| 105 | - $errors = $uploader->getErrors(); |
|
| 106 | - } else { |
|
| 107 | - $testfieldsObj->setVar('tf_urlfile', $uploader->getSavedFileName()); |
|
| 108 | - } |
|
| 109 | - } else { |
|
| 110 | - if ($filename > '') { |
|
| 111 | - $uploaderErrors = $uploader->getErrors(); |
|
| 112 | - } |
|
| 113 | - $testfieldsObj->setVar('tf_urlfile', Request::getString('tf_urlfile')); |
|
| 114 | - } |
|
| 115 | - // Set Var tf_uplimage |
|
| 116 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 117 | - $filename = $_FILES['tf_uplimage']['name']; |
|
| 118 | - $imgMimetype = $_FILES['tf_uplimage']['type']; |
|
| 119 | - $imgNameDef = Request::getString('tf_text'); |
|
| 120 | - $uploaderErrors = ''; |
|
| 121 | - $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_IMAGE_PATH . '/testfields/', |
|
| 122 | - $helper->getConfig('mimetypes_image'), |
|
| 123 | - $helper->getConfig('maxsize_image'), null, null); |
|
| 124 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][2])) { |
|
| 125 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 126 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 127 | - $uploader->setPrefix($imgName); |
|
| 128 | - $uploader->fetchMedia($_POST['xoops_upload_file'][2]); |
|
| 129 | - if (!$uploader->upload()) { |
|
| 130 | - $uploaderErrors = $uploader->getErrors(); |
|
| 131 | - } else { |
|
| 132 | - $savedFilename = $uploader->getSavedFileName(); |
|
| 133 | - $maxwidth = (int)$helper->getConfig('maxwidth_image'); |
|
| 134 | - $maxheight = (int)$helper->getConfig('maxheight_image'); |
|
| 135 | - if ($maxwidth > 0 && $maxheight > 0) { |
|
| 136 | - // Resize image |
|
| 137 | - $imgHandler = new Mymodule2\Common\Resizer(); |
|
| 138 | - $imgHandler->sourceFile = MYMODULE2_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 139 | - $imgHandler->endFile = MYMODULE2_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 140 | - $imgHandler->imageMimetype = $imgMimetype; |
|
| 141 | - $imgHandler->maxWidth = $maxwidth; |
|
| 142 | - $imgHandler->maxHeight = $maxheight; |
|
| 143 | - $result = $imgHandler->resizeImage(); |
|
| 144 | - } |
|
| 145 | - $testfieldsObj->setVar('tf_uplimage', $savedFilename); |
|
| 146 | - } |
|
| 147 | - } else { |
|
| 148 | - if ($filename > '') { |
|
| 149 | - $uploaderErrors = $uploader->getErrors(); |
|
| 150 | - } |
|
| 151 | - $testfieldsObj->setVar('tf_uplimage', Request::getString('tf_uplimage')); |
|
| 152 | - } |
|
| 153 | - // Set Var tf_uplfile |
|
| 154 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 155 | - $filename = $_FILES['tf_uplfile']['name']; |
|
| 156 | - $imgNameDef = Request::getString('tf_text'); |
|
| 157 | - $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/testfields/', |
|
| 158 | - $helper->getConfig('mimetypes_file'), |
|
| 159 | - $helper->getConfig('maxsize_file'), null, null); |
|
| 160 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][3])) { |
|
| 161 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 162 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 163 | - $uploader->setPrefix($imgName); |
|
| 164 | - $uploader->fetchMedia($_POST['xoops_upload_file'][3]); |
|
| 165 | - if (!$uploader->upload()) { |
|
| 166 | - $errors = $uploader->getErrors(); |
|
| 167 | - } else { |
|
| 168 | - $testfieldsObj->setVar('tf_uplfile', $uploader->getSavedFileName()); |
|
| 169 | - } |
|
| 170 | - } else { |
|
| 171 | - if ($filename > '') { |
|
| 172 | - $uploaderErrors = $uploader->getErrors(); |
|
| 173 | - } |
|
| 174 | - $testfieldsObj->setVar('tf_uplfile', Request::getString('tf_uplfile')); |
|
| 175 | - } |
|
| 176 | - $testfieldTextdateselect = date_create_from_format(_SHORTDATESTRING, Request::getString('tf_textdateselect')); |
|
| 177 | - $testfieldsObj->setVar('tf_textdateselect', $testfieldTextdateselect->getTimestamp()); |
|
| 178 | - // Set Var tf_selectfile |
|
| 179 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 180 | - $filename = $_FILES['tf_selectfile']['name']; |
|
| 181 | - $imgNameDef = Request::getString('tf_text'); |
|
| 182 | - $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/testfields/', |
|
| 183 | - $helper->getConfig('mimetypes_file'), |
|
| 184 | - $helper->getConfig('maxsize_file'), null, null); |
|
| 185 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][4])) { |
|
| 186 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 187 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 188 | - $uploader->setPrefix($imgName); |
|
| 189 | - $uploader->fetchMedia($_POST['xoops_upload_file'][4]); |
|
| 190 | - if (!$uploader->upload()) { |
|
| 191 | - $errors = $uploader->getErrors(); |
|
| 192 | - } else { |
|
| 193 | - $testfieldsObj->setVar('tf_selectfile', $uploader->getSavedFileName()); |
|
| 194 | - } |
|
| 195 | - } else { |
|
| 196 | - if ($filename > '') { |
|
| 197 | - $uploaderErrors = $uploader->getErrors(); |
|
| 198 | - } |
|
| 199 | - $testfieldsObj->setVar('tf_selectfile', Request::getString('tf_selectfile')); |
|
| 200 | - } |
|
| 201 | - $testfieldsObj->setVar('tf_status', Request::getInt('tf_status', 0)); |
|
| 202 | - // Insert Data |
|
| 203 | - if ($testfieldsHandler->insert($testfieldsObj)) { |
|
| 204 | - $newTfId = $testfieldsObj->getNewInsertedIdTestfields(); |
|
| 205 | - $permId = isset($_REQUEST['tf_id']) ? $tfId : $newTfId; |
|
| 206 | - $grouppermHandler = xoops_getHandler('groupperm'); |
|
| 207 | - $mid = $GLOBALS['xoopsModule']->getVar('mid'); |
|
| 208 | - // Permission to view_testfields |
|
| 209 | - $grouppermHandler->deleteByModule($mid, 'mymodule2_view_testfields', $permId); |
|
| 210 | - if (isset($_POST['groups_view_testfields'])) { |
|
| 211 | - foreach($_POST['groups_view_testfields'] as $onegroupId) { |
|
| 212 | - $grouppermHandler->addRight('mymodule2_view_testfields', $permId, $onegroupId, $mid); |
|
| 213 | - } |
|
| 214 | - } |
|
| 215 | - // Permission to submit_testfields |
|
| 216 | - $grouppermHandler->deleteByModule($mid, 'mymodule2_submit_testfields', $permId); |
|
| 217 | - if (isset($_POST['groups_submit_testfields'])) { |
|
| 218 | - foreach($_POST['groups_submit_testfields'] as $onegroupId) { |
|
| 219 | - $grouppermHandler->addRight('mymodule2_submit_testfields', $permId, $onegroupId, $mid); |
|
| 220 | - } |
|
| 221 | - } |
|
| 222 | - // Permission to approve_testfields |
|
| 223 | - $grouppermHandler->deleteByModule($mid, 'mymodule2_approve_testfields', $permId); |
|
| 224 | - if (isset($_POST['groups_approve_testfields'])) { |
|
| 225 | - foreach($_POST['groups_approve_testfields'] as $onegroupId) { |
|
| 226 | - $grouppermHandler->addRight('mymodule2_approve_testfields', $permId, $onegroupId, $mid); |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - if ('' !== $uploaderErrors) { |
|
| 230 | - redirect_header('testfields.php?op=edit&tf_id=' . $tfId, 5, $uploaderErrors); |
|
| 231 | - } else { |
|
| 232 | - redirect_header('testfields.php?op=list', 2, _MA_MYMODULE2_FORM_OK); |
|
| 233 | - } |
|
| 234 | - } |
|
| 235 | - // Get Form Error |
|
| 236 | - $GLOBALS['xoopsTpl']->assign('error', $testfieldsObj->getHtmlErrors()); |
|
| 237 | - $form = $testfieldsObj->getFormTestfields(); |
|
| 238 | - $GLOBALS['xoopsTpl']->assign('form', $form->display()); |
|
| 59 | + break; |
|
| 60 | + case 'save': |
|
| 61 | + // Security Check |
|
| 62 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 63 | + redirect_header('testfields.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 64 | + } |
|
| 65 | + $testfieldsObj = $testfieldsHandler->create(); |
|
| 66 | + $testfieldsObj->setVar('tf_text', Request::getString('tf_text', '')); |
|
| 67 | + $testfieldsObj->setVar('tf_textarea', Request::getString('tf_textarea', '')); |
|
| 68 | + $testfieldsObj->setVar('tf_dhtml', Request::getString('tf_dhtml', '')); |
|
| 69 | + $testfieldsObj->setVar('tf_checkbox', Request::getInt('tf_checkbox', 0)); |
|
| 70 | + $testfieldsObj->setVar('tf_yesno', Request::getInt('tf_yesno', 0)); |
|
| 71 | + $testfieldsObj->setVar('tf_selectbox', Request::getString('tf_selectbox', '')); |
|
| 72 | + $testfieldsObj->setVar('tf_user', Request::getInt('tf_user', 0)); |
|
| 73 | + $testfieldsObj->setVar('tf_color', Request::getString('tf_color', '')); |
|
| 74 | + // Set Var tf_imagelist |
|
| 75 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 76 | + $uploader = new \XoopsMediaUploader(XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32', |
|
| 77 | + $helper->getConfig('mimetypes_image'), |
|
| 78 | + $helper->getConfig('maxsize_image'), null, null); |
|
| 79 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
|
| 80 | + //$uploader->setPrefix(tf_imagelist_); |
|
| 81 | + //$uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
|
| 82 | + if (!$uploader->upload()) { |
|
| 83 | + $errors = $uploader->getErrors(); |
|
| 84 | + redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 85 | + } else { |
|
| 86 | + $testfieldsObj->setVar('tf_imagelist', $uploader->getSavedFileName()); |
|
| 87 | + } |
|
| 88 | + } else { |
|
| 89 | + $testfieldsObj->setVar('tf_imagelist', Request::getString('tf_imagelist')); |
|
| 90 | + } |
|
| 91 | + $testfieldsObj->setVar('tf_urlfile', formatUrl($_REQUEST['tf_urlfile'])); |
|
| 92 | + // Set Var tf_urlfile |
|
| 93 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 94 | + $filename = $_FILES['tf_urlfile']['name']; |
|
| 95 | + $imgNameDef = Request::getString('tf_text'); |
|
| 96 | + $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/testfields/', |
|
| 97 | + $helper->getConfig('mimetypes_file'), |
|
| 98 | + $helper->getConfig('maxsize_file'), null, null); |
|
| 99 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][1])) { |
|
| 100 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 101 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 102 | + $uploader->setPrefix($imgName); |
|
| 103 | + $uploader->fetchMedia($_POST['xoops_upload_file'][1]); |
|
| 104 | + if (!$uploader->upload()) { |
|
| 105 | + $errors = $uploader->getErrors(); |
|
| 106 | + } else { |
|
| 107 | + $testfieldsObj->setVar('tf_urlfile', $uploader->getSavedFileName()); |
|
| 108 | + } |
|
| 109 | + } else { |
|
| 110 | + if ($filename > '') { |
|
| 111 | + $uploaderErrors = $uploader->getErrors(); |
|
| 112 | + } |
|
| 113 | + $testfieldsObj->setVar('tf_urlfile', Request::getString('tf_urlfile')); |
|
| 114 | + } |
|
| 115 | + // Set Var tf_uplimage |
|
| 116 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 117 | + $filename = $_FILES['tf_uplimage']['name']; |
|
| 118 | + $imgMimetype = $_FILES['tf_uplimage']['type']; |
|
| 119 | + $imgNameDef = Request::getString('tf_text'); |
|
| 120 | + $uploaderErrors = ''; |
|
| 121 | + $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_IMAGE_PATH . '/testfields/', |
|
| 122 | + $helper->getConfig('mimetypes_image'), |
|
| 123 | + $helper->getConfig('maxsize_image'), null, null); |
|
| 124 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][2])) { |
|
| 125 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 126 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 127 | + $uploader->setPrefix($imgName); |
|
| 128 | + $uploader->fetchMedia($_POST['xoops_upload_file'][2]); |
|
| 129 | + if (!$uploader->upload()) { |
|
| 130 | + $uploaderErrors = $uploader->getErrors(); |
|
| 131 | + } else { |
|
| 132 | + $savedFilename = $uploader->getSavedFileName(); |
|
| 133 | + $maxwidth = (int)$helper->getConfig('maxwidth_image'); |
|
| 134 | + $maxheight = (int)$helper->getConfig('maxheight_image'); |
|
| 135 | + if ($maxwidth > 0 && $maxheight > 0) { |
|
| 136 | + // Resize image |
|
| 137 | + $imgHandler = new Mymodule2\Common\Resizer(); |
|
| 138 | + $imgHandler->sourceFile = MYMODULE2_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 139 | + $imgHandler->endFile = MYMODULE2_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 140 | + $imgHandler->imageMimetype = $imgMimetype; |
|
| 141 | + $imgHandler->maxWidth = $maxwidth; |
|
| 142 | + $imgHandler->maxHeight = $maxheight; |
|
| 143 | + $result = $imgHandler->resizeImage(); |
|
| 144 | + } |
|
| 145 | + $testfieldsObj->setVar('tf_uplimage', $savedFilename); |
|
| 146 | + } |
|
| 147 | + } else { |
|
| 148 | + if ($filename > '') { |
|
| 149 | + $uploaderErrors = $uploader->getErrors(); |
|
| 150 | + } |
|
| 151 | + $testfieldsObj->setVar('tf_uplimage', Request::getString('tf_uplimage')); |
|
| 152 | + } |
|
| 153 | + // Set Var tf_uplfile |
|
| 154 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 155 | + $filename = $_FILES['tf_uplfile']['name']; |
|
| 156 | + $imgNameDef = Request::getString('tf_text'); |
|
| 157 | + $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/testfields/', |
|
| 158 | + $helper->getConfig('mimetypes_file'), |
|
| 159 | + $helper->getConfig('maxsize_file'), null, null); |
|
| 160 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][3])) { |
|
| 161 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 162 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 163 | + $uploader->setPrefix($imgName); |
|
| 164 | + $uploader->fetchMedia($_POST['xoops_upload_file'][3]); |
|
| 165 | + if (!$uploader->upload()) { |
|
| 166 | + $errors = $uploader->getErrors(); |
|
| 167 | + } else { |
|
| 168 | + $testfieldsObj->setVar('tf_uplfile', $uploader->getSavedFileName()); |
|
| 169 | + } |
|
| 170 | + } else { |
|
| 171 | + if ($filename > '') { |
|
| 172 | + $uploaderErrors = $uploader->getErrors(); |
|
| 173 | + } |
|
| 174 | + $testfieldsObj->setVar('tf_uplfile', Request::getString('tf_uplfile')); |
|
| 175 | + } |
|
| 176 | + $testfieldTextdateselect = date_create_from_format(_SHORTDATESTRING, Request::getString('tf_textdateselect')); |
|
| 177 | + $testfieldsObj->setVar('tf_textdateselect', $testfieldTextdateselect->getTimestamp()); |
|
| 178 | + // Set Var tf_selectfile |
|
| 179 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 180 | + $filename = $_FILES['tf_selectfile']['name']; |
|
| 181 | + $imgNameDef = Request::getString('tf_text'); |
|
| 182 | + $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/testfields/', |
|
| 183 | + $helper->getConfig('mimetypes_file'), |
|
| 184 | + $helper->getConfig('maxsize_file'), null, null); |
|
| 185 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][4])) { |
|
| 186 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 187 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 188 | + $uploader->setPrefix($imgName); |
|
| 189 | + $uploader->fetchMedia($_POST['xoops_upload_file'][4]); |
|
| 190 | + if (!$uploader->upload()) { |
|
| 191 | + $errors = $uploader->getErrors(); |
|
| 192 | + } else { |
|
| 193 | + $testfieldsObj->setVar('tf_selectfile', $uploader->getSavedFileName()); |
|
| 194 | + } |
|
| 195 | + } else { |
|
| 196 | + if ($filename > '') { |
|
| 197 | + $uploaderErrors = $uploader->getErrors(); |
|
| 198 | + } |
|
| 199 | + $testfieldsObj->setVar('tf_selectfile', Request::getString('tf_selectfile')); |
|
| 200 | + } |
|
| 201 | + $testfieldsObj->setVar('tf_status', Request::getInt('tf_status', 0)); |
|
| 202 | + // Insert Data |
|
| 203 | + if ($testfieldsHandler->insert($testfieldsObj)) { |
|
| 204 | + $newTfId = $testfieldsObj->getNewInsertedIdTestfields(); |
|
| 205 | + $permId = isset($_REQUEST['tf_id']) ? $tfId : $newTfId; |
|
| 206 | + $grouppermHandler = xoops_getHandler('groupperm'); |
|
| 207 | + $mid = $GLOBALS['xoopsModule']->getVar('mid'); |
|
| 208 | + // Permission to view_testfields |
|
| 209 | + $grouppermHandler->deleteByModule($mid, 'mymodule2_view_testfields', $permId); |
|
| 210 | + if (isset($_POST['groups_view_testfields'])) { |
|
| 211 | + foreach($_POST['groups_view_testfields'] as $onegroupId) { |
|
| 212 | + $grouppermHandler->addRight('mymodule2_view_testfields', $permId, $onegroupId, $mid); |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | + // Permission to submit_testfields |
|
| 216 | + $grouppermHandler->deleteByModule($mid, 'mymodule2_submit_testfields', $permId); |
|
| 217 | + if (isset($_POST['groups_submit_testfields'])) { |
|
| 218 | + foreach($_POST['groups_submit_testfields'] as $onegroupId) { |
|
| 219 | + $grouppermHandler->addRight('mymodule2_submit_testfields', $permId, $onegroupId, $mid); |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | + // Permission to approve_testfields |
|
| 223 | + $grouppermHandler->deleteByModule($mid, 'mymodule2_approve_testfields', $permId); |
|
| 224 | + if (isset($_POST['groups_approve_testfields'])) { |
|
| 225 | + foreach($_POST['groups_approve_testfields'] as $onegroupId) { |
|
| 226 | + $grouppermHandler->addRight('mymodule2_approve_testfields', $permId, $onegroupId, $mid); |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + if ('' !== $uploaderErrors) { |
|
| 230 | + redirect_header('testfields.php?op=edit&tf_id=' . $tfId, 5, $uploaderErrors); |
|
| 231 | + } else { |
|
| 232 | + redirect_header('testfields.php?op=list', 2, _MA_MYMODULE2_FORM_OK); |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | + // Get Form Error |
|
| 236 | + $GLOBALS['xoopsTpl']->assign('error', $testfieldsObj->getHtmlErrors()); |
|
| 237 | + $form = $testfieldsObj->getFormTestfields(); |
|
| 238 | + $GLOBALS['xoopsTpl']->assign('form', $form->display()); |
|
| 239 | 239 | |
| 240 | - break; |
|
| 240 | + break; |
|
| 241 | 241 | } |
| 242 | 242 | // Breadcrumbs |
| 243 | 243 | $xoBreadcrumbs[] = ['title' => _MA_MYMODULE2_SUBMIT]; |
@@ -37,187 +37,187 @@ |
||
| 37 | 37 | exit(); |
| 38 | 38 | } |
| 39 | 39 | switch($op) { |
| 40 | - case 'form': |
|
| 41 | - default: |
|
| 42 | - // Navigation |
|
| 43 | - $navigation = _MA_MYMODULE2_SUBMIT_PROPOSER; |
|
| 44 | - $GLOBALS['xoopsTpl']->assign('navigation', $navigation); |
|
| 45 | - // Title of page |
|
| 46 | - $title = _MA_MYMODULE2_SUBMIT_PROPOSER . ' - '; |
|
| 47 | - $title .= $GLOBALS['xoopsModule']->name(); |
|
| 48 | - $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title); |
|
| 49 | - // Description |
|
| 50 | - $GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags(_MA_MYMODULE2_SUBMIT_PROPOSER)); |
|
| 51 | - // Form Create |
|
| 52 | - $testfieldsObj = $testfieldsHandler->create(); |
|
| 53 | - $form = $testfieldsObj->getFormTestfields(); |
|
| 54 | - $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
| 40 | + case 'form': |
|
| 41 | + default: |
|
| 42 | + // Navigation |
|
| 43 | + $navigation = _MA_MYMODULE2_SUBMIT_PROPOSER; |
|
| 44 | + $GLOBALS['xoopsTpl']->assign('navigation', $navigation); |
|
| 45 | + // Title of page |
|
| 46 | + $title = _MA_MYMODULE2_SUBMIT_PROPOSER . ' - '; |
|
| 47 | + $title .= $GLOBALS['xoopsModule']->name(); |
|
| 48 | + $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title); |
|
| 49 | + // Description |
|
| 50 | + $GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags(_MA_MYMODULE2_SUBMIT_PROPOSER)); |
|
| 51 | + // Form Create |
|
| 52 | + $testfieldsObj = $testfieldsHandler->create(); |
|
| 53 | + $form = $testfieldsObj->getFormTestfields(); |
|
| 54 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
| 55 | 55 | |
| 56 | - break; |
|
| 57 | - case 'save': |
|
| 58 | - // Security Check |
|
| 59 | - if ($GLOBALS['xoopsSecurity']->check()) { |
|
| 60 | - redirect_header('testfields.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 61 | - } |
|
| 62 | - $testfieldsObj = $testfieldsHandler->create(); |
|
| 63 | - $error = false; |
|
| 64 | - $errorMessage = ''; |
|
| 65 | - // Test first the validation |
|
| 66 | - xoops_load('captcha'); |
|
| 67 | - $xoopsCaptcha = \XoopsCaptcha::getInstance(); |
|
| 68 | - if (!$xoopsCaptcha->verify()) { |
|
| 69 | - $errorMessage .= $xoopsCaptcha->getMessage().'<br>'; |
|
| 70 | - $error = true; |
|
| 71 | - } |
|
| 72 | - $testfieldsObj->setVar('tf_text', Request::getString('tf_text', '')); |
|
| 73 | - $testfieldsObj->setVar('tf_textarea', Request::getString('tf_textarea', '')); |
|
| 74 | - $testfieldsObj->setVar('tf_dhtml', Request::getString('tf_dhtml', '')); |
|
| 75 | - $testfieldsObj->setVar('tf_checkbox', Request::getInt('tf_checkbox', 0)); |
|
| 76 | - $testfieldsObj->setVar('tf_yesno', Request::getInt('tf_yesno', 0)); |
|
| 77 | - $testfieldsObj->setVar('tf_selectbox', Request::getString('tf_selectbox', '')); |
|
| 78 | - $testfieldsObj->setVar('tf_user', Request::getInt('tf_user', 0)); |
|
| 79 | - $testfieldsObj->setVar('tf_color', Request::getString('tf_color', '')); |
|
| 80 | - // Set Var tf_imagelist |
|
| 81 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 82 | - $uploader = new \XoopsMediaUploader(XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32', |
|
| 83 | - $helper->getConfig('mimetypes_image'), |
|
| 84 | - $helper->getConfig('maxsize_image'), null, null); |
|
| 85 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
|
| 86 | - //$uploader->setPrefix(tf_imagelist_); |
|
| 87 | - //$uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
|
| 88 | - if (!$uploader->upload()) { |
|
| 89 | - $errors = $uploader->getErrors(); |
|
| 90 | - redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 91 | - } else { |
|
| 92 | - $testfieldsObj->setVar('tf_imagelist', $uploader->getSavedFileName()); |
|
| 93 | - } |
|
| 94 | - } else { |
|
| 95 | - $testfieldsObj->setVar('tf_imagelist', Request::getString('tf_imagelist')); |
|
| 96 | - } |
|
| 97 | - $testfieldsObj->setVar('tf_urlfile', formatUrl($_REQUEST['tf_urlfile'])); |
|
| 98 | - // Set Var tf_urlfile |
|
| 99 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 100 | - $filename = $_FILES['tf_urlfile']['name']; |
|
| 101 | - $imgNameDef = Request::getString('tf_text'); |
|
| 102 | - $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/testfields/', |
|
| 103 | - $helper->getConfig('mimetypes_file'), |
|
| 104 | - $helper->getConfig('maxsize_file'), null, null); |
|
| 105 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][1])) { |
|
| 106 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 107 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 108 | - $uploader->setPrefix($imgName); |
|
| 109 | - $uploader->fetchMedia($_POST['xoops_upload_file'][1]); |
|
| 110 | - if (!$uploader->upload()) { |
|
| 111 | - $errors = $uploader->getErrors(); |
|
| 112 | - } else { |
|
| 113 | - $testfieldsObj->setVar('tf_urlfile', $uploader->getSavedFileName()); |
|
| 114 | - } |
|
| 115 | - } else { |
|
| 116 | - if ($filename > '') { |
|
| 117 | - $uploaderErrors = $uploader->getErrors(); |
|
| 118 | - } |
|
| 119 | - $testfieldsObj->setVar('tf_urlfile', Request::getString('tf_urlfile')); |
|
| 120 | - } |
|
| 121 | - // Set Var tf_uplimage |
|
| 122 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 123 | - $filename = $_FILES['tf_uplimage']['name']; |
|
| 124 | - $imgMimetype = $_FILES['tf_uplimage']['type']; |
|
| 125 | - $imgNameDef = Request::getString('tf_text'); |
|
| 126 | - $uploaderErrors = ''; |
|
| 127 | - $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_IMAGE_PATH . '/testfields/', |
|
| 128 | - $helper->getConfig('mimetypes_image'), |
|
| 129 | - $helper->getConfig('maxsize_image'), null, null); |
|
| 130 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][2])) { |
|
| 131 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 132 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 133 | - $uploader->setPrefix($imgName); |
|
| 134 | - $uploader->fetchMedia($_POST['xoops_upload_file'][2]); |
|
| 135 | - if (!$uploader->upload()) { |
|
| 136 | - $uploaderErrors = $uploader->getErrors(); |
|
| 137 | - } else { |
|
| 138 | - $savedFilename = $uploader->getSavedFileName(); |
|
| 139 | - $maxwidth = (int)$helper->getConfig('maxwidth_image'); |
|
| 140 | - $maxheight = (int)$helper->getConfig('maxheight_image'); |
|
| 141 | - if ($maxwidth > 0 && $maxheight > 0) { |
|
| 142 | - // Resize image |
|
| 143 | - $imgHandler = new Mymodule2\Common\Resizer(); |
|
| 144 | - $imgHandler->sourceFile = MYMODULE2_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 145 | - $imgHandler->endFile = MYMODULE2_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 146 | - $imgHandler->imageMimetype = $imgMimetype; |
|
| 147 | - $imgHandler->maxWidth = $maxwidth; |
|
| 148 | - $imgHandler->maxHeight = $maxheight; |
|
| 149 | - $result = $imgHandler->resizeImage(); |
|
| 150 | - } |
|
| 151 | - $testfieldsObj->setVar('tf_uplimage', $savedFilename); |
|
| 152 | - } |
|
| 153 | - } else { |
|
| 154 | - if ($filename > '') { |
|
| 155 | - $uploaderErrors = $uploader->getErrors(); |
|
| 156 | - } |
|
| 157 | - $testfieldsObj->setVar('tf_uplimage', Request::getString('tf_uplimage')); |
|
| 158 | - } |
|
| 159 | - // Set Var tf_uplfile |
|
| 160 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 161 | - $filename = $_FILES['tf_uplfile']['name']; |
|
| 162 | - $imgNameDef = Request::getString('tf_text'); |
|
| 163 | - $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/testfields/', |
|
| 164 | - $helper->getConfig('mimetypes_file'), |
|
| 165 | - $helper->getConfig('maxsize_file'), null, null); |
|
| 166 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][3])) { |
|
| 167 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 168 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 169 | - $uploader->setPrefix($imgName); |
|
| 170 | - $uploader->fetchMedia($_POST['xoops_upload_file'][3]); |
|
| 171 | - if (!$uploader->upload()) { |
|
| 172 | - $errors = $uploader->getErrors(); |
|
| 173 | - } else { |
|
| 174 | - $testfieldsObj->setVar('tf_uplfile', $uploader->getSavedFileName()); |
|
| 175 | - } |
|
| 176 | - } else { |
|
| 177 | - if ($filename > '') { |
|
| 178 | - $uploaderErrors = $uploader->getErrors(); |
|
| 179 | - } |
|
| 180 | - $testfieldsObj->setVar('tf_uplfile', Request::getString('tf_uplfile')); |
|
| 181 | - } |
|
| 182 | - $testfieldTextdateselect = date_create_from_format(_SHORTDATESTRING, Request::getString('tf_textdateselect')); |
|
| 183 | - $testfieldsObj->setVar('tf_textdateselect', $testfieldTextdateselect->getTimestamp()); |
|
| 184 | - // Set Var tf_selectfile |
|
| 185 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 186 | - $filename = $_FILES['tf_selectfile']['name']; |
|
| 187 | - $imgNameDef = Request::getString('tf_text'); |
|
| 188 | - $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/testfields/', |
|
| 189 | - $helper->getConfig('mimetypes_file'), |
|
| 190 | - $helper->getConfig('maxsize_file'), null, null); |
|
| 191 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][4])) { |
|
| 192 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 193 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 194 | - $uploader->setPrefix($imgName); |
|
| 195 | - $uploader->fetchMedia($_POST['xoops_upload_file'][4]); |
|
| 196 | - if (!$uploader->upload()) { |
|
| 197 | - $errors = $uploader->getErrors(); |
|
| 198 | - } else { |
|
| 199 | - $testfieldsObj->setVar('tf_selectfile', $uploader->getSavedFileName()); |
|
| 200 | - } |
|
| 201 | - } else { |
|
| 202 | - if ($filename > '') { |
|
| 203 | - $uploaderErrors = $uploader->getErrors(); |
|
| 204 | - } |
|
| 205 | - $testfieldsObj->setVar('tf_selectfile', Request::getString('tf_selectfile')); |
|
| 206 | - } |
|
| 207 | - $testfieldsObj->setVar('tf_status', Request::getInt('tf_status', 0)); |
|
| 208 | - if ($error === true) { |
|
| 209 | - $GLOBALS['xoopsTpl']->assign('error_message', $errorMessage); |
|
| 210 | - } else { |
|
| 211 | - // Insert Data |
|
| 212 | - if ($testfields1->insert($testfieldsObj)) { |
|
| 213 | - redirect_header('index.php', 2, _MA_MYMODULE2_FORM_OK); |
|
| 214 | - } |
|
| 215 | - } |
|
| 216 | - // Get Form Error |
|
| 217 | - $GLOBALS['xoopsTpl']->assign('error', $testfieldsObj->getHtmlErrors()); |
|
| 218 | - $form = $testfieldsObj->getFormTestfields(); |
|
| 219 | - $GLOBALS['xoopsTpl']->assign('form', $form->display()); |
|
| 56 | + break; |
|
| 57 | + case 'save': |
|
| 58 | + // Security Check |
|
| 59 | + if ($GLOBALS['xoopsSecurity']->check()) { |
|
| 60 | + redirect_header('testfields.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 61 | + } |
|
| 62 | + $testfieldsObj = $testfieldsHandler->create(); |
|
| 63 | + $error = false; |
|
| 64 | + $errorMessage = ''; |
|
| 65 | + // Test first the validation |
|
| 66 | + xoops_load('captcha'); |
|
| 67 | + $xoopsCaptcha = \XoopsCaptcha::getInstance(); |
|
| 68 | + if (!$xoopsCaptcha->verify()) { |
|
| 69 | + $errorMessage .= $xoopsCaptcha->getMessage().'<br>'; |
|
| 70 | + $error = true; |
|
| 71 | + } |
|
| 72 | + $testfieldsObj->setVar('tf_text', Request::getString('tf_text', '')); |
|
| 73 | + $testfieldsObj->setVar('tf_textarea', Request::getString('tf_textarea', '')); |
|
| 74 | + $testfieldsObj->setVar('tf_dhtml', Request::getString('tf_dhtml', '')); |
|
| 75 | + $testfieldsObj->setVar('tf_checkbox', Request::getInt('tf_checkbox', 0)); |
|
| 76 | + $testfieldsObj->setVar('tf_yesno', Request::getInt('tf_yesno', 0)); |
|
| 77 | + $testfieldsObj->setVar('tf_selectbox', Request::getString('tf_selectbox', '')); |
|
| 78 | + $testfieldsObj->setVar('tf_user', Request::getInt('tf_user', 0)); |
|
| 79 | + $testfieldsObj->setVar('tf_color', Request::getString('tf_color', '')); |
|
| 80 | + // Set Var tf_imagelist |
|
| 81 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 82 | + $uploader = new \XoopsMediaUploader(XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32', |
|
| 83 | + $helper->getConfig('mimetypes_image'), |
|
| 84 | + $helper->getConfig('maxsize_image'), null, null); |
|
| 85 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
|
| 86 | + //$uploader->setPrefix(tf_imagelist_); |
|
| 87 | + //$uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
|
| 88 | + if (!$uploader->upload()) { |
|
| 89 | + $errors = $uploader->getErrors(); |
|
| 90 | + redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 91 | + } else { |
|
| 92 | + $testfieldsObj->setVar('tf_imagelist', $uploader->getSavedFileName()); |
|
| 93 | + } |
|
| 94 | + } else { |
|
| 95 | + $testfieldsObj->setVar('tf_imagelist', Request::getString('tf_imagelist')); |
|
| 96 | + } |
|
| 97 | + $testfieldsObj->setVar('tf_urlfile', formatUrl($_REQUEST['tf_urlfile'])); |
|
| 98 | + // Set Var tf_urlfile |
|
| 99 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 100 | + $filename = $_FILES['tf_urlfile']['name']; |
|
| 101 | + $imgNameDef = Request::getString('tf_text'); |
|
| 102 | + $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/testfields/', |
|
| 103 | + $helper->getConfig('mimetypes_file'), |
|
| 104 | + $helper->getConfig('maxsize_file'), null, null); |
|
| 105 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][1])) { |
|
| 106 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 107 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 108 | + $uploader->setPrefix($imgName); |
|
| 109 | + $uploader->fetchMedia($_POST['xoops_upload_file'][1]); |
|
| 110 | + if (!$uploader->upload()) { |
|
| 111 | + $errors = $uploader->getErrors(); |
|
| 112 | + } else { |
|
| 113 | + $testfieldsObj->setVar('tf_urlfile', $uploader->getSavedFileName()); |
|
| 114 | + } |
|
| 115 | + } else { |
|
| 116 | + if ($filename > '') { |
|
| 117 | + $uploaderErrors = $uploader->getErrors(); |
|
| 118 | + } |
|
| 119 | + $testfieldsObj->setVar('tf_urlfile', Request::getString('tf_urlfile')); |
|
| 120 | + } |
|
| 121 | + // Set Var tf_uplimage |
|
| 122 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 123 | + $filename = $_FILES['tf_uplimage']['name']; |
|
| 124 | + $imgMimetype = $_FILES['tf_uplimage']['type']; |
|
| 125 | + $imgNameDef = Request::getString('tf_text'); |
|
| 126 | + $uploaderErrors = ''; |
|
| 127 | + $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_IMAGE_PATH . '/testfields/', |
|
| 128 | + $helper->getConfig('mimetypes_image'), |
|
| 129 | + $helper->getConfig('maxsize_image'), null, null); |
|
| 130 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][2])) { |
|
| 131 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 132 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 133 | + $uploader->setPrefix($imgName); |
|
| 134 | + $uploader->fetchMedia($_POST['xoops_upload_file'][2]); |
|
| 135 | + if (!$uploader->upload()) { |
|
| 136 | + $uploaderErrors = $uploader->getErrors(); |
|
| 137 | + } else { |
|
| 138 | + $savedFilename = $uploader->getSavedFileName(); |
|
| 139 | + $maxwidth = (int)$helper->getConfig('maxwidth_image'); |
|
| 140 | + $maxheight = (int)$helper->getConfig('maxheight_image'); |
|
| 141 | + if ($maxwidth > 0 && $maxheight > 0) { |
|
| 142 | + // Resize image |
|
| 143 | + $imgHandler = new Mymodule2\Common\Resizer(); |
|
| 144 | + $imgHandler->sourceFile = MYMODULE2_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 145 | + $imgHandler->endFile = MYMODULE2_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 146 | + $imgHandler->imageMimetype = $imgMimetype; |
|
| 147 | + $imgHandler->maxWidth = $maxwidth; |
|
| 148 | + $imgHandler->maxHeight = $maxheight; |
|
| 149 | + $result = $imgHandler->resizeImage(); |
|
| 150 | + } |
|
| 151 | + $testfieldsObj->setVar('tf_uplimage', $savedFilename); |
|
| 152 | + } |
|
| 153 | + } else { |
|
| 154 | + if ($filename > '') { |
|
| 155 | + $uploaderErrors = $uploader->getErrors(); |
|
| 156 | + } |
|
| 157 | + $testfieldsObj->setVar('tf_uplimage', Request::getString('tf_uplimage')); |
|
| 158 | + } |
|
| 159 | + // Set Var tf_uplfile |
|
| 160 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 161 | + $filename = $_FILES['tf_uplfile']['name']; |
|
| 162 | + $imgNameDef = Request::getString('tf_text'); |
|
| 163 | + $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/testfields/', |
|
| 164 | + $helper->getConfig('mimetypes_file'), |
|
| 165 | + $helper->getConfig('maxsize_file'), null, null); |
|
| 166 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][3])) { |
|
| 167 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 168 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 169 | + $uploader->setPrefix($imgName); |
|
| 170 | + $uploader->fetchMedia($_POST['xoops_upload_file'][3]); |
|
| 171 | + if (!$uploader->upload()) { |
|
| 172 | + $errors = $uploader->getErrors(); |
|
| 173 | + } else { |
|
| 174 | + $testfieldsObj->setVar('tf_uplfile', $uploader->getSavedFileName()); |
|
| 175 | + } |
|
| 176 | + } else { |
|
| 177 | + if ($filename > '') { |
|
| 178 | + $uploaderErrors = $uploader->getErrors(); |
|
| 179 | + } |
|
| 180 | + $testfieldsObj->setVar('tf_uplfile', Request::getString('tf_uplfile')); |
|
| 181 | + } |
|
| 182 | + $testfieldTextdateselect = date_create_from_format(_SHORTDATESTRING, Request::getString('tf_textdateselect')); |
|
| 183 | + $testfieldsObj->setVar('tf_textdateselect', $testfieldTextdateselect->getTimestamp()); |
|
| 184 | + // Set Var tf_selectfile |
|
| 185 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 186 | + $filename = $_FILES['tf_selectfile']['name']; |
|
| 187 | + $imgNameDef = Request::getString('tf_text'); |
|
| 188 | + $uploader = new \XoopsMediaUploader(MYMODULE2_UPLOAD_FILES_PATH . '/testfields/', |
|
| 189 | + $helper->getConfig('mimetypes_file'), |
|
| 190 | + $helper->getConfig('maxsize_file'), null, null); |
|
| 191 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][4])) { |
|
| 192 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 193 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 194 | + $uploader->setPrefix($imgName); |
|
| 195 | + $uploader->fetchMedia($_POST['xoops_upload_file'][4]); |
|
| 196 | + if (!$uploader->upload()) { |
|
| 197 | + $errors = $uploader->getErrors(); |
|
| 198 | + } else { |
|
| 199 | + $testfieldsObj->setVar('tf_selectfile', $uploader->getSavedFileName()); |
|
| 200 | + } |
|
| 201 | + } else { |
|
| 202 | + if ($filename > '') { |
|
| 203 | + $uploaderErrors = $uploader->getErrors(); |
|
| 204 | + } |
|
| 205 | + $testfieldsObj->setVar('tf_selectfile', Request::getString('tf_selectfile')); |
|
| 206 | + } |
|
| 207 | + $testfieldsObj->setVar('tf_status', Request::getInt('tf_status', 0)); |
|
| 208 | + if ($error === true) { |
|
| 209 | + $GLOBALS['xoopsTpl']->assign('error_message', $errorMessage); |
|
| 210 | + } else { |
|
| 211 | + // Insert Data |
|
| 212 | + if ($testfields1->insert($testfieldsObj)) { |
|
| 213 | + redirect_header('index.php', 2, _MA_MYMODULE2_FORM_OK); |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | + // Get Form Error |
|
| 217 | + $GLOBALS['xoopsTpl']->assign('error', $testfieldsObj->getHtmlErrors()); |
|
| 218 | + $form = $testfieldsObj->getFormTestfields(); |
|
| 219 | + $GLOBALS['xoopsTpl']->assign('form', $form->display()); |
|
| 220 | 220 | |
| 221 | - break; |
|
| 221 | + break; |
|
| 222 | 222 | } |
| 223 | 223 | require __DIR__ . '/footer.php'; |
@@ -40,213 +40,213 @@ |
||
| 40 | 40 | exit(); |
| 41 | 41 | } |
| 42 | 42 | switch($op) { |
| 43 | - case 'form': |
|
| 44 | - default: |
|
| 45 | - // Navigation |
|
| 46 | - $navigation = _MA_MYMODULE3_SUBMIT_PROPOSER; |
|
| 47 | - $GLOBALS['xoopsTpl']->assign('navigation', $navigation); |
|
| 48 | - // Title of page |
|
| 49 | - $title = _MA_MYMODULE3_SUBMIT_PROPOSER . ' - '; |
|
| 50 | - $title .= $GLOBALS['xoopsModule']->name(); |
|
| 51 | - $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title); |
|
| 52 | - // Description |
|
| 53 | - $GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags(_MA_MYMODULE3_SUBMIT_PROPOSER)); |
|
| 54 | - // Form Create |
|
| 55 | - $testfieldsObj = $testfieldsHandler->create(); |
|
| 56 | - $form = $testfieldsObj->getFormTestfields(); |
|
| 57 | - $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
| 58 | - break; |
|
| 59 | - case 'save': |
|
| 60 | - // Security Check |
|
| 61 | - if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 62 | - redirect_header('testfields.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 63 | - } |
|
| 64 | - $testfieldsObj = $testfieldsHandler->create(); |
|
| 65 | - $testfieldsObj->setVar('tf_text', Request::getString('tf_text', '')); |
|
| 66 | - $testfieldsObj->setVar('tf_textarea', Request::getString('tf_textarea', '')); |
|
| 67 | - $testfieldsObj->setVar('tf_dhtml', Request::getString('tf_dhtml', '')); |
|
| 68 | - $testfieldsObj->setVar('tf_checkbox', Request::getInt('tf_checkbox', 0)); |
|
| 69 | - $testfieldsObj->setVar('tf_yesno', Request::getInt('tf_yesno', 0)); |
|
| 70 | - $testfieldsObj->setVar('tf_selectbox', Request::getInt('tf_selectbox', 0)); |
|
| 71 | - $testfieldsObj->setVar('tf_user', Request::getInt('tf_user', 0)); |
|
| 72 | - $testfieldsObj->setVar('tf_color', Request::getString('tf_color', '')); |
|
| 73 | - // Set Var tf_imagelist |
|
| 74 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 75 | - $uploader = new \XoopsMediaUploader(XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32', |
|
| 76 | - $helper->getConfig('mimetypes_image'), |
|
| 77 | - $helper->getConfig('maxsize_image'), null, null); |
|
| 78 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
|
| 79 | - //$uploader->setPrefix(tf_imagelist_); |
|
| 80 | - //$uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
|
| 81 | - if (!$uploader->upload()) { |
|
| 82 | - $errors = $uploader->getErrors(); |
|
| 83 | - redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 84 | - } else { |
|
| 85 | - $testfieldsObj->setVar('tf_imagelist', $uploader->getSavedFileName()); |
|
| 86 | - } |
|
| 87 | - } else { |
|
| 88 | - $testfieldsObj->setVar('tf_imagelist', Request::getString('tf_imagelist')); |
|
| 89 | - } |
|
| 90 | - $testfieldsObj->setVar('tf_urlfile', formatUrl($_REQUEST['tf_urlfile'])); |
|
| 91 | - // Set Var tf_urlfile |
|
| 92 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 93 | - $filename = $_FILES['tf_urlfile']['name']; |
|
| 94 | - $imgNameDef = Request::getString('tf_text'); |
|
| 95 | - $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_FILES_PATH . '/testfields/', |
|
| 96 | - $helper->getConfig('mimetypes_file'), |
|
| 97 | - $helper->getConfig('maxsize_file'), null, null); |
|
| 98 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][1])) { |
|
| 99 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 100 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 101 | - $uploader->setPrefix($imgName); |
|
| 102 | - $uploader->fetchMedia($_POST['xoops_upload_file'][1]); |
|
| 103 | - if (!$uploader->upload()) { |
|
| 104 | - $errors = $uploader->getErrors(); |
|
| 105 | - } else { |
|
| 106 | - $testfieldsObj->setVar('tf_urlfile', $uploader->getSavedFileName()); |
|
| 107 | - } |
|
| 108 | - } else { |
|
| 109 | - if ($filename > '') { |
|
| 110 | - $uploaderErrors = $uploader->getErrors(); |
|
| 111 | - } |
|
| 112 | - $testfieldsObj->setVar('tf_urlfile', Request::getString('tf_urlfile')); |
|
| 113 | - } |
|
| 114 | - // Set Var tf_uplimage |
|
| 115 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 116 | - $filename = $_FILES['tf_uplimage']['name']; |
|
| 117 | - $imgMimetype = $_FILES['tf_uplimage']['type']; |
|
| 118 | - $imgNameDef = Request::getString('tf_text'); |
|
| 119 | - $uploaderErrors = ''; |
|
| 120 | - $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_IMAGE_PATH . '/testfields/', |
|
| 121 | - $helper->getConfig('mimetypes_image'), |
|
| 122 | - $helper->getConfig('maxsize_image'), null, null); |
|
| 123 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][2])) { |
|
| 124 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 125 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 126 | - $uploader->setPrefix($imgName); |
|
| 127 | - $uploader->fetchMedia($_POST['xoops_upload_file'][2]); |
|
| 128 | - if (!$uploader->upload()) { |
|
| 129 | - $uploaderErrors = $uploader->getErrors(); |
|
| 130 | - } else { |
|
| 131 | - $savedFilename = $uploader->getSavedFileName(); |
|
| 132 | - $maxwidth = (int)$helper->getConfig('maxwidth_image'); |
|
| 133 | - $maxheight = (int)$helper->getConfig('maxheight_image'); |
|
| 134 | - if ($maxwidth > 0 && $maxheight > 0) { |
|
| 135 | - // Resize image |
|
| 136 | - $imgHandler = new Mymodule3\Common\Resizer(); |
|
| 137 | - $imgHandler->sourceFile = MYMODULE3_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 138 | - $imgHandler->endFile = MYMODULE3_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 139 | - $imgHandler->imageMimetype = $imgMimetype; |
|
| 140 | - $imgHandler->maxWidth = $maxwidth; |
|
| 141 | - $imgHandler->maxHeight = $maxheight; |
|
| 142 | - $result = $imgHandler->resizeImage(); |
|
| 143 | - } |
|
| 144 | - $testfieldsObj->setVar('tf_uplimage', $savedFilename); |
|
| 145 | - } |
|
| 146 | - } else { |
|
| 147 | - if ($filename > '') { |
|
| 148 | - $uploaderErrors = $uploader->getErrors(); |
|
| 149 | - } |
|
| 150 | - $testfieldsObj->setVar('tf_uplimage', Request::getString('tf_uplimage')); |
|
| 151 | - } |
|
| 152 | - // Set Var tf_uplfile |
|
| 153 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 154 | - $filename = $_FILES['tf_uplfile']['name']; |
|
| 155 | - $imgNameDef = Request::getString('tf_text'); |
|
| 156 | - $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_FILES_PATH . '/testfields/', |
|
| 157 | - $helper->getConfig('mimetypes_file'), |
|
| 158 | - $helper->getConfig('maxsize_file'), null, null); |
|
| 159 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][3])) { |
|
| 160 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 161 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 162 | - $uploader->setPrefix($imgName); |
|
| 163 | - $uploader->fetchMedia($_POST['xoops_upload_file'][3]); |
|
| 164 | - if (!$uploader->upload()) { |
|
| 165 | - $errors = $uploader->getErrors(); |
|
| 166 | - } else { |
|
| 167 | - $testfieldsObj->setVar('tf_uplfile', $uploader->getSavedFileName()); |
|
| 168 | - } |
|
| 169 | - } else { |
|
| 170 | - if ($filename > '') { |
|
| 171 | - $uploaderErrors = $uploader->getErrors(); |
|
| 172 | - } |
|
| 173 | - $testfieldsObj->setVar('tf_uplfile', Request::getString('tf_uplfile')); |
|
| 174 | - } |
|
| 175 | - $testfieldTextdateselect = date_create_from_format(_SHORTDATESTRING, Request::getString('tf_textdateselect')); |
|
| 176 | - $testfieldsObj->setVar('tf_textdateselect', $testfieldTextdateselect->getTimestamp()); |
|
| 177 | - // Set Var tf_selectfile |
|
| 178 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 179 | - $filename = $_FILES['tf_selectfile']['name']; |
|
| 180 | - $imgNameDef = Request::getString('tf_text'); |
|
| 181 | - $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_FILES_PATH . '/testfields/', |
|
| 182 | - $helper->getConfig('mimetypes_file'), |
|
| 183 | - $helper->getConfig('maxsize_file'), null, null); |
|
| 184 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][4])) { |
|
| 185 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 186 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 187 | - $uploader->setPrefix($imgName); |
|
| 188 | - $uploader->fetchMedia($_POST['xoops_upload_file'][4]); |
|
| 189 | - if (!$uploader->upload()) { |
|
| 190 | - $errors = $uploader->getErrors(); |
|
| 191 | - } else { |
|
| 192 | - $testfieldsObj->setVar('tf_selectfile', $uploader->getSavedFileName()); |
|
| 193 | - } |
|
| 194 | - } else { |
|
| 195 | - if ($filename > '') { |
|
| 196 | - $uploaderErrors = $uploader->getErrors(); |
|
| 197 | - } |
|
| 198 | - $testfieldsObj->setVar('tf_selectfile', Request::getString('tf_selectfile')); |
|
| 199 | - } |
|
| 200 | - $tfPassword = Request::getString('tf_password', ''); |
|
| 201 | - if ('' !== $tfPassword) { |
|
| 202 | - $testfieldsObj->setVar('tf_password', password_hash($tfPassword, PASSWORD_DEFAULT)); |
|
| 203 | - } |
|
| 204 | - $testfieldsObj->setVar('tf_country_list', Request::getString('tf_country_list', '')); |
|
| 205 | - $testfieldsObj->setVar('tf_language', Request::getString('tf_language', '')); |
|
| 206 | - $testfieldsObj->setVar('tf_radio', Request::getInt('tf_radio', 0)); |
|
| 207 | - $testfieldsObj->setVar('tf_status', Request::getInt('tf_status', 0)); |
|
| 208 | - $testfieldDatetimeArr = Request::getArray('tf_datetime'); |
|
| 209 | - $testfieldDatetime = strtotime($testfieldDatetimeArr['date']) + (int)$testfieldDatetimeArr['time']; |
|
| 210 | - $testfieldsObj->setVar('tf_datetime', $testfieldDatetime); |
|
| 211 | - $testfieldsObj->setVar('tf_combobox', Request::getInt('tf_combobox', 0)); |
|
| 212 | - // Insert Data |
|
| 213 | - if ($testfieldsHandler->insert($testfieldsObj)) { |
|
| 214 | - $newTfId = $testfieldsObj->getNewInsertedIdTestfields(); |
|
| 215 | - $permId = isset($_REQUEST['tf_id']) ? $tfId : $newTfId; |
|
| 216 | - $grouppermHandler = xoops_getHandler('groupperm'); |
|
| 217 | - $mid = $GLOBALS['xoopsModule']->getVar('mid'); |
|
| 218 | - // Permission to view_testfields |
|
| 219 | - $grouppermHandler->deleteByModule($mid, 'mymodule3_view_testfields', $permId); |
|
| 220 | - if (isset($_POST['groups_view_testfields'])) { |
|
| 221 | - foreach($_POST['groups_view_testfields'] as $onegroupId) { |
|
| 222 | - $grouppermHandler->addRight('mymodule3_view_testfields', $permId, $onegroupId, $mid); |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - // Permission to submit_testfields |
|
| 226 | - $grouppermHandler->deleteByModule($mid, 'mymodule3_submit_testfields', $permId); |
|
| 227 | - if (isset($_POST['groups_submit_testfields'])) { |
|
| 228 | - foreach($_POST['groups_submit_testfields'] as $onegroupId) { |
|
| 229 | - $grouppermHandler->addRight('mymodule3_submit_testfields', $permId, $onegroupId, $mid); |
|
| 230 | - } |
|
| 231 | - } |
|
| 232 | - // Permission to approve_testfields |
|
| 233 | - $grouppermHandler->deleteByModule($mid, 'mymodule3_approve_testfields', $permId); |
|
| 234 | - if (isset($_POST['groups_approve_testfields'])) { |
|
| 235 | - foreach($_POST['groups_approve_testfields'] as $onegroupId) { |
|
| 236 | - $grouppermHandler->addRight('mymodule3_approve_testfields', $permId, $onegroupId, $mid); |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - if ('' !== $uploaderErrors) { |
|
| 240 | - redirect_header('testfields.php?op=edit&tf_id=' . $tfId, 5, $uploaderErrors); |
|
| 241 | - } else { |
|
| 242 | - redirect_header('testfields.php?op=list', 2, _MA_MYMODULE3_FORM_OK); |
|
| 243 | - } |
|
| 244 | - } |
|
| 245 | - // Get Form Error |
|
| 246 | - $GLOBALS['xoopsTpl']->assign('error', $testfieldsObj->getHtmlErrors()); |
|
| 247 | - $form = $testfieldsObj->getFormTestfields(); |
|
| 248 | - $GLOBALS['xoopsTpl']->assign('form', $form->display()); |
|
| 249 | - break; |
|
| 43 | + case 'form': |
|
| 44 | + default: |
|
| 45 | + // Navigation |
|
| 46 | + $navigation = _MA_MYMODULE3_SUBMIT_PROPOSER; |
|
| 47 | + $GLOBALS['xoopsTpl']->assign('navigation', $navigation); |
|
| 48 | + // Title of page |
|
| 49 | + $title = _MA_MYMODULE3_SUBMIT_PROPOSER . ' - '; |
|
| 50 | + $title .= $GLOBALS['xoopsModule']->name(); |
|
| 51 | + $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title); |
|
| 52 | + // Description |
|
| 53 | + $GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags(_MA_MYMODULE3_SUBMIT_PROPOSER)); |
|
| 54 | + // Form Create |
|
| 55 | + $testfieldsObj = $testfieldsHandler->create(); |
|
| 56 | + $form = $testfieldsObj->getFormTestfields(); |
|
| 57 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
| 58 | + break; |
|
| 59 | + case 'save': |
|
| 60 | + // Security Check |
|
| 61 | + if (!$GLOBALS['xoopsSecurity']->check()) { |
|
| 62 | + redirect_header('testfields.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 63 | + } |
|
| 64 | + $testfieldsObj = $testfieldsHandler->create(); |
|
| 65 | + $testfieldsObj->setVar('tf_text', Request::getString('tf_text', '')); |
|
| 66 | + $testfieldsObj->setVar('tf_textarea', Request::getString('tf_textarea', '')); |
|
| 67 | + $testfieldsObj->setVar('tf_dhtml', Request::getString('tf_dhtml', '')); |
|
| 68 | + $testfieldsObj->setVar('tf_checkbox', Request::getInt('tf_checkbox', 0)); |
|
| 69 | + $testfieldsObj->setVar('tf_yesno', Request::getInt('tf_yesno', 0)); |
|
| 70 | + $testfieldsObj->setVar('tf_selectbox', Request::getInt('tf_selectbox', 0)); |
|
| 71 | + $testfieldsObj->setVar('tf_user', Request::getInt('tf_user', 0)); |
|
| 72 | + $testfieldsObj->setVar('tf_color', Request::getString('tf_color', '')); |
|
| 73 | + // Set Var tf_imagelist |
|
| 74 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 75 | + $uploader = new \XoopsMediaUploader(XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32', |
|
| 76 | + $helper->getConfig('mimetypes_image'), |
|
| 77 | + $helper->getConfig('maxsize_image'), null, null); |
|
| 78 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
|
| 79 | + //$uploader->setPrefix(tf_imagelist_); |
|
| 80 | + //$uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
|
| 81 | + if (!$uploader->upload()) { |
|
| 82 | + $errors = $uploader->getErrors(); |
|
| 83 | + redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 84 | + } else { |
|
| 85 | + $testfieldsObj->setVar('tf_imagelist', $uploader->getSavedFileName()); |
|
| 86 | + } |
|
| 87 | + } else { |
|
| 88 | + $testfieldsObj->setVar('tf_imagelist', Request::getString('tf_imagelist')); |
|
| 89 | + } |
|
| 90 | + $testfieldsObj->setVar('tf_urlfile', formatUrl($_REQUEST['tf_urlfile'])); |
|
| 91 | + // Set Var tf_urlfile |
|
| 92 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 93 | + $filename = $_FILES['tf_urlfile']['name']; |
|
| 94 | + $imgNameDef = Request::getString('tf_text'); |
|
| 95 | + $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_FILES_PATH . '/testfields/', |
|
| 96 | + $helper->getConfig('mimetypes_file'), |
|
| 97 | + $helper->getConfig('maxsize_file'), null, null); |
|
| 98 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][1])) { |
|
| 99 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 100 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 101 | + $uploader->setPrefix($imgName); |
|
| 102 | + $uploader->fetchMedia($_POST['xoops_upload_file'][1]); |
|
| 103 | + if (!$uploader->upload()) { |
|
| 104 | + $errors = $uploader->getErrors(); |
|
| 105 | + } else { |
|
| 106 | + $testfieldsObj->setVar('tf_urlfile', $uploader->getSavedFileName()); |
|
| 107 | + } |
|
| 108 | + } else { |
|
| 109 | + if ($filename > '') { |
|
| 110 | + $uploaderErrors = $uploader->getErrors(); |
|
| 111 | + } |
|
| 112 | + $testfieldsObj->setVar('tf_urlfile', Request::getString('tf_urlfile')); |
|
| 113 | + } |
|
| 114 | + // Set Var tf_uplimage |
|
| 115 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 116 | + $filename = $_FILES['tf_uplimage']['name']; |
|
| 117 | + $imgMimetype = $_FILES['tf_uplimage']['type']; |
|
| 118 | + $imgNameDef = Request::getString('tf_text'); |
|
| 119 | + $uploaderErrors = ''; |
|
| 120 | + $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_IMAGE_PATH . '/testfields/', |
|
| 121 | + $helper->getConfig('mimetypes_image'), |
|
| 122 | + $helper->getConfig('maxsize_image'), null, null); |
|
| 123 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][2])) { |
|
| 124 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 125 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 126 | + $uploader->setPrefix($imgName); |
|
| 127 | + $uploader->fetchMedia($_POST['xoops_upload_file'][2]); |
|
| 128 | + if (!$uploader->upload()) { |
|
| 129 | + $uploaderErrors = $uploader->getErrors(); |
|
| 130 | + } else { |
|
| 131 | + $savedFilename = $uploader->getSavedFileName(); |
|
| 132 | + $maxwidth = (int)$helper->getConfig('maxwidth_image'); |
|
| 133 | + $maxheight = (int)$helper->getConfig('maxheight_image'); |
|
| 134 | + if ($maxwidth > 0 && $maxheight > 0) { |
|
| 135 | + // Resize image |
|
| 136 | + $imgHandler = new Mymodule3\Common\Resizer(); |
|
| 137 | + $imgHandler->sourceFile = MYMODULE3_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 138 | + $imgHandler->endFile = MYMODULE3_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 139 | + $imgHandler->imageMimetype = $imgMimetype; |
|
| 140 | + $imgHandler->maxWidth = $maxwidth; |
|
| 141 | + $imgHandler->maxHeight = $maxheight; |
|
| 142 | + $result = $imgHandler->resizeImage(); |
|
| 143 | + } |
|
| 144 | + $testfieldsObj->setVar('tf_uplimage', $savedFilename); |
|
| 145 | + } |
|
| 146 | + } else { |
|
| 147 | + if ($filename > '') { |
|
| 148 | + $uploaderErrors = $uploader->getErrors(); |
|
| 149 | + } |
|
| 150 | + $testfieldsObj->setVar('tf_uplimage', Request::getString('tf_uplimage')); |
|
| 151 | + } |
|
| 152 | + // Set Var tf_uplfile |
|
| 153 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 154 | + $filename = $_FILES['tf_uplfile']['name']; |
|
| 155 | + $imgNameDef = Request::getString('tf_text'); |
|
| 156 | + $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_FILES_PATH . '/testfields/', |
|
| 157 | + $helper->getConfig('mimetypes_file'), |
|
| 158 | + $helper->getConfig('maxsize_file'), null, null); |
|
| 159 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][3])) { |
|
| 160 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 161 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 162 | + $uploader->setPrefix($imgName); |
|
| 163 | + $uploader->fetchMedia($_POST['xoops_upload_file'][3]); |
|
| 164 | + if (!$uploader->upload()) { |
|
| 165 | + $errors = $uploader->getErrors(); |
|
| 166 | + } else { |
|
| 167 | + $testfieldsObj->setVar('tf_uplfile', $uploader->getSavedFileName()); |
|
| 168 | + } |
|
| 169 | + } else { |
|
| 170 | + if ($filename > '') { |
|
| 171 | + $uploaderErrors = $uploader->getErrors(); |
|
| 172 | + } |
|
| 173 | + $testfieldsObj->setVar('tf_uplfile', Request::getString('tf_uplfile')); |
|
| 174 | + } |
|
| 175 | + $testfieldTextdateselect = date_create_from_format(_SHORTDATESTRING, Request::getString('tf_textdateselect')); |
|
| 176 | + $testfieldsObj->setVar('tf_textdateselect', $testfieldTextdateselect->getTimestamp()); |
|
| 177 | + // Set Var tf_selectfile |
|
| 178 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 179 | + $filename = $_FILES['tf_selectfile']['name']; |
|
| 180 | + $imgNameDef = Request::getString('tf_text'); |
|
| 181 | + $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_FILES_PATH . '/testfields/', |
|
| 182 | + $helper->getConfig('mimetypes_file'), |
|
| 183 | + $helper->getConfig('maxsize_file'), null, null); |
|
| 184 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][4])) { |
|
| 185 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 186 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 187 | + $uploader->setPrefix($imgName); |
|
| 188 | + $uploader->fetchMedia($_POST['xoops_upload_file'][4]); |
|
| 189 | + if (!$uploader->upload()) { |
|
| 190 | + $errors = $uploader->getErrors(); |
|
| 191 | + } else { |
|
| 192 | + $testfieldsObj->setVar('tf_selectfile', $uploader->getSavedFileName()); |
|
| 193 | + } |
|
| 194 | + } else { |
|
| 195 | + if ($filename > '') { |
|
| 196 | + $uploaderErrors = $uploader->getErrors(); |
|
| 197 | + } |
|
| 198 | + $testfieldsObj->setVar('tf_selectfile', Request::getString('tf_selectfile')); |
|
| 199 | + } |
|
| 200 | + $tfPassword = Request::getString('tf_password', ''); |
|
| 201 | + if ('' !== $tfPassword) { |
|
| 202 | + $testfieldsObj->setVar('tf_password', password_hash($tfPassword, PASSWORD_DEFAULT)); |
|
| 203 | + } |
|
| 204 | + $testfieldsObj->setVar('tf_country_list', Request::getString('tf_country_list', '')); |
|
| 205 | + $testfieldsObj->setVar('tf_language', Request::getString('tf_language', '')); |
|
| 206 | + $testfieldsObj->setVar('tf_radio', Request::getInt('tf_radio', 0)); |
|
| 207 | + $testfieldsObj->setVar('tf_status', Request::getInt('tf_status', 0)); |
|
| 208 | + $testfieldDatetimeArr = Request::getArray('tf_datetime'); |
|
| 209 | + $testfieldDatetime = strtotime($testfieldDatetimeArr['date']) + (int)$testfieldDatetimeArr['time']; |
|
| 210 | + $testfieldsObj->setVar('tf_datetime', $testfieldDatetime); |
|
| 211 | + $testfieldsObj->setVar('tf_combobox', Request::getInt('tf_combobox', 0)); |
|
| 212 | + // Insert Data |
|
| 213 | + if ($testfieldsHandler->insert($testfieldsObj)) { |
|
| 214 | + $newTfId = $testfieldsObj->getNewInsertedIdTestfields(); |
|
| 215 | + $permId = isset($_REQUEST['tf_id']) ? $tfId : $newTfId; |
|
| 216 | + $grouppermHandler = xoops_getHandler('groupperm'); |
|
| 217 | + $mid = $GLOBALS['xoopsModule']->getVar('mid'); |
|
| 218 | + // Permission to view_testfields |
|
| 219 | + $grouppermHandler->deleteByModule($mid, 'mymodule3_view_testfields', $permId); |
|
| 220 | + if (isset($_POST['groups_view_testfields'])) { |
|
| 221 | + foreach($_POST['groups_view_testfields'] as $onegroupId) { |
|
| 222 | + $grouppermHandler->addRight('mymodule3_view_testfields', $permId, $onegroupId, $mid); |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + // Permission to submit_testfields |
|
| 226 | + $grouppermHandler->deleteByModule($mid, 'mymodule3_submit_testfields', $permId); |
|
| 227 | + if (isset($_POST['groups_submit_testfields'])) { |
|
| 228 | + foreach($_POST['groups_submit_testfields'] as $onegroupId) { |
|
| 229 | + $grouppermHandler->addRight('mymodule3_submit_testfields', $permId, $onegroupId, $mid); |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + // Permission to approve_testfields |
|
| 233 | + $grouppermHandler->deleteByModule($mid, 'mymodule3_approve_testfields', $permId); |
|
| 234 | + if (isset($_POST['groups_approve_testfields'])) { |
|
| 235 | + foreach($_POST['groups_approve_testfields'] as $onegroupId) { |
|
| 236 | + $grouppermHandler->addRight('mymodule3_approve_testfields', $permId, $onegroupId, $mid); |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + if ('' !== $uploaderErrors) { |
|
| 240 | + redirect_header('testfields.php?op=edit&tf_id=' . $tfId, 5, $uploaderErrors); |
|
| 241 | + } else { |
|
| 242 | + redirect_header('testfields.php?op=list', 2, _MA_MYMODULE3_FORM_OK); |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | + // Get Form Error |
|
| 246 | + $GLOBALS['xoopsTpl']->assign('error', $testfieldsObj->getHtmlErrors()); |
|
| 247 | + $form = $testfieldsObj->getFormTestfields(); |
|
| 248 | + $GLOBALS['xoopsTpl']->assign('form', $form->display()); |
|
| 249 | + break; |
|
| 250 | 250 | } |
| 251 | 251 | // Breadcrumbs |
| 252 | 252 | $xoBreadcrumbs[] = ['title' => _MA_MYMODULE3_SUBMIT]; |
@@ -37,196 +37,196 @@ |
||
| 37 | 37 | exit(); |
| 38 | 38 | } |
| 39 | 39 | switch($op) { |
| 40 | - case 'form': |
|
| 41 | - default: |
|
| 42 | - // Navigation |
|
| 43 | - $navigation = _MA_MYMODULE3_SUBMIT_PROPOSER; |
|
| 44 | - $GLOBALS['xoopsTpl']->assign('navigation', $navigation); |
|
| 45 | - // Title of page |
|
| 46 | - $title = _MA_MYMODULE3_SUBMIT_PROPOSER . ' - '; |
|
| 47 | - $title .= $GLOBALS['xoopsModule']->name(); |
|
| 48 | - $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title); |
|
| 49 | - // Description |
|
| 50 | - $GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags(_MA_MYMODULE3_SUBMIT_PROPOSER)); |
|
| 51 | - // Form Create |
|
| 52 | - $testfieldsObj = $testfieldsHandler->create(); |
|
| 53 | - $form = $testfieldsObj->getFormTestfields(); |
|
| 54 | - $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
| 55 | - break; |
|
| 56 | - case 'save': |
|
| 57 | - // Security Check |
|
| 58 | - if ($GLOBALS['xoopsSecurity']->check()) { |
|
| 59 | - redirect_header('testfields.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 60 | - } |
|
| 61 | - $testfieldsObj = $testfieldsHandler->create(); |
|
| 62 | - $error = false; |
|
| 63 | - $errorMessage = ''; |
|
| 64 | - // Test first the validation |
|
| 65 | - xoops_load('captcha'); |
|
| 66 | - $xoopsCaptcha = \XoopsCaptcha::getInstance(); |
|
| 67 | - if (!$xoopsCaptcha->verify()) { |
|
| 68 | - $errorMessage .= $xoopsCaptcha->getMessage().'<br>'; |
|
| 69 | - $error = true; |
|
| 70 | - } |
|
| 71 | - $testfieldsObj->setVar('tf_text', Request::getString('tf_text', '')); |
|
| 72 | - $testfieldsObj->setVar('tf_textarea', Request::getString('tf_textarea', '')); |
|
| 73 | - $testfieldsObj->setVar('tf_dhtml', Request::getString('tf_dhtml', '')); |
|
| 74 | - $testfieldsObj->setVar('tf_checkbox', Request::getInt('tf_checkbox', 0)); |
|
| 75 | - $testfieldsObj->setVar('tf_yesno', Request::getInt('tf_yesno', 0)); |
|
| 76 | - $testfieldsObj->setVar('tf_selectbox', Request::getInt('tf_selectbox', 0)); |
|
| 77 | - $testfieldsObj->setVar('tf_user', Request::getInt('tf_user', 0)); |
|
| 78 | - $testfieldsObj->setVar('tf_color', Request::getString('tf_color', '')); |
|
| 79 | - // Set Var tf_imagelist |
|
| 80 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 81 | - $uploader = new \XoopsMediaUploader(XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32', |
|
| 82 | - $helper->getConfig('mimetypes_image'), |
|
| 83 | - $helper->getConfig('maxsize_image'), null, null); |
|
| 84 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
|
| 85 | - //$uploader->setPrefix(tf_imagelist_); |
|
| 86 | - //$uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
|
| 87 | - if (!$uploader->upload()) { |
|
| 88 | - $errors = $uploader->getErrors(); |
|
| 89 | - redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 90 | - } else { |
|
| 91 | - $testfieldsObj->setVar('tf_imagelist', $uploader->getSavedFileName()); |
|
| 92 | - } |
|
| 93 | - } else { |
|
| 94 | - $testfieldsObj->setVar('tf_imagelist', Request::getString('tf_imagelist')); |
|
| 95 | - } |
|
| 96 | - $testfieldsObj->setVar('tf_urlfile', formatUrl($_REQUEST['tf_urlfile'])); |
|
| 97 | - // Set Var tf_urlfile |
|
| 98 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 99 | - $filename = $_FILES['tf_urlfile']['name']; |
|
| 100 | - $imgNameDef = Request::getString('tf_text'); |
|
| 101 | - $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_FILES_PATH . '/testfields/', |
|
| 102 | - $helper->getConfig('mimetypes_file'), |
|
| 103 | - $helper->getConfig('maxsize_file'), null, null); |
|
| 104 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][1])) { |
|
| 105 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 106 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 107 | - $uploader->setPrefix($imgName); |
|
| 108 | - $uploader->fetchMedia($_POST['xoops_upload_file'][1]); |
|
| 109 | - if (!$uploader->upload()) { |
|
| 110 | - $errors = $uploader->getErrors(); |
|
| 111 | - } else { |
|
| 112 | - $testfieldsObj->setVar('tf_urlfile', $uploader->getSavedFileName()); |
|
| 113 | - } |
|
| 114 | - } else { |
|
| 115 | - if ($filename > '') { |
|
| 116 | - $uploaderErrors = $uploader->getErrors(); |
|
| 117 | - } |
|
| 118 | - $testfieldsObj->setVar('tf_urlfile', Request::getString('tf_urlfile')); |
|
| 119 | - } |
|
| 120 | - // Set Var tf_uplimage |
|
| 121 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 122 | - $filename = $_FILES['tf_uplimage']['name']; |
|
| 123 | - $imgMimetype = $_FILES['tf_uplimage']['type']; |
|
| 124 | - $imgNameDef = Request::getString('tf_text'); |
|
| 125 | - $uploaderErrors = ''; |
|
| 126 | - $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_IMAGE_PATH . '/testfields/', |
|
| 127 | - $helper->getConfig('mimetypes_image'), |
|
| 128 | - $helper->getConfig('maxsize_image'), null, null); |
|
| 129 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][2])) { |
|
| 130 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 131 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 132 | - $uploader->setPrefix($imgName); |
|
| 133 | - $uploader->fetchMedia($_POST['xoops_upload_file'][2]); |
|
| 134 | - if (!$uploader->upload()) { |
|
| 135 | - $uploaderErrors = $uploader->getErrors(); |
|
| 136 | - } else { |
|
| 137 | - $savedFilename = $uploader->getSavedFileName(); |
|
| 138 | - $maxwidth = (int)$helper->getConfig('maxwidth_image'); |
|
| 139 | - $maxheight = (int)$helper->getConfig('maxheight_image'); |
|
| 140 | - if ($maxwidth > 0 && $maxheight > 0) { |
|
| 141 | - // Resize image |
|
| 142 | - $imgHandler = new Mymodule3\Common\Resizer(); |
|
| 143 | - $imgHandler->sourceFile = MYMODULE3_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 144 | - $imgHandler->endFile = MYMODULE3_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 145 | - $imgHandler->imageMimetype = $imgMimetype; |
|
| 146 | - $imgHandler->maxWidth = $maxwidth; |
|
| 147 | - $imgHandler->maxHeight = $maxheight; |
|
| 148 | - $result = $imgHandler->resizeImage(); |
|
| 149 | - } |
|
| 150 | - $testfieldsObj->setVar('tf_uplimage', $savedFilename); |
|
| 151 | - } |
|
| 152 | - } else { |
|
| 153 | - if ($filename > '') { |
|
| 154 | - $uploaderErrors = $uploader->getErrors(); |
|
| 155 | - } |
|
| 156 | - $testfieldsObj->setVar('tf_uplimage', Request::getString('tf_uplimage')); |
|
| 157 | - } |
|
| 158 | - // Set Var tf_uplfile |
|
| 159 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 160 | - $filename = $_FILES['tf_uplfile']['name']; |
|
| 161 | - $imgNameDef = Request::getString('tf_text'); |
|
| 162 | - $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_FILES_PATH . '/testfields/', |
|
| 163 | - $helper->getConfig('mimetypes_file'), |
|
| 164 | - $helper->getConfig('maxsize_file'), null, null); |
|
| 165 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][3])) { |
|
| 166 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 167 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 168 | - $uploader->setPrefix($imgName); |
|
| 169 | - $uploader->fetchMedia($_POST['xoops_upload_file'][3]); |
|
| 170 | - if (!$uploader->upload()) { |
|
| 171 | - $errors = $uploader->getErrors(); |
|
| 172 | - } else { |
|
| 173 | - $testfieldsObj->setVar('tf_uplfile', $uploader->getSavedFileName()); |
|
| 174 | - } |
|
| 175 | - } else { |
|
| 176 | - if ($filename > '') { |
|
| 177 | - $uploaderErrors = $uploader->getErrors(); |
|
| 178 | - } |
|
| 179 | - $testfieldsObj->setVar('tf_uplfile', Request::getString('tf_uplfile')); |
|
| 180 | - } |
|
| 181 | - $testfieldTextdateselect = date_create_from_format(_SHORTDATESTRING, Request::getString('tf_textdateselect')); |
|
| 182 | - $testfieldsObj->setVar('tf_textdateselect', $testfieldTextdateselect->getTimestamp()); |
|
| 183 | - // Set Var tf_selectfile |
|
| 184 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 185 | - $filename = $_FILES['tf_selectfile']['name']; |
|
| 186 | - $imgNameDef = Request::getString('tf_text'); |
|
| 187 | - $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_FILES_PATH . '/testfields/', |
|
| 188 | - $helper->getConfig('mimetypes_file'), |
|
| 189 | - $helper->getConfig('maxsize_file'), null, null); |
|
| 190 | - if ($uploader->fetchMedia($_POST['xoops_upload_file'][4])) { |
|
| 191 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 192 | - $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 193 | - $uploader->setPrefix($imgName); |
|
| 194 | - $uploader->fetchMedia($_POST['xoops_upload_file'][4]); |
|
| 195 | - if (!$uploader->upload()) { |
|
| 196 | - $errors = $uploader->getErrors(); |
|
| 197 | - } else { |
|
| 198 | - $testfieldsObj->setVar('tf_selectfile', $uploader->getSavedFileName()); |
|
| 199 | - } |
|
| 200 | - } else { |
|
| 201 | - if ($filename > '') { |
|
| 202 | - $uploaderErrors = $uploader->getErrors(); |
|
| 203 | - } |
|
| 204 | - $testfieldsObj->setVar('tf_selectfile', Request::getString('tf_selectfile')); |
|
| 205 | - } |
|
| 206 | - $tfPassword = Request::getString('tf_password', ''); |
|
| 207 | - if ('' !== $tfPassword) { |
|
| 208 | - $testfieldsObj->setVar('tf_password', password_hash($tfPassword, PASSWORD_DEFAULT)); |
|
| 209 | - } |
|
| 210 | - $testfieldsObj->setVar('tf_country_list', Request::getString('tf_country_list', '')); |
|
| 211 | - $testfieldsObj->setVar('tf_language', Request::getString('tf_language', '')); |
|
| 212 | - $testfieldsObj->setVar('tf_radio', Request::getInt('tf_radio', 0)); |
|
| 213 | - $testfieldsObj->setVar('tf_status', Request::getInt('tf_status', 0)); |
|
| 214 | - $testfieldDatetimeArr = Request::getArray('tf_datetime'); |
|
| 215 | - $testfieldDatetime = strtotime($testfieldDatetimeArr['date']) + (int)$testfieldDatetimeArr['time']; |
|
| 216 | - $testfieldsObj->setVar('tf_datetime', $testfieldDatetime); |
|
| 217 | - $testfieldsObj->setVar('tf_combobox', Request::getInt('tf_combobox', 0)); |
|
| 218 | - if ($error === true) { |
|
| 219 | - $GLOBALS['xoopsTpl']->assign('error_message', $errorMessage); |
|
| 220 | - } else { |
|
| 221 | - // Insert Data |
|
| 222 | - if ($testfieldsHandler->insert($testfieldsObj)) { |
|
| 223 | - redirect_header('index.php', 2, _MA_MYMODULE3_FORM_OK); |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - // Get Form Error |
|
| 227 | - $GLOBALS['xoopsTpl']->assign('error', $testfieldsObj->getHtmlErrors()); |
|
| 228 | - $form = $testfieldsObj->getFormTestfields(); |
|
| 229 | - $GLOBALS['xoopsTpl']->assign('form', $form->display()); |
|
| 230 | - break; |
|
| 40 | + case 'form': |
|
| 41 | + default: |
|
| 42 | + // Navigation |
|
| 43 | + $navigation = _MA_MYMODULE3_SUBMIT_PROPOSER; |
|
| 44 | + $GLOBALS['xoopsTpl']->assign('navigation', $navigation); |
|
| 45 | + // Title of page |
|
| 46 | + $title = _MA_MYMODULE3_SUBMIT_PROPOSER . ' - '; |
|
| 47 | + $title .= $GLOBALS['xoopsModule']->name(); |
|
| 48 | + $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title); |
|
| 49 | + // Description |
|
| 50 | + $GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags(_MA_MYMODULE3_SUBMIT_PROPOSER)); |
|
| 51 | + // Form Create |
|
| 52 | + $testfieldsObj = $testfieldsHandler->create(); |
|
| 53 | + $form = $testfieldsObj->getFormTestfields(); |
|
| 54 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
| 55 | + break; |
|
| 56 | + case 'save': |
|
| 57 | + // Security Check |
|
| 58 | + if ($GLOBALS['xoopsSecurity']->check()) { |
|
| 59 | + redirect_header('testfields.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 60 | + } |
|
| 61 | + $testfieldsObj = $testfieldsHandler->create(); |
|
| 62 | + $error = false; |
|
| 63 | + $errorMessage = ''; |
|
| 64 | + // Test first the validation |
|
| 65 | + xoops_load('captcha'); |
|
| 66 | + $xoopsCaptcha = \XoopsCaptcha::getInstance(); |
|
| 67 | + if (!$xoopsCaptcha->verify()) { |
|
| 68 | + $errorMessage .= $xoopsCaptcha->getMessage().'<br>'; |
|
| 69 | + $error = true; |
|
| 70 | + } |
|
| 71 | + $testfieldsObj->setVar('tf_text', Request::getString('tf_text', '')); |
|
| 72 | + $testfieldsObj->setVar('tf_textarea', Request::getString('tf_textarea', '')); |
|
| 73 | + $testfieldsObj->setVar('tf_dhtml', Request::getString('tf_dhtml', '')); |
|
| 74 | + $testfieldsObj->setVar('tf_checkbox', Request::getInt('tf_checkbox', 0)); |
|
| 75 | + $testfieldsObj->setVar('tf_yesno', Request::getInt('tf_yesno', 0)); |
|
| 76 | + $testfieldsObj->setVar('tf_selectbox', Request::getInt('tf_selectbox', 0)); |
|
| 77 | + $testfieldsObj->setVar('tf_user', Request::getInt('tf_user', 0)); |
|
| 78 | + $testfieldsObj->setVar('tf_color', Request::getString('tf_color', '')); |
|
| 79 | + // Set Var tf_imagelist |
|
| 80 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 81 | + $uploader = new \XoopsMediaUploader(XOOPS_ROOT_PATH . '/Frameworks/moduleclasses/icons/32', |
|
| 82 | + $helper->getConfig('mimetypes_image'), |
|
| 83 | + $helper->getConfig('maxsize_image'), null, null); |
|
| 84 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
|
| 85 | + //$uploader->setPrefix(tf_imagelist_); |
|
| 86 | + //$uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
|
| 87 | + if (!$uploader->upload()) { |
|
| 88 | + $errors = $uploader->getErrors(); |
|
| 89 | + redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 90 | + } else { |
|
| 91 | + $testfieldsObj->setVar('tf_imagelist', $uploader->getSavedFileName()); |
|
| 92 | + } |
|
| 93 | + } else { |
|
| 94 | + $testfieldsObj->setVar('tf_imagelist', Request::getString('tf_imagelist')); |
|
| 95 | + } |
|
| 96 | + $testfieldsObj->setVar('tf_urlfile', formatUrl($_REQUEST['tf_urlfile'])); |
|
| 97 | + // Set Var tf_urlfile |
|
| 98 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 99 | + $filename = $_FILES['tf_urlfile']['name']; |
|
| 100 | + $imgNameDef = Request::getString('tf_text'); |
|
| 101 | + $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_FILES_PATH . '/testfields/', |
|
| 102 | + $helper->getConfig('mimetypes_file'), |
|
| 103 | + $helper->getConfig('maxsize_file'), null, null); |
|
| 104 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][1])) { |
|
| 105 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 106 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 107 | + $uploader->setPrefix($imgName); |
|
| 108 | + $uploader->fetchMedia($_POST['xoops_upload_file'][1]); |
|
| 109 | + if (!$uploader->upload()) { |
|
| 110 | + $errors = $uploader->getErrors(); |
|
| 111 | + } else { |
|
| 112 | + $testfieldsObj->setVar('tf_urlfile', $uploader->getSavedFileName()); |
|
| 113 | + } |
|
| 114 | + } else { |
|
| 115 | + if ($filename > '') { |
|
| 116 | + $uploaderErrors = $uploader->getErrors(); |
|
| 117 | + } |
|
| 118 | + $testfieldsObj->setVar('tf_urlfile', Request::getString('tf_urlfile')); |
|
| 119 | + } |
|
| 120 | + // Set Var tf_uplimage |
|
| 121 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 122 | + $filename = $_FILES['tf_uplimage']['name']; |
|
| 123 | + $imgMimetype = $_FILES['tf_uplimage']['type']; |
|
| 124 | + $imgNameDef = Request::getString('tf_text'); |
|
| 125 | + $uploaderErrors = ''; |
|
| 126 | + $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_IMAGE_PATH . '/testfields/', |
|
| 127 | + $helper->getConfig('mimetypes_image'), |
|
| 128 | + $helper->getConfig('maxsize_image'), null, null); |
|
| 129 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][2])) { |
|
| 130 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 131 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 132 | + $uploader->setPrefix($imgName); |
|
| 133 | + $uploader->fetchMedia($_POST['xoops_upload_file'][2]); |
|
| 134 | + if (!$uploader->upload()) { |
|
| 135 | + $uploaderErrors = $uploader->getErrors(); |
|
| 136 | + } else { |
|
| 137 | + $savedFilename = $uploader->getSavedFileName(); |
|
| 138 | + $maxwidth = (int)$helper->getConfig('maxwidth_image'); |
|
| 139 | + $maxheight = (int)$helper->getConfig('maxheight_image'); |
|
| 140 | + if ($maxwidth > 0 && $maxheight > 0) { |
|
| 141 | + // Resize image |
|
| 142 | + $imgHandler = new Mymodule3\Common\Resizer(); |
|
| 143 | + $imgHandler->sourceFile = MYMODULE3_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 144 | + $imgHandler->endFile = MYMODULE3_UPLOAD_IMAGE_PATH . '/testfields/' . $savedFilename; |
|
| 145 | + $imgHandler->imageMimetype = $imgMimetype; |
|
| 146 | + $imgHandler->maxWidth = $maxwidth; |
|
| 147 | + $imgHandler->maxHeight = $maxheight; |
|
| 148 | + $result = $imgHandler->resizeImage(); |
|
| 149 | + } |
|
| 150 | + $testfieldsObj->setVar('tf_uplimage', $savedFilename); |
|
| 151 | + } |
|
| 152 | + } else { |
|
| 153 | + if ($filename > '') { |
|
| 154 | + $uploaderErrors = $uploader->getErrors(); |
|
| 155 | + } |
|
| 156 | + $testfieldsObj->setVar('tf_uplimage', Request::getString('tf_uplimage')); |
|
| 157 | + } |
|
| 158 | + // Set Var tf_uplfile |
|
| 159 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 160 | + $filename = $_FILES['tf_uplfile']['name']; |
|
| 161 | + $imgNameDef = Request::getString('tf_text'); |
|
| 162 | + $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_FILES_PATH . '/testfields/', |
|
| 163 | + $helper->getConfig('mimetypes_file'), |
|
| 164 | + $helper->getConfig('maxsize_file'), null, null); |
|
| 165 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][3])) { |
|
| 166 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 167 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 168 | + $uploader->setPrefix($imgName); |
|
| 169 | + $uploader->fetchMedia($_POST['xoops_upload_file'][3]); |
|
| 170 | + if (!$uploader->upload()) { |
|
| 171 | + $errors = $uploader->getErrors(); |
|
| 172 | + } else { |
|
| 173 | + $testfieldsObj->setVar('tf_uplfile', $uploader->getSavedFileName()); |
|
| 174 | + } |
|
| 175 | + } else { |
|
| 176 | + if ($filename > '') { |
|
| 177 | + $uploaderErrors = $uploader->getErrors(); |
|
| 178 | + } |
|
| 179 | + $testfieldsObj->setVar('tf_uplfile', Request::getString('tf_uplfile')); |
|
| 180 | + } |
|
| 181 | + $testfieldTextdateselect = date_create_from_format(_SHORTDATESTRING, Request::getString('tf_textdateselect')); |
|
| 182 | + $testfieldsObj->setVar('tf_textdateselect', $testfieldTextdateselect->getTimestamp()); |
|
| 183 | + // Set Var tf_selectfile |
|
| 184 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 185 | + $filename = $_FILES['tf_selectfile']['name']; |
|
| 186 | + $imgNameDef = Request::getString('tf_text'); |
|
| 187 | + $uploader = new \XoopsMediaUploader(MYMODULE3_UPLOAD_FILES_PATH . '/testfields/', |
|
| 188 | + $helper->getConfig('mimetypes_file'), |
|
| 189 | + $helper->getConfig('maxsize_file'), null, null); |
|
| 190 | + if ($uploader->fetchMedia($_POST['xoops_upload_file'][4])) { |
|
| 191 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $filename); |
|
| 192 | + $imgName = str_replace(' ', '', $imgNameDef) . '.' . $extension; |
|
| 193 | + $uploader->setPrefix($imgName); |
|
| 194 | + $uploader->fetchMedia($_POST['xoops_upload_file'][4]); |
|
| 195 | + if (!$uploader->upload()) { |
|
| 196 | + $errors = $uploader->getErrors(); |
|
| 197 | + } else { |
|
| 198 | + $testfieldsObj->setVar('tf_selectfile', $uploader->getSavedFileName()); |
|
| 199 | + } |
|
| 200 | + } else { |
|
| 201 | + if ($filename > '') { |
|
| 202 | + $uploaderErrors = $uploader->getErrors(); |
|
| 203 | + } |
|
| 204 | + $testfieldsObj->setVar('tf_selectfile', Request::getString('tf_selectfile')); |
|
| 205 | + } |
|
| 206 | + $tfPassword = Request::getString('tf_password', ''); |
|
| 207 | + if ('' !== $tfPassword) { |
|
| 208 | + $testfieldsObj->setVar('tf_password', password_hash($tfPassword, PASSWORD_DEFAULT)); |
|
| 209 | + } |
|
| 210 | + $testfieldsObj->setVar('tf_country_list', Request::getString('tf_country_list', '')); |
|
| 211 | + $testfieldsObj->setVar('tf_language', Request::getString('tf_language', '')); |
|
| 212 | + $testfieldsObj->setVar('tf_radio', Request::getInt('tf_radio', 0)); |
|
| 213 | + $testfieldsObj->setVar('tf_status', Request::getInt('tf_status', 0)); |
|
| 214 | + $testfieldDatetimeArr = Request::getArray('tf_datetime'); |
|
| 215 | + $testfieldDatetime = strtotime($testfieldDatetimeArr['date']) + (int)$testfieldDatetimeArr['time']; |
|
| 216 | + $testfieldsObj->setVar('tf_datetime', $testfieldDatetime); |
|
| 217 | + $testfieldsObj->setVar('tf_combobox', Request::getInt('tf_combobox', 0)); |
|
| 218 | + if ($error === true) { |
|
| 219 | + $GLOBALS['xoopsTpl']->assign('error_message', $errorMessage); |
|
| 220 | + } else { |
|
| 221 | + // Insert Data |
|
| 222 | + if ($testfieldsHandler->insert($testfieldsObj)) { |
|
| 223 | + redirect_header('index.php', 2, _MA_MYMODULE3_FORM_OK); |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + // Get Form Error |
|
| 227 | + $GLOBALS['xoopsTpl']->assign('error', $testfieldsObj->getHtmlErrors()); |
|
| 228 | + $form = $testfieldsObj->getFormTestfields(); |
|
| 229 | + $GLOBALS['xoopsTpl']->assign('form', $form->display()); |
|
| 230 | + break; |
|
| 231 | 231 | } |
| 232 | 232 | require __DIR__ . '/footer.php'; |
@@ -39,84 +39,84 @@ |
||
| 39 | 39 | exit(); |
| 40 | 40 | } |
| 41 | 41 | switch($op) { |
| 42 | - case 'form': |
|
| 43 | - default: |
|
| 44 | - // Navigation |
|
| 45 | - $navigation = _MA_MYMODULE_SUBMIT_PROPOSER; |
|
| 46 | - $GLOBALS['xoopsTpl']->assign('navigation', $navigation); |
|
| 47 | - // Title of page |
|
| 48 | - $title = _MA_MYMODULE_SUBMIT_PROPOSER . ' - '; |
|
| 49 | - $title .= $GLOBALS['xoopsModule']->name(); |
|
| 50 | - $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title); |
|
| 51 | - // Description |
|
| 52 | - $GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags(_MA_MYMODULE_SUBMIT_PROPOSER)); |
|
| 53 | - // Form Create |
|
| 54 | - $articlesObj = $articlesHandler->create(); |
|
| 55 | - $form = $articlesObj->getFormArticles(); |
|
| 56 | - $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
| 42 | + case 'form': |
|
| 43 | + default: |
|
| 44 | + // Navigation |
|
| 45 | + $navigation = _MA_MYMODULE_SUBMIT_PROPOSER; |
|
| 46 | + $GLOBALS['xoopsTpl']->assign('navigation', $navigation); |
|
| 47 | + // Title of page |
|
| 48 | + $title = _MA_MYMODULE_SUBMIT_PROPOSER . ' - '; |
|
| 49 | + $title .= $GLOBALS['xoopsModule']->name(); |
|
| 50 | + $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title); |
|
| 51 | + // Description |
|
| 52 | + $GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags(_MA_MYMODULE_SUBMIT_PROPOSER)); |
|
| 53 | + // Form Create |
|
| 54 | + $articlesObj = $articlesHandler->create(); |
|
| 55 | + $form = $articlesObj->getFormArticles(); |
|
| 56 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
| 57 | 57 | |
| 58 | - break; |
|
| 59 | - case 'save': |
|
| 60 | - // Security Check |
|
| 61 | - if(!$GLOBALS['xoopsSecurity']->check()) { |
|
| 62 | - redirect_header('articles.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 63 | - } |
|
| 64 | - $articlesObj = $articlesHandler->create(); |
|
| 65 | - $articlesObj->setVar('art_cat', Request::getInt('art_cat', 0)); |
|
| 66 | - $articlesObj->setVar('art_title', Request::getString('art_title', '')); |
|
| 67 | - $articlesObj->setVar('art_descr', Request::getString('art_descr', '')); |
|
| 68 | - // Set Var art_img |
|
| 69 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 70 | - $uploader = new \XoopsMediaUploader(MYMODULE_UPLOAD_IMAGE_PATH . '/articles/', |
|
| 71 | - $helper->getConfig('mimetypes'), |
|
| 72 | - $helper->getConfig('maxsize'), null, null); |
|
| 73 | - if($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
|
| 74 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $_FILES['attachedfile']['name']); |
|
| 75 | - $imgName = str_replace(' ', '', Request::getString('art_title')) . '.' . $extension; |
|
| 76 | - $uploader->setPrefix($imgName); |
|
| 77 | - $uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
|
| 78 | - if(!$uploader->upload()) { |
|
| 79 | - $errors = $uploader->getErrors(); |
|
| 80 | - redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 81 | - } else { |
|
| 82 | - $articlesObj->setVar('art_img', $uploader->getSavedFileName()); |
|
| 83 | - } |
|
| 84 | - } else { |
|
| 85 | - $articlesObj->setVar('art_img', Request::getString('art_img')); |
|
| 86 | - } |
|
| 87 | - $articlesObj->setVar('art_online', Request::getInt('art_online', 0)); |
|
| 88 | - // Set Var art_file |
|
| 89 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 90 | - $uploader = new \XoopsMediaUploader(MYMODULE_UPLOAD_FILES_PATH . '/articles/', |
|
| 91 | - $helper->getConfig('mimetypes'), |
|
| 92 | - $helper->getConfig('maxsize'), null, null); |
|
| 93 | - if($uploader->fetchMedia($_POST['xoops_upload_file'][1])) { |
|
| 94 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $_FILES['art_file']['name']); |
|
| 95 | - $imgName = str_replace(' ', '', Request::getString('art_title')) . '.' . $extension; |
|
| 96 | - $uploader->setPrefix($imgName); |
|
| 97 | - $uploader->fetchMedia($_POST['xoops_upload_file'][1]); |
|
| 98 | - if(!$uploader->upload()) { |
|
| 99 | - $errors = $uploader->getErrors(); |
|
| 100 | - redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 101 | - } else { |
|
| 102 | - $articlesObj->setVar('art_file', $uploader->getSavedFileName()); |
|
| 103 | - } |
|
| 104 | - } else { |
|
| 105 | - $articlesObj->setVar('art_file', Request::getString('art_file')); |
|
| 106 | - } |
|
| 107 | - $articleCreated = date_create_from_format(_SHORTDATESTRING, $_POST['art_created']); |
|
| 108 | - $articlesObj->setVar('art_created', $articleCreated->getTimestamp()); |
|
| 109 | - $articlesObj->setVar('art_submitter', Request::getInt('art_submitter', 0)); |
|
| 110 | - // Insert Data |
|
| 111 | - if($articlesHandler->insert($articlesObj)) { |
|
| 112 | - redirect_header('index.php', 2, _MA_MYMODULE_FORM_OK); |
|
| 113 | - } |
|
| 114 | - // Get Form Error |
|
| 115 | - $GLOBALS['xoopsTpl']->assign('error', $articlesObj->getHtmlErrors()); |
|
| 116 | - $form = $articlesObj->getFormArticles(); |
|
| 117 | - $GLOBALS['xoopsTpl']->assign('form', $form->display()); |
|
| 58 | + break; |
|
| 59 | + case 'save': |
|
| 60 | + // Security Check |
|
| 61 | + if(!$GLOBALS['xoopsSecurity']->check()) { |
|
| 62 | + redirect_header('articles.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 63 | + } |
|
| 64 | + $articlesObj = $articlesHandler->create(); |
|
| 65 | + $articlesObj->setVar('art_cat', Request::getInt('art_cat', 0)); |
|
| 66 | + $articlesObj->setVar('art_title', Request::getString('art_title', '')); |
|
| 67 | + $articlesObj->setVar('art_descr', Request::getString('art_descr', '')); |
|
| 68 | + // Set Var art_img |
|
| 69 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 70 | + $uploader = new \XoopsMediaUploader(MYMODULE_UPLOAD_IMAGE_PATH . '/articles/', |
|
| 71 | + $helper->getConfig('mimetypes'), |
|
| 72 | + $helper->getConfig('maxsize'), null, null); |
|
| 73 | + if($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
|
| 74 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $_FILES['attachedfile']['name']); |
|
| 75 | + $imgName = str_replace(' ', '', Request::getString('art_title')) . '.' . $extension; |
|
| 76 | + $uploader->setPrefix($imgName); |
|
| 77 | + $uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
|
| 78 | + if(!$uploader->upload()) { |
|
| 79 | + $errors = $uploader->getErrors(); |
|
| 80 | + redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 81 | + } else { |
|
| 82 | + $articlesObj->setVar('art_img', $uploader->getSavedFileName()); |
|
| 83 | + } |
|
| 84 | + } else { |
|
| 85 | + $articlesObj->setVar('art_img', Request::getString('art_img')); |
|
| 86 | + } |
|
| 87 | + $articlesObj->setVar('art_online', Request::getInt('art_online', 0)); |
|
| 88 | + // Set Var art_file |
|
| 89 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 90 | + $uploader = new \XoopsMediaUploader(MYMODULE_UPLOAD_FILES_PATH . '/articles/', |
|
| 91 | + $helper->getConfig('mimetypes'), |
|
| 92 | + $helper->getConfig('maxsize'), null, null); |
|
| 93 | + if($uploader->fetchMedia($_POST['xoops_upload_file'][1])) { |
|
| 94 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $_FILES['art_file']['name']); |
|
| 95 | + $imgName = str_replace(' ', '', Request::getString('art_title')) . '.' . $extension; |
|
| 96 | + $uploader->setPrefix($imgName); |
|
| 97 | + $uploader->fetchMedia($_POST['xoops_upload_file'][1]); |
|
| 98 | + if(!$uploader->upload()) { |
|
| 99 | + $errors = $uploader->getErrors(); |
|
| 100 | + redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 101 | + } else { |
|
| 102 | + $articlesObj->setVar('art_file', $uploader->getSavedFileName()); |
|
| 103 | + } |
|
| 104 | + } else { |
|
| 105 | + $articlesObj->setVar('art_file', Request::getString('art_file')); |
|
| 106 | + } |
|
| 107 | + $articleCreated = date_create_from_format(_SHORTDATESTRING, $_POST['art_created']); |
|
| 108 | + $articlesObj->setVar('art_created', $articleCreated->getTimestamp()); |
|
| 109 | + $articlesObj->setVar('art_submitter', Request::getInt('art_submitter', 0)); |
|
| 110 | + // Insert Data |
|
| 111 | + if($articlesHandler->insert($articlesObj)) { |
|
| 112 | + redirect_header('index.php', 2, _MA_MYMODULE_FORM_OK); |
|
| 113 | + } |
|
| 114 | + // Get Form Error |
|
| 115 | + $GLOBALS['xoopsTpl']->assign('error', $articlesObj->getHtmlErrors()); |
|
| 116 | + $form = $articlesObj->getFormArticles(); |
|
| 117 | + $GLOBALS['xoopsTpl']->assign('form', $form->display()); |
|
| 118 | 118 | |
| 119 | - break; |
|
| 119 | + break; |
|
| 120 | 120 | } |
| 121 | 121 | // Breadcrumbs |
| 122 | 122 | $xoBreadcrumbs[] = ['title' => _MA_MYMODULE_SUBMIT]; |
@@ -84,7 +84,7 @@ |
||
| 84 | 84 | $categoriesAll = $categoriesHandler->getAllCategories(0, 'cat_name'); |
| 85 | 85 | foreach(array_keys($categoriesAll) as $i) { |
| 86 | 86 | $permform->addItem($categoriesAll[$i]->getVar('cat_id'), $categoriesAll[$i]->getVar('cat_name')); |
| 87 | - } |
|
| 87 | + } |
|
| 88 | 88 | $GLOBALS['xoopsTpl']->assign('form', $permform->render()); |
| 89 | 89 | } else { |
| 90 | 90 | redirect_header('categories.php?op=new', 3, _AM_MYMODULE_NO_PERMISSIONS_SET); |
@@ -37,96 +37,96 @@ |
||
| 37 | 37 | exit(); |
| 38 | 38 | } |
| 39 | 39 | switch($op) { |
| 40 | - case 'form': |
|
| 41 | - default: |
|
| 42 | - // Navigation |
|
| 43 | - $navigation = _MA_MYMODULE_SUBMIT_PROPOSER; |
|
| 44 | - $GLOBALS['xoopsTpl']->assign('navigation', $navigation); |
|
| 45 | - // Title of page |
|
| 46 | - $title = _MA_MYMODULE_SUBMIT_PROPOSER . ' - '; |
|
| 47 | - $title .= $GLOBALS['xoopsModule']->name(); |
|
| 48 | - $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title); |
|
| 49 | - // Description |
|
| 50 | - $GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags(_MA_MYMODULE_SUBMIT_PROPOSER)); |
|
| 51 | - // Form Create |
|
| 52 | - $articlesObj = $articlesHandler->create(); |
|
| 53 | - $form = $articlesObj->getFormArticles(); |
|
| 54 | - $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
| 40 | + case 'form': |
|
| 41 | + default: |
|
| 42 | + // Navigation |
|
| 43 | + $navigation = _MA_MYMODULE_SUBMIT_PROPOSER; |
|
| 44 | + $GLOBALS['xoopsTpl']->assign('navigation', $navigation); |
|
| 45 | + // Title of page |
|
| 46 | + $title = _MA_MYMODULE_SUBMIT_PROPOSER . ' - '; |
|
| 47 | + $title .= $GLOBALS['xoopsModule']->name(); |
|
| 48 | + $GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title); |
|
| 49 | + // Description |
|
| 50 | + $GLOBALS['xoTheme']->addMeta( 'meta', 'description', strip_tags(_MA_MYMODULE_SUBMIT_PROPOSER)); |
|
| 51 | + // Form Create |
|
| 52 | + $articlesObj = $articlesHandler->create(); |
|
| 53 | + $form = $articlesObj->getFormArticles(); |
|
| 54 | + $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
| 55 | 55 | |
| 56 | - break; |
|
| 57 | - case 'save': |
|
| 58 | - // Security Check |
|
| 59 | - if($GLOBALS['xoopsSecurity']->check()) { |
|
| 60 | - redirect_header('articles.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 61 | - } |
|
| 62 | - $articlesObj = $articlesHandler->create(); |
|
| 63 | - $error = false; |
|
| 64 | - $errorMessage = ''; |
|
| 65 | - // Test first the validation |
|
| 66 | - xoops_load('captcha'); |
|
| 67 | - $xoopsCaptcha = \XoopsCaptcha::getInstance(); |
|
| 68 | - if(!$xoopsCaptcha->verify()) { |
|
| 69 | - $errorMessage .= $xoopsCaptcha->getMessage().'<br>'; |
|
| 70 | - $error = true; |
|
| 71 | - } |
|
| 72 | - $articlesObj->setVar('art_cat', Request::getInt('art_cat', 0)); |
|
| 73 | - $articlesObj->setVar('art_title', Request::getString('art_title', '')); |
|
| 74 | - $articlesObj->setVar('art_descr', Request::getString('art_descr', '')); |
|
| 75 | - // Set Var art_img |
|
| 76 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 77 | - $uploader = new \XoopsMediaUploader(MYMODULE_UPLOAD_IMAGE_PATH . '/articles/', |
|
| 78 | - $helper->getConfig('mimetypes'), |
|
| 79 | - $helper->getConfig('maxsize'), null, null); |
|
| 80 | - if($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
|
| 81 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $_FILES['attachedfile']['name']); |
|
| 82 | - $imgName = str_replace(' ', '', Request::getString('art_title')) . '.' . $extension; |
|
| 83 | - $uploader->setPrefix($imgName); |
|
| 84 | - $uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
|
| 85 | - if(!$uploader->upload()) { |
|
| 86 | - $errors = $uploader->getErrors(); |
|
| 87 | - redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 88 | - } else { |
|
| 89 | - $articlesObj->setVar('art_img', $uploader->getSavedFileName()); |
|
| 90 | - } |
|
| 91 | - } else { |
|
| 92 | - $articlesObj->setVar('art_img', Request::getString('art_img')); |
|
| 93 | - } |
|
| 94 | - $articlesObj->setVar('art_online', Request::getInt('art_online', 0)); |
|
| 95 | - // Set Var art_file |
|
| 96 | - include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 97 | - $uploader = new \XoopsMediaUploader(MYMODULE_UPLOAD_FILES_PATH . '/articles/', |
|
| 98 | - $helper->getConfig('mimetypes'), |
|
| 99 | - $helper->getConfig('maxsize'), null, null); |
|
| 100 | - if($uploader->fetchMedia($_POST['xoops_upload_file'][1])) { |
|
| 101 | - $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $_FILES['art_file']['name']); |
|
| 102 | - $imgName = str_replace(' ', '', Request::getString('art_title')) . '.' . $extension; |
|
| 103 | - $uploader->setPrefix($imgName); |
|
| 104 | - $uploader->fetchMedia($_POST['xoops_upload_file'][1]); |
|
| 105 | - if(!$uploader->upload()) { |
|
| 106 | - $errors = $uploader->getErrors(); |
|
| 107 | - redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 108 | - } else { |
|
| 109 | - $articlesObj->setVar('art_file', $uploader->getSavedFileName()); |
|
| 110 | - } |
|
| 111 | - } else { |
|
| 112 | - $articlesObj->setVar('art_file', Request::getString('art_file')); |
|
| 113 | - } |
|
| 114 | - $articleCreated = date_create_from_format(_SHORTDATESTRING, $_POST['art_created']); |
|
| 115 | - $articlesObj->setVar('art_created', $articleCreated->getTimestamp()); |
|
| 116 | - $articlesObj->setVar('art_submitter', Request::getInt('art_submitter', 0)); |
|
| 117 | - if($error === true) { |
|
| 118 | - $GLOBALS['xoopsTpl']->assign('error_message', $errorMessage); |
|
| 119 | - } else { |
|
| 120 | - // Insert Data |
|
| 121 | - if($articles1->insert($articlesObj)) { |
|
| 122 | - redirect_header('index.php', 2, _MA_MYMODULE_FORM_OK); |
|
| 123 | - } |
|
| 124 | - } |
|
| 125 | - // Get Form Error |
|
| 126 | - $GLOBALS['xoopsTpl']->assign('error', $articlesObj->getHtmlErrors()); |
|
| 127 | - $form = $articlesObj->getFormArticles(); |
|
| 128 | - $GLOBALS['xoopsTpl']->assign('form', $form->display()); |
|
| 56 | + break; |
|
| 57 | + case 'save': |
|
| 58 | + // Security Check |
|
| 59 | + if($GLOBALS['xoopsSecurity']->check()) { |
|
| 60 | + redirect_header('articles.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
|
| 61 | + } |
|
| 62 | + $articlesObj = $articlesHandler->create(); |
|
| 63 | + $error = false; |
|
| 64 | + $errorMessage = ''; |
|
| 65 | + // Test first the validation |
|
| 66 | + xoops_load('captcha'); |
|
| 67 | + $xoopsCaptcha = \XoopsCaptcha::getInstance(); |
|
| 68 | + if(!$xoopsCaptcha->verify()) { |
|
| 69 | + $errorMessage .= $xoopsCaptcha->getMessage().'<br>'; |
|
| 70 | + $error = true; |
|
| 71 | + } |
|
| 72 | + $articlesObj->setVar('art_cat', Request::getInt('art_cat', 0)); |
|
| 73 | + $articlesObj->setVar('art_title', Request::getString('art_title', '')); |
|
| 74 | + $articlesObj->setVar('art_descr', Request::getString('art_descr', '')); |
|
| 75 | + // Set Var art_img |
|
| 76 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 77 | + $uploader = new \XoopsMediaUploader(MYMODULE_UPLOAD_IMAGE_PATH . '/articles/', |
|
| 78 | + $helper->getConfig('mimetypes'), |
|
| 79 | + $helper->getConfig('maxsize'), null, null); |
|
| 80 | + if($uploader->fetchMedia($_POST['xoops_upload_file'][0])) { |
|
| 81 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $_FILES['attachedfile']['name']); |
|
| 82 | + $imgName = str_replace(' ', '', Request::getString('art_title')) . '.' . $extension; |
|
| 83 | + $uploader->setPrefix($imgName); |
|
| 84 | + $uploader->fetchMedia($_POST['xoops_upload_file'][0]); |
|
| 85 | + if(!$uploader->upload()) { |
|
| 86 | + $errors = $uploader->getErrors(); |
|
| 87 | + redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 88 | + } else { |
|
| 89 | + $articlesObj->setVar('art_img', $uploader->getSavedFileName()); |
|
| 90 | + } |
|
| 91 | + } else { |
|
| 92 | + $articlesObj->setVar('art_img', Request::getString('art_img')); |
|
| 93 | + } |
|
| 94 | + $articlesObj->setVar('art_online', Request::getInt('art_online', 0)); |
|
| 95 | + // Set Var art_file |
|
| 96 | + include_once XOOPS_ROOT_PATH . '/class/uploader.php'; |
|
| 97 | + $uploader = new \XoopsMediaUploader(MYMODULE_UPLOAD_FILES_PATH . '/articles/', |
|
| 98 | + $helper->getConfig('mimetypes'), |
|
| 99 | + $helper->getConfig('maxsize'), null, null); |
|
| 100 | + if($uploader->fetchMedia($_POST['xoops_upload_file'][1])) { |
|
| 101 | + $extension = preg_replace('/^.+\.([^.]+)$/sU', '', $_FILES['art_file']['name']); |
|
| 102 | + $imgName = str_replace(' ', '', Request::getString('art_title')) . '.' . $extension; |
|
| 103 | + $uploader->setPrefix($imgName); |
|
| 104 | + $uploader->fetchMedia($_POST['xoops_upload_file'][1]); |
|
| 105 | + if(!$uploader->upload()) { |
|
| 106 | + $errors = $uploader->getErrors(); |
|
| 107 | + redirect_header('javascript:history.go(-1).php', 3, $errors); |
|
| 108 | + } else { |
|
| 109 | + $articlesObj->setVar('art_file', $uploader->getSavedFileName()); |
|
| 110 | + } |
|
| 111 | + } else { |
|
| 112 | + $articlesObj->setVar('art_file', Request::getString('art_file')); |
|
| 113 | + } |
|
| 114 | + $articleCreated = date_create_from_format(_SHORTDATESTRING, $_POST['art_created']); |
|
| 115 | + $articlesObj->setVar('art_created', $articleCreated->getTimestamp()); |
|
| 116 | + $articlesObj->setVar('art_submitter', Request::getInt('art_submitter', 0)); |
|
| 117 | + if($error === true) { |
|
| 118 | + $GLOBALS['xoopsTpl']->assign('error_message', $errorMessage); |
|
| 119 | + } else { |
|
| 120 | + // Insert Data |
|
| 121 | + if($articles1->insert($articlesObj)) { |
|
| 122 | + redirect_header('index.php', 2, _MA_MYMODULE_FORM_OK); |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | + // Get Form Error |
|
| 126 | + $GLOBALS['xoopsTpl']->assign('error', $articlesObj->getHtmlErrors()); |
|
| 127 | + $form = $articlesObj->getFormArticles(); |
|
| 128 | + $GLOBALS['xoopsTpl']->assign('form', $form->display()); |
|
| 129 | 129 | |
| 130 | - break; |
|
| 130 | + break; |
|
| 131 | 131 | } |
| 132 | 132 | require __DIR__ . '/footer.php'; |