Passed
Pull Request — master (#192)
by Lio
04:47
created

kickfromgroup.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;
0 ignored issues
show
This use statement conflicts with another class in this namespace, Request. Consider defining an alias.

Let?s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let?s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
20
use XoopsModules\Suico\{
21
    RelgroupuserHandler,
22
    GroupsHandler
23
};
24
25
require __DIR__ . '/header.php';
26
$group_id     = Request::getInt('group_id', 0, 'POST');
27
$rel_user_uid = Request::getInt('rel_user_uid', 0, 'POST');
28
if (1 !== Request::getInt('confirm', 0, 'POST')) {
29
    xoops_confirm(
30
        [
31
            'rel_user_uid' => $rel_user_uid,
32
            'group_id'     => $group_id,
33
            'confirm'      => 1,
34
        ],
35
        'kickfromgroup.php',
36
        _MD_SUICO_ASKCONFIRMKICKFROMGROUP,
37
        _MD_SUICO_CONFIRMKICK
38
    );
39
} else {
40
    /**
41
     * Creating the factory  and the criteria to delete the picture
42
     * The user must be the owner
43
     */
44
    $relgroupuserFactory = new RelgroupuserHandler(
45
        $xoopsDB
46
    );
47
    $groupsFactory       = new GroupsHandler($xoopsDB);
48
    $group               = $groupsFactory->get2($group_id);
49
    //  echo "<pre>";
50
    //  print_r($group);
51
    if ($xoopsUser->getVar('uid') === $group->getVar('owner_uid')) {
52
        $criteria_rel_user_uid = new Criteria('rel_user_uid', $rel_user_uid);
53
        $criteria_group_id     = new Criteria('rel_group_id', $group_id);
54
        $criteria              = new CriteriaCompo($criteria_rel_user_uid);
55
        $criteria->add($criteria_group_id);
56
        /**
57
         * Try to delete
58
         */
59
        if ($relgroupuserFactory->deleteAll($criteria)) {
60
            redirect_header('group.php?group_id=' . $group_id . '', 2, _MD_SUICO_GROUPKICKED);
61
        } else {
62
            redirect_header('group.php?group_id=' . $group_id . '', 2, _MD_SUICO_ERROR);
63
        }
64
    } else {
65
        redirect_header('group.php?group_id=' . $group_id . '', 2, _MD_SUICO_ERROR);
66
    }
67
}
68
require \dirname(__DIR__, 2) . '/footer.php';
69