Passed
Pull Request — master (#187)
by Michael
16:36
created

editpicture.php (1 issue)

Labels
Severity
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
if (!$GLOBALS['xoopsSecurity']->check()) {
26
    redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 3, _MD_SUICO_TOKENEXPIRED);
27
}
28
$image_id = Request::getInt('image_id', 0, 'POST');
29
$marker   = Request::getInt('marker', 0, 'POST');
30
$uid      = (int)$xoopsUser->getVar('uid');
31
if (1 === $marker) {
32
    /**
33
     * Creating the factory loading the picture changing its caption
34
     */
35
    $imageFactory = new ImageHandler(
36
        $xoopsDB
37
    );
38
    $picture      = $imageFactory->create(false);
39
    $picture->load($image_id);
0 ignored issues
show
The method load() does not exist on XoopsObject. It seems like you code against a sub-type of XoopsObject such as XoopsModules\Suico\Video or XoopsModules\Suico\Suspensions or XoopsBlock or XoopsModules\Suico\Notes or XoopsModules\Suico\Image or XoopsModules\Suico\Friendship or XoopsComments or XoopsModules\Suico\Visitors or XoopsModules\Suico\Relgroupuser or XoopsModules\Suico\Groups or XoopsModules\Suico\Configs or XoopsModules\Suico\Friendrequest or XoopsModules\Suico\Ishot or XoopsModules\Suico\Audio. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

39
    $picture->/** @scrutinizer ignore-call */ 
40
              load($image_id);
Loading history...
40
    $picture->setVar('title', Request::getString('title', '', 'POST'));
41
    $picture->setVar('caption', Request::getString('caption', '', 'POST'));
42
    /**
43
     * Verifying who's the owner to allow changes
44
     */
45
    if ($uid === (int)$picture->getVar('uid_owner')) {
46
        if ($imageFactory->insert2($picture)) {
47
            redirect_header('album.php#' . $image_id . '', 2, _MD_SUICO_DESC_EDITED);
48
        } else {
49
            redirect_header('album.php', 2, _MD_SUICO_ERROR);
50
        }
51
    }
52
}
53
/**
54
 * Creating the factory  and the criteria to edit the desc of the picture
55
 * The user must be the owner
56
 */
57
$imageFactory = new ImageHandler(
58
    $xoopsDB
59
);
60
$criteria_img = new Criteria('image_id', $image_id);
61
$criteriaUid  = new Criteria('uid_owner', $uid);
62
$criteria     = new CriteriaCompo($criteria_img);
63
$criteria->add($criteriaUid);
64
/**
65
 * Lets fetch the info of the pictures to be able to render the form
66
 * The user must be the owner
67
 */
68
$array_pict = $imageFactory->getObjects(
69
    $criteria
70
);
71
if ($array_pict) {
72
    $title    = $array_pict[0]->getVar('title');
73
    $caption  = $array_pict[0]->getVar('caption');
74
    $filename = $array_pict[0]->getVar('filename');
75
}
76
//$url = $xoopsModuleConfig['link_path_upload']."/thumb_".$url;
77
$url = XOOPS_URL . '/uploads/suico/images/thumb_' . $filename;
78
$imageFactory->renderFormEdit($title, $caption, $image_id, $url);
79
require \dirname(__DIR__, 2) . '/footer.php';
80