Passed
Pull Request — master (#81)
by Michael
02:56
created

editdescvideo.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('video_id', 0, 'POST');
31
$marker  = Request::getInt('marker', 0, 'POST');
32
33
$uid = (int)$xoopsUser->getVar('uid');
34
35
if (1 === $marker) {
36
    /**
37
     * Creating the factory  loading the picture changing its caption
38
     */
39
    $videoFactory = new Yogurt\VideoHandler(
40
        $xoopsDB
41
    );
42
    $video        = $videoFactory->create(false);
43
    $video->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

43
    $video->/** @scrutinizer ignore-call */ 
44
            load($cod_img);
Loading history...
44
    $video->setVar('video_desc', trim(htmlspecialchars($_POST['caption'], ENT_QUOTES | ENT_HTML5)));
45
46
    /**
47
     * Verifying who's the owner to allow changes
48
     */
49
    if ($uid === $video->getVar('uid_owner')) {
50
        if ($videoFactory->insert2($video)) {
51
            redirect_header('videos.php?uid=' . $uid, 2, _MD_YOGURT_DESC_EDITED);
52
        } else {
53
            redirect_header('index.php?uid=' . $uid, 2, _MD_YOGURT_ERROR);
54
        }
55
    }
56
}
57
/**
58
 * Creating the factory  and the criteria to edit the desc of the picture
59
 * The user must be the owner
60
 */
61
$videoFactory   = new Yogurt\VideoHandler(
62
    $xoopsDB
63
);
64
$criteria_video = new Criteria('video_id', $cod_img);
65
$criteriaUid    = new Criteria('uid_owner', $uid);
66
$criteria       = new CriteriaCompo($criteria_video);
67
$criteria->add($criteriaUid);
68
69
/**
70
 * Lets fetch the info of the pictures to be able to render the form
71
 * The user must be the owner
72
 */
73
$array_pict = $videoFactory->getObjects(
74
    $criteria
75
);
76
if ($array_pict) {
77
    $caption = $array_pict[0]->getVar('video_desc');
78
    $url     = $array_pict[0]->getVar('youtube_code');
79
}
80
81
$videoFactory->renderFormEdit($caption, $cod_img, $url);
82
83
require dirname(__DIR__, 2) . '/footer.php';
84