function check()
 {
     // Not typed in a category name?
     if (trim($this->name) == '') {
         $this->_error = JText::_('COM_REDEVENT_ADD_GROUP_NAME');
         RedeventError::raiseWarning('REDEVENT_GENERIC_ERROR', $this->_error);
         return false;
     }
     /** check for existing name */
     $query = 'SELECT id FROM #__redevent_groups WHERE name = ' . $this->_db->Quote($this->name);
     $this->_db->setQuery($query);
     $xid = intval($this->_db->loadResult());
     if ($xid && $xid != intval($this->id)) {
         JError::raiseWarning('REDEVENT_GENERIC_ERROR', JText::sprintf('COM_REDEVENT_GROUP_NAME_S_ALREADY_EXISTS', $this->name));
         return false;
     }
     /** check it's the only with default set to 1 **/
     if ($this->isdefault) {
         /** check for existing name */
         $query = 'SELECT id FROM #__redevent_groups WHERE isdefault = 1';
         $this->_db->setQuery($query);
         $xid = intval($this->_db->loadResult());
         if ($xid && $xid != intval($this->id)) {
             JError::raiseWarning('REDEVENT_GENERIC_ERROR', JText::_('COM_REDEVENT_THERE_IS_ALREADY_A_DEFAULT_GROUP'));
             return false;
         }
     }
     return true;
 }
 /**
  * Save the configuration
  */
 function store()
 {
     $table =& JTable::getInstance('component');
     $parampost['params'] = JRequest::getVar('params');
     $parampost['option'] = 'com_redform';
     $table->loadByOption('com_redform');
     $table->bind($parampost);
     // save the changes
     if (!$table->store()) {
         RedeventError::raiseWarning(500, $table->getError());
         return false;
     }
     return true;
 }
Example #3
0
 /**
  * Saves the css
  *
  */
 function savecss()
 {
     $mainframe =& JFactory::getApplication();
     JRequest::checkToken() or die('Invalid Token');
     // Initialize some variables
     $option = JRequest::getVar('option');
     $filename = JRequest::getVar('filename', '', 'post', 'cmd');
     $filecontent = JRequest::getVar('filecontent', '', '', '', JREQUEST_ALLOWRAW);
     if (!$filecontent) {
         $mainframe->redirect('index.php?option=' . $option, JText::_('COM_REDEVENT_OPERATION_FAILED') . ': ' . JText::_('COM_REDEVENT_CONTENT_EMPTY'));
     }
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     $ftp = JClientHelper::getCredentials('ftp');
     $file = JPATH_SITE . DS . 'components' . DS . 'com_redevent' . DS . 'assets' . DS . 'css' . DS . $filename;
     // Try to make the css file writeable
     if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0755')) {
         RedeventError::raiseNotice('REDEVENT_GENERIC_ERROR', 'COULD NOT MAKE CSS FILE WRITABLE');
     }
     jimport('joomla.filesystem.file');
     $return = JFile::write($file, $filecontent);
     // Try to make the css file unwriteable
     if (!$ftp['enabled'] && JPath::isOwner($file) && !JPath::setPermissions($file, '0555')) {
         RedeventError::raiseNotice('REDEVENT_GENERIC_ERROR', 'COULD NOT MAKE CSS FILE UNWRITABLE');
     }
     if ($return) {
         $task = JRequest::getVar('task');
         switch ($task) {
             case 'applycss':
                 $mainframe->redirect('index.php?option=' . $option . '&view=editcss', JText::_('COM_REDEVENT_CSS_FILE_SUCCESSFULLY_ALTERED'));
                 break;
             case 'savecss':
             default:
                 $mainframe->redirect('index.php?option=' . $option, JText::_('COM_REDEVENT_CSS_FILE_SUCCESSFULLY_ALTERED'));
                 break;
         }
     } else {
         $mainframe->redirect('index.php?option=' . $option, JText::_('COM_REDEVENT_OPERATION_FAILED') . ': ' . JText::sprintf('COM_REDEVENT_FAILED_ TO_OPEN_FILE_FOR_WRITING_S', $file));
     }
 }
 function check()
 {
     if (!$this->group_id) {
         $this->_error = JText::_('COM_REDEVENT_GROUP_REQUIRED');
         RedeventError::raiseWarning('REDEVENT_GENERIC_ERROR', $this->_error);
         return false;
     }
     if (!$this->category_id) {
         $this->_error = JText::_('COM_REDEVENT_CATEGORY_REQUIRED');
         RedeventError::raiseWarning('REDEVENT_GENERIC_ERROR', $this->_error);
         return false;
     }
     /** check for existing relationship */
     $query = ' SELECT id FROM #__redevent_groups_categories ' . ' WHERE group_id = ' . $this->_db->Quote($this->group_id) . '   AND category_id = ' . $this->_db->Quote($this->category_id);
     $this->_db->setQuery($query);
     $xid = intval($this->_db->loadResult());
     if ($xid && $xid != intval($this->id)) {
         JError::raiseWarning('REDEVENT_GENERIC_ERROR', JText::_('COM_REDEVENT_GROUP_CATEGORY_RELATIONSHIP_ALREADY_EXISTS'));
         return false;
     }
     return true;
 }
