Ejemplo n.º 1
0
				<tbody valign="top">
				<?php 
    foreach ($this->items as $i => $item) {
        $ordering = $listOrder == 'a.ordering';
        $canCreate = $user->authorise('core.create', 'com_icagenda');
        $canEdit = $user->authorise('core.edit', 'com_icagenda');
        $canCheckin = $user->authorise('core.manage', 'com_icagenda') || $item->checked_out == $userId || $item->checked_out == 0;
        $canChange = $user->authorise('core.edit.state', 'com_icagenda') && $canCheckin;
        $canEditOwn = $user->authorise('core.edit.own', 'com_icagenda') && $item->userid == $userId;
        // Get avatar of the registered user
        $avatar = md5(strtolower(trim($item->email)));
        // Get Username and name
        $data_name = $item->userid ? $item->fullname : $item->name;
        $data_username = $item->userid ? $item->username : false;
        // Load Custom fields DATA
        $customfields = icagendaCustomfields::getListNotEmpty($item->id, 1);
        ?>
					<tr class="row<?php 
        echo $i % 2;
        ?>
">

						<?php 
        // START J3 CODE
        ?>
						<?php 
        if (version_compare(JVERSION, '3.0', 'ge')) {
            ?>

						<?php 
            // *** Ordering (Joomla 3.x) ***
Ejemplo n.º 2
0
    public function registration($array)
    {
        $menu_items = icagendaMenus::iClistMenuItems();
        $itemid = JRequest::getVar('Itemid');
        $linkexist = '';
        foreach ($menu_items as $l) {
            if ($l->published == '1' && $l->id == $itemid) {
                $linkexist = '1';
            }
        }
        if (is_numeric($itemid) && $itemid != 0 && $linkexist == 1) {
            // Import params - Limit Options for User Registration
            $app = JFactory::getApplication();
            $date = JFactory::getDate();
            $params = $app->getParams();
            $isSef = $app->getCfg('sef');
            $eventTimeZone = null;
            $data = new stdClass();
            // Set the values
            $data->id = null;
            $data->eventid = '0';
            $data->userid = isset($array['uid']) ? $array['uid'] : '';
            if (isset($array['name'])) {
                $data->name = $array['name'];
            }
            $data->email = isset($array['email']) ? $array['email'] : '';
            $data->phone = isset($array['phone']) ? $array['phone'] : '';
            if (isset($array['date'])) {
                $data->date = $array['date'];
            }
            if (isset($array['period'])) {
                $data->period = $array['period'];
            }
            if (isset($array['people'])) {
                $data->people = $array['people'];
            }
            $data->notes = isset($array['notes']) ? htmlentities(strip_tags($array['notes'])) : '';
            if (isset($array['event'])) {
                $data->eventid = $array['event'];
            }
            if (isset($array['menuID'])) {
                $data->itemid = $array['menuID'];
            }
            $data->created = $date->toSql();
            $data->created_by = $data->userid;
            $current_url = isset($array['current_url']) ? $array['current_url'] : 'index.php';
            $max_nb_of_tickets = isset($array['max_nb_of_tickets']) ? $array['max_nb_of_tickets'] : '1000000';
            $tos = isset($array['tos']) ? 'checked' : '';
            $custom_fields = isset($array['custom_fields']) ? $array['custom_fields'] : false;
            //			$tickets_left		= isset($array['tickets_left']) ? $array['tickets_left'] : '1000000';
            $email2 = isset($array['email2']) ? $array['email2'] : false;
            // Filter Name
            $array['name'] = str_replace("'", '’', $array['name']);
            $array['name'] = (string) preg_replace('/[\\x00-\\x1F\\x7F]/', '', $array['name']);
            // Set Form Data to Session
            $session = JFactory::getSession();
            $session->set('ic_registration', $array);
            $session->set('ic_submit_tos', $tos);
            $custom_fields_array = isset($array['custom_fields']) ? (array) $array['custom_fields'] : array();
            $session->set('custom_fields', $custom_fields_array);
            $session->set('email2', $email2);
            // Control if still ticket left
            $db = JFactory::getDbo();
            $query = $db->getQuery(true);
            // Registrations total
            $query->select('sum(r.people) AS registered');
            $query->from('`#__icagenda_registration` AS r');
            $query->where('r.state > 0');
            $query->where('r.date = ' . $db->q($data->date));
            $query->where('r.eventid = ' . (int) $data->eventid);
            $db->setQuery($query);
            $registered = $db->loadObject()->registered;
            $data->checked_out_time = date('Y-m-d H:i:s');
            // Set Date in url
            $datesDisplay = $params->get('datesDisplay', 1);
            $date_alias = $data->date ? iCDate::dateToAlias(date('Y-m-d H:i', strtotime($data->date))) : false;
            $date_var = $isSef == 1 ? '?date=' : '&amp;date=';
            $this_date = $date_alias ? $date_var . $date_alias : '';
            $dateInUrl = $datesDisplay === 1 ? $this_date : '';
            // Get the "event" URL
            $baseURL = JURI::base();
            $subpathURL = JURI::base(true);
            $baseURL = str_replace('/administrator', '', $baseURL);
            $subpathURL = str_replace('/administrator', '', $subpathURL);
            // Sub Path filtering
            $subpathURL = ltrim($subpathURL, '/');
            // URL Event Details filtering
            $urlEvent = str_replace('&amp;', '&', JRoute::_('index.php?option=com_icagenda&view=list&layout=event&Itemid=' . (int) $data->itemid . '&id=' . (int) $data->eventid)) . $dateInUrl;
            $urlEvent = ltrim($urlEvent, '/');
            if (substr($urlEvent, 0, strlen($subpathURL) + 1) == "{$subpathURL}/") {
                $urlEvent = substr($urlEvent, strlen($subpathURL) + 1);
            }
            $urlEvent = rtrim($baseURL, '/') . '/' . ltrim($urlEvent, '/');
            // URL List filtering
            $urlList = str_replace('&amp;', '&', JRoute::_('index.php?option=com_icagenda&view=list&Itemid=' . (int) $data->itemid));
            $urlList = ltrim($urlList, '/');
            if (substr($urlList, 0, strlen($subpathURL) + 1) == "{$subpathURL}/") {
                $urlList = substr($urlList, strlen($subpathURL) + 1);
            }
            $urlList = rtrim($baseURL, '/') . '/' . ltrim($urlList, '/');
            // URL Registration filtering // NOT USED
            $urlRegistration = str_replace('&amp;', '&', JRoute::_('index.php?option=com_icagenda&view=list&layout=registration&Itemid=' . (int) $data->itemid . '&id=' . (int) $data->eventid));
            $urlRegistration = ltrim($urlRegistration, '/');
            if (substr($urlRegistration, 0, strlen($subpathURL) + 1) == "{$subpathURL}/") {
                $urlRegistration = substr($urlRegistration, strlen($subpathURL) + 1);
            }
            $urlRegistration = rtrim($baseURL, '/') . '/' . ltrim($urlRegistration, '/');
            // URL Payment filtering
            $urlPayment = str_replace('&amp;', '&', JRoute::_('index.php?option=com_icagenda&view=list&layout=actions&Itemid=' . (int) $data->itemid . '&id=' . (int) $data->eventid));
            $urlPayment = ltrim($urlPayment, '/');
            if (substr($urlPayment, 0, strlen($subpathURL) + 1) == "{$subpathURL}/") {
                $urlPayment = substr($urlPayment, strlen($subpathURL) + 1);
            }
            $urlPayment = rtrim($baseURL, '/') . '/' . ltrim($urlPayment, '/');
            $urlPayment = $urlPayment . '?status=payment';
            // Check number of tickets left
            $tickets_left = $max_nb_of_tickets - $registered;
            // IF NO TICKETS LEFT
            if ($tickets_left <= 0) {
                $app->enqueueMessage(JText::_('COM_ICAGENDA_ALERT_NO_TICKETS_AVAILABLE'), 'warning');
                $app->redirect(htmlspecialchars_decode($urlEvent));
            } elseif ($tickets_left < $data->people) {
                $msg = JText::_('COM_ICAGENDA_ALERT_NOT_ENOUGH_TICKETS_AVAILABLE') . '<br />';
                $msg .= JText::sprintf('COM_ICAGENDA_ALERT_NOT_ENOUGH_TICKETS_AVAILABLE_NOW', $tickets_left) . '<br />';
                $msg .= JText::_('COM_ICAGENDA_ALERT_NOT_ENOUGH_TICKETS_AVAILABLE_CHANGE_NUMBER');
                $app->enqueueMessage($msg, 'error');
                $app->redirect(htmlspecialchars_decode($current_url));
            }
            // CONTROL NAME VALUE
            $name_isValid = '1';
            //			$pattern = "#[/\\\\/\<>/\"%;=\[\]\+()&]|^[0-9]#i";
            $pattern = "#[/\\\\/\\<>/\";=\\[\\]\\+()%&]#i";
            if ($array['name']) {
                $nbMatches = preg_match($pattern, $array['name']);
                // Name contains invalid characters
                if ($nbMatches && $nbMatches == 1) {
                    $name_isValid = '0';
                    $app->enqueueMessage(JText::sprintf('COM_ICAGENDA_REGISTRATION_NAME_NOT_VALID', '<b>' . htmlentities($array['name'], ENT_COMPAT, 'UTF-8') . '</b>'), 'error');
                }
                // Name is less than 2 characters
                if (strlen(utf8_decode($array['name'])) < 2) {
                    $name_isValid = '0';
                    $app->enqueueMessage(JText::_('COM_ICAGENDA_REGISTRATION_NAME_MINIMUM_CHARACTERS'), 'error');
                }
            } else {
                $app->enqueueMessage(JText::_('COM_ICAGENDA_FORM_VALIDATE_FIELD_REQUIRED') . ' ' . JText::_('ICAGENDA_REGISTRATION_FORM_NAME'), 'error');
            }
            $data->name = filter_var($data->name, FILTER_SANITIZE_STRING);
            // CONTROL EMAIL VALUE
            $emailRequired = $params->get('emailRequired', 1);
            $emailConfirm = $params->get('emailConfirm', 1);
            // Check if Email not empty
            if ($emailRequired && !$data->email) {
                $app->enqueueMessage(JText::_('COM_ICAGENDA_FORM_VALIDATE_FIELD_REQUIRED') . ' ' . JText::_('ICAGENDA_REGISTRATION_FORM_EMAIL'), 'error');
            }
            // Check if Confirm Email equals Email
            if ($emailConfirm && empty($data->userid) && $data->email != $email2) {
                $app->enqueueMessage(JText::_('COM_ICAGENDA_FORM_VALIDATE_FIELD_INVALID') . ' ' . JText::_('IC_FORM_EMAIL_CONFIRM_LBL') . '<br />' . JText::_('COM_ICAGENDA_FORM_VALIDATE_FIELD_EMAIL2_MESSAGE'), 'error');
            }
            // Advanced Checkdnsrr email
            $emailCheckdnsrr = JComponentHelper::getParams('com_icagenda')->get('emailCheckdnsrr', '0');
            if (!empty($data->email)) {
                $validEmail = true;
                $checkdnsrr = true;
                if ($emailCheckdnsrr == 1 and function_exists('checkdnsrr')) {
                    $provider = explode('@', $data->email);
                    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
                        if (version_compare(phpversion(), '5.3.0', '<')) {
                            $checkdnsrr = true;
                        }
                    } else {
                        $checkdnsrr = checkdnsrr($provider[1]);
                    }
                } else {
                    $checkdnsrr = true;
                }
            } else {
                $checkdnsrr = true;
            }
            // Check if valid email address
            $validEmail = $validEmail ? $this->validEmail($data->email) : false;
            if (!$checkdnsrr || !$validEmail && $data->email) {
                // message if email is invalid
                $app->enqueueMessage(JText::_('COM_ICAGENDA_REGISTRATION_EMAIL_NOT_VALID'), 'error');
            }
            $eventid = $data->eventid;
            $period = isset($data->period) ? $data->period : '0';
            $people = $data->people;
            $name = $data->name;
            $email = $data->email;
            $phone = $data->phone;
            $notes = html_entity_decode($data->notes);
            $dateReg = $data->date;
            $limitRegEmail = $params->get('limitRegEmail', 1);
            $limitRegDate = $params->get('limitRegDate', 1);
            $alreadyexist = 'no';
            if ($limitRegEmail == 1 || $limitRegDate == 1) {
                $cf = JRequest::getString('email', '', 'post');
                if ($limitRegDate == 0) {
                    $query = "\n\t\t\t\t\t\tSELECT COUNT(*)\n\t\t\t\t\t\tFROM `#__icagenda_registration`\n\t\t\t\t\t\tWHERE `email` = '{$cf}' AND `eventid`='{$eventid}' AND `state`='1'\n\t\t\t\t\t";
                } elseif ($limitRegDate == 1) {
                    $query = "\n\t\t\t\t\t\tSELECT COUNT(*)\n\t\t\t\t\t\tFROM `#__icagenda_registration`\n\t\t\t\t\t\tWHERE `email` = '{$cf}' AND `eventid`='{$eventid}' AND `date`='{$dateReg}' AND `state`='1'\n\t\t\t\t\t";
                }
                $db->setQuery($query);
                if ($email != NULL) {
                    if ($db->loadResult()) {
                        $alreadyexist = 'yes';
                        $app->enqueueMessage(JText::_('COM_ICAGENDA_REGISTRATION_EMAIL_ALERT') . ' ' . $email, 'error');
                    } else {
                        $alreadyexist = 'no';
                    }
                }
            }
            $email = $email ? $email : JText::_('COM_ICAGENDA_NOT_SPECIFIED');
            // Check if Phone not empty
            $phoneRequired = $params->get('phoneRequired', 1);
            if ($phoneRequired && !$phone) {
                $app->enqueueMessage(JText::_('COM_ICAGENDA_FORM_VALIDATE_FIELD_REQUIRED') . ' ' . JText::_('ICAGENDA_REGISTRATION_FORM_PHONE'), 'error');
            }
            $phone = $phone ? $phone : JText::_('COM_ICAGENDA_NOT_SPECIFIED');
            // Check if Custom Fields required not empty
            $customfields_list = icagendaCustomfields::getListCustomFields($data->id, 1, 1);
            if ($customfields_list) {
                foreach ($customfields_list as $cf) {
                    if ($cf->cf_required == 1) {
                        if ($custom_fields[$cf->cf_slug] == '') {
                            $app->enqueueMessage(JText::_('COM_ICAGENDA_FORM_VALIDATE_FIELD_REQUIRED') . ' ' . $cf->cf_title, 'error');
                        }
                    }
                }
            }
            // Check if ToS not checked
            if (!$tos) {
                $app->enqueueMessage(JText::_('COM_ICAGENDA_TERMS_AND_CONDITIONS_NOT_CHECKED_REGISTRATION'), 'error');
            }
            // RECAPTCHA
            $captcha_plugin = $params->get('captcha') ? $params->get('captcha') : $app->getCfg('captcha');
            $reg_captcha = JComponentHelper::getParams('com_icagenda')->get('reg_captcha', 1);
            if ($captcha_plugin && $reg_captcha != '0') {
                JPluginHelper::importPlugin('captcha');
                // JOOMLA 3.x/2.5 SWITCH
                if (version_compare(JVERSION, '3.0', 'ge')) {
                    $dispatcher = JEventDispatcher::getInstance();
                } else {
                    $dispatcher = JDispatcher::getInstance();
                }
                $res = $dispatcher->trigger('onCheckAnswer', $array['recaptcha_response_field']);
                if (!$res[0]) {
                    // message if captcha is invalid
                    $app->enqueueMessage(JText::_('PLG_RECAPTCHA_ERROR_INCORRECT_CAPTCHA_SOL'), 'error');
                }
            }
            // Get the message queue
            $error_messages = $app->getMessageQueue();
            if (count($error_messages)) {
                $app->redirect(htmlspecialchars_decode($current_url));
                return false;
            }
            // clear the data so we don't process it again
            $session->clear('ic_registration');
            $session->clear('custom_fields');
            $session->clear('ic_submit_tos');
            $session->clear('email2');
            /**
             *	SAVE REGISTRATION DATA TO DATABASE
             */
            // Option Email required
            if ($emailRequired == '1') {
                if (is_numeric($eventid) && is_numeric($period) && is_numeric($people) && $name != NULL && $email != NULL) {
                    $db->insertObject('#__icagenda_registration', $data, id);
                }
            } else {
                if (is_numeric($eventid) && is_numeric($period) && is_numeric($people) && $name != NULL) {
                    $db->insertObject('#__icagenda_registration', $data, id);
                }
            }
            /**
             *	SAVE CUSTOM FIELDS TO DATABASE
             */
            if ($custom_fields && is_array($custom_fields)) {
                icagendaCustomfields::saveToData($custom_fields, $data->id, 1);
            }
            /**
             *	NOTIFICATION EMAILS
             */
            $author = '0';
            // Preparing the query
            $query = $db->getQuery(true);
            $query->select('e.title AS title, e.startdate AS startdate, e.enddate AS enddate,
					e.created_by AS authorID, e.email AS contactemail, e.displaytime AS displaytime')->from('#__icagenda_events AS e')->where("(e.id={$data->eventid})");
            $db->setQuery($query);
            $title = $db->loadObject()->title;
            $startdate = $db->loadObject()->startdate;
            $enddate = $db->loadObject()->enddate;
            $authorID = $db->loadObject()->authorID;
            $contactemail = $db->loadObject()->contactemail;
            $displayTime = $db->loadObject()->displaytime;
            $startD = $this->formatDate($startdate);
            $endD = $this->formatDate($enddate);
            $startT = JHtml::date($startdate, 'H:i', $eventTimeZone);
            $endT = JHtml::date($enddate, 'H:i', $eventTimeZone);
            $regDate = $this->formatDate($data->date);
            $regTime = JHtml::date($data->date, 'H:i', $eventTimeZone);
            $regDateTime = !empty($displayTime) ? $regDate . ' - ' . $regTime : $regDate;
            $regStartDateTime = !empty($displayTime) ? $startD . ' - ' . $startT : $startD;
            $regEndDateTime = !empty($displayTime) ? $endD . ' - ' . $endT : $endD;
            $periodreg = $data->period;
            $defaultemail = $params->get('regEmailUser', '1');
            $emailUserSubjectPeriod = $params->get('emailUserSubjectPeriod', '');
            $emailUserBodyPeriod = $params->get('emailUserBodyPeriod', '');
            $emailUserSubjectDate = $params->get('emailUserSubjectDate', '');
            $emailUserBodyDate = $params->get('emailUserBodyDate', '');
            $emailAdminSend = $params->get('emailAdminSend', '1');
            $emailAdminSend_select = $params->get('emailAdminSend_select', array('0'));
            $emailAdminSend_custom = $params->get('emailAdminSend_Placeholder', '');
            $emailUserSend = $params->get('emailUserSend', '1');
            $eUSP = isset($emailUserSubjectPeriod) ? $emailUserSubjectPeriod : JText::_('COM_ICAGENDA_REGISTRATION_EMAIL_USER_PERIOD_DEFAULT_SUBJECT');
            $eUBP = isset($emailUserBodyPeriod) ? $emailUserBodyPeriod : JText::_('COM_ICAGENDA_REGISTRATION_EMAIL_USER_PERIOD_DEFAULT_BODY');
            $eUSD = isset($emailUserSubjectDate) ? $emailUserSubjectDate : JText::_('COM_ICAGENDA_REGISTRATION_EMAIL_USER_DATE_DEFAULT_SUBJECT');
            $eUBD = isset($emailUserBodyDate) ? $emailUserBodyDate : JText::_('COM_ICAGENDA_REGISTRATION_EMAIL_USER_DATE_DEFAULT_BODY');
            $period_set = substr($startdate, 0, 4);
            if ($periodreg == 1 || $array['date'] == '' && !$periodreg) {
                $periodd = $period_set != '0000' ? JText::sprintf('COM_ICAGENDA_REGISTERED_EVENT_PERIOD', $startD, $startT, $endD, $endT) : '';
                $adminsubject = JText::_('COM_ICAGENDA_REGISTRATION_EMAIL_ADMIN_DEFAULT_SUBJECT');
                $adminbody = JText::_('COM_ICAGENDA_REGISTRATION_EMAIL_ADMIN_PERIOD_DEFAULT_BODY');
                if ($defaultemail == 0) {
                    $subject = $eUSP;
                    $body = $eUBP;
                } else {
                    $subject = JText::_('COM_ICAGENDA_REGISTRATION_EMAIL_USER_PERIOD_DEFAULT_SUBJECT');
                    $body = JText::_('COM_ICAGENDA_REGISTRATION_EMAIL_USER_PERIOD_DEFAULT_BODY');
                }
            } else {
                //				$periodd		= ($period_set != '0000')
                //								? JText::sprintf( 'COM_ICAGENDA_REGISTERED_EVENT_DATE', $regDate, '' )
                //								: '';
                $periodd = JText::sprintf('COM_ICAGENDA_REGISTERED_EVENT_DATE', $regDate, '');
                $adminsubject = JText::_('COM_ICAGENDA_REGISTRATION_EMAIL_ADMIN_DEFAULT_SUBJECT');
                $adminbody = JText::_('COM_ICAGENDA_REGISTRATION_EMAIL_ADMIN_DATE_DEFAULT_BODY');
                if ($defaultemail == 0) {
                    $subject = $eUSD;
                    $body = $eUBD;
                } else {
                    $subject = JText::_('COM_ICAGENDA_REGISTRATION_EMAIL_USER_DATE_DEFAULT_SUBJECT');
                    $body = JText::_('COM_ICAGENDA_REGISTRATION_EMAIL_USER_DATE_DEFAULT_BODY');
                }
            }
            // Get the site name
            $sitename = $app->getCfg('sitename');
            $siteURL = JURI::base();
            $siteURL = rtrim($siteURL, '/');
            // Get Author Email
            $authormail = '';
            if ($authorID != NULL) {
                // Preparing the query
                $query = $db->getQuery(true);
                $query->select('email AS authormail, name AS authorname')->from('#__users AS u')->where("(u.id={$authorID})");
                $db->setQuery($query);
                $authormail = $db->loadObject()->authormail;
                $authorname = $db->loadObject()->authorname;
                if ($authormail == NULL) {
                    $authormail = $app->getCfg('mailfrom');
                }
            }
            // Generates filled custom fields into email body
            $customfields = icagendaCustomfields::getListNotEmpty($data->id);
            $custom_fields = '';
            $newline = $defaultemail == '0' ? "<br />" : "\n";
            if ($customfields) {
                foreach ($customfields as $customfield) {
                    $cf_value = isset($customfield->cf_value) ? $customfield->cf_value : JText::_('IC_NOT_SPECIFIED');
                    $custom_fields .= $customfield->cf_title . ": " . $cf_value . $newline;
                }
            }
            // MAIL REPLACEMENTS
            $replacements = array("\\n" => "\n", '[SITENAME]' => $sitename, '[SITEURL]' => $siteURL, '[AUTHOR]' => $authorname, '[AUTHOREMAIL]' => $authormail, '[CONTACTEMAIL]' => $contactemail, '[TITLE]' => $title, '[EVENTURL]' => $urlEvent, '[NAME]' => $name, '[EMAIL]' => $email, '[PHONE]' => $phone, '[PLACES]' => $people, '[CUSTOMFIELDS]' => $custom_fields, '[NOTES]' => $notes, '[DATE]' => $regDate, '[TIME]' => $regTime, '[DATETIME]' => $regDateTime, '[STARTDATE]' => $startD, '[ENDDATE]' => $endD, '[STARTDATETIME]' => $regStartDateTime, '[ENDDATETIME]' => $regEndDateTime, '&nbsp;' => ' ');
            foreach ($replacements as $key => $value) {
                $subject = str_replace($key, $value, $subject);
                $body = str_replace($key, $value, $body);
                $adminsubject = str_replace($key, $value, $adminsubject);
                $adminbody = str_replace($key, $value, $adminbody);
            }
            // Set Sender of USER and ADMIN emails
            $mailer = JFactory::getMailer();
            $adminmailer = JFactory::getMailer();
            $mailfrom = $app->getCfg('mailfrom');
            $fromname = $app->getCfg('fromname');
            $mailer->setSender(array($mailfrom, $fromname));
            $adminmailer->setSender(array($mailfrom, $fromname));
            // Set Recipient of USER email
            $user = JFactory::getUser();
            if (!isset($data->email)) {
                $recipient = $user->email;
            } else {
                $recipient = $data->email;
            }
            $mailer->addRecipient($recipient);
            // Set Recipient of ADMIN email
            $admin_array = array();
            if (in_array('0', $emailAdminSend_select)) {
                array_push($admin_array, $mailfrom);
            }
            if (in_array('1', $emailAdminSend_select)) {
                array_push($admin_array, $authormail);
            }
            if (in_array('2', $emailAdminSend_select)) {
                $customs_emails = explode(',', $emailAdminSend_custom);
                $customs_emails = str_replace(' ', '', $customs_emails);
                foreach ($customs_emails as $cust_mail) {
                    array_push($admin_array, $cust_mail);
                }
            }
            if (in_array('3', $emailAdminSend_select)) {
                array_push($admin_array, $contactemail);
            }
            $adminrecipient = $admin_array;
            $adminmailer->addRecipient($adminrecipient);
            // Set Subject of USER and ADMIN email
            $mailer->setSubject($subject);
            $adminmailer->setSubject($adminsubject);
            // Set Body of USER and ADMIN email
            if ($defaultemail == 0) {
                // HTML custom notification email send to user
                $mailer->isHTML(true);
                $mailer->Encoding = 'base64';
            }
            $adminbody = str_replace("<br />", "\n", $adminbody);
            $mailer->setBody($body);
            $adminmailer->setBody($adminbody);
            // Optional file attached
            //			$mailer->addAttachment(JPATH_COMPONENT.DS.'assets'.DS.'document.pdf');
            // Send USER email confirmation, if enabled
            if ($emailUserSend == 1 && isset($data->email)) {
                $send = $mailer->Send();
            }
            // Send ADMIN email notification, if enabled
            if ($emailAdminSend == 1) {
                if ($emailAdminSend == 1 && isset($data->eventid) && $data->eventid != '0' && $data->name != NULL) {
                    $sendadmin = $adminmailer->Send();
                }
            }
            $evtParams = $this->evtParams($i);
            $reg_payment = $evtParams->get('icpayment', '');
            $iCpaymentPlugin = JPluginHelper::getPlugin('content', 'ic_payment');
            if ($iCpaymentPlugin) {
                $plgParams = new JRegistry($iCpaymentPlugin->params);
                $reg_payment = $reg_payment ? $reg_payment : $plgParams->get('icpayment', '');
            }
            if ($alreadyexist == 'no') {
                $thank_you = JText::_('COM_ICAGENDA_REGISTRATION_TY') . ' ' . $data->name;
                $thank_you .= ', ' . JText::sprintf('COM_ICAGENDA_REGISTRATION', $title);
                $thank_you .= '<br />' . $periodd . ' (<a href="' . $urlEvent . '">' . JText::_('COM_ICAGENDA_REGISTRATION_EVENT_LINK') . '</a>)';
                // redirect after successful registration
                $app->enqueueMessage($thank_you, 'message');
                if ($reg_payment) {
                    $app->redirect(htmlspecialchars_decode($urlPayment));
                } else {
                    $app->redirect(htmlspecialchars_decode($urlList));
                }
            }
        } else {
            JError::raiseError('404', JTEXT::_('JERROR_LAYOUT_PAGE_NOT_FOUND'));
            return false;
        }
    }