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\Helper; |
||
| 27 | use XoopsModules\Adslight\PicturesHandler; |
||
| 28 | |||
| 29 | /** @var Helper $helper */ |
||
| 30 | |||
| 31 | require_once __DIR__ . '/header.php'; |
||
| 32 | /** |
||
| 33 | * Xoops Header |
||
| 34 | */ |
||
| 35 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Include modules classes |
||
| 39 | */ |
||
| 40 | |||
| 41 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 42 | redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 3, _ADSLIGHT_TOKENEXPIRED); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Receiving info from get parameters |
||
| 47 | */ |
||
| 48 | $cod_img = Request::getInt('cod_img', 0, 'POST'); |
||
| 49 | $marker = Request::getInt('marker', 0, 'POST'); |
||
| 50 | |||
| 51 | if (1 === $marker) { |
||
| 52 | /** |
||
| 53 | * Creating the factory loading the picture changing its caption |
||
| 54 | */ |
||
| 55 | $title = Request::getString('caption', '', 'POST'); |
||
| 56 | |||
| 57 | $picture_factory = new PicturesHandler($xoopsDB); |
||
| 58 | $picture = $picture_factory->create(false); |
||
| 59 | $picture->load($cod_img); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 60 | $picture->setVar('title', $title); |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Verifying who's the owner to allow changes |
||
| 64 | */ |
||
| 65 | $uid = $GLOBALS['xoopsUser']->getVar('uid'); |
||
| 66 | $lid = $picture->getVar('lid'); |
||
| 67 | if ($uid === $picture->getVar('uid_owner')) { |
||
| 68 | if ($picture_factory->insert($picture)) { |
||
| 69 | $helper->redirect("view_photos.php?lid={$lid}&uid={$uid}", 2, _ADSLIGHT_DESC_EDITED); |
||
| 70 | } else { |
||
| 71 | $helper->redirect("view_photos.php?lid={$lid}&uid={$uid}", 2, _ADSLIGHT_NOCACHACA); |
||
| 72 | } |
||
| 73 | } |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Creating the factory and the criteria to edit the desc of the picture |
||
| 78 | * The user must be the owner |
||
| 79 | */ |
||
| 80 | $albumFactory = new PicturesHandler($xoopsDB); |
||
| 81 | $criteria_img = new \Criteria('cod_img', $cod_img); |
||
| 82 | $uid = $GLOBALS['xoopsUser']->getVar('uid'); |
||
| 83 | $criteria_uid = new \Criteria('uid_owner', $uid); |
||
| 84 | $criteria = new \CriteriaCompo($criteria_img); |
||
| 85 | $criteria->add($criteria_uid); |
||
| 86 | |||
| 87 | /** |
||
| 88 | * Let's fetch the info of the pictures to be able to render the form |
||
| 89 | * The user must be the owner |
||
| 90 | */ |
||
| 91 | $array_pict = $albumFactory->getObjects($criteria); |
||
| 92 | if ($array_pict) { |
||
| 93 | $caption = $array_pict[0]->getVar('title'); |
||
| 94 | $url = $array_pict[0]->getVar('url'); |
||
| 95 | } |
||
| 96 | $url = "{$GLOBALS['xoopsModuleConfig']['adslight_link_upload']}/thumbs/thumb_{$url}"; |
||
| 97 | $albumFactory->renderFormEdit($caption, $cod_img, $url); |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Close page |
||
| 101 | */ |
||
| 102 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
| 103 |