Example #5
0
 /**
  * Method to get categories item data
  *
  * @access public
  * @return array
  */
 function getData()
 {
     $app =& JFactory::getApplication();
     $contents = '';
     $file = $app->getCfg('log_path') . DS . 'com_redevent.log';
     if (file_exists($file)) {
         $handle = fopen($file, "r");
         if (!$handle) {
             RedeventError::raiseWarning('0', 'error opening: ' . $file);
         }
         $contents = '';
         while (!feof($handle)) {
             $contents .= fread($handle, 8192);
         }
         fclose($handle);
     }
     if (empty($contents)) {
         $contents = array(JText::_('COM_REDEVENT_No_log'));
     } else {
         $contents = explode("\n", $contents);
         array_shift($contents);
     }
     return $contents;
 }
Example #6
0
 /**
  * create user from posted data
  *
  * @param int $sid redform submission id
  * @return object|false created user
  */
 function _createUser($sid)
 {
     // 		require_once(JPATH_SITE.DS.'components'.DS.'com_user'.DS.'controller.php');
     jimport('joomla.user.helper');
     $db =& JFactory::getDBO();
     $rfcore = new redformCore();
     $answers = $rfcore->getSidContactEmails($sid);
     if (!$answers) {
         throw new Exception(JText::_('COM_REDEVENT_NO_ANSWERS_FOUND_FOR_SID') . ' ' . $sid);
     }
     $details = current($answers);
     if (!$details['email']) {
         //throw new Exception(JText::_('COM_REDEVENT_NEED_MISSING_EMAIL_TO_CREATE_USER'));
         RedeventError::raiseWarning('', JText::_('COM_REDEVENT_NEED_MISSING_EMAIL_TO_CREATE_USER'));
         return false;
     }
     if ($uid = $this->_getUserIdFromEmail($details['email'])) {
         return JFactory::getUser($uid);
     }
     if (!$details['username'] && !$details['fullname']) {
         $username = '******' . $sid;
         $details['fullname'] = $username;
     } else {
         $username = $details['username'] ? $details['username'] : $details['fullname'];
         $details['fullname'] = $details['fullname'] ? $details['fullname'] : $username;
     }
     // check unicity
     $i = 2;
     while (true) {
         $query = 'SELECT id FROM #__users WHERE username = '******'username'] . '_' . $i++;
         } else {
             break;
         }
     }
     jimport('joomla.application.component.helper');
     // Get required system objects
     $user = clone JFactory::getUser(0);
     $usersParams =& JComponentHelper::getParams('com_users');
     // load the Params
     $password = JUserHelper::genRandomPassword();
     $config = JComponentHelper::getParams('com_users');
     // Default to Registered.
     $defaultUserGroup = $config->get('new_usertype', 2);
     // Set some initial user values
     $user->set('id', 0);
     $user->set('name', $details['fullname']);
     $user->set('username', $username);
     $user->set('email', $details['email']);
     $user->set('groups', array($defaultUserGroup));
     $user->set('password', md5($password));
     if (!$user->save()) {
         RedeventError::raiseWarning('', JText::_($user->getError()));
         return false;
     }
     // send email using juser controller
     $this->_sendUserCreatedMail($user, $password);
     return $user;
 }
