示例#1
0
 /**
  * Method to load required data
  *
  * @access	private
  * @return	array
  * @since	0.9
  */
 protected function _loadDetails()
 {
     if (empty($this->_event)) {
         $user =& JFactory::getUser();
         // Get the WHERE clause
         $where = $this->_buildDetailsWhere();
         $query = 'SELECT x.*, a.*, a.id AS did, x.id AS xref, a.title, a.datdescription, ' . ' a.meta_keywords, a.meta_description, a.datimage, a.registra, a.unregistra, a.summary, ' . ' x.title as session_title, ' . ' CASE WHEN CHAR_LENGTH(x.title) THEN CONCAT_WS(\' - \', a.title, x.title) ELSE a.title END as full_title, ' . ' a.created_by, a.redform_id, x.maxwaitinglist, x.maxattendees, a.juser, a.show_names, a.showfields, ' . ' a.submission_type_email, a.submission_type_external, a.submission_type_phone, a.review_message, ' . ' v.venue, v.city AS location, v.country, v.locimage, v.street, v.plz, v.state, v.locdescription as venue_description, v.map, v.url as venueurl,' . ' v.city, v.latitude, v.longitude, v.company AS venue_company, ' . ' u.name AS creator_name, u.email AS creator_email, ' . ' f.formname, ' . " a.confirmation_message, IF (x.course_credit = 0, '', x.course_credit) AS course_credit, a.course_code, a.submission_types, c.catname, c.access," . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug, ' . ' CASE WHEN CHAR_LENGTH(x.alias) THEN CONCAT_WS(\':\', x.id, x.alias) ELSE x.id END as xslug, ' . ' CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(\':\', c.id, c.alias) ELSE c.id END as categoryslug, ' . ' CASE WHEN CHAR_LENGTH(v.alias) THEN CONCAT_WS(":", v.id, v.alias) ELSE v.id END as venueslug ' . ' FROM #__redevent_events AS a' . ' LEFT JOIN #__redevent_event_venue_xref AS x ON x.eventid = a.id' . ' LEFT JOIN #__redevent_venues AS v ON x.venueid = v.id' . ' LEFT JOIN #__redevent_event_category_xref AS xcat ON xcat.event_id = a.id' . ' LEFT JOIN #__redevent_categories AS c ON c.id = xcat.category_id' . ' LEFT JOIN #__rwf_forms AS f ON f.id = a.redform_id ' . ' LEFT JOIN #__users AS u ON a.created_by = u.id ' . $where;
         $this->_db->setQuery($query);
         $this->_event = $this->_db->loadObject();
         if ($this->_event) {
             $this->_details = $this->_getEventCategories($this->_event);
             $this->_details->attachments = REAttach::getAttachments('event' . $this->_details->did, max($user->getAuthorisedViewLevels()));
         }
         return (bool) $this->_event;
     }
     return true;
 }
示例#2
0
 /**
  * Delete attachment
  *
  * @return true on sucess
  * @access private
  * @since 1.1
  */
 function ajaxattachremove()
 {
     $mainframe =& JFactory::getApplication();
     $id = JRequest::getVar('id', 0, 'request', 'int');
     $res = REAttach::remove($id);
     if (!$res) {
         echo 0;
         $mainframe->close();
     }
     $cache =& JFactory::getCache('com_redevent');
     $cache->clean();
     echo 1;
     $mainframe->close();
 }
示例#3
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;
 }
