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

friends.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
    FriendsController
25
};
26
27
$GLOBALS['xoopsOption']['template_main'] = 'suico_friends.tpl';
28
require __DIR__ . '/header.php';
29
$controller = new FriendsController($xoopsDB, $xoopsUser);
30
/**
31
 * Fetching numbers of groups friends videos pictures etc...
32
 */
33
$nbSections = $controller->getNumbersSections();
34
$start      = Request::getInt('start', 0, 'GET');
35
/**
36
 * Filter for new friend friendrequest
37
 */
38
$friendrequest = 0;
39
if (1 === $controller->isOwner) {
40
    $criteria_uidfriendrequest = new Criteria('friendrequestto_uid', $controller->uidOwner);
41
    $newFriendrequest          = $controller->friendrequestFactory->getObjects($criteria_uidfriendrequest);
42
    if ($newFriendrequest) {
43
        $countFriendrequest     = count($newFriendrequest);
44
        $friendrequesterHandler = xoops_getHandler('member');
45
        $friendrequester        = $friendrequesterHandler->getUser($newFriendrequest[0]->getVar('friendrequester_uid'));
46
        $friendrequester_uid    = $friendrequester->getVar('uid');
47
        $friendrequester_uname  = $friendrequester->getVar('uname');
48
        $friendrequester_avatar = $friendrequester->getVar('user_avatar');
49
        $friendrequest_id       = $newFriendrequest[0]->getVar('friendreq_id');
50
        $friendrequest          = 1;
51
    }
52
}
53
/**
54
 * Friends
55
 */
56
$criteria_friends = new Criteria('friend1_uid', (int)$controller->uidOwner);
57
$countFriends     = $controller->friendshipsFactory->getCount($criteria_friends);
58
$criteria_friends->setLimit($helper->getConfig('friendsperpage'));
59
$criteria_friends->setStart($start);
60
$vetor = $controller->friendshipsFactory->getFriends('', $criteria_friends, 0);
0 ignored issues
show
'' of type string is incompatible with the type integer expected by parameter $countFriends of XoopsModules\Suico\FriendshipHandler::getFriends(). ( Ignorable by Annotation )

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

60
$vetor = $controller->friendshipsFactory->getFriends(/** @scrutinizer ignore-type */ '', $criteria_friends, 0);
Loading history...
61
if (0 === $countFriends) {
62
    $xoopsTpl->assign('lang_nofriendsyet', _MD_SUICO_NOFRIENDSYET);
63
}
64
/**
65
 * Let's get the user name of the owner of the album
66
 */
67
$owner      = new \XoopsUser();
68
$identifier = $owner::getUnameFromId($controller->uidOwner);
69
/**
70
 * Creating the navigation bar if you have a lot of friends
71
 */
72
$navigationBar = new \XoopsPageNav(
73
    $nbSections['countFriends'], $helper->getConfig('friendsperpage'), $start, 'start', 'uid=' . (int)$controller->uidOwner
74
);
75
$navegacao     = $navigationBar->renderImageNav(2);
76
//requests to become friend
77
if (1 === $friendrequest) {
78
    $xoopsTpl->assign('lang_you_have_x_friendrequests', sprintf(_MD_SUICO_YOU_HAVE_X_FRIENDREQUESTS, $countFriendrequest));
79
    $xoopsTpl->assign('friendrequester_uid', $friendrequester_uid);
80
    $xoopsTpl->assign('friendrequester_uname', $friendrequester_uname);
81
    $xoopsTpl->assign('friendrequester_avatar', $friendrequester_avatar);
82
    $xoopsTpl->assign('friendrequest', $friendrequest);
83
    $xoopsTpl->assign('friendrequest_id', $friendrequest_id);
84
    $xoopsTpl->assign('lang_rejected', _MD_SUICO_UNKNOWN_REJECTING);
85
    $xoopsTpl->assign('lang_accepted', _MD_SUICO_UNKNOWN_ACCEPTING);
86
    $xoopsTpl->assign('lang_acquaintance', _MD_SUICO_AQUAITANCE);
87
    $xoopsTpl->assign('lang_friend', _MD_SUICO_FRIEND);
88
    $xoopsTpl->assign('lang_bestfriend', _MD_SUICO_BESTFRIEND);
89
    $linkedpetioner = '<a href="index.php?uid=' . $friendrequester_uid . '">' . $friendrequester_uname . '</a>';
90
    $xoopsTpl->assign('lang_askingfriend', sprintf(_MD_SUICO_ASKINGFRIEND, $linkedpetioner));
91
}
92
$xoopsTpl->assign('lang_askusertobefriend', _MD_SUICO_ASKBEFRIEND);
93
$xoopsTpl->assign('lang_addfriend', _MD_SUICO_ADDFRIEND);
94
$xoopsTpl->assign('lang_friendrequestpending', _MD_SUICO_FRIENDREQUEST_PENDING);
95
$xoopsTpl->assign('lang_myfriend', _MD_SUICO_MYFRIEND);
96
$xoopsTpl->assign('lang_friendrequestsent', _MD_SUICO_FRIENDREQUEST_SENT);
97
$xoopsTpl->assign('lang_acceptfriend', _MD_SUICO_FRIEND_ACCEPT);
98
$xoopsTpl->assign('lang_rejectfriend', _MD_SUICO_FRIEND_REJECT);
99
$xoopsTpl->assign('lang_deletefriend', _MD_SUICO_FRIENDSHIP_DELETE);
100
$xoopsTpl->assign('lang_friendshipsettings', _MD_SUICO_FRIENDSHIP_SETTINGS);
101
//navbar
102
$xoopsTpl->assign('module_name', $xoopsModule->getVar('name'));
103
$xoopsTpl->assign('lang_mysection', _MD_SUICO_MYFRIENDS);
104
$xoopsTpl->assign('lang_friendstitle', sprintf(_MD_SUICO_FRIENDSTITLE, $identifier));
105
//$xoopsTpl->assign('path_suico_uploads',$helper->getConfig('link_path_upload'));
106
$xoopsTpl->assign('friends', $vetor);
107
$xoopsTpl->assign('lang_delete', _MD_SUICO_DELETE);
108
$xoopsTpl->assign('lang_evaluate', _MD_SUICO_FRIENDSHIP_CONFIGS);
109
$xoopsTpl->assign('allow_friendshiplevel', $helper->getConfig('allow_friendshiplevel'));
110
$xoopsTpl->assign('allow_fanssevaluation', $helper->getConfig('allow_fanssevaluation'));
111
// Navigation
112
$xoopsTpl->assign('navegacao', $navegacao);
113
require __DIR__ . '/footer.php';
114
require dirname(__DIR__, 2) . '/footer.php';
115