Example #7
0
 /**
  * Image selection List
  *
  * @since 0.9
  */
 function display($tpl = null)
 {
     $mainframe =& JFactory::getApplication();
     $option = JRequest::getCmd('option');
     $document =& JFactory::getDocument();
     if ($this->getLayout() == 'uploadimage') {
         $this->_displayuploadimage($tpl);
         return;
     }
     //get vars
     $task = JRequest::getVar('task');
     $search = $mainframe->getUserStateFromRequest($option . '.search', 'search', '', 'string');
     $search = trim(JString::strtolower($search));
     //set variables
     switch ($task) {
         case 'selecteventimg':
             $folder = 'events';
             $task = 'eventimg';
             $redi = 'selecteventimg';
             break;
         case 'selectvenueimg':
             $folder = 'venues';
             $task = 'venueimg';
             $redi = 'selectvenueimg';
             break;
         case 'selectcategoryimg':
             $folder = 'categories';
             $task = 'categoryimg';
             $redi = 'selectcategoryimg';
             break;
     }
     JRequest::setVar('folder', $folder);
     // Do not allow cache
     JResponse::allowCache(false);
     //add css
     $document->addStyleSheet('components/com_redevent/assets/css/redeventbackend.css');
     //get images
     $images = $this->get('images');
     $pageNav =& $this->get('Pagination');
     if (count($images) > 0 || $search) {
         $this->assignRef('images', $images);
         $this->assignRef('folder', $folder);
         $this->assignRef('task', $redi);
         $this->assignRef('search', $search);
         $this->assignRef('state', $this->get('state'));
         $this->assignRef('pageNav', $pageNav);
         parent::display($tpl);
     } else {
         //no images in the folder, redirect to uploadscreen and raise notice
         RedeventError::raiseNotice('REDEVENT_GENERIC_ERROR', JText::_('COM_REDEVENT_NO_IMAGES_AVAILABLE'));
         $this->setLayout('uploadimage');
         JRequest::setVar('task', $task);
         $this->_displayuploadimage($tpl);
         return;
     }
 }
Example #8
0
 /**
  * Send the signup email
  */
 public function getSendFormalOfferEmail($tags)
 {
     /* Initialise the mailer */
     $this->Mailer();
     /* Load the details for this course */
     $db = JFactory::getDBO();
     $q = "SELECT * \n\t\t\tFROM #__redevent_event_venue_xref x\n\t\t\tLEFT JOIN #__redevent_events e\n\t\t\tON e.id = x.eventid\n\t\t\tLEFT JOIN #__redevent_venues v\n\t\t\tON v.id = x.venueid\n\t\t\tWHERE x.id = " . JRequest::getInt('xref');
     $db->setQuery($q);
     $details = $db->loadObject();
     /* Add the recipient */
     $this->mailer->AddAddress(JRequest::getVar('subemailaddress'), JRequest::getVar('subemailname'));
     /* Set the subject */
     $this->mailer->setSubject($tags->ReplaceTags($details->submission_type_formal_offer_subject));
     /* Add the body to the mail */
     /* Read the template */
     $message = $tags->ReplaceTags($details->submission_type_formal_offer_body);
     // convert urls
     $message = REOutput::ImgRelAbs($message);
     $this->mailer->setBody($message);
     /* Sent out the mail */
     if (!$this->mailer->Send()) {
         RedeventError::raiseWarning(0, JText::_('COM_REDEVENT_NO_MAIL_SEND') . ' ' . $this->mailer->error);
         return false;
     }
     /* Clear the mail details */
     $this->mailer->ClearAddresses();
     return true;
 }
Example #9
0
 /**
  * Tests if the event is checked out
  *
  * @access  public
  * @param int A user id
  * @return  boolean True if checked out
  * @since 0.9
  */
 function isCheckedOut($uid = 0)
 {
     if ($this->_loadData()) {
         if ($uid) {
             return $this->_data->checked_out && $this->_data->checked_out != $uid;
         } else {
             return $this->_data->checked_out;
         }
     } elseif ($this->_id < 1) {
         return false;
     } else {
         RedeventError::raiseWarning(0, 'Unable to Load Data');
         return false;
     }
 }
