Passed
Pull Request — master (#81)
by Michael
03:04
created

friends.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
$GLOBALS['xoopsOption']['template_main'] = 'yogurt_friends.tpl';
27
require __DIR__ . '/header.php';
28
29
$controller = new Yogurt\FriendsController($xoopsDB, $xoopsUser);
30
31
/**
32
 * Fetching numbers of groups friends videos pictures etc...
33
 */
34
$nbSections = $controller->getNumbersSections();
35
36
$start = Request::getInt('start', 0, 'GET');
37
38
/**
39
 * Filter for new friend friendrequest
40
 */
41
$friendrequest = 0;
42
if (1 === $controller->isOwner) {
43
    $criteria_uidfriendrequest = new Criteria('friendrequestto_uid', $controller->uidOwner);
44
    $newFriendrequest          = $controller->friendrequestFactory->getObjects($criteria_uidfriendrequest);
45
    if ($newFriendrequest) {
46
        $countFriendrequest     = count($newFriendrequest);
47
        $friendrequesterHandler = xoops_getHandler('member');
48
        $friendrequester        = $friendrequesterHandler->getUser($newFriendrequest[0]->getVar('friendrequester_uid'));
0 ignored issues
show
The method getUser() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsAvatarHandler or XoopsPersistableObjectHandler. ( Ignorable by Annotation )

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

48
        /** @scrutinizer ignore-call */ 
49
        $friendrequester        = $friendrequesterHandler->getUser($newFriendrequest[0]->getVar('friendrequester_uid'));
Loading history...
49
        $friendrequester_uid    = $friendrequester->getVar('uid');
50
        $friendrequester_uname  = $friendrequester->getVar('uname');
51
        $friendrequester_avatar = $friendrequester->getVar('user_avatar');
52
        $friendrequest_id       = $newFriendrequest[0]->getVar('friendreq_id');
53
        $friendrequest          = 1;
54
    }
55
}
56
57
/**
58
 * Friends
59
 */
60
$criteria_friends = new Criteria('friend1_uid', (int)$controller->uidOwner);
61
$countFriends     = $controller->friendshipsFactory->getCount($criteria_friends);
62
$criteria_friends->setLimit($helper->getConfig('friendsperpage'));
63
$criteria_friends->setStart($start);
64
$vetor = $controller->friendshipsFactory->getFriends('', $criteria_friends, 0);
65
if (0 === $countFriends) {
66
    $xoopsTpl->assign('lang_nofriendsyet', _MD_YOGURT_NOFRIENDSYET);
67
}
68
69
/**
70
 * Let's get the user name of the owner of the album
71
 */
72
$owner      = new XoopsUser();
73
$identifier = $owner::getUnameFromId($controller->uidOwner);
74
75
/**
76
 * Creating the navigation bar if you have a lot of friends
77
 */
78
$navigationBar = new XoopsPageNav(
79
    $nbSections['nbFriends'], $helper->getConfig('friendsperpage'), $start, 'start', 'uid=' . (int)$controller->uidOwner
80
);
81
$navegacao     = $navigationBar->renderImageNav(2);
82
83
//requests to become friend
84
if (1 === $friendrequest) {
85
    $xoopsTpl->assign('lang_youhavexfriendrequests', sprintf(_MD_YOGURT_YOUHAVEXFRIENDREQUESTS, $countFriendrequest));
86
    $xoopsTpl->assign('friendrequester_uid', $friendrequester_uid);
87
    $xoopsTpl->assign('friendrequester_uname', $friendrequester_uname);
88
    $xoopsTpl->assign('friendrequester_avatar', $friendrequester_avatar);
89
    $xoopsTpl->assign('friendrequest', $friendrequest);
90
    $xoopsTpl->assign('friendrequest_id', $friendrequest_id);
91
    $xoopsTpl->assign('lang_rejected', _MD_YOGURT_UNKNOWN_REJECTING);
92
    $xoopsTpl->assign('lang_accepted', _MD_YOGURT_UNKNOWN_ACCEPTING);
93
    $xoopsTpl->assign('lang_acquaintance', _MD_YOGURT_AQUAITANCE);
94
    $xoopsTpl->assign('lang_friend', _MD_YOGURT_FRIEND);
95
    $xoopsTpl->assign('lang_bestfriend', _MD_YOGURT_BESTFRIEND);
96
    $linkedpetioner = '<a href="index.php?uid=' . $friendrequester_uid . '">' . $friendrequester_uname . '</a>';
97
    $xoopsTpl->assign('lang_askingfriend', sprintf(_MD_YOGURT_ASKINGFRIEND, $linkedpetioner));
98
}
99
$xoopsTpl->assign('lang_askusertobefriend', _MD_YOGURT_ASKBEFRIEND);
100
$xoopsTpl->assign('lang_addfriend', _MD_YOGURT_ADDFRIEND);
101
$xoopsTpl->assign('lang_friendrequestpending', _MD_YOGURT_FRIENDREQUEST_PENDING);
102
$xoopsTpl->assign('lang_myfriend', _MD_YOGURT_MYFRIEND);
103
$xoopsTpl->assign('lang_friendrequestsent', _MD_YOGURT_FRIENDREQUEST_SENT);
104
$xoopsTpl->assign('lang_acceptfriend', _MD_YOGURT_FRIEND_ACCEPT);
105
$xoopsTpl->assign('lang_rejectfriend', _MD_YOGURT_FRIEND_REJECT);
106
$xoopsTpl->assign('lang_deletefriend', _MD_YOGURT_FRIENDSHIP_DELETE);
107
$xoopsTpl->assign('lang_friendshipsettings', _MD_YOGURT_FRIENDSHIP_SETTINGS);
108
109
//navbar
110
$xoopsTpl->assign('module_name', $xoopsModule->getVar('name'));
111
$xoopsTpl->assign('lang_mysection', _MD_YOGURT_MYFRIENDS);
112
$xoopsTpl->assign('lang_friendstitle', sprintf(_MD_YOGURT_FRIENDSTITLE, $identifier));
113
//$xoopsTpl->assign('path_yogurt_uploads',$helper->getConfig('link_path_upload'));
114
115
$xoopsTpl->assign('friends', $vetor);
116
117
$xoopsTpl->assign('lang_delete', _MD_YOGURT_DELETE);
118
$xoopsTpl->assign('lang_evaluate', _MD_YOGURT_FRIENDSHIP_CONFIGS);
119
$xoopsTpl->assign('allow_friendshiplevel', $helper->getConfig('allow_friendshiplevel'));
120
$xoopsTpl->assign('allow_fanssevaluation', $helper->getConfig('allow_fanssevaluation'));
121
122
// Navigation
123
$xoopsTpl->assign('navegacao', $navegacao);
124
125
require __DIR__ . '/footer.php';
126
require dirname(__DIR__, 2) . '/footer.php';
127