Passed
Push — master ( 4ef713...b149e1 )
by
unknown
05:52 queued 02:52
created

editpicture.php (1 issue)

Labels
Severity
1
<?php declare(strict_types=1);
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
*/
12
13
/**
14
 * @copyright    XOOPS Project https://xoops.org/
15
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
16
 * @author       Marcello Brandão aka  Suico
17
 * @author       XOOPS Development Team
18
 * @since
19
 */
20
21
use Xmf\Request;
22
use XoopsModules\Yogurt;
23
24
require __DIR__ . '/header.php';
25
26
if (!$GLOBALS['xoopsSecurity']->check()) {
27
    redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 3, _MD_YOGURT_TOKENEXPIRED);
28
}
29
30
$cod_img = Request::getInt('cod_img', 0, 'POST');
31
$marker  = Request::getInt('marker', 0, 'POST');
32
$uid     = (int)$xoopsUser->getVar('uid');
33
34
if (1 === $marker) {
35
    /**
36
     * Creating the factory loading the picture changing its caption
37
     */
38
    $imageFactory = new Yogurt\ImageHandler(
39
        $xoopsDB
40
    );
41
    $picture      = $imageFactory->create(false);
42
    $picture->load($cod_img);
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\Yogurt\Groups or XoopsModules\Yogurt\Ishot or XoopsModules\Yogurt\Friendrequest or XoopsModules\Yogurt\Relgroupuser or XoopsModules\Yogurt\Visitors or XoopsComments or XoopsModules\Yogurt\Audio or XoopsModules\Yogurt\Video or XoopsModules\Yogurt\Notes or XoopsModules\Yogurt\Friendship or XoopsModules\Yogurt\Image or XoopsModules\Yogurt\Configs or XoopsModules\Yogurt\Suspensions. ( Ignorable by Annotation )

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

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