Example #10
0
 /**
  * logic to mass delete images
  *
  * @access public
  * @return void
  * @since 0.9
  */
 function delete()
 {
     $mainframe =& JFactory::getApplication();
     // Set FTP credentials, if given
     jimport('joomla.client.helper');
     JClientHelper::setCredentialsFromRequest('ftp');
     // Get some data from the request
     $images = JRequest::getVar('rm', array(), '', 'array');
     $folder = JRequest::getVar('folder');
     if (count($images)) {
         foreach ($images as $image) {
             if ($image !== JFilterInput::clean($image, 'path')) {
                 RedeventError::raiseWarning(100, JText::_('COM_REDEVENT_UNABLE_TO_DELETE') . ' ' . htmlspecialchars($image, ENT_COMPAT, 'UTF-8'));
                 continue;
             }
             $fullPath = JPath::clean(JPATH_SITE . DS . 'images' . DS . 'redevent' . DS . $folder . DS . $image);
             $fullPaththumb = JPath::clean(JPATH_SITE . DS . 'images' . DS . 'redevent' . DS . $folder . DS . 'small' . DS . $image);
             if (is_file($fullPath)) {
                 JFile::delete($fullPath);
                 if (JFile::exists($fullPaththumb)) {
                     JFile::delete($fullPaththumb);
                 }
             }
         }
     }
     switch ($folder) {
         case 'events':
             $task = 'selecteventimg';
             break;
         case 'venues':
             $task = 'selectvenueimg';
             break;
         case 'categories':
             $task = 'selectcategoryimg';
             break;
     }
     $mainframe->redirect('index.php?option=com_redevent&view=imagehandler&task=' . $task . '&tmpl=component');
 }
Example #11
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;
 }
Example #12
0
 /**
  * Method to get event data for the Detailsview
  *
  * @access public
  * @return array
  * @since 0.9
  */
 public function getData()
 {
     /*
      * Load the Category data
      */
     if ($this->_loadDetails()) {
         $user =& JFactory::getUser();
         // Is the category published?
         if (!count($this->_event->categories)) {
             RedeventError::raiseError(404, JText::_("COM_REDEVENT_CATEGORY_NOT_PUBLISHED"));
         }
         // Do we have access to any category ?
         $access = false;
         foreach ($this->_details->categories as $cat) {
             if ($cat->access <= max($user->getAuthorisedViewLevels())) {
                 $access = true;
                 break;
             }
         }
         if (!$access) {
             JError::raiseError(403, JText::_("COM_REDEVENT_ALERTNOTAUTH"));
         }
     }
     return $this->_event;
 }
Example #13
0
 /**
  * Cleanes and saves the submitted event to the database
  *
  * TODO: Check if the user is allowed to post events assigned to this category/venue
  *
  * @since 0.4
  */
 function saveevent()
 {
     // Check for request forgeries
     JRequest::checkToken() or die('Invalid Token');
     //get image
     $file = JRequest::getVar('userfile', '', 'files', 'array');
     $post = JRequest::get('post', 4);
     $isNew = $post['id'] ? false : true;
     $model = $this->getModel('editevent');
     $this->addModelPath(JPATH_BASE . DS . 'administrator' . DS . 'components' . DS . 'com_redevent' . DS . 'models');
     $model_wait = $this->getModel('waitinglist');
     if ($row = $model->store($post, $file)) {
         JPluginHelper::importPlugin('redevent');
         $dispatcher =& JDispatcher::getInstance();
         $res = $dispatcher->trigger('onEventEdited', array($row->id, $isNew));
         $cache =& JFactory::getCache('com_redevent');
         $cache->clean();
         $msg = 'saved';
         //			$link = JRequest::getString('referer', RedeventHelperRoute::getMyeventsRoute(), 'post');
     } else {
         $msg = $model->getError();
         //			$link = JRequest::getString('referer', RedeventHelperRoute::getMyeventsRoute(), 'post');
         RedeventError::raiseWarning(0, $model->getError());
     }
     $model->checkin();
     switch (JRequest::getWord('referer')) {
         case 'myevents':
             $link = JRoute::_(RedeventHelperRoute::getMyeventsRoute(), false);
             break;
         default:
             if ($row && $row->published) {
                 $link = JRoute::_(RedeventHelperRoute::getDetailsRoute($row->id, $row->xref ? $row->xref : null), false);
             } else {
                 $link = JRoute::_(RedeventHelperRoute::getMyeventsRoute(), false);
             }
     }
     $this->setRedirect($link, $msg);
 }
