Completed
Branch master (55a138)
by Michael
03:21
created

event.php ➔ clear_unicodeslashes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 52 and the first side effect is on line 22.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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
 * @copyright    {@link https://xoops.org/ XOOPS Project}
14
 * @license      {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
15
 * @package      extcal
16
 * @since
17
 * @author       XOOPS Development Team,
18
 */
19
20
use XoopsModules\Extcal;
21
22
include __DIR__ . '/../../mainfile.php';
23
require_once __DIR__ . '/include/constantes.php';
24
$params                                  = ['view' => _EXTCAL_NAV_NEW_EVENT, 'file' => _EXTCAL_FILE_NEW_EVENT];
25
$GLOBALS['xoopsOption']['template_main'] = 'extcal_event.tpl';
26
require_once __DIR__ . '/header.php';
27
28
//exit;
29
30
include XOOPS_ROOT_PATH . '/include/comment_view.php';
31
32 View Code Duplication
if (!isset($_GET['event'])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
    $eventId = 0;
34
} else {
35
    $eventId = (int)$_GET['event'];
36
}
37
$eventHandler          = Extcal\Helper::getInstance()->getHandler(_EXTCAL_CLN_EVENT);
38
$fileHandler           = Extcal\Helper::getInstance()->getHandler(_EXTCAL_CLN_FILE);
39
$eventMemberHandler    = Extcal\Helper::getInstance()->getHandler(_EXTCAL_CLN_MEMBER);
40
$eventNotMemberHandler = Extcal\Helper::getInstance()->getHandler(_EXTCAL_CLN_NOT_MEMBER);
41
$permHandler           = Extcal\Perm::getHandler();
42
//require_once __DIR__ . '/class/etablissement.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
48% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
43
//require_once __DIR__ . '/class/Utility.php';
44
$myts = \MyTextSanitizer::getInstance(); // MyTextSanitizer object
45
46
if (!function_exists('clear_unicodeslashes')) {
47
    /**
48
     * @param $text
49
     *
50
     * @return mixed
51
     */
52
    function clear_unicodeslashes($text)
53
    {
54
        $text = str_replace(["\\'"], "'", $text);
55
        $text = str_replace(["\\\\\\'"], "'", $text);
56
        $text = str_replace(['\\"'], '"', $text);
57
58
        return $text;
59
    }
60
}
61
62
// Retriving event
63
$eventObj = $eventHandler->getEvent($eventId);
64
65
if (!$eventObj) {
66
    redirect_header('index.php', 3, '');
67
}
68
69
$event = $eventHandler->objectToArray($eventObj, ['cat_id', 'event_submitter']);
70
$eventHandler->serverTimeToUserTime($event);
71
72
$configHandler = xoops_getHandler('config');
73
$extcalConfig  = $configHandler->getConfigList($module->getVar('mid'));
74
75
// Adding formated date for start and end event
76
$eventHandler->formatEventDate($event, $extcalConfig['event_date_event']);
77
78
// Assigning event to the template
79
$xoopsTpl->assign('event', $event);
80
$xoopsTpl->assign('event_desc', html_entity_decode($myts->displayTarea(clear_unicodeslashes($event['event_desc']), 1, 1, 1, 1, 1)));
81
$xoopsTpl->assign('event_address', html_entity_decode($myts->displayTarea(clear_unicodeslashes($event['event_address']), 1, 1, 1, 1, 1)));
82
83
// Title of the page
84
$xoopsTpl->assign('xoops_pagetitle', $event['event_title']);
85
86
// $lang = array(
0 ignored issues
show
Unused Code Comprehensibility introduced by
45% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
87
//     'start' => _MD_EXTCAL_START, 'end' => _MD_EXTCAL_END, 'contact_info' => _MD_EXTCAL_CONTACT_INFO, 'email' => _MD_EXTCAL_EMAIL, 'url' => _MD_EXTCAL_URL, 'whos_going' => _MD_EXTCAL_WHOS_GOING, 'whosnot_going' => _MD_EXTCAL_WHOSNOT_GOING, 'reccur_rule' => _MD_EXTCAL_RECCUR_RULE, 'posted_by' => _MD_EXTCAL_POSTED_BY, 'on' => _MD_EXTCAL_ON
88
// );
89
// // Assigning language data to the template
90
// $xoopsTpl->assign('lang', $lang);
91
92
// Getting event attachement
93
$eventFiles = $fileHandler->objectToArray($fileHandler->getEventFiles($eventId));
94
$fileHandler->formatFilesSize($eventFiles);
95
$xoopsTpl->assign('event_attachement', $eventFiles);
96
97
// Token to disallow direct posting on membre/nonmember page
98
$xoopsTpl->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML());
99
100
// Etablissement
101
$etablissementHandler = Extcal\Helper::getInstance()->getHandler(_EXTCAL_CLN_ETABLISSEMENT);
102
$etablissementObj     = $etablissementHandler->get($event['event_etablissement']);
103
//$etablissement = $etablissementHandler->objectToArray($etablissementObj);
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
104
$etablissement = $etablissementObj->vars;
105
$xoopsTpl->assign('etablissement', $etablissement);
106
107
// $t =print_r($etablissementObj->vars,true);
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
108
// echo "<hr>etablissement {$event['event_etablissement']}<hr><pre>{$t}</pre><hr>";
109
110
// ### For Who's Going function ###
111
112
// If the who's goging function is enabled
113
if ($extcalConfig['whos_going']) {
114
115
    // Retriving member's for this event
116
    $members = $eventMemberHandler->getMembers($eventId);
117
118
    // Initializing variable
119
    $eventmember['member']['show_button'] = false;
120
121
    $nbUser = 0;
122
    // Making a list with members and counting regitered user's
123 View Code Duplication
    foreach ($members as $k => $v) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
124
        ++$nbUser;
125
        $eventmember['member']['userList'][] = ['uid' => $k, 'uname' => $v->getVar('uname')];
126
    }
127
    $eventmember['member']['nbUser'] = $nbUser;
128
129
    // If the user is logged
130
    if ($xoopsUser) {
131
132
        // Initializing variable
133
        $eventmember['member']['show_button']     = true;
134
        $eventmember['member']['button_disabled'] = '';
135
136
        // If the user is already restired to this event
137
        if (array_key_exists($xoopsUser->getVar('uid'), $members)) {
138
            $eventmember['member']['button_text']    = _MD_EXTCAL_REMOVE_ME;
139
            $eventmember['member']['joinevent_mode'] = 'remove';
140
        } else {
141
            $eventmember['member']['button_text']    = _MD_EXTCAL_ADD_ME;
142
            $eventmember['member']['joinevent_mode'] = 'add';
143
144
            // If this event is full
145
            if (0 != $event['event_nbmember']
146
                && $eventMemberHandler->getNbMember($eventId) >= $event['event_nbmember']) {
147
                $eventmember['member']['disabled'] = ' disabled="disabled"';
148
            }
149
        }
150
    }
151
}
152
153
// ### For Who's not Going function ###
154
155
// If the who's not goging function is enabled
156
if ($extcalConfig['whosnot_going']) {
157
158
    // Retriving not member's for this event
159
    $notmembers = $eventNotMemberHandler->getMembers($eventId);
160
161
    // Initializing variable
162
    $eventmember['notmember']['show_button'] = false;
163
164
    $nbUser = 0;
165
    // Making a list with not members
166 View Code Duplication
    foreach ($notmembers as $k => $v) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
167
        ++$nbUser;
168
        $eventmember['notmember']['userList'][] = ['uid' => $k, 'uname' => $v->getVar('uname')];
169
    }
