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
|
|
|
GroupController |
22
|
|
|
}; |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'suico_groups_results.tpl'; |
26
|
|
|
require __DIR__ . '/header.php'; |
27
|
|
|
$controller = new GroupController($xoopsDB, $xoopsUser); |
28
|
|
|
/** |
29
|
|
|
* Fetching numbers of groups friends videos pictures etc... |
30
|
|
|
*/ |
31
|
|
|
$nbSections = $controller->getNumbersSections(); |
32
|
|
|
$start_all = Request::getInt('start_all', 0, 'GET'); |
33
|
|
|
$start_my = Request::getInt('start_my', 0, 'GET'); |
34
|
|
|
$group_keyword = trim(htmlspecialchars(Request::getString('group_keyword', '', 'GET'), ENT_QUOTES | ENT_HTML5)); |
35
|
|
|
/** |
36
|
|
|
* All Groups |
37
|
|
|
*/ |
38
|
|
|
$criteria_title = new Criteria('group_title', '%' . $group_keyword . '%', 'LIKE'); |
39
|
|
|
$criteria_desc = new Criteria('group_desc', '%' . $group_keyword . '%', 'LIKE'); |
40
|
|
|
$criteria_groups = new CriteriaCompo($criteria_title); |
41
|
|
|
$criteria_groups->add($criteria_desc, 'OR'); |
42
|
|
|
$countGroups = $controller->groupsFactory->getCount($criteria_groups); |
43
|
|
|
$criteria_groups->setLimit($helper->getConfig('groupsperpage')); |
44
|
|
|
$criteria_groups->setStart($start_all); |
45
|
|
|
$groups_objects = $controller->groupsFactory->getObjects($criteria_groups); |
46
|
|
|
$i = 0; |
47
|
|
|
foreach ($groups_objects as $group_object) { |
48
|
|
|
$groups[$i]['id'] = $group_object->getVar('group_id'); |
49
|
|
|
$groups[$i]['title'] = $group_object->getVar('group_title'); |
50
|
|
|
$groups[$i]['img'] = $group_object->getVar('group_img'); |
51
|
|
|
$groups[$i]['desc'] = $group_object->getVar('group_desc'); |
52
|
|
|
$groups[$i]['uid'] = $group_object->getVar('owner_uid'); |
53
|
|
|
$i++; |
54
|
|
|
} |
55
|
|
|
/** |
56
|
|
|
* My Groups |
57
|
|
|
*/ |
58
|
|
|
$mygroups = ''; |
59
|
|
|
$criteria_mygroups = new Criteria('rel_user_uid', $controller->uidOwner); |
60
|
|
|
$countMyGroups = $controller->relgroupusersFactory->getCount($criteria_mygroups); |
61
|
|
|
$criteria_mygroups->setLimit($helper->getConfig('groupsperpage')); |
62
|
|
|
$criteria_mygroups->setStart($start_my); |
63
|
|
|
$mygroups = $controller->relgroupusersFactory->getGroups('', $criteria_mygroups, 0); |
64
|
|
|
$mygroupsid = []; |
65
|
|
|
foreach ($mygroups as $value) { |
66
|
|
|
$mygroupsid[] = $value['group_id']; |
67
|
|
|
} |
68
|
|
|
/** |
69
|
|
|
* Creating the navigation bar if you have a lot of friends |
70
|
|
|
*/ |
71
|
|
|
$navigationBar = new \XoopsPageNav( |
72
|
|
|
$countGroups, |
73
|
|
|
$helper->getConfig('groupsperpage'), |
74
|
|
|
$start_all, |
75
|
|
|
'start_all', |
76
|
|
|
'group_keyword=' . $group_keyword . '&start_my=' . $start_my |
77
|
|
|
); |
78
|
|
|
$imageNav = $navigationBar->renderImageNav(2); |
79
|
|
|
//form |
80
|
|
|
//$xoopsTpl->assign('lang_youcanupload',sprintf(_MD_SUICO_YOU_CAN_UPLOAD,$maxfilebytes/1024)); |
81
|
|
|
$xoopsTpl->assign( |
82
|
|
|
'lang_groupimage', |
83
|
|
|
_MD_SUICO_GROUP_IMAGE |
84
|
|
|
); |
85
|
|
|
//$xoopsTpl->assign('maxfilesize',$maxfilebytes); |
86
|
|
|
$xoopsTpl->assign('lang_title', _MD_SUICO_GROUP_TITLE); |
87
|
|
|
$xoopsTpl->assign('lang_description', _MD_SUICO_GROUP_DESC); |
88
|
|
|
$xoopsTpl->assign('lang_savegroup', _MD_SUICO_UPLOADGROUP); |
89
|
|
|
//navbar |
90
|
|
|
$xoopsTpl->assign('lang_mysection', _MD_SUICO_MYGROUPS); |
91
|
|
|
$xoopsTpl->assign('section_name', _MD_SUICO_GROUPS); |
92
|
|
|
//$xoopsTpl->assign('path_suico_uploads',$helper->getConfig('link_path_upload')); |
93
|
|
|
$xoopsTpl->assign('groups', $groups); |
94
|
|
|
//$xoopsTpl->assign('mygroups',$mygroups); |
95
|
|
|
$xoopsTpl->assign('lang_mygroupstitle', _MD_SUICO_MYGROUPS); |
96
|
|
|
$xoopsTpl->assign('lang_groupstitle', _MD_SUICO_ALLGROUPS . ' (' . $countGroups . ')'); |
97
|
|
|
$xoopsTpl->assign('lang_nogroupsyet', _MD_SUICO_NOGROUPSYET); |
98
|
|
|
//page nav |
99
|
|
|
$xoopsTpl->assign('navigationBar', $imageNav); |
100
|
|
|
//$xoopsTpl->assign('navigationBar_my',$imageNav_my); |
101
|
|
|
//$xoopsTpl->assign('countGroups',$countMyGroups);// this is the one wich shows in the upper bar actually is about the mygroups |
102
|
|
|
$xoopsTpl->assign( |
103
|
|
|
'countGroups_all', |
104
|
|
|
$countGroups |
105
|
|
|
); //this is total number of groups |
106
|
|
|
$xoopsTpl->assign('lang_creategroup', _MD_SUICOCREATEYOURGROUP); |
107
|
|
|
$xoopsTpl->assign('lang_owner', _MD_SUICO_GROUPOWNER); |
108
|
|
|
$xoopsTpl->assign('lang_abandongroup', _MD_SUICO_GROUP_ABANDON); |
109
|
|
|
$xoopsTpl->assign('lang_joingroup', _MD_SUICO_GROUP_JOIN); |
110
|
|
|
$xoopsTpl->assign('lang_searchgroup', _MD_SUICO_GROUP_SEARCH); |
111
|
|
|
$xoopsTpl->assign('lang_groupkeyword', _MD_SUICO_GROUP_SEARCHKEYWORD); |
112
|
|
|
$xoopsTpl->assign('lang_memberofgroup', _MD_SUICO_MEMBEROFGROUP); |
113
|
|
|
require __DIR__ . '/footer.php'; |
114
|
|
|
require \dirname(__DIR__, 2) . '/footer.php'; |
115
|
|
|
|
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: