1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @category Module |
14
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
15
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
16
|
|
|
* @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org> |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use Xmf\Request; |
|
|
|
|
20
|
|
|
use XoopsModules\Suico\{ |
21
|
|
|
FriendsController |
22
|
|
|
}; |
23
|
|
|
|
24
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'suico_friends.tpl'; |
25
|
|
|
require __DIR__ . '/header.php'; |
26
|
|
|
$controller = new FriendsController($xoopsDB, $xoopsUser); |
27
|
|
|
/** |
28
|
|
|
* Fetching numbers of groups friends videos pictures etc... |
29
|
|
|
*/ |
30
|
|
|
$nbSections = $controller->getNumbersSections(); |
31
|
|
|
$start = Request::getInt('start', 0, 'GET'); |
32
|
|
|
/** |
33
|
|
|
* Filter for new friend friendrequest |
34
|
|
|
*/ |
35
|
|
|
$friendrequest = 0; |
36
|
|
|
if (1 === $controller->isOwner) { |
37
|
|
|
$criteria_uidfriendrequest = new Criteria('friendrequestto_uid', $controller->uidOwner); |
38
|
|
|
$newFriendrequest = $controller->friendrequestFactory->getObjects($criteria_uidfriendrequest); |
39
|
|
|
if ($newFriendrequest) { |
40
|
|
|
$countFriendrequest = count($newFriendrequest); |
41
|
|
|
$friendrequesterHandler = xoops_getHandler('member'); |
42
|
|
|
$friendrequester = $friendrequesterHandler->getUser($newFriendrequest[0]->getVar('friendrequester_uid')); |
|
|
|
|
43
|
|
|
$friendrequester_uid = $friendrequester->getVar('uid'); |
44
|
|
|
$friendrequester_uname = $friendrequester->getVar('uname'); |
45
|
|
|
$friendrequester_avatar = $friendrequester->getVar('user_avatar'); |
46
|
|
|
$friendrequest_id = $newFriendrequest[0]->getVar('friendreq_id'); |
47
|
|
|
$friendrequest = 1; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
/** |
51
|
|
|
* Friends |
52
|
|
|
*/ |
53
|
|
|
$criteria_friends = new Criteria('friend1_uid', (int)$controller->uidOwner); |
54
|
|
|
$countFriends = $controller->friendshipsFactory->getCount($criteria_friends); |
55
|
|
|
$criteria_friends->setLimit($helper->getConfig('friendsperpage')); |
56
|
|
|
$criteria_friends->setStart($start); |
57
|
|
|
$vetor = $controller->friendshipsFactory->getFriends('', $criteria_friends, 0); |
|
|
|
|
58
|
|
|
if (0 === $countFriends) { |
59
|
|
|
$xoopsTpl->assign('lang_nofriendsyet', _MD_SUICO_NOFRIENDSYET); |
60
|
|
|
} |
61
|
|
|
/** |
62
|
|
|
* Let's get the user name of the owner of the album |
63
|
|
|
*/ |
64
|
|
|
$owner = new \XoopsUser(); |
65
|
|
|
$identifier = $owner::getUnameFromId($controller->uidOwner); |
66
|
|
|
/** |
67
|
|
|
* Creating the navigation bar if you have a lot of friends |
68
|
|
|
*/ |
69
|
|
|
$navigationBar = new \XoopsPageNav( |
70
|
|
|
$nbSections['countFriends'], |
71
|
|
|
$helper->getConfig('friendsperpage'), |
72
|
|
|
$start, |
73
|
|
|
'start', |
74
|
|
|
'uid=' . (int)$controller->uidOwner |
75
|
|
|
); |
76
|
|
|
$navegacao = $navigationBar->renderImageNav(2); |
77
|
|
|
//requests to become friend |
78
|
|
|
if (1 === $friendrequest) { |
79
|
|
|
$xoopsTpl->assign('lang_you_have_x_friendrequests', sprintf(_MD_SUICO_YOU_HAVE_X_FRIENDREQUESTS, $countFriendrequest)); |
80
|
|
|
$xoopsTpl->assign('friendrequester_uid', $friendrequester_uid); |
81
|
|
|
$xoopsTpl->assign('friendrequester_uname', $friendrequester_uname); |
82
|
|
|
$xoopsTpl->assign('friendrequester_avatar', $friendrequester_avatar); |
83
|
|
|
$xoopsTpl->assign('friendrequest', $friendrequest); |
84
|
|
|
$xoopsTpl->assign('friendrequest_id', $friendrequest_id); |
85
|
|
|
$xoopsTpl->assign('lang_rejected', _MD_SUICO_UNKNOWN_REJECTING); |
86
|
|
|
$xoopsTpl->assign('lang_accepted', _MD_SUICO_UNKNOWN_ACCEPTING); |
87
|
|
|
$xoopsTpl->assign('lang_acquaintance', _MD_SUICO_AQUAITANCE); |
88
|
|
|
$xoopsTpl->assign('lang_friend', _MD_SUICO_FRIEND); |
89
|
|
|
$xoopsTpl->assign('lang_bestfriend', _MD_SUICO_BESTFRIEND); |
90
|
|
|
$linkedpetioner = '<a href="index.php?uid=' . $friendrequester_uid . '">' . $friendrequester_uname . '</a>'; |
91
|
|
|
$xoopsTpl->assign('lang_askingfriend', sprintf(_MD_SUICO_ASKINGFRIEND, $linkedpetioner)); |
92
|
|
|
} |
93
|
|
|
$xoopsTpl->assign('lang_askusertobefriend', _MD_SUICO_ASKBEFRIEND); |
94
|
|
|
$xoopsTpl->assign('lang_addfriend', _MD_SUICO_ADDFRIEND); |
95
|
|
|
$xoopsTpl->assign('lang_friendrequestpending', _MD_SUICO_FRIENDREQUEST_PENDING); |
96
|
|
|
$xoopsTpl->assign('lang_myfriend', _MD_SUICO_MYFRIEND); |
97
|
|
|
$xoopsTpl->assign('lang_friendrequestsent', _MD_SUICO_FRIENDREQUEST_SENT); |
98
|
|
|
$xoopsTpl->assign('lang_acceptfriend', _MD_SUICO_FRIEND_ACCEPT); |
99
|
|
|
$xoopsTpl->assign('lang_rejectfriend', _MD_SUICO_FRIEND_REJECT); |
100
|
|
|
$xoopsTpl->assign('lang_deletefriend', _MD_SUICO_FRIENDSHIP_DELETE); |
101
|
|
|
$xoopsTpl->assign('lang_friendshipsettings', _MD_SUICO_FRIENDSHIP_SETTINGS); |
102
|
|
|
//navbar |
103
|
|
|
$xoopsTpl->assign('module_name', $xoopsModule->getVar('name')); |
104
|
|
|
$xoopsTpl->assign('lang_mysection', _MD_SUICO_MYFRIENDS); |
105
|
|
|
$xoopsTpl->assign('lang_friendstitle', sprintf(_MD_SUICO_FRIENDSTITLE, $identifier)); |
106
|
|
|
//$xoopsTpl->assign('path_suico_uploads',$helper->getConfig('link_path_upload')); |
107
|
|
|
$xoopsTpl->assign('friends', $vetor); |
108
|
|
|
$xoopsTpl->assign('lang_delete', _MD_SUICO_DELETE); |
109
|
|
|
$xoopsTpl->assign('lang_evaluate', _MD_SUICO_FRIENDSHIP_CONFIGS); |
110
|
|
|
$xoopsTpl->assign('allow_friendshiplevel', $helper->getConfig('allow_friendshiplevel')); |
111
|
|
|
$xoopsTpl->assign('allow_fanssevaluation', $helper->getConfig('allow_fanssevaluation')); |
112
|
|
|
// Navigation |
113
|
|
|
$xoopsTpl->assign('navegacao', $navegacao); |
114
|
|
|
require __DIR__ . '/footer.php'; |
115
|
|
|
require \dirname(__DIR__, 2) . '/footer.php'; |
116
|
|
|
|
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: