Esempio n. 1
0
 /**
  * Method to store the venue
  *
  * @access	public
  * @return	id
  * @since	0.9
  */
 function store($data, $file)
 {
     $mainframe =& JFactory::getApplication();
     $user =& JFactory::getUser();
     $elsettings =& redEVENTHelper::config();
     //Get mailinformation
     $SiteName = $mainframe->getCfg('sitename');
     $MailFrom = $mainframe->getCfg('mailfrom');
     $FromName = $mainframe->getCfg('fromname');
     $tzoffset = $mainframe->getCfg('offset');
     $params = $mainframe->getParams('com_redevent');
     $row =& JTable::getInstance('redevent_venues', '');
     //bind it to the table
     if (!$row->bind($data)) {
         RedeventError::raiseError(500, $this->_db->stderr());
         return false;
     }
     //Are we saving from an item edit?
     if ($row->id) {
         $row->modified = gmdate('Y-m-d H:i:s');
         $row->modified_by = $user->get('id');
     } else {
         //get IP, time and userid
         $row->created = gmdate('Y-m-d H:i:s');
         $row->author_ip = $elsettings->get('storeip', '1') ? getenv('REMOTE_ADDR') : 'DISABLED';
         $row->created_by = $user->get('id');
     }
     //Image upload
     //If image upload is required we will stop here if no file was attached
     if (empty($file['name']) && $params->get('edit_image', 1) == 2) {
         $this->setError(JText::_('COM_REDEVENT_IMAGE_EMPTY'));
         return false;
     }
     if (($params->get('edit_image', 1) == 2 || $params->get('edit_image', 1) == 1) && !empty($file['name'])) {
         jimport('joomla.filesystem.file');
         if ($params->get('default_image_path', 'redevent')) {
             $reldirpath = $params->get('default_image_path', 'redevent') . DS . 'venues' . DS;
         } else {
             $reldirpath = '';
         }
         $base_Dir = JPATH_SITE . DS . 'images' . DS . $reldirpath;
         //check the image
         $check = redEVENTImage::check($file, $elsettings);
         if ($check === false) {
             $mainframe->redirect($_SERVER['HTTP_REFERER']);
         }
         //sanitize the image filename
         $filename = redEVENTImage::sanitize($base_Dir, $file['name']);
         $filepath = $base_Dir . $filename;
         if (!JFile::upload($file['tmp_name'], $filepath)) {
             $this->setError(JText::_('COM_REDEVENT_UPLOAD_FAILED'));
             return false;
         } else {
             $row->locimage = 'images' . DS . $reldirpath . $filename;
         }
     } else {
         //keep image if edited and left blank
         $row->locimage = $row->curimage;
     }
     //end image upload if
     //Check description
     $editoruser = ELUser::editoruser();
     if (!$editoruser) {
         //check description --> wipe out code
         $row->locdescription = strip_tags($row->locdescription, '<br><br/>');
         //convert the linux \n (Mac \r, Win \r\n) to <br /> linebreaks
         $row->locdescription = str_replace(array("\r\n", "\r", "\n"), "<br />", $row->locdescription);
         //cut too long words
         $row->locdescription = wordwrap($row->locdescription, 75, " ", 1);
         //check length
         $length = JString::strlen($row->locdescription);
         if ($length > $params->get('max_description', 1000)) {
             // if required shorten it
             $row->locdescription = JString::substr($row->locdescription, 0, $params->get('max_description', 1000));
             //if shortened add ...
             $row->locdescription = $row->locdescription . '...';
         }
     }
     $row->venue = trim(JFilterOutput::ampReplace($row->venue));
     //Make sure the data is valid
     if (!$row->check($elsettings)) {
         $this->setError($row->getError());
         return false;
     }
     //is this an edited venue or not?
     //after store we allways have an id
     $edited = $row->id ? $row->id : false;
     //store it in the db
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // update the event category xref
     // first, delete current rows for this event
     $query = ' DELETE FROM #__redevent_venue_category_xref WHERE venue_id = ' . $this->_db->Quote($row->id);
     $this->_db->setQuery($query);
     if (!$this->_db->query()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // insert new ref
     foreach ((array) $data['categories'] as $cat_id) {
         $query = ' INSERT INTO #__redevent_venue_category_xref (venue_id, category_id) VALUES (' . $this->_db->Quote($row->id) . ', ' . $this->_db->Quote($cat_id) . ')';
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
     }
     // attachments
     if ($params->get('allow_attachments', 1)) {
         REAttach::store('venue' . $row->id);
     }
     jimport('joomla.utilities.mail');
     $link = JRoute::_(JURI::base() . RedeventHelperRoute::getVenueEventsRoute($row->id), false);
     //create mail
     if ($params->get('mailinform') == 2 || $params->get('mailinform') == 3) {
         $mail = JFactory::getMailer();
         $state = $row->published ? JText::sprintf('COM_REDEVENT_MAIL_VENUE_PUBLISHED', $link) : JText::_('COM_REDEVENT_MAIL_VENUE_UNPUBLISHED');
         if ($edited) {
             $modified_ip = getenv('REMOTE_ADDR');
             $edited = JHTML::Date($row->modified, JText::_('DATE_FORMAT_LC2'));
             $mailbody = JText::sprintf('COM_REDEVENT_MAIL_EDIT_VENUE', $user->name, $user->username, $user->email, $modified_ip, $edited, $row->venue, $row->url, $row->street, $row->plz, $row->city, $row->country, $row->locdescription, $state);
             $mail->setSubject($SiteName . JText::_('COM_REDEVENT_EDIT_VENUE_MAIL'));
         } else {
             $created = JHTML::Date($row->modified, JText::_('DATE_FORMAT_LC2'));
             $mailbody = JText::sprintf('COM_REDEVENT_MAIL_NEW_VENUE', $user->name, $user->username, $user->email, $row->author_ip, $created, $row->venue, $row->url, $row->street, $row->plz, $row->city, $row->country, $row->locdescription, $state);
             $mail->setSubject($SiteName . JText::_('COM_REDEVENT_NEW_VENUE_MAIL'));
         }
         $receivers = explode(',', trim($params->get('mailinformrec')));
         $mail->addRecipient($receivers);
         $mail->setSender(array($MailFrom, $FromName));
         $mail->setBody($mailbody);
         if (!$mail->Send()) {
             RedeventHelperLog::simpleLog('Error sending created/edited venue notification to site owner');
         }
     }
     //create the mail for the user
     if ($params->get('mailinformuser') == 2 || $params->get('mailinformuser') == 3) {
         $usermail = JFactory::getMailer();
         $state = $row->published ? JText::sprintf('COM_REDEVENT_USER_MAIL_VENUE_PUBLISHED', $link) : JText::_('COM_REDEVENT_USER_MAIL_VENUE_UNPUBLISHED');
         if ($edited) {
             $edited = JHTML::Date($row->modified, JText::_('DATE_FORMAT_LC2'));
             $mailbody = JText::sprintf('COM_REDEVENT_USER_MAIL_EDIT_VENUE', $user->name, $user->username, $edited, $row->venue, $row->url, $row->street, $row->plz, $row->city, $row->country, $row->locdescription, $state);
             $usermail->setSubject($SiteName . JText::_('COM_REDEVENT_EDIT_USER_VENUE_MAIL'));
         } else {
             $created = JHTML::Date($row->modified, JText::_('DATE_FORMAT_LC2'));
             $mailbody = JText::sprintf('COM_REDEVENT_USER_MAIL_NEW_VENUE', $user->name, $user->username, $created, $row->venue, $row->url, $row->street, $row->plz, $row->city, $row->country, $row->locdescription, $state);
             $usermail->setSubject($SiteName . JText::_('COM_REDEVENT_NEW_USER_VENUE_MAIL'));
         }
         $usermail->addRecipient($user->email);
         $usermail->setSender(array($MailFrom, $FromName));
         $usermail->setBody($mailbody);
         if (!$usermail->Send()) {
             RedeventHelperLog::simpleLog('Error sending created/edited venue notification to venue owner');
         }
     }
     //update item order
     $row->reorder();
     return $row->id;
 }
Esempio n. 2
0
 public static function raiseWarning($code, $msg, $info = null)
 {
     RedeventHelperLog::simplelog("Notice {$code}: {$msg}");
     return parent::raiseWarning($code, $msg, $info = null);
 }
Esempio n. 3
0
 /**
  * Clears log file
  *
  */
 function clearlog()
 {
     RedeventHelperLog::clear();
     $msg = JText::_('COM_REDEVENT_LOG_CLEARED');
     $this->setRedirect('index.php?option=com_redevent&view=log', $msg);
     $this->redirect();
 }
Esempio n. 4
0
 /**
  * adds xref repeats to the database.
  * 
  * @return bool true on success
  */
 function generaterecurrences($recurrence_id = null)
 {
     $db =& JFactory::getDBO();
     $nulldate = '0000-00-00';
     // generate until limit
     $params =& JComponentHelper::getParams('com_redevent');
     $limit = $params->get('recurrence_limit', 30);
     $limit_date_int = time() + $limit * 3600 * 24;
     // get active recurrences
     $query = ' SELECT MAX(rp.xref_id) as xref_id, r.rrule, r.id as recurrence_id ' . ' FROM #__redevent_repeats AS rp ' . ' INNER JOIN #__redevent_recurrences AS r on r.id = rp.recurrence_id ' . ' INNER JOIN #__redevent_event_venue_xref AS x on x.id = rp.xref_id ' . ' WHERE r.ended = 0 ' . '   AND x.dates > 0 ';
     if ($recurrence_id) {
         $query .= ' AND r.id = ' . $db->Quote($recurrence_id);
     }
     $query .= ' GROUP BY rp.recurrence_id ';
     $db->setQuery($query);
     $recurrences = $db->loadObjectList();
     if (empty($recurrences)) {
         return true;
     }
     // get corresponding xrefs
     $rids = array();
     foreach ($recurrences as $r) {
         $rids[] = $r->xref_id;
     }
     $query = ' SELECT x.*, rp.count ' . ' FROM #__redevent_event_venue_xref AS x ' . ' INNER JOIN #__redevent_repeats AS rp ON rp.xref_id = x.id ' . ' WHERE x.id IN (' . implode(",", $rids) . ')';
     $db->setQuery($query);
     $xrefs = $db->loadObjectList('id');
     // now, do the job...
     foreach ($recurrences as $r) {
         $next = RedeventHelperRecurrence::getnext($r->rrule, $xrefs[$r->xref_id]);
         while ($next) {
             if (strtotime($next->dates) > $limit_date_int) {
                 break;
             }
             //record xref
             $object =& JTable::getInstance('RedEvent_eventvenuexref', '');
             $object->bind($next);
             if ($object->store()) {
                 // copy the roles
                 $query = ' INSERT INTO #__redevent_sessions_roles (xref, role_id, user_id) ' . ' SELECT ' . $object->id . ', role_id, user_id ' . ' FROM #__redevent_sessions_roles ' . ' WHERE xref = ' . $db->Quote($r->xref_id);
                 $db->setQuery($query);
                 if (!$db->query()) {
                     RedeventHelperLog::simpleLog('recurrence copying roles error: ' . $db->getErrorMsg());
                 }
                 // copy the prices
                 $query = ' INSERT INTO #__redevent_sessions_pricegroups (xref, pricegroup_id, price) ' . ' SELECT ' . $object->id . ', pricegroup_id, price ' . ' FROM #__redevent_sessions_pricegroups ' . ' WHERE xref = ' . $db->Quote($r->xref_id);
                 $db->setQuery($query);
                 if (!$db->query()) {
                     RedeventHelperLog::simpleLog('recurrence copying prices error: ' . $db->getErrorMsg());
                 }
                 // update repeats table
                 $query = ' INSERT INTO #__redevent_repeats ' . ' SET xref_id = ' . $db->Quote($object->id) . '   , recurrence_id = ' . $db->Quote($r->recurrence_id) . '   , count = ' . $db->Quote($next->count);
                 $db->setQuery($query);
                 if (!$db->query()) {
                     RedeventHelperLog::simpleLog('saving repeat error: ' . $db->getErrorMsg());
                 }
                 //           echo "added xref $object->id / count $next->count";
                 //           echo '<br>';
             } else {
                 RedeventHelperLog::simpleLog('saving recurrence xref error: ' . $db->getErrorMsg());
             }
             $next = RedeventHelperRecurrence::getnext($r->rrule, $next);
         }
         if (!$next) {
             // no more events to generate, we can disable the rule
             $query = ' UPDATE #__redevent_recurrences SET ended = 1 WHERE id = ' . $db->Quote($r->recurrence_id);
             $db->setQuery($query);
             $db->query();
         }
     }
     return true;
 }
Esempio n. 5
0
    function notifyManagers($unreg = false)
    {
        jimport('joomla.mail.helper');
        $app =& JFactory::getApplication();
        $params = $app->getParams('com_redevent');
        $tags = new redEVENT_tags();
        $tags->setXref($this->getXref());
        $tags->setSubmitkey($this->load()->submit_key);
        $tags->addOptions(array('sids' => array($this->load()->sid)));
        $event = $this->getSessionDetails();
        $recipients = $this->getAdminEmails();
        if (!count($recipients)) {
            return true;
        }
        $mailer =& JFactory::getMailer();
        if ($this->getEmail() && $params->get('allow_email_aliasing', 1)) {
            $sender = array($this->getEmail(), $this->getFullname());
        } else {
            // default to site settings
            $sender = array($app->getCfg('mailfrom'), $app->getCfg('sitename'));
        }
        $mailer->setSender($sender);
        $mailer->addReplyTo($sender);
        foreach ($recipients as $r) {
            $mailer->addAddress($r['email'], $r['name']);
        }
        $mail = '<HTML><HEAD>
			<STYLE TYPE="text/css">
			<!--
			  table.formanswers , table.formanswers td, table.formanswers th
				{
				    border-color: darkgrey;
				    border-style: solid;
				    text-align:left;
				}			
				table.formanswers
				{
				    border-width: 0 0 1px 1px;
				    border-spacing: 0;
				    border-collapse: collapse;
				    padding: 5px;
				}			
				table.formanswers td, table.formanswers th
				{
				    margin: 0;
				    padding: 4px;
				    border-width: 1px 1px 0 0;
				}		  
			-->
			</STYLE>
			</head>
			<BODY bgcolor="#FFFFFF">
			' . $tags->ReplaceTags($unreg ? $params->get('unregistration_notification_body') : $params->get('registration_notification_body')) . '
			</body>
			</html>';
        // convert urls
        $mail = REOutput::ImgRelAbs($mail);
        if (!$unreg && $params->get('registration_notification_attach_rfuploads', 1)) {
            // files submitted through redform
            $files = $this->getRFFiles();
            $filessize = 0;
            foreach ($files as $f) {
                $filessize += filesize($f);
            }
            if ($filessize < $params->get('registration_notification_attach_rfuploads_maxsize', 1500) * 1000) {
                foreach ($files as $f) {
                    $mailer->addAttachment($f);
                }
            }
        }
        $mailer->setSubject($tags->ReplaceTags($unreg ? $params->get('unregistration_notification_subject') : $params->get('registration_notification_subject')));
        $mailer->MsgHTML($mail);
        if (!$mailer->send()) {
            RedeventHelperLog::simplelog(JText::_('COM_REDEVENT_ERROR_REGISTRATION_MANAGERS_NOTIFICATION_FAILED'));
            $this->setError(JText::_('COM_REDEVENT_ERROR_REGISTRATION_MANAGERS_NOTIFICATION_FAILED'));
            return false;
        }
        return true;
    }
Esempio n. 6
0
 /**
  * Saves xref data
  * @param array
  * @return boolean true on success
  */
 function storeXref($data)
 {
     $user =& JFactory::getUser();
     $settings =& redEVENTHelper::config();
     // TODO : check user group access ?
     $row =& JTable::getInstance('RedEvent_eventvenuexref', '');
     if ($data['id']) {
         if (!$this->canManageXref($data['id'])) {
             $this->setError('YOU ARE NOT ALLOWED TO EDIT THIS DATE');
             return false;
         }
         $row->load($data['id']);
     } else {
         if (!$this->getCanAddXref()) {
             $this->setError('YOU ARE NOT ALLOWED TO ADD EVENT DATE');
             return false;
         }
     }
     if (!$row->bind($data)) {
         $this->setError('SUBMIT XREF ERROR BINDING DATA');
         RedeventHelperLog::simplelog('SUBMIT XREF ERROR BINDING DATA');
         return false;
     }
     if (!$row->check()) {
         $this->setError('SUBMIT XREF ERROR CHECK DATA');
         RedeventHelperLog::simplelog('SUBMIT XREF ERROR CHECK DATA');
         return false;
     }
     if (!$row->store(true)) {
         $this->setError('SUBMIT XREF ERROR STORE DATA');
         RedeventHelperLog::simplelog('SUBMIT XREF ERROR STORE DATA');
         return false;
     }
     /** roles **/
     // first remove current rows
     $query = ' DELETE FROM #__redevent_sessions_roles ' . ' WHERE xref = ' . $this->_db->Quote($row->id);
     $this->_db->setQuery($query);
     if (!$this->_db->query()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // then recreate them if any
     foreach ((array) $data['rrole'] as $k => $r) {
         if (!($data['rrole'][$k] && $data['urole'][$k])) {
             continue;
         }
         $new =& JTable::getInstance('RedEvent_sessions_roles', '');
         $new->set('xref', $row->id);
         $new->set('role_id', $r);
         $new->set('user_id', $data['urole'][$k]);
         if (!($new->check() && $new->store())) {
             $this->setError($new->getError());
             return false;
         }
     }
     /** roles END **/
     /** prices **/
     // first remove current rows
     $query = ' DELETE FROM #__redevent_sessions_pricegroups ' . ' WHERE xref = ' . $this->_db->Quote($row->id);
     $this->_db->setQuery($query);
     if (!$this->_db->query()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // then recreate them if any
     foreach ((array) $data['pricegroup'] as $k => $r) {
         if (!$data['pricegroup'][$k]) {
             continue;
         }
         $new =& JTable::getInstance('RedEvent_sessions_pricegroups', '');
         $new->set('xref', $row->id);
         $new->set('pricegroup_id', $r);
         $new->set('price', $data['price'][$k]);
         if (!($new->check() && $new->store())) {
             $this->setError($new->getError());
             return false;
         }
     }
     /** prices END **/
     // we need to save the recurrence too
     $recurrence =& JTable::getInstance('RedEvent_recurrences', '');
     if (!isset($data['recurrenceid']) || !$data['recurrenceid']) {
         $rrule = RedeventHelperRecurrence::parsePost($data);
         if (!empty($rrule)) {
             // new recurrence
             $recurrence->rrule = $rrule;
             if (!$recurrence->store()) {
                 $this->setError($recurrence->getError());
                 return false;
             }
             // add repeat record
             $repeat =& JTable::getInstance('RedEvent_repeats', '');
             $repeat->set('xref_id', $row->id);
             $repeat->set('recurrence_id', $recurrence->id);
             $repeat->set('count', 0);
             if (!$repeat->store()) {
                 $this->setError($repeat->getError());
                 return false;
             }
         }
     } else {
         if ($data['repeat'] == 0) {
             $recurrence->load($data['recurrenceid']);
             // reset the status
             $recurrence->ended = 0;
             // TODO: maybe add a check to have a choice between updating rrule or not...
             $rrule = RedeventHelperRecurrence::parsePost($data);
             $recurrence->rrule = $rrule;
             if (!$recurrence->store()) {
                 $this->setError($recurrence->getError());
                 return false;
             }
         }
     }
     if ($recurrence->id) {
         redEVENTHelper::generaterecurrences($recurrence->id);
     }
     return true;
 }
Esempio n. 7
0
 function notifyManagers()
 {
     jimport('joomla.mail.helper');
     $app =& JFactory::getApplication();
     $params = $app->getParams('com_redevent');
     $event = $this->getDetails();
     $tags = new redEVENT_tags();
     $tags->setXref($this->_xref);
     $tags->setSubmitkey(JRequest::getVar('submit_key'));
     $recipients = array();
     // default recipients
     $default = $params->get('registration_default_recipients');
     if (!empty($default)) {
         if (strstr($default, ';')) {
             $addresses = explode(";", $default);
         } else {
             $addresses = explode(",", $default);
         }
         foreach ($addresses as $a) {
             $a = trim($a);
             if (JMailHelper::isEmailAddress($a)) {
                 $recipients[] = array('email' => $a, 'name' => '');
             }
         }
     }
     // creator
     if ($params->get('registration_notify_creator', 1)) {
         if (JMailHelper::isEmailAddress($event->creator_email)) {
             $recipients[] = array('email' => $event->creator_email, 'name' => $event->creator_name);
         }
     }
     // group recipients
     $gprecipients = $this->_getXrefRegistrationRecipients();
     foreach ($gprecipients as $r) {
         $recipients[] = array('email' => $r->email, 'name' => $r->name);
     }
     if (!count($recipients)) {
         return true;
     }
     $mailer =& JFactory::getMailer();
     foreach ($recipients as $r) {
         $mailer->addAddress($r['email'], $r['name']);
     }
     $mailer->setSubject($tags->ReplaceTags($params->get('registration_notification_subject')));
     // convert urls
     $htmlmsg = '<html><body>' . $tags->ReplaceTags($params->get('registration_notification_body')) . '</body></html>';
     $htmlmsg = REOutput::ImgRelAbs($htmlmsg);
     $mailer->MsgHTML($htmlmsg);
     if (!$mailer->send()) {
         RedeventHelperLog::simplelog(JText::_('COM_REDEVENT_ERROR_REGISTRATION_MANAGERS_NOTIFICATION_FAILED'));
         $this->setError(JText::_('COM_REDEVENT_ERROR_REGISTRATION_MANAGERS_NOTIFICATION_FAILED'));
         return false;
     }
     return true;
 }
Esempio n. 8
0
 /**
  * return full url to thumbnail
  *
  * @param string image path, relative to joomla images folder
  * @return url or false if it doesn't exists
  */
 public static function getThumbUrl($path, $maxdim = null)
 {
     jimport('joomla.filesystem.file');
     $app =& JFactory::getApplication();
     $settings = redEVENTHelper::config();
     if ($maxdim) {
         $width = $maxdim;
         $height = $maxdim;
     } else {
         $width = $settings->get('imagewidth', 100);
         $height = $settings->get('imageheight', 100);
     }
     $base = JURI::root();
     $thumb_name = md5(basename($path)) . $width . '_' . $height . '.png';
     if (dirname($path) != '.') {
         $thumb_path = JPATH_SITE . DS . dirname($path) . DS . 're_thumb' . DS . $thumb_name;
         $thumb_uri = $base . str_replace("\"", "/", dirname($path)) . '/re_thumb/' . $thumb_name;
     } else {
         JError::raisewarning(0, JText::sprintf('COM_REDEVENT_THUMBNAILS_WRONG_BASE_PATH', dirname($thumb_path)));
     }
     if (JFile::exists($thumb_path)) {
         return $thumb_uri;
     } else {
         if (JFile::exists(JPATH_SITE . DS . $path)) {
             //try to generate the thumb
             if (!JFolder::exists(dirname($thumb_path)) && !JFolder::create(dirname($thumb_path))) {
                 RedeventHelperLog::simpleLog(sprintf('Can\'t create path for thumbnail: %s', dirname($thumb_path)));
                 return false;
             }
             if (redEVENTImage::thumb(JPATH_SITE . DS . $path, $thumb_path, $width, $height)) {
                 return $thumb_uri;
             }
         }
     }
     return false;
 }
Esempio n. 9
0
 /**
  * Confirms the users request
  */
 function activate()
 {
     $mainframe =& JFactory::getApplication();
     $msgtype = 'message';
     /* Get the confirm ID */
     $confirmid = JRequest::getVar('confirmid', '', 'get');
     /* Get the details out of the confirmid */
     list($uip, $xref, $uid, $register_id, $submit_key) = explode("x", $confirmid);
     /* Confirm sign up via mail */
     $model = $this->getModel('Registration', 'RedEventModel');
     $model->setXref($xref);
     $eventdata = $model->getSessionDetails();
     /* This loads the tags replacer */
     JRequest::setVar('xref', $xref);
     require_once JPATH_COMPONENT_SITE . DS . 'helpers' . DS . 'tags.php';
     $tags = new redEVENT_tags();
     $tags->setXref($xref);
     $tags->setSubmitkey($submit_key);
     /* Check the db if this entry exists */
     $db = JFactory::getDBO();
     $q = ' SELECT r.confirmed ' . ' FROM #__redevent_register r ' . ' WHERE r.uid = ' . $db->Quote($uid) . ' AND r.submit_key = ' . $db->Quote($submit_key) . ' AND r.xref = ' . $db->Quote($xref) . ' AND r.id = ' . $db->Quote($register_id);
     $db->setQuery($q);
     $regdata = $db->loadObject();
     if ($regdata && $regdata->confirmed == 0) {
         $model->confirm($register_id);
         // send activation confirmation email if activated
         if ($eventdata->enable_activation_confirmation) {
             $this->_Mailer();
             $rfcore = new RedFormCore();
             $addresses = $rfcore->getSubmissionContactEmail($submit_key);
             /* Check if there are any addresses to be mailed */
             if (count($addresses) > 0) {
                 /* Start mailing */
                 foreach ($addresses as $key => $sid) {
                     foreach ($sid as $email) {
                         /* Send a off mailinglist mail to the submitter if set */
                         /* Add the email address */
                         $this->mailer->AddAddress($email['email']);
                         /* Mail submitter */
                         $htmlmsg = '<html><head><title></title></title></head><body>' . $tags->ReplaceTags($eventdata->notify_confirm_body) . '</body></html>';
                         // convert urls
                         $htmlmsg = REOutput::ImgRelAbs($htmlmsg);
                         $this->mailer->setBody($htmlmsg);
                         $this->mailer->setSubject($tags->ReplaceTags($eventdata->notify_confirm_subject));
                         /* Send the mail */
                         if (!$this->mailer->Send()) {
                             $mainframe->enqueueMessage(JText::_('COM_REDEVENT_THERE_WAS_A_PROBLEM_SENDING_MAIL'));
                             RedeventHelperLog::simpleLog('Error sending confirm email' . ': ' . $this->mailer->error);
                         }
                         /* Clear the mail details */
                         $this->mailer->ClearAddresses();
                     }
                 }
             }
         }
         $msg = JText::_('COM_REDEVENT_REGISTRATION_ACTIVATION_SUCCESSFULL');
     } else {
         if ($regdata && $regdata->confirmed == 1) {
             $msg = JText::_('COM_REDEVENT_YOUR_SUBMISSION_HAS_ALREADY_BEEN_CONFIRMED');
             $msgtype = 'error';
         } else {
             $msg = JText::_('COM_REDEVENT_YOUR_SUBMISSION_CANNOT_BE_CONFIRMED');
             $msgtype = 'error';
         }
     }
     $this->setRedirect(JRoute::_(RedeventHelperRoute::getDetailsRoute($eventdata->did, $xref)), $msg, $msgtype);
 }