Completed
Push — master ( 5f5d60...a9decc )
by Michael
03:36
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 33 and the first side effect is on line 3.

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
include __DIR__ . '/../../mainfile.php';
4
include_once __DIR__ . '/include/constantes.php';
5
$params                                  = array('view' => _EXTCAL_NAV_NEW_EVENT, 'file' => _EXTCAL_FILE_NEW_EVENT);
6
$GLOBALS['xoopsOption']['template_main'] = 'extcal_event.tpl';
7
include_once __DIR__ . '/header.php';
8
9
//exit;
10
11
include XOOPS_ROOT_PATH . '/include/comment_view.php';
12
13 View Code Duplication
if (!isset($_GET['event'])) {
14
    $eventId = 0;
15
} else {
16
    $eventId = (int)$_GET['event'];
17
}
18
$eventHandler          = xoops_getModuleHandler(_EXTCAL_CLS_EVENT, _EXTCAL_MODULE);
19
$fileHandler           = xoops_getModuleHandler(_EXTCAL_CLS_FILE, _EXTCAL_MODULE);
20
$eventMemberHandler    = xoops_getModuleHandler(_EXTCAL_CLS_MEMBER, _EXTCAL_MODULE);
21
$eventNotMemberHandler = xoops_getModuleHandler(_EXTCAL_CLS_NOT_MEMBER, _EXTCAL_MODULE);
22
$permHandler           = ExtcalPerm::getHandler();
23
include_once __DIR__ . '/class/etablissement.php';
24
include_once __DIR__ . '/class/utilities.php';
25
$myts = MyTextSanitizer::getInstance(); // MyTextSanitizer object
26
27
if (!function_exists('clear_unicodeslashes')) {
28
    /**
29
     * @param $text
30
     *
31
     * @return mixed
32
     */
33
    function clear_unicodeslashes($text)
34
    {
35
        $text = str_replace(array("\\'"), "'", $text);
36
        $text = str_replace(array("\\\\\\'"), "'", $text);
37
        $text = str_replace(array('\\"'), '"', $text);
38
39
        return $text;
40
    }
41
}
42
43
// Retriving event
44
$eventObj = $eventHandler->getEvent($eventId);
45
46
if (!$eventObj) {
47
    redirect_header('index.php', 3, '');
48
}
49
50
$event = $eventHandler->objectToArray($eventObj, array('cat_id', 'event_submitter'));
51
$eventHandler->serverTimeToUserTime($event);
52
53
$configHandler = xoops_getHandler('config');
54
$extcalConfig  = $configHandler->getConfigList($module->getVar('mid'));
55
56
// Adding formated date for start and end event
57
$eventHandler->formatEventDate($event, $extcalConfig['event_date_event']);
58
59
// Assigning event to the template
60
$xoopsTpl->assign('event', $event);
61
$xoopsTpl->assign('event_desc', html_entity_decode($myts->displayTarea(clear_unicodeslashes($event['event_desc']), 1, 1, 1, 1, 1)));
62
$xoopsTpl->assign('event_address', html_entity_decode($myts->displayTarea(clear_unicodeslashes($event['event_address']), 1, 1, 1, 1, 1)));
63
64
// Title of the page
65
$xoopsTpl->assign('xoops_pagetitle', $event['event_title']);
66
67
// $lang = array(
68
//     '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
69
// );
70
// // Assigning language data to the template
71
// $xoopsTpl->assign('lang', $lang);
72
73
// Getting event attachement
74
$eventFiles = $fileHandler->objectToArray($fileHandler->getEventFiles($eventId));
75
$fileHandler->formatFilesSize($eventFiles);
76
$xoopsTpl->assign('event_attachement', $eventFiles);
77
78
// Token to disallow direct posting on membre/nonmember page
79
$xoopsTpl->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML());
80
81
// Etablissement
82
$etablissementHandler = xoops_getModuleHandler(_EXTCAL_CLS_ETABLISSEMENT, _EXTCAL_MODULE);
83
$etablissementObj     = $etablissementHandler->get($event['event_etablissement']);
84
//$etablissement = $etablissementHandler->objectToArray($etablissementObj);
85
$etablissement = $etablissementObj->vars;
86
$xoopsTpl->assign('etablissement', $etablissement);
87
88
// $t =print_r($etablissementObj->vars,true);
89
// echo "<hr>etablissement {$event['event_etablissement']}<hr><pre>{$t}</pre><hr>";
90
91
// ### For Who's Going function ###
92
93
// If the who's goging function is enabled
94
if ($extcalConfig['whos_going']) {
95
96
    // Retriving member's for this event
97
    $members = $eventMemberHandler->getMembers($eventId);
98
99
    // Initializing variable
100
    $eventmember['member']['show_button'] = false;
101
102
    $nbUser = 0;
103
    // Making a list with members and counting regitered user's
104 View Code Duplication
    foreach ($members as $k => $v) {
105
        ++$nbUser;
106
        $eventmember['member']['userList'][] = array('uid' => $k, 'uname' => $v->getVar('uname'));
107
    }
108
    $eventmember['member']['nbUser'] = $nbUser;
109
110
    // If the user is logged
111
    if ($xoopsUser) {
112
113
        // Initializing variable
114
        $eventmember['member']['show_button']     = true;
115
        $eventmember['member']['button_disabled'] = '';
116
117
        // If the user is already restired to this event
118
        if (array_key_exists($xoopsUser->getVar('uid'), $members)) {
119
            $eventmember['member']['button_text']    = _MD_EXTCAL_REMOVE_ME;
120
            $eventmember['member']['joinevent_mode'] = 'remove';
121
        } else {
122
            $eventmember['member']['button_text']    = _MD_EXTCAL_ADD_ME;
123
            $eventmember['member']['joinevent_mode'] = 'add';
124
125
            // If this event is full
126
            if ($event['event_nbmember'] != 0
127
                && $eventMemberHandler->getNbMember($eventId) >= $event['event_nbmember']
128
            ) {
129
                $eventmember['member']['disabled'] = ' disabled="disabled"';
130
            }
131
        }
132
    }
133
}
134
135
// ### For Who's not Going function ###
136
137
// If the who's not goging function is enabled
138
if ($extcalConfig['whosnot_going']) {
139
140
    // Retriving not member's for this event
141
    $notmembers = $eventNotMemberHandler->getMembers($eventId);
142
143
    // Initializing variable
144
    $eventmember['notmember']['show_button'] = false;
145
146
    $nbUser = 0;
147
    // Making a list with not members
148 View Code Duplication
    foreach ($notmembers as $k => $v) {
149
        ++$nbUser;
150
        $eventmember['notmember']['userList'][] = array('uid' => $k, 'uname' => $v->getVar('uname'));
151
    }
152
    $eventmember['notmember']['nbUser'] = $nbUser;
153
154
    // If the user is logged
155
    if ($xoopsUser) {
156
157
        // Initializing variable
158
        $eventmember['notmember']['show_button']     = true;
159
        $eventmember['notmember']['button_disabled'] = '';
160
161
        // If the user is already restired to this event
162
        if (array_key_exists($xoopsUser->getVar('uid'), $notmembers)) {
163
            $eventmember['notmember']['button_text']    = _MD_EXTCAL_REMOVE_ME;
164
            $eventmember['notmember']['joinevent_mode'] = 'remove';
165
        } else {
166
            $eventmember['notmember']['button_text']    = _MD_EXTCAL_ADD_ME;
167
            $eventmember['notmember']['joinevent_mode'] = 'add';
168
        }
169
    }
170
}
171
172
// If who's going or not going function is enabled
173
if ($extcalConfig['whos_going'] || $extcalConfig['whosnot_going']) {
174
    $xoopsTpl->assign('eventmember', $eventmember);
175
}
176
177
// Checking user perm
178
if ($xoopsUser) {
179
    $xoopsTpl->assign('isAdmin', $xoopsUser->isAdmin());
180
    $canEdit = $permHandler->isAllowed($xoopsUser, 'extcal_cat_edit', $event['cat']['cat_id'])
181
               && $xoopsUser->getVar('uid') == $event['user']['uid'];
182
    $xoopsTpl->assign('canEdit', $canEdit);
183
} else {
184
    $xoopsTpl->assign('isAdmin', false);
185
    $xoopsTpl->assign('canEdit', false);
186
}
187
188
$xoopsTpl->assign('whosGoing', $extcalConfig['whos_going']);
189
$xoopsTpl->assign('whosNotGoing', $extcalConfig['whosnot_going']);
190
191
//-------------
192
$xoopsTpl->assign('params', $params);
193
$tNavBar = getNavBarTabs($params['view']);
194
$xoopsTpl->assign('tNavBar', $tNavBar);
195
//---------------------
196
197
/*  test modofication status    JJD
198
  $k = 'status';
199
  $isStatus = _EXTCAL_STATUS_DESINSCRIPTION;
200
  $xfStatus = new XoopsFormSelect('', $k, $isStatus, 1, false) ;
201
  $tStatus = array(_EXTCAL_STATUS_NONE    => _MD_EXTCAL_LIB_NONE,
202
                   _EXTCAL_STATUS_COME    => _MD_EXTCAL_LIB_COME,
203
                   _EXTCAL_STATUS_NOTCOME => _MD_EXTCAL_LIB_NOTCOME);
204
205
  $xfStatus->addOptionArray($tStatus);
206
  $xoopsTpl->assign('status', $xfStatus->render());
207
*/
208
209
$xoTheme->addScript('browse.php?modules/extcal/assets/js/highslide.js');
210
$xoTheme->addStylesheet('browse.php?modules/extcal/assets/js/highslide.css');
211
212
//function XoopsFormDhtmlTextArea($caption, $name, $value = "", $rows = 5, $cols = 50, $hiddentext = "xoopsHiddenText", $options = array());
213
214
include XOOPS_ROOT_PATH . '/footer.php';
215