Example #14
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;
 }
Example #15
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;
 }
Example #16
0
 /**
  * Delete registered users
  *
  * @access public
  * @return true on success
  * @since 2.5
  */
 public function remove($cid = array())
 {
     if (!count($cid)) {
         return true;
     }
     /**
      * track xrefs attendees are being cancelled from
      * @var array
      */
     $xrefs = array();
     foreach ($cid as $register_id) {
         $db =& JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('e.redform_id,r.xref AS xref_id');
         $query->from('#__redevent_register AS r');
         $query->join('INNER', '#__redevent_event_venue_xref AS x ON x.id = r.xref');
         $query->join('INNER', '#__redevent_events AS e ON e.id = x.eventid');
         $query->where('r.id = ' . (int) $register_id);
         $db->setQuery($query);
         $res = $db->loadObject();
         $xrefs[] = $res->xref_id;
         $query = ' DELETE s, f, r ' . ' FROM #__redevent_register AS r ' . ' LEFT JOIN #__rwf_submitters AS s ON r.sid = s.id ' . ' LEFT JOIN #__rwf_forms_' . $res->redform_id . ' AS f ON f.id = s.answer_id ' . ' WHERE r.id = ' . $register_id . '   AND r.cancelled = 1 ';
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             RedeventError::raiseError(1001, $this->_db->getErrorMsg());
             return false;
         }
     }
     // now update waiting list for all updated sessions
     foreach ($xrefs as $xref) {
         $model_wait = JModel::getInstance('waitinglist', 'RedeventModel');
         $model_wait->setXrefId($xref);
         if (!$model_wait->UpdateWaitingList()) {
             $this->setError($model_wait->getError());
             return false;
         }
     }
     return true;
 }
 function check()
 {
     // Not typed in a category name?
     if (trim($this->catname) == '') {
         $this->_error = JText::_('COM_REDEVENT_ADD_NAME_CATEGORY');
         RedeventError::raiseWarning('REDEVENT_GENERIC_ERROR', $this->_error);
         return false;
     }
     $alias = JFilterOutput::stringURLSafe($this->catname);
     if (empty($this->alias) || $this->alias === $alias) {
         $this->alias = $alias;
     }
     return true;
 }
