|
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.tpl'; |
|
26
|
|
|
require __DIR__ . '/header.php'; |
|
27
|
|
|
$controller = new GroupController($xoopsDB, $xoopsUser); |
|
28
|
|
|
$start_all = Request::getInt('start_all', 0, 'GET'); |
|
29
|
|
|
$start_my = Request::getInt('start_my', 0, 'GET'); |
|
30
|
|
|
/** |
|
31
|
|
|
* Fetching numbers of groups friends videos pictures etc... |
|
32
|
|
|
*/ |
|
33
|
|
|
$nbSections = $controller->getNumbersSections(); |
|
34
|
|
|
/** |
|
35
|
|
|
* All Groups |
|
36
|
|
|
*/ |
|
37
|
|
|
$criteria_groups = new Criteria('group_id', 0, '>'); |
|
38
|
|
|
$countGroups = $controller->groupsFactory->getCount($criteria_groups); |
|
39
|
|
|
//$criteria_groups->setLimit($helper->getConfig('groupsperpage')); |
|
40
|
|
|
$criteria_groups->setStart($start_all); |
|
41
|
|
|
$groups = $controller->groupsFactory->getGroups($criteria_groups); |
|
42
|
|
|
/** |
|
43
|
|
|
* My Groups |
|
44
|
|
|
*/ |
|
45
|
|
|
$mygroups = ''; |
|
46
|
|
|
$criteria_mygroups = new Criteria('rel_user_uid', $controller->uidOwner); |
|
47
|
|
|
$countMyGroups = $controller->relgroupusersFactory->getCount($criteria_mygroups); |
|
48
|
|
|
//$criteria_mygroups->setLimit($helper->getConfig('groupsperpage')); |
|
49
|
|
|
$criteria_mygroups->setStart($start_my); |
|
50
|
|
|
$mygroups = $controller->relgroupusersFactory->getGroups('', $criteria_mygroups, 0); |
|
51
|
|
|
$mygroupsid = []; |
|
52
|
|
|
foreach ($mygroups as $value) { |
|
53
|
|
|
$mygroupsid[] = $value['group_id']; |
|
54
|
|
|
} |
|
55
|
|
|
/** |
|
56
|
|
|
* Creating the navigation bar if you have a lot of friends |
|
57
|
|
|
*/ |
|
58
|
|
|
$navigationBar = new \XoopsPageNav( |
|
59
|
|
|
$countGroups, |
|
60
|
|
|
$helper->getConfig('groupsperpage'), |
|
61
|
|
|
$start_all, |
|
62
|
|
|
'start_all', |
|
63
|
|
|
'uid=' . (int)$controller->uidOwner . '&start_my=' . $start_my . '#allgroups' |
|
64
|
|
|
); |
|
65
|
|
|
$imageNav = $navigationBar->renderImageNav(2); //allgroups |
|
66
|
|
|
$navigationBar_my = new \XoopsPageNav( |
|
67
|
|
|
$countMyGroups, |
|
68
|
|
|
$helper->getConfig('groupsperpage'), |
|
69
|
|
|
$start_my, |
|
70
|
|
|
'start_my', |
|
71
|
|
|
'uid=' . (int)$controller->uidOwner . '&start_all=' . $start_all . '#mygroups' |
|
72
|
|
|
); |
|
73
|
|
|
$imageNav_my = $navigationBar_my->renderImageNav(2); |
|
74
|
|
|
$maxfilebytes = $helper->getConfig('maxfilesize'); |
|
75
|
|
|
//form |
|
76
|
|
|
$xoopsTpl->assign('lang_youcanupload', sprintf(_MD_SUICO_YOU_CAN_UPLOAD, $maxfilebytes / 1024)); |
|
77
|
|
|
$xoopsTpl->assign('lang_groupimage', _MD_SUICO_GROUP_IMAGE); |
|
78
|
|
|
$xoopsTpl->assign('maxfilesize', $maxfilebytes); |
|
79
|
|
|
$xoopsTpl->assign('lang_title', _MD_SUICO_GROUP_TITLE); |
|
80
|
|
|
$xoopsTpl->assign('lang_description', _MD_SUICO_GROUP_DESC); |
|
81
|
|
|
$xoopsTpl->assign('lang_savegroup', _MD_SUICO_UPLOADGROUP); |
|
82
|
|
|
//$xoopsTpl->assign('path_suico_uploads',$helper->getConfig('link_path_upload')); |
|
83
|
|
|
$xoopsTpl->assign('groups', $groups); |
|
84
|
|
|
$xoopsTpl->assign('mygroups', $mygroups); |
|
85
|
|
|
$xoopsTpl->assign('mygroupsid', $mygroupsid); |
|
86
|
|
|
$xoopsTpl->assign('lang_mygroupstitle', _MD_SUICO_MYGROUPS); |
|
87
|
|
|
$xoopsTpl->assign('lang_groupstitle', _MD_SUICO_ALLGROUPS . ' (' . $countGroups . ')'); |
|
88
|
|
|
$xoopsTpl->assign('lang_nogroupsyet', _MD_SUICO_NOGROUPSYET); |
|
89
|
|
|
$xoopsTpl->assign('lang_availablegroups', _MD_SUICO_AVAILABLEGROUPS); |
|
90
|
|
|
$xoopsTpl->assign('groupstotal', $countGroups); |
|
91
|
|
|
$xoopsTpl->assign('lang_groupslist', _MD_SUICO_GROUPSLIST); |
|
92
|
|
|
//page nav |
|
93
|
|
|
$xoopsTpl->assign('navigationBar', $imageNav); //allgroups |
|
94
|
|
|
$xoopsTpl->assign('navigationBar_my', $imageNav_my); |
|
95
|
|
|
$xoopsTpl->assign( |
|
96
|
|
|
'countGroups', |
|
97
|
|
|
$countMyGroups |
|
98
|
|
|
); // this is the one which shows in the upper bar actually is about the mygroups |
|
99
|
|
|
$xoopsTpl->assign( |
|
100
|
|
|
'countGroups_all', |
|
101
|
|
|
$countGroups |
|
102
|
|
|
); //this is total number of groups |
|
103
|
|
|
$xoopsTpl->assign('lang_creategroup', _MD_SUICOCREATEYOURGROUP); |
|
104
|
|
|
$xoopsTpl->assign('lang_owner', _MD_SUICO_GROUPOWNER); |
|
105
|
|
|
$xoopsTpl->assign('lang_abandongroup', _MD_SUICO_GROUP_ABANDON); |
|
106
|
|
|
$xoopsTpl->assign('lang_joingroup', _MD_SUICO_GROUP_JOIN); |
|
107
|
|
|
$xoopsTpl->assign('lang_searchgroup', _MD_SUICO_GROUP_SEARCH); |
|
108
|
|
|
$xoopsTpl->assign('lang_groupkeyword', _MD_SUICO_GROUP_SEARCHKEYWORD); |
|
109
|
|
|
$xoopsTpl->assign('lang_memberofgroup', _MD_SUICO_MEMBEROFGROUP); |
|
110
|
|
|
$xoopsTpl->assign('lang_grouptotalmembers', _MD_SUICO_GROUPTOTALMEMBERS); |
|
111
|
|
|
$xoopsTpl->assign('lang_mysection', _MD_SUICO_MYGROUPS); |
|
112
|
|
|
$xoopsTpl->assign('section_name', _MD_SUICO_GROUPS); |
|
113
|
|
|
require __DIR__ . '/footer.php'; |
|
114
|
|
|
require \dirname(__DIR__, 2) . '/footer.php'; |
|
115
|
|
|
|
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare 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.phpHowever, as
OtherDir/Foo.phpdoes 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: