Passed
Push — master ( f0fd80...9c2eb6 )
by Michael
33s queued 12s
created

editfriendship.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
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
9
 This program is distributed in the hope that it will be useful,
10
 but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
*/
13
14
/**
15
 * @category        Module
16
 * @package         suico
17
 * @copyright       {@link https://xoops.org/ XOOPS Project}
18
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
19
 * @author          Marcello Brandão aka  Suico, Mamba, LioMJ  <https://xoops.org>
20
 */
21
22
use Xmf\Request;
23
use XoopsModules\Suico\{
24
    FriendshipHandler
25
};
26
27
require __DIR__ . '/header.php';
28
if (!$xoopsUser) {
29
    redirect_header('index.php');
30
}
31
$friendshipFactory = new FriendshipHandler($xoopsDB);
32
$friend2_uid       = Request::getInt('friend_uid', 0, 'POST');
33
$marker            = Request::getInt('marker', 0, 'POST');
34
$friend            = new \XoopsUser($friend2_uid);
0 ignored issues
show
$friend2_uid of type integer is incompatible with the type array|null expected by parameter $id of XoopsUser::__construct(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

34
$friend            = new \XoopsUser(/** @scrutinizer ignore-type */ $friend2_uid);
Loading history...
35
if (1 === $marker) {
36
    $level         = $_POST['level'];
37
    $cool          = $_POST['cool'];
38
    $friendly      = $_POST['hot'];
39
    $funny         = $_POST['trust'];
40
    $fan           = $_POST['fan'];
41
    $friendship_id = Request::getInt('friendship_id', 0, 'POST');
42
    $criteria      = new Criteria('friendship_id', $friendship_id);
43
    $friendships   = $friendshipFactory->getObjects($criteria);
44
    $friendship    = $friendships[0];
45
    $friendship->setVar('level', $level);
46
    $friendship->setVar('cool', $cool);
47
    $friendship->setVar('hot', $friendly);
48
    $friendship->setVar('trust', $funny);
49
    $friendship->setVar('fan', $fan);
50
    $friend2_uid = (int)$friendship->getVar('friend2_uid');
51
    $friendship->unsetNew();
52
    $friendshipFactory->insert2($friendship);
53
    redirect_header('friends.php', 2, _MD_SUICO_FRIENDSHIP_UPDATED);
54
} else {
55
    $friendshipFactory->renderFormSubmit($friend);
56
}
57
require dirname(__DIR__, 2) . '/footer.php';
58