Passed
Push — master ( 7c9d88...a7d412 )
by Michael
03:18 queued 10s
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
25
require __DIR__ . '/header.php';
26
if (!$xoopsUser) {
27
    redirect_header('index.php');
28
}
29
$friendshipFactory = new Suico\FriendshipHandler($xoopsDB);
30
$friend2_uid       = Request::getInt('friend_uid', 0, 'POST');
31
$marker            = Request::getInt('marker', 0, 'POST');
32
$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

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