mambax7 /
extgallery
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * ExtGallery User area |
||
| 4 | * |
||
| 5 | * You may not change or alter any portion of this comment or credits |
||
| 6 | * of supporting developers from this source code or any supporting source code |
||
| 7 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 8 | * This program is distributed in the hope that it will be useful, |
||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 11 | * |
||
| 12 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 13 | * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
||
| 14 | * @author Zoullou (http://www.zoullou.net) |
||
| 15 | * @package ExtGallery |
||
| 16 | */ |
||
| 17 | |||
| 18 | |||
| 19 | use XoopsModules\Extgallery; |
||
| 20 | /** @var Extgallery\Helper $helper */ |
||
| 21 | $helper = Extgallery\Helper::getInstance(); |
||
| 22 | |||
| 23 | include __DIR__ . '/header.php'; |
||
| 24 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
| 25 | //require_once __DIR__ . '/class/Utility.php'; |
||
| 26 | |||
| 27 | if (isset($_GET['op'])) { |
||
| 28 | $op = $_GET['op']; |
||
| 29 | } else { |
||
| 30 | $op = 'default'; |
||
| 31 | } |
||
| 32 | |||
| 33 | if (isset($_POST['step'])) { |
||
| 34 | $step = $_POST['step']; |
||
| 35 | } else { |
||
| 36 | $step = 'default'; |
||
| 37 | } |
||
| 38 | |||
| 39 | if (!isset($GLOBALS['xoopsUser'])) { |
||
| 40 | redirect_header('index.php'); |
||
| 41 | } elseif (!$GLOBALS['xoopsUser']->isAdmin()) { |
||
| 42 | redirect_header('index.php'); |
||
| 43 | } |
||
| 44 | $moduleDirName = basename(__DIR__); |
||
| 45 | $utility = new Extgallery\Utility(); |
||
| 46 | switch ($op) { |
||
| 47 | |||
| 48 | case 'edit': |
||
| 49 | |||
| 50 | switch ($step) { |
||
| 51 | |||
| 52 | case 'enreg': |
||
| 53 | /** @var Extgallery\PublicPhotoHandler $photoHandler */ |
||
| 54 | $photoHandler = Extgallery\Helper::getInstance()->getHandler('PublicPhoto'); |
||
| 55 | $myts = \MyTextSanitizer::getInstance(); |
||
| 56 | $photo = $photoHandler->getPhoto($_POST['photo_id']); |
||
| 57 | |||
| 58 | $data['cat_id'] = $_POST['cat_id']; |
||
| 59 | $data['photo_desc'] = $_POST['photo_desc']; |
||
| 60 | $data['photo_title'] = $_POST['photo_title']; |
||
| 61 | $data['photo_weight'] = $_POST['photo_weight']; |
||
| 62 | |||
| 63 | if (isset($_POST['photo_extra'])) { |
||
| 64 | $data['photo_extra'] = $_POST['photo_extra']; |
||
| 65 | } |
||
| 66 | |||
| 67 | $photoHandler->modifyPhoto(\Xmf\Request::getInt('photo_id', 0, 'POST'), $data); |
||
|
0 ignored issues
–
show
|
|||
| 68 | |||
| 69 | // For xoops tag |
||
| 70 | if ((1 == $helper->getConfig('usetag')) && is_dir('../tag')) { |
||
| 71 | $tagHandler = \XoopsModules\Tag\Helper::getInstance()->getHandler('Tag'); // xoops_getModuleHandler('tag', 'tag'); |
||
| 72 | $tagHandler->updateByItem($_POST['tag'], $_POST['photo_id'], $xoopsModule->getVar('dirname'), 0); |
||
| 73 | } |
||
| 74 | |||
| 75 | // If the photo category change |
||
| 76 | if ($photo->getVar('cat_id') != $_POST['cat_id']) { |
||
| 77 | $catHandler = Extgallery\Helper::getInstance()->getHandler('PublicCategory'); |
||
| 78 | $oldCat = $catHandler->getCat($photo->getVar('cat_id')); |
||
| 79 | $newCat = $catHandler->getCat($_POST['cat_id']); |
||
| 80 | |||
| 81 | // Set new category as album |
||
| 82 | $catHandler->modifyCat(['cat_id' => \Xmf\Request::getInt('cat_id', 0, 'POST'), 'cat_isalbum' => 1]); |
||
| 83 | |||
| 84 | // Update album count |
||
| 85 | if (1 == $oldCat->getVar('cat_nb_photo')) { |
||
| 86 | $criteria = new \CriteriaCompo(); |
||
| 87 | $criteria->add(new \Criteria('nleft', $oldCat->getVar('nleft'), '<')); |
||
| 88 | $criteria->add(new \Criteria('nright', $oldCat->getVar('nright'), '>')); |
||
| 89 | $catHandler->updateFieldValue('cat_nb_album', 'cat_nb_album - 1', $criteria); |
||
| 90 | } |
||
| 91 | |||
| 92 | if (0 == $newCat->getVar('cat_nb_photo')) { |
||
| 93 | $criteria = new \CriteriaCompo(); |
||
| 94 | $criteria->add(new \Criteria('nleft', $newCat->getVar('nleft'), '<')); |
||
| 95 | $criteria->add(new \Criteria('nright', $newCat->getVar('nright'), '>')); |
||
| 96 | $catHandler->updateFieldValue('cat_nb_album', 'cat_nb_album + 1', $criteria); |
||
| 97 | } |
||
| 98 | |||
| 99 | // Update photo count |
||
| 100 | $criteria = new \CriteriaCompo(); |
||
| 101 | $criteria->add(new \Criteria('nleft', $newCat->getVar('nleft'), '<=')); |
||
| 102 | $criteria->add(new \Criteria('nright', $newCat->getVar('nright'), '>=')); |
||
| 103 | $catHandler->updateFieldValue('cat_nb_photo', 'cat_nb_photo + 1', $criteria); |
||
| 104 | |||
| 105 | $criteria = new \CriteriaCompo(); |
||
| 106 | $criteria->add(new \Criteria('nleft', $oldCat->getVar('nleft'), '<=')); |
||
| 107 | $criteria->add(new \Criteria('nright', $oldCat->getVar('nright'), '>=')); |
||
| 108 | $catHandler->updateFieldValue('cat_nb_photo', 'cat_nb_photo - 1', $criteria); |
||
| 109 | |||
| 110 | // If the old album don't contains other photo |
||
| 111 | if (0 == $photoHandler->nbPhoto($oldCat)) { |
||
| 112 | $catHandler->modifyCat(['cat_id' => $photo->getVar('cat_id'), 'cat_isalbum' => 0]); |
||
| 113 | redirect_header('public-categories.php?id=' . $photo->getVar('cat_id'), 3, _MD_EXTGALLERY_PHOTO_UPDATED); |
||
| 114 | } else { |
||
| 115 | redirect_header('public-album.php?id=' . $photo->getVar('cat_id'), 3, _MD_EXTGALLERY_PHOTO_UPDATED); |
||
| 116 | } |
||
| 117 | } else { |
||
| 118 | redirect_header('public-photo.php?photoId=' . $photo->getVar('photo_id'), 3, _MD_EXTGALLERY_PHOTO_UPDATED); |
||
| 119 | } |
||
| 120 | |||
| 121 | break; |
||
| 122 | |||
| 123 | case 'default': |
||
| 124 | default: |
||
| 125 | |||
| 126 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 127 | $myts = \MyTextSanitizer::getInstance(); |
||
| 128 | /** @var Extgallery\PublicCategoryHandler $catHandler */ |
||
| 129 | $catHandler = Extgallery\Helper::getInstance()->getHandler('PublicCategory'); |
||
| 130 | /** @var Extgallery\PublicPhotoHandler $photoHandler */ |
||
| 131 | $photoHandler = Extgallery\Helper::getInstance()->getHandler('PublicPhoto'); |
||
| 132 | |||
| 133 | $photo = $photoHandler->getPhoto(\Xmf\Request::getInt('id', 0, 'GET')); |
||
| 134 | |||
| 135 | echo '<img src="' . XOOPS_URL . '/uploads/extgallery/public-photo/thumb/thumb_' . $photo->getVar('photo_name') . '">'; |
||
| 136 | |||
| 137 | $form = new \XoopsThemeForm(_MD_EXTGALLERY_MODIFY_PHOTO, 'add_photo', 'public-modify.php?op=edit', 'post', true); |
||
| 138 | $form->addElement(new \XoopsFormLabel(_MD_EXTGALLERY_CATEGORY, $catHandler->getLeafSelect('cat_id', false, $photo->getVar('cat_id')))); |
||
| 139 | $form->addElement(new \XoopsFormText(_MD_EXTGALLERY_PHOTO_WEIGHT, 'photo_weight', '3', '11', $photo->getVar('photo_weight')), false); |
||
| 140 | $form->addElement(new \XoopsFormText(_MD_EXTGALLERY_PHOTO_TITLE, 'photo_title', '50', '150', $photo->getVar('photo_title')), false); |
||
| 141 | //DNPROSSI - wysiwyg editors from xoopseditors |
||
| 142 | //TODO dohtml - dobr |
||
| 143 | $photo_desc = $myts->displayTarea($photo->getVar('photo_desc'), 0, 1, 1, 1, 0); |
||
| 144 | $editor = $utility::getWysiwygForm(_MD_EXTGALLERY_DESC, 'photo_desc', $photo_desc, 15, 60, '100%', '350px', 'hometext_hidden'); |
||
| 145 | $form->addElement($editor, false); |
||
| 146 | if ($helper->getConfig('display_extra_field')) { |
||
| 147 | $form->addElement(new \XoopsFormTextArea(_MD_EXTGALLERY_EXTRA_INFO, 'photo_extra', $photo->getVar('photo_extra'))); |
||
| 148 | } |
||
| 149 | |||
| 150 | // For xoops tag |
||
| 151 | if ((1 == $helper->getConfig('usetag')) && is_dir('../tag')) { |
||
| 152 | $tagId = $photo->isNew() ? 0 : $photo->getVar('photo_id'); |
||
| 153 | require_once XOOPS_ROOT_PATH . '/modules/tag/include/formtag.php'; |
||
| 154 | $form->addElement(new TagFormTag('tag', 60, 255, $tagId, 0)); |
||
| 155 | } |
||
| 156 | |||
| 157 | $form->addElement(new \XoopsFormHidden('photo_id', $_GET['id'])); |
||
| 158 | $form->addElement(new \XoopsFormHidden('step', 'enreg')); |
||
| 159 | $form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
||
| 160 | $form->display(); |
||
| 161 | |||
| 162 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
| 163 | |||
| 164 | break; |
||
| 165 | |||
| 166 | } |
||
| 167 | |||
| 168 | break; |
||
| 169 | |||
| 170 | case 'delete': |
||
| 171 | /** @var Extgallery\PublicCategoryHandler $catHandler */ |
||
| 172 | $catHandler = Extgallery\Helper::getInstance()->getHandler('PublicCategory'); |
||
| 173 | /** @var Extgallery\PublicPhotoHandler $photoHandler */ |
||
| 174 | $photoHandler = Extgallery\Helper::getInstance()->getHandler('PublicPhoto'); |
||
| 175 | |||
| 176 | $photo = $photoHandler->getPhoto(\Xmf\Request::getInt('id', 0, 'GET')); |
||
| 177 | $photoHandler->deletePhoto($photo); |
||
| 178 | |||
| 179 | $cat = $catHandler->getCat($photo->getVar('cat_id')); |
||
| 180 | |||
| 181 | // Update photo count |
||
| 182 | $criteria = new \CriteriaCompo(); |
||
| 183 | $criteria->add(new \Criteria('nleft', $cat->getVar('nleft'), '<=')); |
||
| 184 | $criteria->add(new \Criteria('nright', $cat->getVar('nright'), '>=')); |
||
| 185 | $catHandler->updateFieldValue('cat_nb_photo', 'cat_nb_photo - 1', $criteria); |
||
| 186 | |||
| 187 | if (1 == $cat->getVar('cat_nb_photo')) { |
||
| 188 | |||
| 189 | // Update album count |
||
| 190 | $criteria = new \CriteriaCompo(); |
||
| 191 | $criteria->add(new \Criteria('nleft', $cat->getVar('nleft'), '<')); |
||
| 192 | $criteria->add(new \Criteria('nright', $cat->getVar('nright'), '>')); |
||
| 193 | $catHandler->updateFieldValue('cat_nb_album', 'cat_nb_album - 1', $criteria); |
||
| 194 | |||
| 195 | $catHandler->modifyCat(['cat_id' => $photo->getVar('cat_id'), 'cat_isalbum' => 0]); |
||
| 196 | |||
| 197 | redirect_header('public-categories.php?id=' . $photo->getVar('cat_id')); |
||
| 198 | } else { |
||
| 199 | redirect_header('public-album.php?id=' . $photo->getVar('cat_id')); |
||
| 200 | } |
||
| 201 | |||
| 202 | break; |
||
| 203 | |||
| 204 | } |
||
| 205 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths