1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @category Module |
14
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
15
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
16
|
|
|
* @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org> |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use Xmf\Request; |
20
|
|
|
use XoopsModules\Suico\{ |
21
|
|
|
ImageHandler |
22
|
|
|
}; |
23
|
|
|
|
24
|
|
|
require __DIR__ . '/header.php'; |
25
|
|
|
//require_once __DIR__ . '/class/Image.php'; |
26
|
|
|
if (!$GLOBALS['xoopsSecurity']->check()) { |
27
|
|
|
redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 3, _MD_SUICO_TOKENEXPIRED); |
28
|
|
|
} |
29
|
|
|
$image_id = Request::getInt('image_id', 0, 'POST'); |
30
|
|
|
/** |
31
|
|
|
* Creating the factory loading the picture changing its caption |
32
|
|
|
*/ |
33
|
|
|
$imageFactory = new ImageHandler( |
34
|
|
|
$xoopsDB |
35
|
|
|
); |
36
|
|
|
$picture = $imageFactory->create(false); |
37
|
|
|
$picture->load($image_id); |
|
|
|
|
38
|
|
|
$picture->setVar('private', Request::getInt('private', 0, 'POST')); |
39
|
|
|
/** |
40
|
|
|
* Verifying who's the owner to allow changes |
41
|
|
|
*/ |
42
|
|
|
$uid = (int)$xoopsUser->getVar('uid'); |
43
|
|
|
if ($uid === (int)$picture->getVar('uid_owner')) { |
44
|
|
|
if ($imageFactory->insert2($picture)) { |
45
|
|
|
if (1 === Request::getInt('private', 0, 'POST')) { |
46
|
|
|
redirect_header('album.php', 2, _MD_SUICO_PRIVATIZED); |
47
|
|
|
} else { |
48
|
|
|
redirect_header('album.php', 2, _MD_SUICO_UNPRIVATIZED); |
49
|
|
|
} |
50
|
|
|
} else { |
51
|
|
|
redirect_header('album.php', 2, _MD_SUICO_ERROR); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
require \dirname(__DIR__, 2) . '/footer.php'; |
55
|
|
|
|