Example #18
0
 /**
  * Method to remove a venue
  *
  * @access	public
  * @return	boolean	True on success
  * @since	0.9
  */
 function delete($cid)
 {
     $cids = implode(',', $cid);
     $query = 'SELECT v.id, v.venue, COUNT( x.venueid ) AS numcat' . ' FROM #__redevent_venues AS v' . ' LEFT JOIN #__redevent_event_venue_xref AS x ON x.venueid = v.id' . ' WHERE v.id IN (' . $cids . ')' . ' GROUP BY v.id';
     $this->_db->setQuery($query);
     if (!($rows = $this->_db->loadObjectList())) {
         RedeventError::raiseError(500, $this->_db->stderr());
         return false;
     }
     $err = array();
     $cid = array();
     foreach ($rows as $row) {
         if ($row->numcat == 0) {
             $cid[] = $row->id;
         } else {
             $err[] = $row->venue;
         }
     }
     if (count($cid)) {
         $cids = implode(',', $cid);
         $query = 'DELETE FROM #__redevent_venues' . ' WHERE id IN (' . $cids . ')';
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
     }
     if (count($err)) {
         $cids = implode(', ', $err);
         $msg = JText::sprintf('COM_REDEVENT_VENUE_ASSIGNED_EVENT_S', $cids);
         return $msg;
     }
     // for finder plugins
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('finder');
     foreach ($cid as $row_id) {
         $obj = new stdclass();
         $obj->id = $row_id;
         // Trigger the onFinderAfterDelete event.
         $dispatcher->trigger('onFinderAfterDelete', array('com_redevent.venue', $obj));
     }
     $total = count($cid);
     $msg = $total . ' ' . JText::_('COM_REDEVENT_VENUES_DELETED');
     return $msg;
 }
 /**
  * Method to remove a venues category
  *
  * @access	public
  * @return	string $msg
  * @since	0.9
  */
 function delete($cid)
 {
     $cids = implode(',', $cid);
     $query = 'SELECT c.id, c.name, COUNT( xv.category_id ) AS numvenues' . ' FROM #__redevent_venues_categories AS c' . ' LEFT JOIN #__redevent_venue_category_xref AS xv ON xv.category_id = c.id' . ' WHERE c.id IN (' . $cids . ')' . ' GROUP BY c.id';
     $this->_db->setQuery($query);
     if (!($rows = $this->_db->loadObjectList())) {
         RedeventError::raiseError(500, $this->_db->stderr());
         return false;
     }
     $err = array();
     $cid = array();
     foreach ($rows as $row) {
         if ($row->numvenues == 0) {
             $cid[] = $row->id;
         } else {
             $err[] = $row->name;
         }
     }
     if (count($cid)) {
         $cids = implode(',', $cid);
         $query = 'DELETE FROM #__redevent_venues_categories' . ' WHERE id IN (' . $cids . ')';
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             $this->setError($this->_db->getErrorMsg());
             return false;
         }
         $table = JTable::getInstance('redevent_venues_categories', '');
         $table->rebuildTree();
     }
     if (count($err)) {
         $cids = implode(', ', $err);
         $msg = JText::sprintf('COM_REDEVENT_VENUES_ASSIGNED_CATEGORY_S', $cids);
         return $msg;
     } else {
         $total = count($cid);
         $msg = $total . ' ' . JText::_('COM_REDEVENT_CATEGORIES_DELETED');
         return $msg;
     }
 }
 /**
  * Method to store the category
  *
  * @access	public
  * @return	boolean	True on success
  * @since	1.5
  */
 function store($data)
 {
     $row =& $this->getTable('redevent_venues_categories', '');
     // bind it to the table
     if (!$row->bind($data)) {
         RedeventError::raiseError(500, $this->_db->getErrorMsg());
         return false;
     }
     if (!$row->id) {
         $row->ordering = $row->getNextOrder();
     }
     // Make sure the data is valid
     if (!$row->check()) {
         $this->setError($row->getError());
         return false;
     }
     // Store it in the db
     if (!$row->store()) {
         RedeventError::raiseError(500, $this->_db->getErrorMsg());
         return false;
     }
     return $row->id;
 }
Example #21
0
 /**
  * Logic to delete text library element
  *
  * @access public
  * @return void
  * @since 2.0
  */
 function remove()
 {
     $option = JRequest::getCmd('option');
     $cid = JRequest::getVar('cid', array(0), 'post', 'array');
     if (!is_array($cid) || count($cid) < 1) {
         JError::raiseError(500, JText::_('COM_REDEVENT_Select_an_item_to_delete'));
     }
     $model = $this->getModel('textlibrary');
     if ($model->delete($cid)) {
         $msg = count($cid) . ' ' . JText::_('COM_REDEVENT_TAGS_DELETED');
     } else {
         $msg = JText::_('COM_REDEVENT_ERROR_REMOVE_TAG_FAILED' . ': ' . $model->getError());
         RedeventError::raiseWarning(1, $msg);
     }
     $cache =& JFactory::getCache('com_redevent');
     $cache->clean();
     $this->setRedirect('index.php?option=' . $option . '&view=textlibrary', $msg);
 }
