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

abandongroup.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
};
23
24
require __DIR__ . '/header.php';
25
/**
26
 * Verify Token
27
 */
28
//if (!($GLOBALS['xoopsSecurity']->check())){
29
//            redirect_header(\Xmf\Request::getString('HTTP_REFERER', '', 'SERVER'), 5, _MD_SUICO_TOKENEXPIRED);
30
//}
31
/**
32
 * Receiving info from get parameters
33
 */
34
$relgroupuser_id = Request::getInt('relgroup_id', 0, 'POST');
35
$group_id        = Request::getInt('group_id', 0, 'POST');
36
if (!isset($_POST['confirm']) || 1 !== Request::getInt('confirm', 0, 'POST')) {
37
    xoops_confirm(
38
        [
39
            'relgroup_id' => $relgroupuser_id,
40
            'group_id'    => $group_id,
41
            'confirm'     => 1,
42
        ],
43
        'abandongroup.php',
44
        _MD_SUICO_ASKCONFIRMABANDONGROUP,
45
        _MD_SUICO_CONFIRMABANDON
46
    );
47
} else {
48
    /**
49
     * Creating the factory  and the criteria to delete the picture
50
     * The user must be the owner
51
     */
52
    $relgroupuserFactory = new RelgroupuserHandler(
53
        $xoopsDB
54
    );
55
    $criteria_rel_id     = new Criteria('rel_id', $relgroupuser_id);
56
    $uid                 = (int)$xoopsUser->getVar('uid');
57
    $criteriaUid         = new Criteria('rel_user_uid', $uid);
58
    $criteria            = new CriteriaCompo($criteria_rel_id);
59
    $criteria->add($criteriaUid);
60
    /**
61
     * Try to delete
62
     */
63
    if ($relgroupuserFactory->deleteAll($criteria)) {
64
        redirect_header('group.php?group_id=' . $group_id . '', 1, _MD_SUICO_GROUPABANDONED);
65
    } else {
66
        redirect_header('group.php?group_id=' . $group_id . '', 1, _MD_SUICO_ERROR);
67
    }
68
}
69
require \dirname(__DIR__, 2) . '/footer.php';
70