|
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
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'suico_editgroup.tpl'; |
|
25
|
|
|
require __DIR__ . '/header.php'; |
|
26
|
|
|
$controller = new GroupController($xoopsDB, $xoopsUser); |
|
27
|
|
|
/** |
|
28
|
|
|
* Fetching numbers of groups friends videos pictures etc... |
|
29
|
|
|
*/ |
|
30
|
|
|
$nbSections = $controller->getNumbersSections(); |
|
31
|
|
|
$group_id = Request::getInt('group_id', 0, 'POST'); |
|
32
|
|
|
$marker = Request::getInt('marker', 0, 'POST'); |
|
33
|
|
|
$criteria = new Criteria('group_id', $group_id); |
|
34
|
|
|
$groups = $controller->groupsFactory->getObjects($criteria); |
|
35
|
|
|
$group = $groups[0]; |
|
36
|
|
|
$uid = $xoopsUser->getVar('uid'); |
|
37
|
|
|
if (1 === $marker && $group->getVar('owner_uid') === $uid) { |
|
38
|
|
|
$title = Request::getString('title', '', 'POST'); |
|
39
|
|
|
$desc = Request::getString('desc', '', 'POST'); |
|
40
|
|
|
$img = Request::getString('img', '', 'POST'); |
|
41
|
|
|
$updateImg = 1 === Request::getInt('flag_oldimg', 0, 'POST') ? 0 : 1; |
|
42
|
|
|
$path_upload = XOOPS_ROOT_PATH . '/uploads/suico/images'; |
|
43
|
|
|
$maxfilebytes = $helper->getConfig('maxfilesize'); |
|
44
|
|
|
$maxfileheight = $helper->getConfig('max_original_height'); |
|
45
|
|
|
$maxfilewidth = $helper->getConfig('max_original_width'); |
|
46
|
|
|
$controller->groupsFactory->receiveGroup( |
|
47
|
|
|
$title, |
|
48
|
|
|
$desc, |
|
49
|
|
|
$img, |
|
50
|
|
|
$path_upload, |
|
51
|
|
|
$maxfilebytes, |
|
52
|
|
|
$maxfilewidth, |
|
53
|
|
|
$maxfileheight, |
|
54
|
|
|
$updateImg, |
|
55
|
|
|
$group |
|
56
|
|
|
); |
|
57
|
|
|
redirect_header('group.php?group_id=' . $group_id . '', 3, _MD_SUICO_GROUPEDITED); |
|
58
|
|
|
} else { |
|
59
|
|
|
/** |
|
60
|
|
|
* Render a form with the info of the user |
|
61
|
|
|
*/ |
|
62
|
|
|
$group_members = $controller->relgroupusersFactory->getUsersFromGroup( |
|
63
|
|
|
$group_id, |
|
64
|
|
|
0, |
|
65
|
|
|
50 |
|
66
|
|
|
); |
|
67
|
|
|
$xoopsTpl->assign('group_members', $group_members); |
|
68
|
|
|
$maxfilebytes = $helper->getConfig('maxfilesize'); |
|
69
|
|
|
$xoopsTpl->assign('lang_savegroup', _MD_SUICO_UPLOADGROUP); |
|
70
|
|
|
$xoopsTpl->assign('maxfilesize', $maxfilebytes); |
|
71
|
|
|
$xoopsTpl->assign('group_title', $group->getVar('group_title')); |
|
72
|
|
|
$xoopsTpl->assign('group_desc', $group->getVar('group_desc')); |
|
73
|
|
|
$xoopsTpl->assign('group_img', $group->getVar('group_img')); |
|
74
|
|
|
$xoopsTpl->assign('group_id', $group->getVar('group_id')); |
|
75
|
|
|
//permissions |
|
76
|
|
|
$xoopsTpl->assign('allow_notes', $controller->checkPrivilegeBySection('notes')); |
|
77
|
|
|
$xoopsTpl->assign('allow_friends', $controller->checkPrivilegeBySection('friends')); |
|
78
|
|
|
$xoopsTpl->assign('allow_groups', $controller->checkPrivilegeBySection('groups')); |
|
79
|
|
|
$xoopsTpl->assign('allow_pictures', $controller->checkPrivilegeBySection('pictures')); |
|
80
|
|
|
$xoopsTpl->assign('allow_videos', $controller->checkPrivilegeBySection('videos')); |
|
81
|
|
|
$xoopsTpl->assign('allow_audios', $controller->checkPrivilegeBySection('audio')); |
|
82
|
|
|
$xoopsTpl->assign('allow_profile_contact', $controller->checkPrivilege('profile_contact') ? 1 : 0); |
|
|
|
|
|
|
83
|
|
|
$xoopsTpl->assign('allow_profile_general', $controller->checkPrivilege('profile_general') ? 1 : 0); |
|
84
|
|
|
$xoopsTpl->assign('allow_profile_stats', $controller->checkPrivilege('profile_stats') ? 1 : 0); |
|
85
|
|
|
$xoopsTpl->assign('lang_membersofgroup', _MD_SUICO_MEMBERSOFGROUP); |
|
86
|
|
|
$xoopsTpl->assign('lang_editgroup', _MD_SUICO_EDIT_GROUP); |
|
87
|
|
|
$xoopsTpl->assign('lang_groupimage', _MD_SUICO_GROUP_IMAGE); |
|
88
|
|
|
$xoopsTpl->assign('lang_keepimage', _MD_SUICO_MAINTAIN_OLD_IMAGE); |
|
89
|
|
|
$xoopsTpl->assign('lang_youcanupload', sprintf(_MD_SUICO_YOU_CAN_UPLOAD, $maxfilebytes / 1024)); |
|
90
|
|
|
$xoopsTpl->assign('lang_titlegroup', _MD_SUICO_GROUP_TITLE); |
|
91
|
|
|
$xoopsTpl->assign('lang_descgroup', _MD_SUICO_GROUP_DESC); |
|
92
|
|
|
//Owner data |
|
93
|
|
|
$xoopsTpl->assign('uid_owner', $controller->uidOwner); |
|
94
|
|
|
$xoopsTpl->assign('owner_uname', $controller->nameOwner); |
|
95
|
|
|
$xoopsTpl->assign('isOwner', $controller->isOwner); |
|
96
|
|
|
$xoopsTpl->assign('isAnonym', $controller->isAnonym); |
|
97
|
|
|
//numbers |
|
98
|
|
|
$xoopsTpl->assign('countGroups', $nbSections['countGroups']); |
|
99
|
|
|
$xoopsTpl->assign('countPhotos', $nbSections['countPhotos']); |
|
100
|
|
|
$xoopsTpl->assign('countVideos', $nbSections['countGroups']); |
|
101
|
|
|
$xoopsTpl->assign('countNotes', $nbSections['countNotes']); |
|
102
|
|
|
$xoopsTpl->assign('countFriends', $nbSections['countFriends']); |
|
103
|
|
|
$xoopsTpl->assign('countAudio', $nbSections['countAudios']); |
|
104
|
|
|
//navbar |
|
105
|
|
|
$xoopsTpl->assign('module_name', $xoopsModule->getVar('name')); |
|
106
|
|
|
$xoopsTpl->assign('lang_mysection', _MD_SUICO_GROUPS . ' :: ' . _MD_SUICO_EDIT_GROUP); |
|
107
|
|
|
$xoopsTpl->assign('section_name', _MD_SUICO_GROUPS . '> ' . _MD_SUICO_EDIT_GROUP); |
|
108
|
|
|
$xoopsTpl->assign('lang_home', _MD_SUICO_HOME); |
|
109
|
|
|
$xoopsTpl->assign('lang_photos', _MD_SUICO_PHOTOS); |
|
110
|
|
|
$xoopsTpl->assign('lang_friends', _MD_SUICO_FRIENDS); |
|
111
|
|
|
$xoopsTpl->assign('lang_videos', _MD_SUICO_VIDEOS); |
|
112
|
|
|
$xoopsTpl->assign('lang_notebook', _MD_SUICO_NOTEBOOK); |
|
113
|
|
|
$xoopsTpl->assign('lang_profile', _MD_SUICO_PROFILE); |
|
114
|
|
|
$xoopsTpl->assign('lang_groups', _MD_SUICO_GROUPS); |
|
115
|
|
|
$xoopsTpl->assign('lang_configs', _MD_SUICO_CONFIGS_TITLE); |
|
116
|
|
|
$xoopsTpl->assign('lang_audio', _MD_SUICO_AUDIOS); |
|
117
|
|
|
//xoopsToken |
|
118
|
|
|
$xoopsTpl->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML()); |
|
119
|
|
|
//page atributes |
|
120
|
|
|
$xoopsTpl->assign( |
|
121
|
|
|
'xoops_pagetitle', |
|
122
|
|
|
sprintf(_MD_SUICO_PAGETITLE, $xoopsModule->getVar('name'), $controller->nameOwner) |
|
|
|
|
|
|
123
|
|
|
); |
|
124
|
|
|
//$xoopsTpl->assign('path_suico_uploads',$helper->getConfig('link_path_upload')); |
|
125
|
|
|
$xoopsTpl->assign( |
|
126
|
|
|
'lang_owner', |
|
127
|
|
|
_MD_SUICO_GROUPOWNER |
|
128
|
|
|
); |
|
129
|
|
|
} |
|
130
|
|
|
require __DIR__ . '/footer.php'; |
|
131
|
|
|
require \dirname(__DIR__, 2) . '/footer.php'; |
|
132
|
|
|
|
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: