Passed
Branch master (410c7b)
by Michael
03:30
created

editdescvideo.php (1 issue)

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

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