示例#4
0
 /**
  * Method to store the event
  *
  * @access	public
  * @return	boolean	True on success
  * @since	1.5
  */
 function store($data)
 {
     $mainframe =& JFactory::getApplication();
     // triggers for smart search
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('finder');
     $elsettings = JComponentHelper::getParams('com_redevent');
     $user =& JFactory::getUser();
     $tzoffset = $mainframe->getCfg('offset');
     $row =& JTable::getInstance('redevent_events', '');
     // Bind the form fields to the table
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // Check/sanitize the metatags
     $row->meta_description = htmlspecialchars(trim(addslashes($row->meta_description)));
     if (JString::strlen($row->meta_description) > 255) {
         $row->meta_description = JString::substr($row->meta_description, 0, 254);
     }
     $row->meta_keywords = htmlspecialchars(trim(addslashes($row->meta_keywords)));
     if (JString::strlen($row->meta_keywords) > 200) {
         $row->meta_keywords = JString::substr($row->meta_keywords, 0, 199);
     }
     //Check if image was selected
     jimport('joomla.filesystem.file');
     if ($row->datimage) {
         $format = strtolower(JFile::getExt($row->datimage));
         $allowable = array('gif', 'jpg', 'png');
         if (in_array($format, $allowable)) {
             $row->datimage = $row->datimage;
         } else {
             $mainframe->enqueueMessage(JText::_('COM_REDEVENT_IMAGE_FORMAT_NOT_ALLOWED') . ': ' . $format);
             $row->datimage = '';
         }
     }
     // sanitise id field
     $row->id = (int) $row->id;
     $nullDate = $this->_db->getNullDate();
     // 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');
         $row->created_by = $row->created_by ? $row->created_by : $user->get('id');
         $isNew = false;
     } else {
         $row->modified = $nullDate;
         $row->modified_by = '';
         //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 = $row->created_by ? $row->created_by : $user->get('id');
         $isNew = true;
     }
     // Make sure the data is valid
     if (!$row->check($elsettings)) {
         $this->setError($row->getError());
         return false;
     }
     // Trigger the onFinderBeforeSave event.
     $results = $dispatcher->trigger('onFinderBeforeSave', array($this->option . '.' . $this->name, $row, $isNew));
     // Store the table to the database
     if (!$row->store(true)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // update the event category xref
     // first, delete current rows for this event
     $query = ' DELETE FROM #__redevent_event_category_xref WHERE event_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_event_category_xref (event_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
     REAttach::store('event' . $row->id);
     // Trigger the onFinderAfterSave event.
     $results = $dispatcher->trigger('onFinderAfterSave', array($this->option . '.' . $this->name, $row, $isNew));
     return $row->id;
 }
示例#5
0
 /**
  * Method to get the Category
  *
  * @access public
  * @return integer
  */
 function getCategory()
 {
     if (!$this->_category) {
         $user =& JFactory::getUser();
         $query = 'SELECT *,' . ' CASE WHEN CHAR_LENGTH(alias) THEN CONCAT_WS(\':\', id, alias) ELSE id END as slug' . ' FROM #__redevent_categories' . ' WHERE id = ' . $this->_id;
         $this->_db->setQuery($query);
         $this->_category = $this->_db->loadObject();
         if ($this->_category->private) {
             $acl =& UserAcl::getInstance();
             $cats = $acl->getManagedCategories();
             if (!is_array($cats) || !in_array($this->_category->id, $cats)) {
                 JError::raiseError(403, JText::_('COM_REDEVENT_ACCESS_NOT_ALLOWED'));
             }
         }
         $this->_category->attachments = REAttach::getAttachments('category' . $this->_category->id, max($user->getAuthorisedViewLevels()));
     }
     return $this->_category;
 }
示例#6
0
 /**
  * Method to store the venue
  *
  * @access	public
  * @return	boolean	True on success
  * @since	1.5
  */
 function store($data)
 {
     $elsettings = JComponentHelper::getParams('com_redevent');
     $user =& JFactory::getUser();
     $config =& JFactory::getConfig();
     $tzoffset = $config->getValue('config.offset');
     $row =& $this->getTable('redevent_venues', '');
     // triggers for smart search
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('finder');
     // bind it to the table
     if (!$row->bind($data)) {
         RedeventError::raiseError(500, $this->_db->getErrorMsg());
         return false;
     }
     // Check if image was selected
     jimport('joomla.filesystem.file');
     $format = strtolower(JFile::getExt($row->locimage));
     $allowable = array('gif', 'jpg', 'png');
     if (in_array($format, $allowable)) {
         $row->locimage = $row->locimage;
     } else {
         $row->locimage = '';
     }
     // sanitise id field
     $row->id = (int) $row->id;
     $nullDate = $this->_db->getNullDate();
     // 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');
         $isNew = false;
     } else {
         $row->modified = $nullDate;
         $row->modified_by = '';
         //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');
         $isNew = true;
     }
     //uppercase needed by mapservices
     if ($row->country) {
         $row->country = JString::strtoupper($row->country);
     }
     //update item order
     if (!$row->id) {
         $row->ordering = $row->getNextOrder();
     }
     // Make sure the data is valid
     if (!$row->check($elsettings)) {
         $this->setError($row->getError());
         return false;
     }
     // Trigger the onFinderBeforeSave event.
     $results = $dispatcher->trigger('onFinderBeforeSave', array($this->option . '.' . $this->name, $row, $isNew));
     // Store it in the db
     if (!$row->store()) {
         RedeventError::raiseError(500, $this->_db->getErrorMsg());
         return false;
     }
     // update the venue 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
     if (isset($data['categories'])) {
         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
     REAttach::store('venue' . $row->id);
     // Trigger the onFinderAfterSave event.
     $results = $dispatcher->trigger('onFinderAfterSave', array($this->option . '.' . $this->name, $row, $isNew));
     return $row->id;
 }
