mambax7 /
extcal
| 1 | <?php |
||||||
| 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 https://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 | require_once dirname(dirname(__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 | require_once XOOPS_ROOT_PATH . '/include/comment_view.php'; |
||||||
| 31 | |||||||
| 32 | if (!isset($_GET['event'])) { |
||||||
| 33 | $eventId = 0; |
||||||
| 34 | } else { |
||||||
| 35 | $eventId = \Xmf\Request::getInt('event', 0, 'GET'); |
||||||
| 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 | $myts = \MyTextSanitizer::getInstance(); // MyTextSanitizer object |
||||||
| 43 | |||||||
| 44 | if (!function_exists('clear_unicodeslashes')) { |
||||||
| 45 | /** |
||||||
| 46 | * @param $text |
||||||
| 47 | * |
||||||
| 48 | * @return mixed |
||||||
| 49 | */ |
||||||
| 50 | function clear_unicodeslashes($text) |
||||||
| 51 | { |
||||||
| 52 | $text = str_replace(["\\'"], "'", $text); |
||||||
| 53 | $text = str_replace(["\\\\\\'"], "'", $text); |
||||||
| 54 | $text = str_replace(['\\"'], '"', $text); |
||||||
| 55 | |||||||
| 56 | return $text; |
||||||
| 57 | } |
||||||
| 58 | } |
||||||
| 59 | |||||||
| 60 | // Retriving event |
||||||
| 61 | $eventObj = $eventHandler->getEvent($eventId); |
||||||
| 62 | |||||||
| 63 | if (!$eventObj) { |
||||||
| 64 | redirect_header('index.php', 3, ''); |
||||||
| 65 | } |
||||||
| 66 | |||||||
| 67 | $event = $eventHandler->objectToArray($eventObj, ['cat_id', 'event_submitter']); |
||||||
| 68 | $eventHandler->serverTimeToUserTime($event); |
||||||
| 69 | |||||||
| 70 | $configHandler = xoops_getHandler('config'); |
||||||
| 71 | $extcalConfig = $configHandler->getConfigList($module->getVar('mid')); |
||||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||||
| 72 | |||||||
| 73 | // Adding formated date for start and end event |
||||||
| 74 | $eventHandler->formatEventDate($event, $extcalConfig['event_date_event']); |
||||||
|
0 ignored issues
–
show
The method
formatEventDate() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 75 | |||||||
| 76 | // Assigning event to the template |
||||||
| 77 | $xoopsTpl->assign('event', $event); |
||||||
| 78 | $xoopsTpl->assign('event_desc', html_entity_decode($myts->displayTarea(clear_unicodeslashes($event['event_desc']), 1, 1, 1, 1, 1))); |
||||||
| 79 | $xoopsTpl->assign('event_address', html_entity_decode($myts->displayTarea(clear_unicodeslashes($event['event_address']), 1, 1, 1, 1, 1))); |
||||||
| 80 | |||||||
| 81 | // Title of the page |
||||||
| 82 | $xoopsTpl->assign('xoops_pagetitle', $event['event_title']); |
||||||
| 83 | |||||||
| 84 | // $lang = array( |
||||||
| 85 | // '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 |
||||||
| 86 | // ); |
||||||
| 87 | // // Assigning language data to the template |
||||||
| 88 | // $xoopsTpl->assign('lang', $lang); |
||||||
| 89 | |||||||
| 90 | // Getting event attachement |
||||||
| 91 | $eventFiles = $fileHandler->objectToArray($fileHandler->getEventFiles($eventId)); |
||||||
| 92 | $fileHandler->formatFilesSize($eventFiles); |
||||||
| 93 | $xoopsTpl->assign('event_attachement', $eventFiles); |
||||||
| 94 | |||||||
| 95 | // Token to disallow direct posting on membre/nonmember page |
||||||
| 96 | $xoopsTpl->assign('token', $GLOBALS['xoopsSecurity']->getTokenHTML()); |
||||||
| 97 | |||||||
| 98 | // Location |
||||||
| 99 | $locationHandler = Extcal\Helper::getInstance()->getHandler(_EXTCAL_CLN_LOCATION); |
||||||
| 100 | $locationObj = $locationHandler->get($event['event_location']); |
||||||
| 101 | //$location = $locationHandler->objectToArray($locationObj); |
||||||
| 102 | $location = $locationObj->vars; |
||||||
| 103 | $xoopsTpl->assign('location', $location); |
||||||
| 104 | |||||||
| 105 | // $t =print_r($locationObj->vars,true); |
||||||
| 106 | // echo "<hr>location {$event['event_location']}<hr><pre>{$t}</pre><hr>"; |
||||||
| 107 | |||||||
| 108 | // ### For Who's Going function ### |
||||||
| 109 | |||||||
| 110 | // If the who's goging function is enabled |
||||||
| 111 | if ($extcalConfig['whos_going']) { |
||||||
| 112 | // Retriving member's for this event |
||||||
| 113 | $members = $eventMemberHandler->getMembers($eventId); |
||||||
| 114 | |||||||
| 115 | // Initializing variable |
||||||
| 116 | $eventmember['member']['show_button'] = false; |
||||||
| 117 | |||||||
| 118 | $nbUser = 0; |
||||||
| 119 | // Making a list with members and counting regitered user's |
||||||
| 120 | foreach ($members as $k => $v) { |
||||||
| 121 | ++$nbUser; |
||||||
| 122 | $eventmember['member']['userList'][] = ['uid' => $k, 'uname' => $v->getVar('uname')]; |
||||||
| 123 | } |
||||||
| 124 | $eventmember['member']['nbUser'] = $nbUser; |
||||||
| 125 | |||||||
| 126 | // If the user is logged |
||||||
| 127 | if ($xoopsUser) { |
||||||
| 128 | // Initializing variable |
||||||
| 129 | $eventmember['member']['show_button'] = true; |
||||||
| 130 | $eventmember['member']['button_disabled'] = ''; |
||||||
| 131 | |||||||
| 132 | // If the user is already restired to this event |
||||||
| 133 | if (array_key_exists($xoopsUser->getVar('uid'), $members)) { |
||||||
| 134 | $eventmember['member']['button_text'] = _MD_EXTCAL_REMOVE_ME; |
||||||
| 135 | $eventmember['member']['joinevent_mode'] = 'remove'; |
||||||
| 136 | } else { |
||||||
| 137 | $eventmember['member']['button_text'] = _MD_EXTCAL_ADD_ME; |
||||||
| 138 | $eventmember['member']['joinevent_mode'] = 'add'; |
||||||
| 139 | |||||||
| 140 | // If this event is full |
||||||
| 141 | if (0 != $event['event_nbmember'] |
||||||
| 142 | && $eventMemberHandler->getNbMember($eventId) >= $event['event_nbmember']) { |
||||||
| 143 | $eventmember['member']['disabled'] = ' disabled="disabled"'; |
||||||
| 144 | } |
||||||
| 145 | } |
||||||
| 146 | } |
||||||
| 147 | } |
||||||
| 148 | |||||||
| 149 | // ### For Who's not Going function ### |
||||||
| 150 | |||||||
| 151 | // If the who's not goging function is enabled |
||||||
| 152 | if ($extcalConfig['whosnot_going']) { |
||||||
| 153 | // Retriving not member's for this event |
||||||
| 154 | $notmembers = $eventNotMemberHandler->getMembers($eventId); |
||||||
| 155 | |||||||
| 156 | // Initializing variable |
||||||
| 157 | $eventmember['notmember']['show_button'] = false; |
||||||
| 158 | |||||||
| 159 | $nbUser = 0; |
||||||
| 160 | // Making a list with not members |
||||||
| 161 | foreach ($notmembers as $k => $v) { |
||||||
| 162 | ++$nbUser; |
||||||
| 163 | $eventmember['notmember']['userList'][] = ['uid' => $k, 'uname' => $v->getVar('uname')]; |
||||||
| 164 | } |
||||||
| 165 | $eventmember['notmember']['nbUser'] = $nbUser; |
||||||
| 166 | |||||||
| 167 | // If the user is logged |
||||||
| 168 | if ($xoopsUser) { |
||||||
| 169 | // Initializing variable |
||||||
| 170 | $eventmember['notmember']['show_button'] = true; |
||||||
| 171 | $eventmember['notmember']['button_disabled'] = ''; |
||||||
| 172 | |||||||
| 173 | // If the user is already restired to this event |
||||||
| 174 | if (array_key_exists($xoopsUser->getVar('uid'), $notmembers)) { |
||||||
| 175 | $eventmember['notmember']['button_text'] = _MD_EXTCAL_REMOVE_ME; |
||||||
| 176 | $eventmember['notmember']['joinevent_mode'] = 'remove'; |
||||||
| 177 | } else { |
||||||
| 178 | $eventmember['notmember']['button_text'] = _MD_EXTCAL_ADD_ME; |
||||||
| 179 | $eventmember['notmember']['joinevent_mode'] = 'add'; |
||||||
| 180 | } |
||||||
| 181 | } |
||||||
| 182 | } |
||||||
| 183 | |||||||
| 184 | // If who's going or not going function is enabled |
||||||
| 185 | if ($extcalConfig['whos_going'] || $extcalConfig['whosnot_going']) { |
||||||
| 186 | $xoopsTpl->assign('eventmember', $eventmember); |
||||||
| 187 | } |
||||||
| 188 | |||||||
| 189 | // Checking user perm |
||||||
| 190 | if ($xoopsUser) { |
||||||
| 191 | $xoopsTpl->assign('isAdmin', $xoopsUser->isAdmin()); |
||||||
| 192 | $canEdit = $permHandler->isAllowed($xoopsUser, 'extcal_cat_edit', $event['cat']['cat_id']) |
||||||
| 193 | && $xoopsUser->getVar('uid') == $event['user']['uid']; |
||||||
| 194 | $xoopsTpl->assign('canEdit', $canEdit); |
||||||
| 195 | } else { |
||||||
| 196 | $xoopsTpl->assign('isAdmin', false); |
||||||
| 197 | $xoopsTpl->assign('canEdit', false); |
||||||
| 198 | } |
||||||
| 199 | |||||||
| 200 | $xoopsTpl->assign('whosGoing', $extcalConfig['whos_going']); |
||||||
| 201 | $xoopsTpl->assign('whosNotGoing', $extcalConfig['whosnot_going']); |
||||||
| 202 | |||||||
| 203 | //------------- |
||||||
| 204 | $xoopsTpl->assign('params', $params); |
||||||
| 205 | $tNavBar = getNavBarTabs($params['view']); |
||||||
| 206 | $xoopsTpl->assign('tNavBar', $tNavBar); |
||||||
| 207 | //--------------------- |
||||||
| 208 | |||||||
| 209 | /* |
||||||
| 210 | // TZV // |
||||||
| 211 | // mb missing for xBootstrap templates by Tzvook |
||||||
| 212 | $lang = ['start' => _MD_EXTCAL_START, |
||||||
| 213 | 'end' => _MD_EXTCAL_END, |
||||||
| 214 | 'calmonth' => _MD_EXTCAL_NAV_CALMONTH, |
||||||
| 215 | 'calweek' => _MD_EXTCAL_NAV_CALWEEK, |
||||||
| 216 | 'year' => _MD_EXTCAL_NAV_YEAR, |
||||||
| 217 | 'month' => _MD_EXTCAL_NAV_MONTH, |
||||||
| 218 | 'week' => _MD_EXTCAL_NAV_WEEK, |
||||||
| 219 | 'day' => _MD_EXTCAL_NAV_DAY, |
||||||
| 220 | 'agendaweek' => _MD_EXTCAL_NAV_AGENDA_WEEK, |
||||||
| 221 | 'agendaday' => _MD_EXTCAL_NAV_AGENDA_DAY, |
||||||
| 222 | 'search' => _MD_EXTCAL_NAV_SEARCH, |
||||||
| 223 | 'newevent' => _MD_EXTCAL_NAV_NEW_EVENT, |
||||||
| 224 | ]; |
||||||
| 225 | |||||||
| 226 | // Assigning language data to the template |
||||||
| 227 | $xoopsTpl->assign('lang', $lang); |
||||||
| 228 | $xoopsTpl->assign('view', 'event'); |
||||||
| 229 | |||||||
| 230 | */ |
||||||
| 231 | |||||||
| 232 | /* test modofication status JJD |
||||||
| 233 | $k = 'status'; |
||||||
| 234 | $isStatus = _EXTCAL_STATUS_DESINSCRIPTION; |
||||||
| 235 | $xfStatus = new \XoopsFormSelect('', $k, $isStatus, 1, false) ; |
||||||
| 236 | $tStatus = array(_EXTCAL_STATUS_NONE => _MD_EXTCAL_LIB_NONE, |
||||||
| 237 | _EXTCAL_STATUS_COME => _MD_EXTCAL_LIB_COME, |
||||||
| 238 | _EXTCAL_STATUS_NOTCOME => _MD_EXTCAL_LIB_NOTCOME); |
||||||
| 239 | |||||||
| 240 | $xfStatus->addOptionArray($tStatus); |
||||||
| 241 | $xoopsTpl->assign('status', $xfStatus->render()); |
||||||
| 242 | */ |
||||||
| 243 | |||||||
| 244 | /** @var xos_opal_Theme $xoTheme */ |
||||||
| 245 | $xoTheme->addScript('browse.php?modules/extcal/assets/js/highslide.js'); |
||||||
| 246 | $xoTheme->addStylesheet('browse.php?modules/extcal/assets/js/highslide.css'); |
||||||
| 247 | |||||||
| 248 | //function XoopsFormDhtmlTextArea($caption, $name, $value = "", $rows = 5, $cols = 50, $hiddentext = "xoopsHiddenText", $options = []); |
||||||
| 249 | |||||||
| 250 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||||||
| 251 |