Passed
Push — master ( eaf682...6209eb )
by
unknown
05:05 queued 02:33
created

editfriendship.php (1 issue)

Labels
Severity
1
<?php declare(strict_types=1);
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
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
13
/**
14
 * @copyright    XOOPS Project https://xoops.org/
15
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
16
 * @author       Marcello Brandão aka  Suico
17
 * @author       XOOPS Development Team
18
 * @since
19
 */
20
21
use Xmf\Request;
22
use XoopsModules\Yogurt;
23
24
require __DIR__ . '/header.php';
25
26
if (!$xoopsUser) {
27
    redirect_header('index.php');
28
}
29
30
$friendshipFactory = new Yogurt\FriendshipHandler($xoopsDB);
31
$friend2_uid       = Request::getInt('friend_uid', 0, 'POST');
32
$marker            = Request::getInt('marker', 0, 'POST');
33
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
36
if (1 === $marker) {
37
    $level         = $_POST['level'];
38
    $cool          = $_POST['cool'];
39
    $friendly      = $_POST['hot'];
40
    $funny         = $_POST['trust'];
41
    $fan           = $_POST['fan'];
42
    $friendship_id = Request::getInt('friendship_id', 0, 'POST');
43
44
    $criteria    = new Criteria('friendship_id', $friendship_id);
45
    $friendships = $friendshipFactory->getObjects($criteria);
46
    $friendship  = $friendships[0];
47
    $friendship->setVar('level', $level);
48
    $friendship->setVar('cool', $cool);
49
    $friendship->setVar('hot', $friendly);
50
    $friendship->setVar('trust', $funny);
51
    $friendship->setVar('fan', $fan);
52
    $friend2_uid = (int)$friendship->getVar('friend2_uid');
53
    $friendship->unsetNew();
54
    $friendshipFactory->insert2($friendship);
55
    redirect_header('friends.php', 2, _MD_YOGURT_FRIENDSHIP_UPDATED);
56
} else {
57
    $friendshipFactory->renderFormSubmit($friend);
58
}
59
60
require dirname(dirname(__DIR__)) . '/footer.php';
61