示例#7
0
 /**
  * Method to store the event
  *
  * @access	public
  * @return	id
  * @since	0.9
  */
 function store($data, $file)
 {
     $mainframe =& JFactory::getApplication();
     $user =& JFactory::getUser();
     $elsettings =& redEVENTHelper::config();
     $params = $mainframe->getParams();
     $acl = UserAcl::getInstance();
     //Get mailinformation
     $SiteName = $mainframe->getCfg('sitename');
     $MailFrom = $mainframe->getCfg('mailfrom');
     $FromName = $mainframe->getCfg('fromname');
     $tzoffset = $mainframe->getCfg('offset');
     $row =& JTable::getInstance('redevent_events', '');
     if ($data['id']) {
         $row->load((int) $data['id']);
     } else {
         $category_ids = isset($data['categories']) ? $data['categories'] : array();
         $template_event = $this->_getEventTemplate($category_ids);
         $template_event = $template_event ? $template_event : $params->get('event_template', 0);
         if ($template_event) {
             $row->load($template_event);
             $row->id = null;
             $row->alias = null;
             $row->checked_out = null;
             $row->checked_out_time = null;
         } else {
             JError::raiseWarning(0, JText::_('COM_REDEVENT_MISSING_FRONTEND_SUBMISSION_EVENT_TEMPLATE'));
             return false;
         }
     }
     //Sanitize
     $data['datdescription'] = JRequest::getVar('datdescription', $row->datdescription, 'post', 'string', JREQUEST_ALLOWRAW);
     $curimage = JRequest::getVar('curimage', '', 'post', 'string');
     // published state
     if (!$acl->canPublishEvent($this->_id)) {
         // use default state
         $row->published = $params->get('default_submit_published_state', 0);
     }
     //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) {
         //check if user is allowed to edit events
         if (!$acl->canEditEvent($this->_id)) {
             JError::raiseError(403, JText::_('COM_REDEVENT_NO_ACCESS'));
         }
         $row->modified = gmdate('Y-m-d H:i:s');
         $row->modified_by = $user->get('id');
     } else {
         //check if user is allowed to submit new events
         if (!$acl->canAddEvent()) {
             JError::raiseError(403, JText::_('COM_REDEVENT_NO_ACCESS'));
         }
         //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');
         $base_Dir = JPATH_SITE . '/images/redevent/events/';
         //check the image
         $check = redEVENTImage::check($file, $elsettings);
         if ($check === false) {
             JError::raiseWarning(0, JText::_('COM_REDEVENT_EDITEVENT_IMAGE_CHECKFAILED'));
         } else {
             //sanitize the image filename
             $filename = redEVENTImage::sanitize($base_Dir, $file['name']);
             $filepath = $base_Dir . $filename;
             if (!JFile::upload($file['tmp_name'], $filepath)) {
                 JError::raiseWarning(0, JText::_('COM_REDEVENT_UPLOAD_FAILED'));
             } else {
                 $row->datimage = '/images/redevent/events/' . $filename;
             }
         }
     } else {
         //keep image if edited and left blank
         $row->datimage = $curimage;
     }
     //end image if
     //Make sure the table is valid
     if (!$row->check($elsettings)) {
         $this->setError($row->getError());
         return false;
     }
     //is this an edited event or not?
     //after store we allways have an id
     $edited = $row->id ? $row->id : false;
     //store it in the db
     if (!$row->store(true)) {
         JError::raiseError(500, $this->_db->stderr());
         return false;
     }
     // update the event category xref
     if (isset($data['categories'])) {
         // first, delete current rows for this event
         $query = ' DELETE FROM #__redevent_event_category_xref WHERE event_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_event_category_xref (event_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;
             }
         }
     } else {
         if (!$edited) {
             // copy category from template event
             $query = ' INSERT INTO #__redevent_event_category_xref (event_id, category_id) ' . ' SELECT ' . $this->_db->Quote($row->id) . ', category_id ' . '       FROM #__redevent_event_category_xref ' . '       WHERE event_id = ' . $this->_db->Quote($template_event);
             $this->_db->setQuery($query);
             if (!$this->_db->query()) {
                 $this->setError($this->_db->getErrorMsg());
                 JError::raiseWarning(0, JText::_('COM_REDEVENT_copying_categories_failed') . ': ' . $xref->getError());
             }
         }
     }
     // is there a date ?
     if (isset($data['dates']) && strlen($data['dates'])) {
         $xref =& JTable::getInstance('redevent_eventvenuexref', '');
         if (isset($data['xref'])) {
             $xref->load($data['xref']);
         }
         $xref->bind($data);
         $xref->id = isset($data['xref']) ? $data['xref'] : null;
         $xref->eventid = $row->id;
         $xref->published = $row->published;
         if (isset($data['session_title'])) {
             $xref->title = $data['session_title'];
         }
         if (!($xref->check() && $xref->store())) {
             JError::raiseWarning(0, JText::_('COM_REDEVENT_Saving_event_session_failed') . ': ' . $xref->getError());
         }
         $row->xref = $xref->id;
         if ($params->get('edit_roles', 0)) {
             /** roles **/
             // first remove current rows
             $query = ' DELETE FROM #__redevent_sessions_roles ' . ' WHERE xref = ' . $this->_db->Quote($xref->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', $xref->id);
                 $new->set('role_id', $r);
                 $new->set('user_id', $data['urole'][$k]);
                 if (!($new->check() && $new->store())) {
                     $this->setError($recurrence->getError());
                     return false;
                 }
             }
         }
         /** prices **/
         if ($params->get('edit_price', 0)) {
             // first remove current rows
             $query = ' DELETE FROM #__redevent_sessions_pricegroups ' . ' WHERE xref = ' . $this->_db->Quote($xref->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', $xref->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', $xref->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);
         }
     }
     /** session end **/
     // attachments
     if ($params->get('allow_attachments', 1)) {
         REAttach::store('event' . $row->id);
     }
     // MAIL HANDLING
     $this->_db->setQuery('SELECT * FROM #__redevent_venues AS v LEFT JOIN #__redevent_event_venue_xref AS x ON x.venueid = v.id WHERE x.eventid = ' . (int) $row->id);
     $rowloc = $this->_db->loadObject();
     jimport('joomla.utilities.mail');
     $link = JRoute::_(JURI::base() . RedeventHelperRoute::getDetailsRoute($row->id), isset($xref) ? $xref->id : false);
     //create the mail for the site owner
     if ($params->get('mailinform') == 1 || $params->get('mailinform') == 3) {
         $receivers = explode(',', trim($params->get('mailinformrec')));
         if (!count($receivers) || !JMailHelper::isEmailAddress($receivers[0])) {
             $mainframe->enqueueMessage(JText::_('COM_REDEVENT_EDIT_EVENT_NOTIFICATION_MISSING_RECIPIENT'), 'notice');
         } else {
             $mail = JFactory::getMailer();
             $state = $row->published ? JText::sprintf('COM_REDEVENT_MAIL_EVENT_PUBLISHED', $link) : JText::_('COM_REDEVENT_MAIL_EVENT_UNPUBLISHED');
             if ($edited) {
                 $modified_ip = getenv('REMOTE_ADDR');
                 $edited = JHTML::Date($row->modified, JText::_('DATE_FORMAT_LC2'));
                 $mailbody = JText::sprintf('COM_REDEVENT_MAIL_EDIT_EVENT', $user->name, $user->username, $user->email, $modified_ip, $edited, $row->title, $xref->dates, $xref->times, $rowloc->venue, $rowloc->city, $row->datdescription, $state);
                 $mail->setSubject($SiteName . JText::_('COM_REDEVENT_EDIT_EVENT_MAIL'));
             } else {
                 $created = JHTML::Date($row->created, JText::_('DATE_FORMAT_LC2'));
                 $mailbody = JText::sprintf('COM_REDEVENT_MAIL_NEW_EVENT', $user->name, $user->username, $user->email, $row->author_ip, $created, $row->title, $xref->dates, $xref->times, $rowloc->venue, $rowloc->city, $row->datdescription, $state);
                 $mail->setSubject($SiteName . JText::_('COM_REDEVENT_NEW_EVENT_MAIL'));
             }
             $mail->addRecipient($receivers);
             $mail->setSender(array($MailFrom, $FromName));
             $mail->setBody($mailbody);
             $sent = $mail->Send();
             if (!$sent) {
                 RedeventHelperLog::simpleLog('Error sending created/edited event notification to site owner');
             }
         }
     }
     //mail end
     //create the mail for the user
     if ($params->get('mailinformuser') == 1 || $params->get('mailinformuser') == 3) {
         $usermail = JFactory::getMailer();
         $state = $row->published ? JText::sprintf('COM_REDEVENT_USER_MAIL_EVENT_PUBLISHED', $link) : JText::_('COM_REDEVENT_USER_MAIL_EVENT_UNPUBLISHED');
         if ($edited) {
             $edited = JHTML::Date($row->modified, JText::_('DATE_FORMAT_LC2'));
             $mailbody = JText::sprintf('COM_REDEVENT_USER_MAIL_EDIT_EVENT', $user->name, $user->username, $edited, $row->title, $xref->dates, $xref->times, $rowloc->venue, $rowloc->city, $row->datdescription, $state);
             $usermail->setSubject($SiteName . JText::_('COM_REDEVENT_EDIT_USER_EVENT_MAIL'));
         } else {
             $created = JHTML::Date($row->created, JText::_('DATE_FORMAT_LC2'));
             $mailbody = JText::sprintf('COM_REDEVENT_USER_MAIL_NEW_EVENT', $user->name, $user->username, $created, $row->title, $xref->dates, $xref->times, $rowloc->venue, $rowloc->city, $row->datdescription, $state);
             $usermail->setSubject($SiteName . JText::_('COM_REDEVENT_NEW_USER_EVENT_MAIL'));
         }
         $usermail->addRecipient($user->email);
         $usermail->setSender(array($MailFrom, $FromName));
         $usermail->setBody($mailbody);
         $sent = $usermail->Send();
         if (!$sent) {
             RedeventHelperLog::simpleLog('Error sending created/edited event notification to event owner');
         }
     }
     return $row;
 }
