XoopsModules25x /
suico
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 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 | |||
| 9 | This program is distributed in the hope that it will be useful, |
||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 12 | */ |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @category Module |
||
| 16 | * @package suico |
||
| 17 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 18 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
| 19 | * @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org> |
||
| 20 | */ |
||
| 21 | |||
| 22 | use Xmf\Request; |
||
| 23 | use XoopsModules\Suico\{ |
||
| 24 | ImageHandler |
||
| 25 | }; |
||
| 26 | |||
| 27 | require __DIR__ . '/header.php'; |
||
| 28 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 29 | redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 3, _MD_SUICO_TOKENEXPIRED); |
||
| 30 | } |
||
| 31 | $image_id = Request::getInt('image_id', 0, 'POST'); |
||
| 32 | $marker = Request::getInt('marker', 0, 'POST'); |
||
| 33 | $uid = (int)$xoopsUser->getVar('uid'); |
||
| 34 | if (1 === $marker) { |
||
| 35 | /** |
||
| 36 | * Creating the factory loading the picture changing its caption |
||
| 37 | */ |
||
| 38 | $imageFactory = new ImageHandler( |
||
| 39 | $xoopsDB |
||
| 40 | ); |
||
| 41 | $picture = $imageFactory->create(false); |
||
| 42 | $picture->load($image_id); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 43 | $picture->setVar('title', Request::getString('title', '', 'POST')); |
||
| 44 | $picture->setVar('caption', Request::getString('caption', '', 'POST')); |
||
| 45 | /** |
||
| 46 | * Verifying who's the owner to allow changes |
||
| 47 | */ |
||
| 48 | if ($uid === (int)$picture->getVar('uid_owner')) { |
||
| 49 | if ($imageFactory->insert2($picture)) { |
||
| 50 | redirect_header('album.php#' . $image_id . '', 2, _MD_SUICO_DESC_EDITED); |
||
| 51 | } else { |
||
| 52 | redirect_header('album.php', 2, _MD_SUICO_ERROR); |
||
| 53 | } |
||
| 54 | } |
||
| 55 | } |
||
| 56 | /** |
||
| 57 | * Creating the factory and the criteria to edit the desc of the picture |
||
| 58 | * The user must be the owner |
||
| 59 | */ |
||
| 60 | $imageFactory = new ImageHandler( |
||
| 61 | $xoopsDB |
||
| 62 | ); |
||
| 63 | $criteria_img = new Criteria('image_id', $image_id); |
||
| 64 | $criteriaUid = new Criteria('uid_owner', $uid); |
||
| 65 | $criteria = new CriteriaCompo($criteria_img); |
||
| 66 | $criteria->add($criteriaUid); |
||
| 67 | /** |
||
| 68 | * Lets fetch the info of the pictures to be able to render the form |
||
| 69 | * The user must be the owner |
||
| 70 | */ |
||
| 71 | $array_pict = $imageFactory->getObjects( |
||
| 72 | $criteria |
||
| 73 | ); |
||
| 74 | if ($array_pict) { |
||
| 75 | $title = $array_pict[0]->getVar('title'); |
||
| 76 | $caption = $array_pict[0]->getVar('caption'); |
||
| 77 | $filename = $array_pict[0]->getVar('filename'); |
||
| 78 | } |
||
| 79 | //$url = $xoopsModuleConfig['link_path_upload']."/thumb_".$url; |
||
| 80 | $url = XOOPS_URL . '/uploads/suico/images/thumb_' . $filename; |
||
| 81 | $imageFactory->renderFormEdit($title, $caption, $image_id, $url); |
||
| 82 | require dirname(__DIR__, 2) . '/footer.php'; |
||
| 83 |