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