Passed
Push — master ( 06e1aa...b7b18e )
by
unknown
03:40 queued 51s
created

group.php (2 issues)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
/*
5
 You may not change or alter any portion of this comment or credits
6
 of supporting developers from this source code or any supporting source code
7
 which is considered copyrighted (c) material of the original comment or credit authors.
8
9
 This program is distributed in the hope that it will be useful,
10
 but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
*/
13
14
/**
15
 * @category        Module
16
 * @package         suico
17
 * @copyright       {@link https://xoops.org/ XOOPS Project}
18
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
19
 * @author          Marcello Brandão aka  Suico, Mamba, LioMJ  <https://xoops.org>
20
 */
21
22
use Xmf\Request;
23
use XoopsModules\Suico;
24
25
$GLOBALS['xoopsOption']['template_main'] = 'suico_group.tpl';
26
require __DIR__ . '/header.php';
27
$helper->loadLanguage('main');
28
$controller = new Suico\GroupController($xoopsDB, $xoopsUser);
29
/**
30
 * Fetching numbers of groups friends videos pictures etc...
31
 */
32
$nbSections = $controller->getNumbersSections();
33
$group_id   = Request::getInt('group_id', 0, 'GET');
34
$criteria   = new Criteria('group_id', $group_id);
35
$groups     = $controller->groupsFactory->getObjects($criteria);
36
$group      = $groups[0];
37
38
/**
39
 * Get Total Comment for Group */
40
$module_handler = xoops_gethandler("module"); 
41
$mod_suico = $module_handler->getByDirname('suico');
0 ignored issues
show
The method getByDirname() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsModuleHandler 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

41
$mod_suico = $module_handler->/** @scrutinizer ignore-call */ getByDirname('suico');
Loading history...
42
$sql= "SELECT count(com_id) FROM ".$GLOBALS['xoopsDB']->prefix('xoopscomments')." WHERE com_modid = '".$mod_suico->getVar('mid')."' AND com_itemid = '".$group_id."'";
43
$result = $GLOBALS['xoopsDB']->query($sql);
44
while ($row = $GLOBALS['xoopsDB']->fetchArray($result)) {
45
$group_total_comments=$row['count(com_id)'];
46
}
47
            if ($group_total_comments > 0) {
48
                if (1 == $group_total_comments) {
49
                    $xoopsTpl->assign('group_total_comments', '' . _MD_SUICO_ONECOMMENT . '&nbsp;');
50
                } else {
51
                    $xoopsTpl->assign('group_total_comments', '' . $group_total_comments . '&nbsp;' . _MD_SUICO_COMMENTS . '&nbsp;');
52
                }
53
            } else {
54
                $xoopsTpl->assign('group_total_comments', '' . _MD_SUICO_NO_COMMENTS . '&nbsp;');
55
            }
56
57
/**
58
 * Fetching rel_id
59
 */
60
$sql               = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix('suico_relgroupuser') . ' WHERE rel_group_id=' . $group_id . ' AND rel_user_uid=' . $controller->uidOwner . '';
61
$result            = $GLOBALS['xoopsDB']->query($sql);
62
$myrow             = $GLOBALS['xoopsDB']->fetchArray($result);
63
$mygroup['rel_id'] = $myrow['rel_id'];
64
$xoopsTpl->assign('group_rel_id', $mygroup['rel_id']);
65
/**
66
 * Render a form with the info of the user
67
 */
68
$group_members     = $controller->relgroupusersFactory->getUsersFromGroup(
69
    $group_id,
70
    0,
71
    50
72
);
73
$grouptotalmembers = 0;
74
foreach ($group_members as $group_member) {
75
    $uids[] = (int)$group_member['uid'];
76
    $grouptotalmembers++;
77
}
78
            if ($grouptotalmembers > 0) {
79
                if (1 == $grouptotalmembers) {
80
                    $xoopsTpl->assign('grouptotalmembers', '' . _MD_SUICO_ONEMEMBER . '&nbsp;');
81
                } else {
82
                    $xoopsTpl->assign('grouptotalmembers', '' . $grouptotalmembers . '&nbsp;' . _MD_SUICO_GROUPSMEMBERS . '&nbsp;');
0 ignored issues
show
The constant _MD_SUICO_GROUPSMEMBERS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
83
                }
84
            } else {
85
                $xoopsTpl->assign('grouptotalmembers', '' . _MD_SUICO_NO_MEMBER . '&nbsp;');
86
            }