Example #22
0
 public static function check($file, $elsettings)
 {
     jimport('joomla.filesystem.file');
     $sizelimit = $elsettings->get('sizelimit', '100') * 1024;
     //size limit in kb
     $imagesize = $file['size'];
     //check if the upload is an image...getimagesize will return false if not
     if (!getimagesize($file['tmp_name'])) {
         JError::raiseWarning(100, JText::_('COM_REDEVENT_UPLOAD_FAILED_NOT_AN_IMAGE') . ': ' . htmlspecialchars($file['name'], ENT_COMPAT, 'UTF-8'));
         return false;
     }
     //check if the imagefiletype is valid
     $fileext = strtolower(JFile::getExt($file['name']));
     $allowable = array('gif', 'jpg', 'png');
     if (!in_array($fileext, $allowable)) {
         JError::raiseWarning(100, JText::_('COM_REDEVENT_WRONG_IMAGE_FILE_TYPE') . ': ' . htmlspecialchars($file['name'], ENT_COMPAT, 'UTF-8'));
         return false;
     }
     //Check filesize
     if ($imagesize > $sizelimit) {
         JError::raiseWarning(100, JText::_('COM_REDEVENT_IMAGE_FILE_SIZE') . ': ' . htmlspecialchars($file['name'], ENT_COMPAT, 'UTF-8'));
         return false;
     }
     //XSS check
     $xss_check = JFile::read($file['tmp_name'], false, 256);
     $html_tags = array('abbr', 'acronym', 'address', 'applet', 'area', 'audioscope', 'base', 'basefont', 'bdo', 'bgsound', 'big', 'blackface', 'blink', 'blockquote', 'body', 'bq', 'br', 'button', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'comment', 'custom', 'dd', 'del', 'dfn', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'fn', 'font', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'html', 'iframe', 'ilayer', 'img', 'input', 'ins', 'isindex', 'keygen', 'kbd', 'label', 'layer', 'legend', 'li', 'limittext', 'link', 'listing', 'map', 'marquee', 'menu', 'meta', 'multicol', 'nobr', 'noembed', 'noframes', 'noscript', 'nosmartquotes', 'object', 'ol', 'optgroup', 'option', 'param', 'plaintext', 'pre', 'rt', 'ruby', 's', 'samp', 'script', 'select', 'server', 'shadow', 'sidebar', 'small', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'tt', 'ul', 'var', 'wbr', 'xml', 'xmp', '!DOCTYPE', '!--');
     foreach ($html_tags as $tag) {
         // A tag is '<tagname ', so we need to add < and a space or '<tagname>'
         if (stristr($xss_check, '<' . $tag . ' ') || stristr($xss_check, '<' . $tag . '>')) {
             RedeventError::raiseWarning(100, JText::_('COM_REDEVENT_WARN_IE_XSS'));
             return false;
         }
     }
     return true;
 }
Example #23
0
 /**
  * unconfirm attendees
  * 
  * @param $cid array of attendees id to unconfirm
  * @return boolean true on success
  */
 function unconfirmattendees($cid = array())
 {
     if (count($cid)) {
         $ids = implode(',', $cid);
         $query = 'UPDATE #__redevent_register SET confirmed = 0 WHERE id IN (' . $ids . ') ';
         $this->_db->setQuery($query);
         if (!$this->_db->query()) {
             RedeventError::raiseError(1001, $this->_db->getErrorMsg());
             return false;
         }
     }
     return true;
 }
Example #24
0
 /**
  * perform integrity fix on db
  * 
  * @return bool true if no problem 
  */
 function fixdb()
 {
     // all the redevent_register records in redevent without an associated record in redform submitters can be deleted
     $q = ' SELECT r.id FROM #__redevent_register AS r ' . ' LEFT JOIN #__rwf_submitters AS s ON s.id = r.sid ' . ' WHERE s.id IS NULL ';
     $this->_db->setQuery($q);
     $register_ids = $this->_db->loadResultArray();
     if (!empty($register_ids)) {
         $q = ' DELETE r.* FROM #__redevent_register AS r ' . ' LEFT JOIN #__rwf_submitters AS s ON s.id = r.sid ' . ' WHERE s.id IS NULL ';
         $this->_db->setQuery($q);
         if (!$this->_db->query()) {
             RedeventError::raiseWarning(0, JText::_("COM_REDEVENT_CANT_DELETE_REGISTRATIONS") . ': ' . $this->_db->getErrorMsg());
             $this->setError(JText::_("COM_REDEVENT_CANT_DELETE_REGISTRATIONS") . ': ' . $this->_db->getErrorMsg());
             return false;
         }
     }
     return true;
 }