示例#8
0
 /**
  * Method to get the Venue
  *
  * @access public
  * @return array
  */
 function getVenue()
 {
     $user =& JFactory::getUser();
     //Location holen
     $query = 'SELECT *, v.id AS venueid, ' . ' CASE WHEN CHAR_LENGTH(v.alias) THEN CONCAT_WS(\':\', v.id, v.alias) ELSE v.id END as slug ' . ' FROM #__redevent_venues AS v' . ' WHERE v.id = ' . $this->_id;
     $this->_db->setQuery($query);
     $_venue = $this->_db->loadObject();
     if ($_venue->private) {
         $acl =& UserAcl::getInstance();
         $cats = $acl->getManagedVenues();
         if (!is_array($cats) || !in_array($_venue->id, $cats)) {
             JError::raiseError(403, JText::_('COM_REDEVENT_ACCESS_NOT_ALLOWED'));
         }
     }
     $_venue->attachments = REAttach::getAttachments('venue' . $_venue->id, max($user->getAuthorisedViewLevels()));
     return $_venue;
 }
示例#9
0
 /**
  * Method to store the category
  *
  * @access	public
  * @return	boolean	True on success
  * @since	1.5
  */
 function store($data)
 {
     // triggers for smart search
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('finder');
     $row =& $this->getTable('redevent_categories', '');
     // bind it to the table
     if (!$row->bind($data)) {
         RedeventError::raiseError(500, $this->_db->getErrorMsg());
         return false;
     }
     $isNew = false;
     if (!$row->id) {
         $row->ordering = $row->getNextOrder();
         $isNew = true;
     }
     // Make sure the data is valid
     if (!$row->check()) {
         $this->setError($row->getError());
         return false;
     }
     // Trigger the onFinderBeforeSave event.
     $results = $dispatcher->trigger('onFinderBeforeSave', array($this->option . '.' . $this->name, $row, $isNew));
     // Store it in the db
     if (!$row->store()) {
         RedeventError::raiseError(500, $this->_db->getErrorMsg());
         return false;
     }
     // attachments
     REAttach::store('category' . $row->id);
     // Trigger the onFinderAfterSave event.
     $results = $dispatcher->trigger('onFinderAfterSave', array($this->option . '.' . $this->name, $row, $isNew));
     return $row->id;
 }