87
88
89
90
91
92
93
94
if (!empty($uids)) {
95
    if ($xoopsUser) {
96
        $uid = (int)$xoopsUser->getVar('uid');
97
        if (in_array($uid, $uids, true)) {
98
            $xoopsTpl->assign('memberOfGroup', 1);
99
        }
100
        $xoopsTpl->assign('useruid', $uid);
101
    }
102
}
103
$owner_uid       = $group->getVar('owner_uid');
104
$group_ownername = XoopsUser::getUnameFromId($owner_uid);
105
$xoopsTpl->assign('group_members', $group_members);
106
$maxfilebytes = $helper->getConfig('maxfilesize');
107
$xoopsTpl->assign('lang_savegroup', _MD_SUICO_UPLOADGROUP);
108
$xoopsTpl->assign('maxfilesize', $maxfilebytes);
109
$xoopsTpl->assign('group_title', $group->getVar('group_title'));
110
$xoopsTpl->assign('group_desc', $group->getVar('group_desc'));
111
$xoopsTpl->assign('group_img', $group->getVar('group_img'));
112
$xoopsTpl->assign('group_id', $group->getVar('group_id'));
113
$xoopsTpl->assign('group_date_created', formatTimestamp($group->getVar('date_created')));
114
$xoopsTpl->assign('group_date_updated', formatTimestamp($group->getVar('date_updated')));
115
$xoopsTpl->assign('group_owneruid', $group->getVar('owner_uid'));
116
$xoopsTpl->assign('group_ownername', $group_ownername);
117
$xoopsTpl->assign('lang_groupmembers', _MD_SUICO_GROUPMEMBERS);
118
$xoopsTpl->assign('lang_membersofgroup', _MD_SUICO_MEMBERSOFGROUP);
119
$xoopsTpl->assign('lang_editgroup', _MD_SUICO_EDIT_GROUP);
120
$xoopsTpl->assign('lang_groupimage', _MD_SUICO_GROUP_IMAGE);
121
$xoopsTpl->assign('lang_keepimage', _MD_SUICO_MAINTAIN_OLD_IMAGE);
122
$xoopsTpl->assign('lang_youcanupload', sprintf(_MD_SUICO_YOU_CAN_UPLOAD, $maxfilebytes / 1024));
123
$xoopsTpl->assign('lang_titlegroup', _MD_SUICO_GROUP_TITLE);
124
$xoopsTpl->assign('lang_descgroup', _MD_SUICO_GROUP_DESC);
125
$xoopsTpl->assign('lang_abandongroup', _MD_SUICO_GROUP_ABANDON);
126
$xoopsTpl->assign('lang_joingroup', _MD_SUICO_GROUP_JOIN);
127
$xoopsTpl->assign('lang_ownerofgroup', _MD_SUICO_OWNEROFGROUP);
128
$xoopsTpl->assign('lang_removemember', _MD_SUICO_KICKOUT);
129
//$xoopsTpl->assign('path_suico_uploads',$helper->getConfig('link_path_upload'));
130
$xoopsTpl->assign(
131
    'lang_owner',
132
    _MD_SUICO_GROUPOWNER
133
);
134
$xoopsTpl->assign('lang_mysection', _MD_SUICO_GROUPS . ' :: ' . $group->getVar('group_title'));
135
$xoopsTpl->assign('section_name', _MD_SUICO_GROUPS . '> ' . $group->getVar('group_title'));
136
require_once XOOPS_ROOT_PATH . '/include/comment_view.php';
137
require __DIR__ . '/footer.php';
138
require dirname(__DIR__, 2) . '/footer.php';
139