Example #25
0
 /**
  * Method to get the registered users
  *
  * @access	public
  * @return	object
  * @since	2.0
  * @todo Complete CB integration
  */
 function getRegisters($all_fields = false, $admin = false)
 {
     // make sure the init is done
     $session = $this->getSession();
     if (!$session->registra && !$admin) {
         return null;
     }
     $db = JFactory::getDBO();
     // first, get all submissions
     $query = ' SELECT r.*, r.waitinglist, r.confirmed, r.confirmdate, r.submit_key ' . ' FROM #__redevent_register AS r ' . ' LEFT JOIN #__users AS u ON r.uid = u.id ' . ' WHERE r.xref = ' . $this->_xref . ' AND r.confirmed = 1' . ' AND r.cancelled = 0 ';
     $db->setQuery($query);
     $submitters = $db->loadObjectList('submit_key');
     if ($submitters === null) {
         $msg = JText::_('COM_REDEVENT_ERROR_GETTING_ATTENDEES');
         $this->setError($msg);
         RedeventError::raiseWarning(5, $msg);
         return null;
     } else {
         if (empty($submitters)) {
             // no submitters
             return null;
         }
     }
     /* At least 1 redFORM field must be selected to show the user data from */
     if ((!empty($session->showfields) || $admin) && $session->redform_id > 0) {
         $fields = $this->getFormFields($all_fields);
         if (!$fields) {
             RedeventError::raiseWarning('error', JText::_('COM_REDEVENT_Cannot_load_fields') . $db->getErrorMsg());
             return null;
         }
         if (count($fields)) {
             $table_fields = array();
             $fields_names = array();
             foreach ($fields as $key => $field) {
                 $table_fields[] = 'a.field_' . $field->id;
                 $fields_names['field_' . $field->id] = $field->field_header;
             }
             $query = ' SELECT ' . implode(', ', $table_fields) . ' , s.submit_key, s.id ' . ' FROM #__redevent_register AS r ' . ' INNER JOIN #__rwf_submitters AS s ON r.sid = s.id ' . ' INNER JOIN #__rwf_forms_' . $fields[0]->form_id . ' AS a ON s.answer_id = a.id ' . ' WHERE r.xref = ' . $this->_xref . ' AND r.confirmed = 1' . ' AND r.cancelled = 0 ';
             $filter_order = $this->getState('filter_order');
             $filter_order_Dir = $this->getState('filter_order_Dir');
             if (!empty($filter_order) && !empty($filter_order_Dir)) {
                 $query .= ' ORDER BY ' . $filter_order . ' ' . $filter_order_Dir;
             } else {
                 $query .= ' ORDER BY r.id ASC';
             }
             $db->setQuery($query);
             if (!$db->query()) {
                 RedeventError::raiseWarning('error', JText::_('COM_REDEVENT_Cannot_load_registered_users') . ' ' . $db->getErrorMsg());
                 return null;
             }
             $answers = $db->loadObjectList();
         } else {
             $answers = array();
         }
         // add the answers to submitters list
         $registers = array();
         foreach ($answers as $answer) {
             if (!isset($submitters[$answer->submit_key])) {
                 $msg = JText::_('COM_REDEVENT_ERROR_REGISTRATION_WITHOUT_SUBMITTER') . ': ' . $answer->id;
                 $this->setError($msg);
                 RedeventError::raiseWarning(10, $msg);
                 return null;
             }
             // build the object
             $register = new stdclass();
             $register->id = $answer->id;
             $register->attendee_id = $submitters[$answer->submit_key]->id;
             $register->submitter = $submitters[$answer->submit_key];
             $register->answers = $answer;
             $register->fields = $fields_names;
             unset($register->answers->id);
             // just the fields
             unset($register->answers->submit_key);
             // just the fields
             $registers[] = $register;
         }
         return $registers;
     }
     return null;
 }
Example #26
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;
 }