mambax7 /
adslight
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /* |
||
| 6 | * You may not change or alter any portion of this comment or credits |
||
| 7 | * of supporting developers from this source code or any supporting source code |
||
| 8 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 9 | * |
||
| 10 | * This program is distributed in the hope that it will be useful, |
||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 13 | */ |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @copyright XOOPS Project (https://xoops.org) |
||
| 17 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
| 18 | * @author XOOPS Development Team |
||
| 19 | * @author Pascal Le Boustouller: original author ([email protected]) |
||
| 20 | * @author Luc Bizet (www.frxoops.org) |
||
| 21 | * @author jlm69 (www.jlmzone.com) |
||
| 22 | * @author mamba (www.xoops.org) |
||
| 23 | */ |
||
| 24 | |||
| 25 | use Xmf\Request; |
||
| 26 | use XoopsModules\Adslight\{ |
||
| 27 | Helper, |
||
| 28 | PicturesHandler |
||
| 29 | }; |
||
| 30 | |||
| 31 | /** @var Helper $helper */ |
||
| 32 | |||
| 33 | require_once __DIR__ . '/header.php'; |
||
| 34 | /** |
||
| 35 | * Xoops Header |
||
| 36 | */ |
||
| 37 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 38 | |||
| 39 | $helper = Helper::getInstance(); |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Include modules classes |
||
| 43 | */ |
||
| 44 | |||
| 45 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 46 | redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 3, _ADSLIGHT_TOKENEXPIRED); |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Receiving info from get parameters |
||
| 51 | */ |
||
| 52 | $cod_img = Request::getInt('cod_img', 0, 'POST'); |
||
| 53 | $marker = Request::getInt('marker', 0, 'POST'); |
||
| 54 | |||
| 55 | if (1 === $marker) { |
||
| 56 | /** |
||
| 57 | * Creating the factory loading the picture changing its caption |
||
| 58 | */ |
||
| 59 | $title = Request::getString('caption', '', 'POST'); |
||
| 60 | |||
| 61 | $picturesHandler = $helper->getHandler('Pictures'); |
||
| 62 | $picture = $picturesHandler->create(false); |
||
| 63 | $picture->load($cod_img); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 64 | $picture->setVar('title', $title); |
||
| 65 | |||
| 66 | /** |
||
| 67 | * Verifying who's the owner to allow changes |
||
| 68 | */ |
||
| 69 | $uid = $GLOBALS['xoopsUser']->getVar('uid'); |
||
| 70 | $lid = $picture->getVar('lid'); |
||
| 71 | if ($uid === $picture->getVar('uid_owner')) { |
||
| 72 | if ($picturesHandler->insert($picture)) { |
||
| 73 | $helper->redirect("view_photos.php?lid={$lid}&uid={$uid}", 2, _ADSLIGHT_DESC_EDITED); |
||
| 74 | } else { |
||
| 75 | $helper->redirect("view_photos.php?lid={$lid}&uid={$uid}", 2, _ADSLIGHT_NOCACHACA); |
||
| 76 | } |
||
| 77 | } |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Creating the factory and the criteria to edit the desc of the picture |
||
| 82 | * The user must be the owner |
||
| 83 | */ |
||
| 84 | $picturesHandler = $helper->getHandler('Pictures'); |
||
| 85 | $criteria_img = new \Criteria('cod_img', $cod_img); |
||
| 86 | $uid = $GLOBALS['xoopsUser']->getVar('uid'); |
||
| 87 | $criteria_uid = new \Criteria('uid_owner', $uid); |
||
| 88 | $criteria = new \CriteriaCompo($criteria_img); |
||
| 89 | $criteria->add($criteria_uid); |
||
| 90 | |||
| 91 | /** |
||
| 92 | * Let's fetch the info of the pictures to be able to render the form |
||
| 93 | * The user must be the owner |
||
| 94 | */ |
||
| 95 | $array_pict = $picturesHandler->getObjects($criteria); |
||
| 96 | if ($array_pict) { |
||
| 97 | $caption = $array_pict[0]->getVar('title'); |
||
| 98 | $url = $array_pict[0]->getVar('url'); |
||
| 99 | } |
||
| 100 | $url = "{$helper->getConfig('adslight_link_upload')}/thumbs/thumb_{$url}"; |
||
| 101 | $picturesHandler->renderFormEdit($caption, $cod_img, $url); |
||
| 102 | |||
| 103 | /** |
||
| 104 | * Close page |
||
| 105 | */ |
||
| 106 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
| 107 |