/** * Headlines constructor * * @param string $pageContent Template content */ function __construct($pageContent) { parent::__construct('.'); parent::getSettings(); $this->pageContent = $pageContent; \Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl); }
/** * Create's new rss feed for the calendar module * * @global array $_CONFIG * @global object $objDatabase */ function creatFeed() { global $_CONFIG, $objDatabase; parent::getFrontendLanguages(); parent::getSettings(); $this->objEventManager->getEventlist(); foreach ($this->arrFrontendLanguages as $langKey => $arrFrontendLanguage) { $objRSSWriter = new \RSSWriter(); $objRSSWriter->characterEncoding = CONTREXX_CHARSET; $objRSSWriter->channelTitle = contrexx_raw2xml($this->arrSettings['rssFeedTitle']); $objRSSWriter->channelLink = contrexx_raw2xml($this->domainUrl . 'index.php?section=' . $this->moduleName); $objRSSWriter->channelDescription = contrexx_raw2xml($this->arrSettings['rssFeedDescription']); $objRSSWriter->channelLanguage = contrexx_raw2xml($arrFrontendLanguage['lang']); $objRSSWriter->channelCopyright = contrexx_raw2xml('Copyright ' . date('Y') . ', ' . $this->domainUrl); if (!empty($this->arrSettings['rssFeedImage'])) { $objRSSWriter->channelImageUrl = $this->arrSettings['rssFeedImage']; $objRSSWriter->channelImageTitle = $objRSSWriter->channelTitle; $objRSSWriter->channelImageLink = $objRSSWriter->channelLink; } $objRSSWriter->channelWebMaster = $_CONFIG['coreAdminEmail']; $objRSSWriter->channelLastBuildDate = date('r', mktime()); foreach ($this->objEventManager->eventList as $eventKey => $objEvent) { $objFWUser = \FWUser::getFWUserObject(); $showIn = explode(',', $objEvent->showIn); if (in_array($arrFrontendLanguage['id'], $showIn)) { $itemTitle = contrexx_raw2xml(html_entity_decode($objEvent->arrData['title'][$arrFrontendLanguage['id']], ENT_QUOTES, CONTREXX_CHARSET)); $itemLink = $objEvent->type == 0 ? $this->domainUrl . $this->objEventManager->_getDetailLink($objEvent) : $objEvent->arrData['redirect'][$arrFrontendLanguage['id']]; $itemLink = contrexx_raw2xml(html_entity_decode($itemLink)); $itemDescription = contrexx_raw2xml($objEvent->arrData['description'][$arrFrontendLanguage['id']]); if ($objUser = $objFWUser->objUser->getUser(intval($objEvent->author))) { $itemAuthor = $objUser->getEmail(); } else { $itemAuthor = "unknown"; } $itemAuthor = contrexx_raw2xml($itemAuthor); $itemCategory = array(); $itemComments = null; $itemEnclosure = array(); $itemGuid = array(); $itemPubDate = contrexx_raw2xml($objEvent->startDate); $itemSource = array(); $objRSSWriter->addItem($itemTitle, $itemLink, $itemDescription, $itemAuthor, $itemCategory, $itemComments, $itemEnclosure, $itemGuid, $itemPubDate, $itemSource); } } $objRSSWriter->feedType = 'xml'; $objRSSWriter->xmlDocumentPath = \Env::get('cx')->getWebsiteFeedPath() . '/calendar_all_' . $arrFrontendLanguage['lang'] . '.' . $objRSSWriter->feedType; $objRSSWriter->write(); } }
function loadEventFromPost($data) { list($startDate, $strStartTime) = explode(' ', $data['startDate']); list($startHour, $startMin) = explode(':', $strStartTime); list($endDate, $strEndTime) = explode(' ', $data['endDate']); list($endHour, $endMin) = explode(':', $strEndTime); list($startHour, $startMin) = array(0, 0); list($endHour, $endMin) = array(0, 0); //event data $startDate = parent::getDateTimestamp($startDate, intval($startHour), intval($startMin)); $endDate = parent::getDateTimestamp($endDate, intval($endHour), intval($endMin)); $this->startDate = $startDate; $this->endDate = $endDate; //series pattern $seriesStatus = isset($data['seriesStatus']) ? intval($data['seriesStatus']) : 0; $seriesType = isset($data['seriesType']) ? intval($data['seriesType']) : 0; $seriesPatternCount = 0; $seriesPatternWeekday = 0; $seriesPatternDay = 0; $seriesPatternWeek = 0; $seriesPatternMonth = 0; $seriesPatternType = 0; $seriesPatternDouranceType = 0; $seriesPatternEnd = 0; $seriesExeptions = ''; if ($seriesStatus == 1) { switch ($seriesType) { case 1: if ($seriesStatus == 1) { $seriesPatternType = isset($data['seriesDaily']) ? intval($data['seriesDaily']) : 0; if ($seriesPatternType == 1) { $seriesPatternWeekday = 0; $seriesPatternDay = isset($data['seriesDailyDays']) ? intval($data['seriesDailyDays']) : 0; } else { $seriesPatternWeekday = "1111100"; $seriesPatternDay = 0; } $seriesPatternWeek = 0; $seriesPatternMonth = 0; $seriesPatternCount = 0; } break; case 2: if ($seriesStatus == 1) { $seriesPatternWeek = isset($data['seriesWeeklyWeeks']) ? intval($data['seriesWeeklyWeeks']) : 0; $weekdayPattern = ''; for ($i = 1; $i <= 7; $i++) { if (isset($data['seriesWeeklyDays'][$i])) { $weekdayPattern .= "1"; } else { $weekdayPattern .= "0"; } } // To DO: not correct to set day to monday $seriesPatternWeekday = (int) $weekdayPattern == 0 ? '1000000' : $weekdayPattern; $seriesPatternCount = 0; $seriesPatternDay = 0; $seriesPatternMonth = 0; $seriesPatternType = 0; } break; case 3: if ($seriesStatus == 1) { $seriesPatternType = isset($data['seriesMonthly']) ? intval($data['seriesMonthly']) : 0; if ($seriesPatternType == 1) { $seriesPatternMonth = isset($data['seriesMonthlyMonth_1']) ? intval($data['seriesMonthlyMonth_1']) : 0; $seriesPatternDay = isset($data['seriesMonthlyDay']) ? intval($data['seriesMonthlyDay']) : 0; $seriesPatternWeekday = 0; } else { $seriesPatternCount = isset($data['seriesMonthlyDayCount']) ? intval($data['seriesMonthlyDayCount']) : 0; $seriesPatternMonth = isset($data['seriesMonthlyMonth_2']) ? intval($data['seriesMonthlyMonth_2']) : 0; if ($seriesPatternMonth < 1) { // the increment must be at least once a month, otherwise we will end up in a endless loop in the presence $seriesPatternMonth = 1; } $seriesPatternWeekday = isset($data['seriesMonthlyWeekday']) ? $data['seriesMonthlyWeekday'] : ''; $seriesPatternDay = 0; } $seriesPatternWeek = 0; } break; } $seriesPatternDouranceType = isset($data['seriesDouranceType']) ? intval($data['seriesDouranceType']) : 0; $seriesPatternEndDate = ''; switch ($seriesPatternDouranceType) { case 1: $seriesPatternEnd = 0; break; case 2: $seriesPatternEnd = isset($data['seriesDouranceEvents']) ? intval($data['seriesDouranceEvents']) : 0; break; case 3: $seriesPatternEndDate = parent::getDateTimestamp($data['seriesDouranceDate'], 0, 0); break; } } $this->seriesData['seriesPatternCount'] = intval($seriesPatternCount); $this->seriesData['seriesType'] = intval($seriesType); $this->seriesData['seriesPatternCount'] = intval($seriesPatternCount); $this->seriesData['seriesPatternWeekday'] = htmlentities($seriesPatternWeekday, ENT_QUOTES, CONTREXX_CHARSET); $this->seriesData['seriesPatternDay'] = intval($seriesPatternDay); $this->seriesData['seriesPatternWeek'] = intval($seriesPatternWeek); $this->seriesData['seriesPatternMonth'] = intval($seriesPatternMonth); $this->seriesData['seriesPatternType'] = intval($seriesPatternType); $this->seriesData['seriesPatternDouranceType'] = intval($seriesPatternDouranceType); $this->seriesData['seriesPatternEnd'] = intval($seriesPatternEnd); $this->seriesData['seriesPatternEndDate'] = intval($seriesPatternEndDate); $this->seriesData['seriesPatternBegin'] = 0; $this->seriesData['seriesPatternExceptions'] = ''; }
/** * show date and time by user settings > several day view * * @param object $objEvent Event object * @param string $separatorDateTime Date time separator * @param string $separatorSeveralDays SeveralDays separator * @param boolean $showClock true to show clock, false to hide * @param integer $part Part of the multi date event * * @return null */ function getMultiDateBlock($objEvent, $separatorDateTime, $separatorSeveralDays, $showClock, $part) { global $_ARRAYLANG; $this->sepDateTime = html_entity_decode($separatorDateTime); if ($part == 1) { // parse part 1 (start) //date $this->date = date(parent::getDateFormat(), $objEvent->startDate); //time $this->time = date('H:i', $objEvent->startDate); //show / hide clock $showClock && $this->time != '' ? $this->clock = ' ' . $_ARRAYLANG['TXT_CALENDAR_OCLOCK'] : ($this->clock = ''); //add separator for several days if ($this->clock != '') { $this->clock .= html_entity_decode($separatorSeveralDays); } else { $this->time .= html_entity_decode($separatorSeveralDays); } } else { // parse part 2 (end) //date $this->date = date(parent::getDateFormat(), $objEvent->endDate); //time $this->time = date('H:i', $objEvent->endDate); //show / hide clock $showClock && $this->time != '' ? $this->clock = ' ' . $_ARRAYLANG['TXT_CALENDAR_OCLOCK'] : ($this->clock = ''); } }
/** * Save the registration * * @param array $data posted data from the form * * @return boolean true if the registration saved, false otherwise */ function save($data) { global $objDatabase, $objInit, $_LANGID; /* foreach ($this->form->inputfields as $key => $arrInputfield) { if($arrInputfield['type'] == 'selectBillingAddress') { $affiliationStatus = $data['registrationField'][$arrInputfield['id']]; } } */ foreach ($this->form->inputfields as $key => $arrInputfield) { /* if($affiliationStatus == 'sameAsContact') { if($arrInputfield['required'] == 1 && empty($data['registrationField'][$arrInputfield['id']]) && $arrInputfield['affiliation'] != 'billing') { return false; } if($arrInputfield['required'] == 1 && $arrInputfield['type'] == 'mail' && $arrInputfield['affiliation'] != 'billing') { $objValidator = new FWValidator(); if(!$objValidator->isEmail($data['registrationField'][$arrInputfield['id']])) { return false; } } } else { */ if ($arrInputfield['required'] == 1 && empty($data['registrationField'][$arrInputfield['id']])) { return false; } if ($arrInputfield['required'] == 1 && $arrInputfield['type'] == 'mail') { $objValidator = new \FWValidator(); if (!$objValidator->isEmail($data['registrationField'][$arrInputfield['id']])) { return false; } } /* } */ } $regId = intval($data['regid']); $eventId = intval($data['id']); $formId = intval($data['form']); $eventDate = intval($data['date']); $userId = intval($data['userid']); $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent($eventId); $query = 'SELECT `id` FROM `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field` WHERE `type` = "seating" LIMIT 1'; $objResult = $objDatabase->Execute($query); $numSeating = intval($data['registrationField'][$objResult->fields['id']]); $type = intval($objEvent->freePlaces - $numSeating) < 0 ? 2 : (isset($data['registrationType']) ? intval($data['registrationType']) : 1); $this->saveIn = intval($type); $paymentMethod = intval($data['paymentMethod']); $paid = intval($data['paid']); $hostName = 0; $ipAddress = 0; $key = parent::generateKey(); if ($regId == 0) { $query = 'INSERT INTO ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration (`event_id`,`date`,`host_name`,`ip_address`,`type`,`key`,`user_id`,`lang_id`,`export`,`payment_method`,`paid`) VALUES ("' . $eventId . '","' . $eventDate . '","' . $hostName . '","' . $ipAddress . '","' . $type . '","' . $key . '","' . $userId . '","' . $_LANGID . '",0,"' . $paymentMethod . '","' . $paid . '")'; $objResult = $objDatabase->Execute($query); if ($objResult !== false) { $this->id = $objDatabase->Insert_ID(); } else { return false; } } else { $query = 'UPDATE `' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration` SET `event_id` = ' . $eventId . ', `date` = ' . $eventDate . ', `host_name` = ' . $hostName . ', `ip_address` = ' . $ipAddress . ', `key` = "' . $key . '", `user_id` = ' . $userId . ', `type` = ' . $type . ', `lang_id` = ' . $_LANGID . ', `payment_method` = ' . $paymentMethod . ', `paid` = ' . $paid . ' WHERE `id` = ' . $regId; $objResult = $objDatabase->Execute($query); if ($objResult === false) { return false; } } if ($regId != 0) { $this->id = $regId; $deleteQuery = 'DELETE FROM ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_value WHERE `reg_id` = ' . $this->id; $objDeleteResult = $objDatabase->Execute($deleteQuery); if ($objDeleteResult === false) { return false; } } foreach ($this->form->inputfields as $key => $arrInputfield) { $value = $data['registrationField'][$arrInputfield['id']]; $id = $arrInputfield['id']; if (is_array($value)) { $subvalue = array(); foreach ($value as $key => $element) { if (!empty($data['registrationFieldAdditional'][$id][$element - 1])) { $subvalue[] = $element . '[[' . $data['registrationFieldAdditional'][$id][$element - 1] . ']]'; } else { $subvalue[] = $element; } } $value = join(",", $subvalue); } else { if (isset($data['registrationFieldAdditional'][$id][$value - 1])) { $value = $value . "[[" . $data['registrationFieldAdditional'][$id][$value - 1] . "]]"; } } $query = 'INSERT INTO ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_value (`reg_id`, `field_id`, `value`) VALUES (' . $this->id . ', ' . $id . ', "' . contrexx_input2db($value) . '")'; $objResult = $objDatabase->Execute($query); if ($objResult === false) { return false; } } if ($objInit->mode == 'frontend') { $objMailManager = new \Cx\Modules\Calendar\Controller\CalendarMailManager(); $templateId = $objEvent->emailTemplate[FRONTEND_LANG_ID]; $objMailManager->sendMail(intval($_REQUEST['id']), \Cx\Modules\Calendar\Controller\CalendarMailManager::MAIL_CONFIRM_REG, $this->id, $templateId); $objMailManager->sendMail(intval($_REQUEST['id']), \Cx\Modules\Calendar\Controller\CalendarMailManager::MAIL_ALERT_REG, $this->id); } return true; }
/** * Return's the mailing template list drop down * * @param integer $selectedId Template list to be selected * @param action $actionId Action id * * @return string Html drop down with the mail templates */ function getTemplateDropdown($selectedId = null, $actionId = null, $languageId = null) { global $_ARRAYLANG; parent::getSettings(); parent::getFrontendLanguages(); if (empty($selectedId)) { if (empty($this->templateList[$actionId][$languageId])) { // if no templates are available in associated language (or template is deactivated), select default template foreach ($this->arrFrontendLanguages as $lang_id => $lang) { foreach ($this->templateList[$actionId][$lang_id] as $objMail) { if ($objMail->is_default) { $selectedId = $objMail->id; break; } } if (!empty($selectedId)) { break; } } } else { // if default template is set for associated language, select default template foreach ($this->templateList[$actionId][$languageId] as $objMail) { if ($objMail->is_default) { $selectedId = $objMail->id; break; } } // if templates are available in associated language, select first template of own language if (empty($selectedId)) { $mail = reset($this->templateList[$actionId][$languageId]); $selectedId = $mail->id; } } } $options = ''; foreach ($this->arrFrontendLanguages as $lang_id => $lang) { if (!empty($this->templateList[$actionId][$lang_id])) { $options .= '<optgroup label="' . $lang['name'] . '">'; foreach ($this->templateList[$actionId][$lang_id] as $objMail) { $options .= "<option value='{$objMail->id}'\r\n " . ($selectedId == $objMail->id ? "selected='selected'" : '') . "\r\n style='" . (!$objMail->status ? "color : #A0A0A0;" : '') . "'\r\n >\r\n {$objMail->title}\r\n " . ($objMail->is_default ? " (" . $_ARRAYLANG["TXT_{$this->moduleLangVar}_DEFAULT"] . ")" : '') . "\r\n " . (!$objMail->status ? " (" . $_ARRAYLANG["TXT_{$this->moduleLangVar}_INACTIVE"] . ")" : '') . "\r\n </option>"; } $options .= '</optgroup>'; } } return $options; }
/** * Initialize the mail functionality to the recipient * * @global object $objDatabase * @global array $_ARRAYLANG * @global integer $_LANGID * @global array $_CONFIG * @param integer $eventId * @param integer $actionId * @param integer $regId * @param string $mailTemplate */ function sendMail($eventId, $actionId, $regId = null, $mailTemplate = null) { global $objDatabase, $_ARRAYLANG, $_CONFIG; $this->mailList = array(); // Loads the mail template which needs for this action $this->loadMailList($actionId, $mailTemplate); if (!empty($this->mailList)) { $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent($eventId); $objRegistration = null; if (!empty($regId)) { $objRegistration = new \Cx\Modules\Calendar\Controller\CalendarRegistration($objEvent->registrationForm, $regId); list($registrationDataText, $registrationDataHtml) = $this->getRegistrationData($objRegistration); $query = 'SELECT `v`.`value`, `n`.`default`, `f`.`type` FROM ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_value AS `v` INNER JOIN ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field_name AS `n` ON `v`.`field_id` = `n`.`field_id` INNER JOIN ' . DBPREFIX . 'module_' . $this->moduleTablePrefix . '_registration_form_field AS `f` ON `v`.`field_id` = `f`.`id` WHERE `v`.`reg_id` = ' . $regId . ' AND ( `f`.`type` = "salutation" OR `f`.`type` = "firstname" OR `f`.`type` = "lastname" OR `f`.`type` = "mail" )'; $objResult = $objDatabase->Execute($query); $arrDefaults = array(); $arrValues = array(); if ($objResult !== false) { while (!$objResult->EOF) { if (!empty($objResult->fields['default'])) { $arrDefaults[$objResult->fields['type']] = explode(',', $objResult->fields['default']); } $arrValues[$objResult->fields['type']] = $objResult->fields['value']; $objResult->MoveNext(); } } $regSalutation = !empty($arrValues['salutation']) ? $arrDefaults['salutation'][$arrValues['salutation'] - 1] : ''; $regFirstname = !empty($arrValues['firstname']) ? $arrValues['firstname'] : ''; $regLastname = !empty($arrValues['lastname']) ? $arrValues['lastname'] : ''; $regMail = !empty($arrValues['mail']) ? $arrValues['mail'] : ''; $regType = $objRegistration->type == 1 ? $_ARRAYLANG['TXT_CALENDAR_REG_REGISTRATION'] : $_ARRAYLANG['TXT_CALENDAR_REG_SIGNOFF']; $regSearch = array('[[REGISTRATION_TYPE]]', '[[REGISTRATION_SALUTATION]]', '[[REGISTRATION_FIRSTNAME]]', '[[REGISTRATION_LASTNAME]]', '[[REGISTRATION_EMAIL]]'); $regReplace = array($regType, $regSalutation, $regFirstname, $regLastname, $regMail); } $domain = ASCMS_PROTOCOL . "://" . $_CONFIG['domainUrl'] . ASCMS_PATH_OFFSET . "/"; $date = date(parent::getDateFormat() . " - H:i:s"); $eventTitle = $objEvent->title; $eventStart = $objEvent->all_day ? date(parent::getDateFormat(), $objEvent->startDate) : date(parent::getDateFormat() . " (H:i:s)", $objEvent->startDate); $eventEnd = $objEvent->all_day ? date(parent::getDateFormat(), $objEvent->endDate) : date(parent::getDateFormat() . " (H:i:s)", $objEvent->endDate); $placeholder = array('[[TITLE]]', '[[START_DATE]]', '[[END_DATE]]', '[[LINK_EVENT]]', '[[LINK_REGISTRATION]]', '[[USERNAME]]', '[[FIRSTNAME]]', '[[LASTNAME]]', '[[URL]]', '[[DATE]]'); $recipients = $this->getSendMailRecipients($actionId, $objEvent, $regId, $objRegistration); $objMail = new \phpmailer(); if ($_CONFIG['coreSmtpServer'] > 0) { $arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer']); if ($arrSmtp !== false) { $objMail->IsSMTP(); $objMail->Host = $arrSmtp['hostname']; $objMail->Port = $arrSmtp['port']; $objMail->SMTPAuth = true; $objMail->Username = $arrSmtp['username']; $objMail->Password = $arrSmtp['password']; } } $objMail->CharSet = CONTREXX_CHARSET; $objMail->From = $_CONFIG['coreAdminEmail']; $objMail->FromName = $_CONFIG['coreGlobalPageTitle']; $objMail->AddReplyTo($_CONFIG['coreAdminEmail']); foreach ($recipients as $mailAdress => $langId) { if (!empty($mailAdress)) { $langId = $this->getSendMailLangId($actionId, $mailAdress, $langId); if ($objUser = \FWUser::getFWUserObject()->objUser->getUsers($filter = array('email' => $mailAdress, 'is_active' => true))) { $userNick = $objUser->getUsername(); $userFirstname = $objUser->getProfileAttribute('firstname'); $userLastname = $objUser->getProfileAttribute('lastname'); } else { $userNick = $mailAdress; if (!empty($regId) && $mailAdress == $regMail) { $userFirstname = $regFirstname; $userLastname = $regLastname; } else { $userFirstname = ''; $userLastname = ''; } } $mailTitle = $this->mailList[$langId]['mail']->title; $mailContentText = !empty($this->mailList[$langId]['mail']->content_text) ? $this->mailList[$langId]['mail']->content_text : strip_tags($this->mailList[$langId]['mail']->content_html); $mailContentHtml = !empty($this->mailList[$langId]['mail']->content_html) ? $this->mailList[$langId]['mail']->content_html : $this->mailList[$langId]['mail']->content_text; // actual language of selected e-mail template $contentLanguage = $this->mailList[$langId]['lang_id']; if ($actionId == self::MAIL_NOTFY_NEW_APP && $objEvent->arrSettings['confirmFrontendEvents'] == 1) { $eventLink = $domain . "/cadmin/index.php?cmd={$this->moduleName}&act=modify_event&id={$objEvent->id}&confirm=1"; } else { $eventLink = \Cx\Core\Routing\Url::fromModuleAndCmd($this->moduleName, 'detail', $contentLanguage, array('id' => $objEvent->id, 'date' => $objEvent->startDate))->toString(); } $regLink = \Cx\Core\Routing\Url::fromModuleAndCmd($this->moduleName, 'register', $contentLanguage, array('id' => $objEvent->id, 'date' => $objEvent->startDate))->toString(); $replaceContent = array($eventTitle, $eventStart, $eventEnd, $eventLink, $regLink, $userNick, $userFirstname, $userLastname, $domain, $date); $mailTitle = str_replace($placeholder, $replaceContent, $mailTitle); $mailContentText = str_replace($placeholder, $replaceContent, $mailContentText); $mailContentHtml = str_replace($placeholder, $replaceContent, $mailContentHtml); if (!empty($regId)) { $mailTitle = str_replace($regSearch, $regReplace, $mailTitle); $mailContentText = str_replace($regSearch, $regReplace, $mailContentText); $mailContentHtml = str_replace($regSearch, $regReplace, $mailContentHtml); $mailContentText = str_replace('[[REGISTRATION_DATA]]', $registrationDataText, $mailContentText); $mailContentHtml = str_replace('[[REGISTRATION_DATA]]', $registrationDataHtml, $mailContentHtml); } /*echo "send to: ".$mailAdress."<br />"; echo "send title: ".$mailTitle."<br />";*/ $objMail->Subject = $mailTitle; $objMail->Body = $mailContentHtml; $objMail->AltBody = $mailContentText; $objMail->AddAddress($mailAdress); $objMail->Send(); $objMail->ClearAddresses(); } } } }
/** * Add / Edit registration * * @param integer $eventId Event id * @param integer $regId Rgistration id */ function modifyRegistration($eventId, $regId) { global $objDatabase, $_ARRAYLANG; $this->_objTpl->loadTemplateFile('module_calendar_modify_registration.html'); if (isset($_POST['submitModifyRegistration'])) { $objRegistration = new \Cx\Modules\Calendar\Controller\CalendarRegistration(intval($_POST['form'])); if ($objRegistration->save($_POST)) { switch ($_POST['registrationType']) { case 0: $tpl = 'd'; break; case 1: default: $tpl = 'r'; break; case 2: $tpl = 'w'; break; } $tpl = !empty($_POST['regtpl']) ? $_POST['regtpl'] : $tpl; $this->okMessage = $_ARRAYLANG['TXT_CALENDAR_REGISTRATION_SUCCESSFULLY_SAVED']; \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?cmd=' . $this->moduleName . '&act=event_registrations&tpl=' . $tpl . '&id=' . $eventId); } else { $this->errMessage = $_ARRAYLANG['TXT_CALENDAR_REGISTRATION_CORRUPT_SAVED']; } } $objFWUser = \FWUser::getFWUserObject(); $objUser = $objFWUser->objUser; $userId = intval($objUser->getId()); $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent($eventId); if ($regId != 0) { $this->_pageTitle = $_ARRAYLANG['TXT_CALENDAR_EVENT_EDIT_REGISTRATION']; $objRegistration = new \Cx\Modules\Calendar\Controller\CalendarRegistration($objEvent->registrationForm, $regId); } else { $this->_pageTitle = $_ARRAYLANG['TXT_CALENDAR_EVENT_INSERT_REGISTRATION']; $objRegistration = new \Cx\Modules\Calendar\Controller\CalendarRegistration($objEvent->registrationForm); } $objRegistrationManager = new \Cx\Modules\Calendar\Controller\CalendarRegistrationManager($eventId, true, true, true); $objRegistrationManager->getRegistrationList(); $objRegistrationManager->showRegistrationInputfields($objEvent->registrationForm, $regId, $this->_objTpl); parent::getSettings(); if ($this->arrSettings['paymentStatus'] == '1' && ($this->arrSettings['paymentBillStatus'] == '1' || $this->arrSettings['paymentYellowpayStatus'] == '1')) { $selectedBill = $objRegistration->paymentMethod == 1 ? 'selected="selected"' : ''; $selectedYellowpay = $objRegistration->paymentMethod == 2 ? 'selected="selected"' : ''; $paymentMethods = '<select style="width: 204px;" class="calendarSelect" name="paymentMethod">'; $paymentMethods .= $this->arrSettings['paymentBillStatus'] == '1' ? '<option value="1" ' . $selectedBill . '>' . $_ARRAYLANG['TXT_CALENDAR_PAYMENT_BILL'] . '</option>' : ''; $paymentMethods .= $this->arrSettings['paymentYellowpayStatus'] == '1' ? '<option value="2" ' . $selectedYellowpay . '>' . $_ARRAYLANG['TXT_CALENDAR_PAYMENT_YELLOWPAY'] . '</option>' : ''; $paymentMethods .= '</select>'; $this->_objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_PAYMENT_METHOD' => $_ARRAYLANG['TXT_CALENDAR_PAYMENT_METHOD'], 'TXT_' . $this->moduleLangVar . '_PAID' => $_ARRAYLANG['TXT_PAYMENT_COMPLETED'], $this->moduleLangVar . '_PAYMENT_METHODS' => $paymentMethods, $this->moduleLangVar . '_PAID' => $objRegistration->paid == true ? " checked='checked'" : "")); $this->_objTpl->parse('calendarRegistrationPayment'); } else { $this->_objTpl->hideBlock('calendarRegistrationPayment'); } $this->_objTpl->setGlobalVariable(array('TXT_' . $this->moduleLangVar . '_REGISTRATION_TITLE' => $this->_pageTitle, 'TXT_' . $this->moduleLangVar . '_SAVE' => $_ARRAYLANG['TXT_CALENDAR_SAVE'], 'TXT_' . $this->moduleLangVar . '_BACK' => $_ARRAYLANG['TXT_CALENDAR_BACK'], $this->moduleLangVar . '_EVENT_ID' => $eventId, $this->moduleLangVar . '_REGISTRATION_TPL' => $_GET['tpl'], $this->moduleLangVar . '_REGISTRATION_ID' => $regId, $this->moduleLangVar . '_REGISTRATION_TYPE' => $objRegistration->type, $this->moduleLangVar . '_FORM_ID' => $objEvent->registrationForm, $this->moduleLangVar . '_EVENT_DATE' => $objEvent->startDate, $this->moduleLangVar . '_USER_ID' => $userId)); }
/** * Sets placeholders for the form view. * * @param object $objTpl Template object * @param integer $formId Form id * @param integer $intView request mode frontend or backend * @param integer $arrNumSeating number of seating * * @return null */ function showForm($objTpl, $formId, $intView, $ticketSales = false) { global $_ARRAYLANG, $_LANGID; $objForm = new \Cx\Modules\Calendar\Controller\CalendarForm(intval($formId)); if (!empty($formId)) { $this->formList[$formId] = $objForm; } switch ($intView) { case 1: parent::getFrontendLanguages(); $objTpl->setGlobalVariable(array($this->moduleLangVar . '_FORM_ID' => !empty($formId) ? $objForm->id : '', $this->moduleLangVar . '_FORM_TITLE' => !empty($formId) ? $objForm->title : '')); $i = 0; $formFields = array(); if (!empty($formId)) { foreach ($objForm->inputfields as $key => $arrInputfield) { $i++; $fieldValue = array(); $defaultFieldValue = array(); foreach ($this->arrFrontendLanguages as $key => $arrLang) { $fieldValue[$arrLang['id']] = $arrInputfield['name'][$arrLang['id']]; $defaultFieldValue[$arrLang['id']] = $arrInputfield['default_value'][$arrLang['id']]; } $formFields[] = array('type' => $arrInputfield['type'], 'id' => $arrInputfield['id'], 'row' => $i % 2 == 0 ? 'row2' : 'row1', 'order' => $arrInputfield['order'], 'name_master' => $arrInputfield['name'][0], 'default_value_master' => $arrInputfield['default_value'][0], 'required' => $arrInputfield['required'], 'affiliation' => $arrInputfield['affiliation'], 'field_value' => json_encode($fieldValue), 'default_field_value' => json_encode($defaultFieldValue)); } } foreach ($this->arrFrontendLanguages as $key => $arrLang) { $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_INPUTFIELD_LANG_SHORTCUT' => $arrLang['lang'])); $objTpl->parse('inputfieldNameList'); $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_LANG_ID' => $arrLang['id'], $this->moduleLangVar . '_INPUTFIELD_LANG_NAME' => $arrLang['name'], $this->moduleLangVar . '_INPUTFIELD_LANG_SHORTCUT' => $arrLang['lang'])); $objTpl->parse('inputfieldDefaultValueList'); $objTpl->setVariable(array($this->moduleLangVar . '_INPUTFIELD_LANG_NAME' => $arrLang['name'])); $objTpl->parse('inputfieldLanguagesList'); } foreach ($this->arrInputfieldTypes as $fieldType) { $objTpl->setVariable(array($this->moduleLangVar . '_FORM_FIELD_TYPE' => $fieldType, 'TXT_' . $this->moduleLangVar . '_FORM_FIELD_TYPE' => $_ARRAYLANG['TXT_CALENDAR_FORM_FIELD_' . strtoupper($fieldType)])); $objTpl->parse('inputfieldTypes'); } foreach ($this->arrRegistrationFields as $fieldType) { $objTpl->setVariable(array($this->moduleLangVar . '_FORM_FIELD_TYPE' => $fieldType, 'TXT_' . $this->moduleLangVar . '_FORM_FIELD_TYPE' => $_ARRAYLANG['TXT_CALENDAR_FORM_FIELD_' . strtoupper($fieldType)])); $objTpl->parse('inputRegfieldTypes'); } /* foreach ($this->arrInputfieldAffiliations as $strAffiliation) { $objTpl->setVariable(array( $this->moduleLangVar.'_FORM_FIELD_TYPE' => $strAffiliation, 'TXT_'.$this->moduleLangVar.'_FORM_FIELD_TYPE' => $_ARRAYLANG['TXT_CALENDAR_FORM_FIELD_AFFILIATION_'.strtoupper($strAffiliation)], )); $objTpl->parse('fieldAfflications'); }*/ $objTpl->setVariable(array($this->moduleLangVar . '_FORM_DATA' => json_encode($formFields), $this->moduleLangVar . '_FRONTEND_LANG_COUNT' => count($this->arrFrontendLanguages), $this->moduleLangVar . '_INPUTFIELD_LAST_ID' => $objForm->getLastInputfieldId(), $this->moduleLangVar . '_INPUTFIELD_LAST_ROW' => $i % 2 == 0 ? "'row2'" : "'row1'", $this->moduleLangVar . '_DISPLAY_EXPAND' => count($this->arrFrontendLanguages) > 1 ? "block" : "none")); break; case 2: $objFieldTemplate = new \Cx\Core\Html\Sigma('.'); $objFieldTemplate->setTemplate(self::frontendFieldTemplate, true, true); $objFieldTemplate->setVariable(array('TXT_' . $this->moduleLangVar . '_FIELD_NAME' => $_ARRAYLANG['TXT_CALENDAR_TYPE'] . '<font class="calendarRequired"> *</font>', $this->moduleLangVar . '_FIELD_INPUT' => '<select class="calendarSelect affiliateForm" name="registrationType"><option value="1" selected="selected"/>' . $_ARRAYLANG['TXT_CALENDAR_REG_REGISTRATION'] . '</option><option value="0"/>' . $_ARRAYLANG['TXT_CALENDAR_REG_SIGNOFF'] . '</option></select>', $this->moduleLangVar . '_FIELD_CLASS' => 'affiliationForm')); $objTpl->setVariable($this->moduleLangVar . '_REGISTRATION_FIELD', $objFieldTemplate->get()); $objTpl->parse('calendarRegistrationField'); // $selectBillingAddressStatus = false; foreach ($objForm->inputfields as $key => $arrInputfield) { $objFieldTemplate->setTemplate(self::frontendFieldTemplate, true, true); $options = array(); $options = explode(',', $arrInputfield['default_value'][$_LANGID]); $inputfield = null; $hide = false; $optionSelect = true; if (isset($_POST['registrationField'][$arrInputfield['id']])) { $value = $_POST['registrationField'][$arrInputfield['id']]; } elseif (\FWUser::getFWUserObject()->objUser->login() && in_array($arrInputfield['type'], array('mail', 'firstname', 'lastname'))) { $value = ''; switch ($arrInputfield['type']) { case 'mail': $value = \FWUser::getFWUserObject()->objUser->getEmail(); break; case 'firstname': $value = \FWUser::getFWUserObject()->objUser->getProfileAttribute('firstname'); break; case 'lastname': $value = \FWUser::getFWUserObject()->objUser->getProfileAttribute('lastname'); break; default: $value = $arrInputfield['default_value'][$_LANGID]; break; } } else { $value = $arrInputfield['default_value'][$_LANGID]; } $affiliationClass = 'affiliation' . ucfirst($arrInputfield['affiliation']); switch ($arrInputfield['type']) { case 'inputtext': case 'mail': case 'firstname': case 'lastname': $inputfield = '<input type="text" class="calendarInputText" name="registrationField[' . $arrInputfield['id'] . ']" value="' . $value . '" /> '; break; case 'textarea': $inputfield = '<textarea class="calendarTextarea" name="registrationField[' . $arrInputfield['id'] . ']">' . $value . '</textarea>'; break; case 'seating': if (!$ticketSales) { $hide = true; } $optionSelect = false; case 'select': case 'salutation': $inputfield = '<select class="calendarSelect" name="registrationField[' . $arrInputfield['id'] . ']">'; $selected = empty($_POST) ? 'selected="selected"' : ''; $inputfield .= $optionSelect ? '<option value="" ' . $selected . '>' . $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHOOSE'] . '</option>' : ''; foreach ($options as $key => $name) { $selected = $key + 1 == $value ? 'selected="selected"' : ''; $inputfield .= '<option value="' . intval($key + 1) . '" ' . $selected . '>' . $name . '</option>'; } $inputfield .= '</select>'; break; case 'radio': foreach ($options as $key => $name) { $checked = $key + 1 == $value || empty($_POST) && $key == 0 ? 'checked="checked"' : ''; $textValue = isset($_POST["registrationFieldAdditional"][$arrInputfield['id']][$key]) ? $_POST["registrationFieldAdditional"][$arrInputfield['id']][$key] : ''; $textfield = '<input type="text" class="calendarInputCheckboxAdditional" name="registrationFieldAdditional[' . $arrInputfield['id'] . '][' . $key . ']" value="' . contrexx_input2xhtml($textValue) . '" />'; $name = str_replace('[[INPUT]]', $textfield, $name); $inputfield .= '<input type="radio" class="calendarInputCheckbox" name="registrationField[' . $arrInputfield['id'] . ']" value="' . intval($key + 1) . '" ' . $checked . '/> ' . $name . '<br />'; } break; case 'checkbox': foreach ($options as $key => $name) { $textValue = isset($_POST["registrationFieldAdditional"][$arrInputfield['id']][$key]) ? $_POST["registrationFieldAdditional"][$arrInputfield['id']][$key] : ''; $textfield = '<input type="text" class="calendarInputCheckboxAdditional" name="registrationFieldAdditional[' . $arrInputfield['id'] . '][' . $key . ']" value="' . contrexx_input2xhtml($textValue) . '" />'; $name = str_replace('[[INPUT]]', $textfield, $name); $checked = in_array($key + 1, $_POST['registrationField'][$arrInputfield['id']]) ? 'checked="checked"' : ''; $inputfield .= '<input ' . $checked . ' type="checkbox" class="calendarInputCheckbox" name="registrationField[' . $arrInputfield['id'] . '][]" value="' . intval($key + 1) . '" /> ' . $name . '<br />'; } break; case 'agb': $inputfield = '<input class="calendarInputCheckbox" type="checkbox" name="registrationField[' . $arrInputfield['id'] . '][]" value="1" /> ' . $_ARRAYLANG['TXT_CALENDAR_AGB'] . '<br />'; break; /* case 'selectBillingAddress': if(!$selectBillingAddressStatus) { if($_REQUEST['registrationField'][$arrInputfield['id']] == 'deviatesFromContact') { $selectDeviatesFromContact = 'selected="selected"'; } else { $selectDeviatesFromContact = ''; } $inputfield = '<select id="calendarSelectBillingAddress" class="calendarSelect" name="registrationField['.$arrInputfield['id'].']">'; $inputfield .= '<option value="sameAsContact">'.$_ARRAYLANG['TXT_CALENDAR_SAME_AS_CONTACT'].'</option>'; $inputfield .= '<option value="deviatesFromContact" '.$selectDeviatesFromContact.'>'.$_ARRAYLANG['TXT_CALENDAR_DEVIATES_FROM_CONTACT'].'</option>'; $inputfield .= '</select>'; $selectBillingAddressStatus = true; } break; */ /* case 'selectBillingAddress': if(!$selectBillingAddressStatus) { if($_REQUEST['registrationField'][$arrInputfield['id']] == 'deviatesFromContact') { $selectDeviatesFromContact = 'selected="selected"'; } else { $selectDeviatesFromContact = ''; } $inputfield = '<select id="calendarSelectBillingAddress" class="calendarSelect" name="registrationField['.$arrInputfield['id'].']">'; $inputfield .= '<option value="sameAsContact">'.$_ARRAYLANG['TXT_CALENDAR_SAME_AS_CONTACT'].'</option>'; $inputfield .= '<option value="deviatesFromContact" '.$selectDeviatesFromContact.'>'.$_ARRAYLANG['TXT_CALENDAR_DEVIATES_FROM_CONTACT'].'</option>'; $inputfield .= '</select>'; $selectBillingAddressStatus = true; } break; */ case 'fieldset': $inputfield = null; break; } $field = ''; if ($arrInputfield['type'] == 'fieldset') { $field = '</fieldset><fieldset><legend>' . $arrInputfield['name'][$_LANGID] . '</legend>'; $hide = true; } else { $required = $arrInputfield['required'] == 1 ? '<font class="calendarRequired"> *</font>' : ''; $label = $arrInputfield['name'][$_LANGID] . $required; } if (!$hide) { $objFieldTemplate->setVariable(array('TXT_' . $this->moduleLangVar . '_FIELD_NAME' => $label, $this->moduleLangVar . '_FIELD_INPUT' => $inputfield, $this->moduleLangVar . '_FIELD_CLASS' => $affiliationClass)); $field = $objFieldTemplate->get(); } $objTpl->setVariable($this->moduleLangVar . '_REGISTRATION_FIELD', $field); $objTpl->parse('calendarRegistrationField'); } break; } }
/** * Count the number of entries in the category * * @return integer Entry count of the category */ function countEntries($getAll = false, $onlyActive = false) { global $objDatabase; // get startdate if (!empty($_GET['from'])) { $startDate = parent::getDateTimestamp($_GET['from']); } else { if ($_GET['cmd'] == 'archive') { $startDate = null; } else { $startDay = isset($_GET['day']) ? $_GET['day'] : date("d", mktime()); $startMonth = isset($_GET['month']) ? $_GET['month'] : date("m", mktime()); $startYear = isset($_GET['year']) ? $_GET['year'] : date("Y", mktime()); $startDay = $_GET['cmd'] == 'boxes' ? 1 : $startDay; $startDate = mktime(0, 0, 0, $startMonth, $startDay, $startYear); } } // get enddate if (!empty($_GET['till'])) { $endDate = parent::getDateTimestamp($_GET['till']); } else { if ($_GET['cmd'] == 'archive') { $endDate = mktime(); } else { $endDay = isset($_GET['endDay']) ? $_GET['endDay'] : date("d", mktime()); $endMonth = isset($_GET['endMonth']) ? $_GET['endMonth'] : date("m", mktime()); $endYear = isset($_GET['endYear']) ? $_GET['endYear'] : date("Y", mktime()); $endYear = empty($_GET['endYear']) && empty($_GET['endMonth']) ? $endYear + 10 : $endYear; $endDate = mktime(23, 59, 59, $endMonth, $endDay, $endYear); } } $searchTerm = !empty($_GET['term']) ? contrexx_addslashes($_GET['term']) : null; // set the start date as null if $getAll is true if ($getAll) { $startDate = null; } $objEventManager = new \Cx\Modules\Calendar\Controller\CalendarEventManager($startDate, $endDate, $this->id, $searchTerm, true, false, $onlyActive); $objEventManager->getEventList(); $count = count($objEventManager->eventList); return $count; }
/** * Return's the category dropdown * * @global array $_ARRAYLANG * @param integer $selectedId * @param integer $type * @return string Return's the html dropdown of the categories. */ function getCategoryDropdown($selectedId = null, $type) { global $_ARRAYLANG; parent::getSettings(); $arrOptions = array(); foreach ($this->categoryList as $key => $objCategory) { if ($this->arrSettings['countCategoryEntries'] == 1) { $count = ' (' . $objCategory->countEntries(false, true) . ')'; } else { $count = ''; } $arrOptions[$objCategory->id] = $objCategory->name . $count; } switch (intval($type)) { case 1: $options = "<option value=''>" . $_ARRAYLANG['TXT_CALENDAR_ALL_CAT'] . "</option>"; break; case 2: $options = "<option value=''>" . $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHOOSE'] . "</option>"; break; default: $options = "<option value=''></option>"; break; } $options .= parent::buildDropdownmenu($arrOptions, $selectedId); return $options; }
/** * Return's the settings Elements by its section id * * @param object $objTpl Template object * @param integer $section section id * * @return null */ function _getSettingElements($objTpl, $section) { global $_ARRAYLANG, $objDatabase; parent::getSettings(); $query = "SELECT id,title\r\n FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_settings_section\r\n WHERE parent='" . intval($section) . "'\r\n ORDER BY `order` ASC"; $objResult = $objDatabase->Execute($query); if ($objResult !== false) { while (!$objResult->EOF) { $objTpl->setVariable(array('TXT_CALENDAR_SECTION_NAME' => $_ARRAYLANG[$objResult->fields['title']])); $query = "SELECT id,name,title,value,info,type,options,special\r\n FROM " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_settings\r\n WHERE section_id='" . intval($objResult->fields['id']) . "'\r\n ORDER BY `order` ASC"; $objResultSetting = $objDatabase->Execute($query); if ($objResultSetting !== false) { $i = 0; while (!$objResultSetting->EOF) { $arrSetting = array(); $arrSetting = $this->_getSettingProperties($objResultSetting->fields['id'], $objResultSetting->fields['name'], $objResultSetting->fields['title'], $objResultSetting->fields['value'], $objResultSetting->fields['info'], $objResultSetting->fields['type'], $objResultSetting->fields['options'], $objResultSetting->fields['special']); $objTpl->setVariable(array($this->moduleLangVar . '_SETTING_ROW' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_SETTING_NAME' => $objResultSetting->fields['name'], 'TXT_' . $this->moduleLangVar . '_SETTING_NAME' => $_ARRAYLANG[$objResultSetting->fields['title']], $this->moduleLangVar . '_SETTING_VALUE' => $arrSetting['output'], $this->moduleLangVar . '_SETTING_INFO' => $arrSetting['infobox'])); $infoboxJS .= $arrSetting['infoboxJS']; $i++; $objTpl->parse('settingsList'); $objResultSetting->MoveNext(); } } $objTpl->parse('sectionList'); $objResult->MoveNext(); } $objTpl->setVariable(array($this->moduleLangVar . '_SETTING_INFO_JS' => $infoboxJS)); } }