Passed
Push — master ( cca0b5...ef4664 )
by
unknown
34s queued 15s
created

editfriendship.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
*/
14
15
/**
16
 * @category        Module
17
 * @package         yogurt
18
 * @copyright       {@link https://xoops.org/ XOOPS Project}
19
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
20
 * @author          Marcello Brandão aka  Suico, Mamba, LioMJ  <https://xoops.org>
21
 */
22
23
use Xmf\Request;
24
use XoopsModules\Yogurt;
25
26
require __DIR__ . '/header.php';
27
28
if (!$xoopsUser) {
29
    redirect_header('index.php');
30
}
31
32
$friendshipFactory = new Yogurt\FriendshipHandler($xoopsDB);
33
$friend2_uid       = Request::getInt('friend_uid', 0, 'POST');
34
$marker            = Request::getInt('marker', 0, 'POST');
35
36
$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

36
$friend = new XoopsUser(/** @scrutinizer ignore-type */ $friend2_uid);
Loading history...
37
38
if (1 === $marker) {
39
    $level = $_POST['level'];
40
41
    $cool = $_POST['cool'];
42
43
    $friendly = $_POST['hot'];
44
45
    $funny = $_POST['trust'];
46
47
    $fan = $_POST['fan'];
48
49
    $friendship_id = Request::getInt('friendship_id', 0, 'POST');
50
51
    $criteria = new Criteria('friendship_id', $friendship_id);
52
53
    $friendships = $friendshipFactory->getObjects($criteria);
54
55
    $friendship = $friendships[0];
56
57
    $friendship->setVar('level', $level);
58
59
    $friendship->setVar('cool', $cool);
60
61
    $friendship->setVar('hot', $friendly);
62
63
    $friendship->setVar('trust', $funny);
64
65
    $friendship->setVar('fan', $fan);
66
67
    $friend2_uid = (int)$friendship->getVar('friend2_uid');
68
69
    $friendship->unsetNew();
70
71
    $friendshipFactory->insert2($friendship);
72
73
    redirect_header('friends.php', 2, _MD_YOGURT_FRIENDSHIP_UPDATED);
74
} else {
75
    $friendshipFactory->renderFormSubmit($friend);
76
}
77
78
require dirname(dirname(__DIR__)) . '/footer.php';
79