170
    $eventmember['notmember']['nbUser'] = $nbUser;
171
172
    // If the user is logged
173
    if ($xoopsUser) {
174
175
        // Initializing variable
176
        $eventmember['notmember']['show_button']     = true;
177
        $eventmember['notmember']['button_disabled'] = '';
178
179
        // If the user is already restired to this event
180
        if (array_key_exists($xoopsUser->getVar('uid'), $notmembers)) {
181
            $eventmember['notmember']['button_text']    = _MD_EXTCAL_REMOVE_ME;
182
            $eventmember['notmember']['joinevent_mode'] = 'remove';
183
        } else {
184
            $eventmember['notmember']['button_text']    = _MD_EXTCAL_ADD_ME;
185
            $eventmember['notmember']['joinevent_mode'] = 'add';
186
        }
187
    }
188
}
189
190
// If who's going or not going function is enabled
191
if ($extcalConfig['whos_going'] || $extcalConfig['whosnot_going']) {
192
    $xoopsTpl->assign('eventmember', $eventmember);
193
}
194
195
// Checking user perm
196
if ($xoopsUser) {
197
    $xoopsTpl->assign('isAdmin', $xoopsUser->isAdmin());
198
    $canEdit = $permHandler->isAllowed($xoopsUser, 'extcal_cat_edit', $event['cat']['cat_id'])
199
               && $xoopsUser->getVar('uid') == $event['user']['uid'];
200
    $xoopsTpl->assign('canEdit', $canEdit);
201
} else {
202
    $xoopsTpl->assign('isAdmin', false);
203
    $xoopsTpl->assign('canEdit', false);
204
}
205
206
$xoopsTpl->assign('whosGoing', $extcalConfig['whos_going']);
207
$xoopsTpl->assign('whosNotGoing', $extcalConfig['whosnot_going']);
208
209
//-------------
210
$xoopsTpl->assign('params', $params);
211
$tNavBar = getNavBarTabs($params['view']);
212
$xoopsTpl->assign('tNavBar', $tNavBar);
213
//---------------------
214
215
/*  test modofication status    JJD
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
216
  $k = 'status';
217
  $isStatus = _EXTCAL_STATUS_DESINSCRIPTION;
218
  $xfStatus = new \XoopsFormSelect('', $k, $isStatus, 1, false) ;
219
  $tStatus = array(_EXTCAL_STATUS_NONE    => _MD_EXTCAL_LIB_NONE,
220
                   _EXTCAL_STATUS_COME    => _MD_EXTCAL_LIB_COME,
221
                   _EXTCAL_STATUS_NOTCOME => _MD_EXTCAL_LIB_NOTCOME);
222
223
  $xfStatus->addOptionArray($tStatus);
224
  $xoopsTpl->assign('status', $xfStatus->render());
225
*/
226
227
/** @var xos_opal_Theme $xoTheme */
228
$xoTheme->addScript('browse.php?modules/extcal/assets/js/highslide.js');
229
$xoTheme->addStylesheet('browse.php?modules/extcal/assets/js/highslide.css');
230
231
//function XoopsFormDhtmlTextArea($caption, $name, $value = "", $rows = 5, $cols = 50, $hiddentext = "xoopsHiddenText", $options = array());
0 ignored issues
show
Unused Code Comprehensibility introduced by
52% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
232
233
include XOOPS_ROOT_PATH . '/footer.php';
234