Passed
Push — master ( cd4615...b1d497 )
by Michael
02:16
created

public-rating.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * ExtGallery User area
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
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
 * @copyright   {@link https://xoops.org/ XOOPS Project}
13
 * @license     GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
14
 * @author      Zoullou (http://www.zoullou.net)
15
 * @package     ExtGallery
16
 */
17
18
use XoopsModules\Extgallery;
19
/** @var Extgallery\Helper $helper */
20
$helper = Extgallery\Helper::getInstance();
21
22
include __DIR__ . '/header.php';
23
//require_once XOOPS_ROOT_PATH . '/modules/extgallery/class/publicPerm.php';
24
25
$catId = \Xmf\Request::getInt('id', 0, 'GET');
0 ignored issues
show
The type Xmf\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
27
$rate = \Xmf\Request::getInt('rate', 0, 'GET');
28
29
/** @var Extgallery\PublicPhotoHandler $photoHandler */
30
$photoHandler = Extgallery\Helper::getInstance()->getHandler('PublicPhoto');
31
$photo        = $photoHandler->get($photoId);
32
33
$permHandler = Extgallery\PublicPermHandler::getInstance();
34
if ($helper->getConfig('enable_rating')
35
    && !$permHandler->isAllowed($GLOBALS['xoopsUser'], 'public_rate', $photo->getVar('cat_id'))) {
36
    redirect_header('index.php', 3, _MD_EXTGALLERY_NOPERM);
37
}
38
39
$ratingHandler = Extgallery\Helper::getInstance()->getHandler('PublicRating');
40
41
if ($ratingHandler->rate($photoId, $rate)) {
42
    $rating = $ratingHandler->getRate($photoId);
43
    $photoHandler->modifyPhoto($photoId, ['photo_rating' => $rating]);
44
45
    redirect_header('public-photo.php?photoId=' . $photoId . '#photoNav', 3, _MD_EXTGALLERY_VOTE_THANKS);
46
} else {
47
    redirect_header('public-photo.php?photoId=' . $photoId . '#photoNav', 3, _MD_EXTGALLERY_ALREADY_VOTED);
48
}
49