Esempio n. 1
0
	/**
	 * logic for uploading an image
	 *
	 * @access public
	 * @return void
	 *
	 */
	function uploadimage()
	{
		$app = JFactory::getApplication();

		// Check for request forgeries
		JSession::checkToken() or jexit('Invalid token');

		$jemsettings = JEMAdmin::config();

		$file 		= JFactory::getApplication()->input->files->get('userfile', array(), 'array');
		$task 		= JFactory::getApplication()->input->get('task', '');

		// Set FTP credentials, if given
		jimport('joomla.client.helper');
		JClientHelper::setCredentialsFromRequest('ftp');
		//$ftp = JClientHelper::getCredentials('ftp');

		//set the target directory
		if ($task == 'venueimgup') {
			$base_Dir = JPATH_SITE.'/images/jem/venues/';
		} else if ($task == 'eventimgup') {
			$base_Dir = JPATH_SITE.'/images/jem/events/';
		} else if ($task == 'categoriesimgup') {
			$base_Dir = JPATH_SITE.'/images/jem/categories/';
		}

		//do we have an upload?
		if (empty($file['name'])) {
			echo "<script> alert('".JText::_('COM_JEM_IMAGE_EMPTY')."'); window.history.go(-1); </script>\n";
			$app->close();
		}

		//check the image
		$check = JEMImage::check($file, $jemsettings);

		if ($check === false) {
			$app->redirect($_SERVER['HTTP_REFERER']);
		}

		//sanitize the image filename
		$filename = JEMImage::sanitize($base_Dir, $file['name']);
		$filepath = $base_Dir . $filename;

		//upload the image
		if (!JFile::upload($file['tmp_name'], $filepath)) {
			echo "<script> alert('".JText::_('COM_JEM_UPLOAD_FAILED')."'); window.history.go(-1); </script>\n";
			$app->close();
		} else {
			echo "<script> alert('".JText::_('COM_JEM_UPLOAD_COMPLETE')."'); window.history.go(-1); window.parent.SelectImage('$filename', '$filename'); </script>\n";
			$app->close();
		}

	}
<?php

/**
 * @package JEM
 * @copyright (C) 2013-2015 joomlaeventmanager.net
 * @copyright (C) 2005-2009 Christoph Lukes
 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 */
defined('_JEXEC') or die;
$gdv = JEMImage::gdVersion();
$group = 'globalattribs';
?>
<fieldset class="form-horizontal">
	<legend><?php 
echo JText::_('COM_JEM_IMAGE_HANDLING');
?>
</legend>
			
		<div class="control-group">	
			<div class="control-label"><?php 
echo $this->form->getLabel('sizelimit');
?>
</div>
			<div class="controls"><?php 
echo $this->form->getInput('sizelimit');
?>
</div>
		</div>

		<div class="control-group">	
			<div class="control-label"><?php 
Esempio n. 3
0
	/**
	 * Method to get the events
	 *
	 * @access public
	 * @return array
	 */
	public static function getList(&$params)
	{
		mb_internal_encoding('UTF-8');

		$db     = JFactory::getDBO();
		$user   = JemFactory::getUser();
		$levels = $user->getAuthorisedViewLevels();

		# Retrieve Eventslist model for the data
		$model = JModelLegacy::getInstance('Eventslist', 'JemModel', array('ignore_request' => true));

		# Set params for the model
		# has to go before the getItems function
		$model->setState('params', $params);

		# filter published
		#  0: unpublished
		#  1: published
		#  2: archived
		# -2: trashed

		# type:
		#  0: upcoming (not started) - dates,times > now+offset
		#  1: unfinished (not ended) - enddates,endtimes > now+offset
		#  2: archived               - no limit, but from now back to the past
		#  3: running (today)        - enddates,endtimes > today+offset AND dates,times < tomorrow+offset
		#  4: featured               - ? (same as upcoming yet)
		$type = (int)$params->get('type');
		$offset_hours = (int)$params->get('offset_hours', 0);
		$max_title_length = (int)$params->get('cuttitle', '25');

		# clean parameter data
		$catids = JemHelper::getValidIds($params->get('catid'));
		$venids = JemHelper::getValidIds($params->get('venid'));
		$eventids = JemHelper::getValidIds($params->get('eventid'));
		$stateloc      = $params->get('stateloc');
		$stateloc_mode = $params->get('stateloc_mode', 0);

		# Open date support
		$opendates = empty($eventids) ? 0 : 1; // allow open dates if limited to specific events
		$model->setState('filter.opendates', $opendates);

		# all upcoming or unfinished events
		if (($type == 0) || ($type == 1)) {
			$offset_minutes = $offset_hours * 60;

			$model->setState('filter.published',1);
			$model->setState('filter.orderby',array('a.dates ASC','a.times ASC'));

			$cal_from = "(a.dates IS NULL OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > $offset_minutes) ";
			$cal_from .= ($type == 1) ? " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > $offset_minutes)) " : ") ";
		}

		# archived events only
		elseif ($type == 2) {
			$model->setState('filter.published',2);
			$model->setState('filter.orderby',array('a.dates DESC','a.times DESC'));
			$cal_from = "";
		}

		# currently running events only (today + offset is inbetween start and end date of event)
		elseif ($type == 3) {
			$offset_days = (int)round($offset_hours / 24);

			$model->setState('filter.published',1);
			$model->setState('filter.orderby',array('a.dates ASC','a.times ASC'));

			$cal_from = " ((DATEDIFF(a.dates, CURDATE()) <= $offset_days) AND (DATEDIFF(IFNULL(a.enddates,a.dates), CURDATE()) >= $offset_days))";
		}

		# featured
		elseif ($type == 4) {
			$offset_minutes = $offset_hours * 60;

			$model->setState('filter.featured',1);
			$model->setState('filter.orderby',array('a.dates ASC','a.times ASC'));

			$cal_from  = "((TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > $offset_minutes) ";
			$cal_from .= " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > $offset_minutes)) ";
		}

		$model->setState('filter.calendar_from',$cal_from);
		$model->setState('filter.groupby','a.id');

		# filter category's
		if ($catids) {
			$model->setState('filter.category_id', $catids);
			$model->setState('filter.category_id.include', true);
		}

		# filter venue's
		if ($venids) {
			$model->setState('filter.venue_id', $venids);
			$model->setState('filter.venue_id.include', true);
		}

		# filter event id's
		if ($eventids) {
			$model->setState('filter.event_id', $eventids);
			$model->setState('filter.event_id.include', true);
		}

		# filter venue's state/province
		if ($stateloc) {
			$model->setState('filter.venue_state', $stateloc);
			$model->setState('filter.venue_state.mode', $stateloc_mode); // 0: exact, 1: partial
		}

		# count
		$count = $params->get('count', '2');
		$model->setState('list.limit', $count);

		if ($params->get('use_modal', 0)) {
			JHtml::_('behavior.modal', 'a.flyermodal');
		}

		# date/time
		$dateFormat = $params->get('formatdate', '');
		$timeFormat = $params->get('formattime', '');
		$addSuffix  = empty($timeFormat); // if we use component's default time format we can also add corresponding suffix

		# Retrieve the available Events
		$events = $model->getItems();

		$color = $params->get('color');
		$fallback_color = $params->get('fallbackcolor', '#EEEEEE');

		# Loop through the result rows and prepare data
		$lists = array();
		$i     = 0;

		foreach ($events as $row)
		{
			# create thumbnails if needed and receive imagedata
			$dimage = $row->datimage ? JEMImage::flyercreator($row->datimage, 'event') : null;
			$limage = $row->locimage ? JEMImage::flyercreator($row->locimage, 'venue') : null;

			#################
			## DEFINE LIST ##
			#################

			$lists[$i] = new stdClass();

			# check view access
			if (in_array($row->access, $levels)) {
				# We know that user has the privilege to view the event
				$lists[$i]->link = JRoute::_(JEMHelperRoute::getEventRoute($row->slug));
				$lists[$i]->linkText = JText::_('MOD_JEM_TEASER_READMORE');
			} else {
				$lists[$i]->link = JRoute::_('index.php?option=com_users&view=login');
				$lists[$i]->linkText = JText::_('MOD_JEM_TEASER_READMORE_REGISTER');
			}

			# cut titel
			$fulltitle = htmlspecialchars($row->title, ENT_COMPAT, 'UTF-8');
			if (mb_strlen($fulltitle) > $max_title_length) {
				$title = mb_substr($fulltitle, 0, $max_title_length) . '...';
			} else {
				$title = $fulltitle;
			}

			$lists[$i]->title       = $title;
			$lists[$i]->fulltitle   = $fulltitle;
			$lists[$i]->venue       = htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8');
			$lists[$i]->catname     = implode(", ", JemOutput::getCategoryList($row->categories, $params->get('linkcategory', 1)));
			$lists[$i]->state       = htmlspecialchars($row->state, ENT_COMPAT, 'UTF-8');
			$lists[$i]->city        = htmlspecialchars($row->city, ENT_COMPAT, 'UTF-8');
			$lists[$i]->eventlink   = $params->get('linkevent', 1) ? JRoute::_(JEMHelperRoute::getEventRoute($row->slug)) : '';
			$lists[$i]->venuelink   = $params->get('linkvenue', 1) ? JRoute::_(JEMHelperRoute::getVenueRoute($row->venueslug)) : '';

			# time/date
			static $formats  = array('year' => 'Y', 'month' => 'F', 'day' => 'j', 'weekday' => 'l');
			static $defaults = array('year' => '&nbsp;', 'month' => '', 'day' => '?', 'weekday' => '');

			$lists[$i]->day         = modJEMteaserHelper::_format_day($row, $params);
			$tmpdate                = empty($row->dates) ? $defaults : self::_format_date_fields($row->dates, $formats);
			$lists[$i]->dayname     = $tmpdate['weekday']; // keep them for backward compatibility
			$lists[$i]->daynum      = $tmpdate['day'];
			$lists[$i]->month       = $tmpdate['month'];
			$lists[$i]->year        = $tmpdate['year'];
			$lists[$i]->startdate   = $tmpdate;
			$lists[$i]->enddate     = empty($row->enddates) ? $defaults : self::_format_date_fields($row->enddates, $formats);
			list($lists[$i]->date,
			     $lists[$i]->time)  = self::_format_date_time($row, $params->get('datemethod', 1), $dateFormat, $timeFormat, $addSuffix);
			$lists[$i]->dateinfo    = JEMOutput::formatDateTime($row->dates, $row->times, $row->enddates, $row->endtimes, $dateFormat, $timeFormat, $addSuffix);

			if ($dimage == null) {
				$lists[$i]->eventimage     = JUri::base(true).'/media/system/images/blank.png';
				$lists[$i]->eventimageorig = JUri::base(true).'/media/system/images/blank.png';
			} else {
				$lists[$i]->eventimage     = JUri::base(true).'/'.$dimage['thumb'];
				$lists[$i]->eventimageorig = JUri::base(true).'/'.$dimage['original'];
			}

			if ($limage == null) {
				$lists[$i]->venueimage     = JUri::base(true).'/media/system/images/blank.png';
				$lists[$i]->venueimageorig = JUri::base(true).'/media/system/images/blank.png';
			} else {
				$lists[$i]->venueimage     = JUri::base(true).'/'.$limage['thumb'];
				$lists[$i]->venueimageorig = JUri::base(true).'/'.$limage['original'];
			}

			$length = $params->get('descriptionlength');
			$length2 = 1;
			$etc = '...';
			$etc2 = JText::_('MOD_JEM_TEASER_NO_DESCRIPTION');

			//append <br /> tags on line breaking tags so they can be stripped below
			$description = preg_replace("'<(hr[^/>]*?/|/(div|h[1-6]|li|p|tr))>'si", "$0<br />", $row->introtext);

			//strip html tags but leave <br /> tags
			$description = strip_tags($description, "<br>");

			//switch <br /> tags to space character
			if ($params->get('br') == 0) {
				$description = str_replace('<br />',' ', $description);
			}
			//
			if (strlen($description) > $length) {
				$length -= strlen($etc);
				$description = preg_replace('/\s+?(\S+)?$/', '', substr($description, 0, $length+1));
				$lists[$i]->eventdescription = substr($description, 0, $length).$etc;
			} elseif (strlen($description) < $length2) {
				$length -= strlen($etc2);
				$description = preg_replace('/\s+?(\S+)?$/', '', substr($description, 0, $length+1));
				$lists[$i]->eventdescription = substr($description, 0, $length).$etc2;
			} else {
				$lists[$i]->eventdescription = $description;
			}

			$lists[$i]->readmore = strlen(trim($row->fulltext));

			$lists[$i]->colorclass = $color;
			if (($color == 'category') && !empty($row->categories)) {
				$colors = array();
				foreach ($row->categories as $category) {
					if (!empty($category->color)) {
						$colors[$category->color] = $category->color;
					}
				}
				$lists[$i]->color = (count($colors) == 1) ? array_pop($colors) : $fallback_color;
			}

			$i++;
		} // foreach ($events as $row)

		return $lists;
	}
Esempio n. 4
0
	/**
	 * Method to get a list of events.
	 */
	public function getItems()
	{
		// Get a storage key.
		$store = $this->getStoreId();
		$query = $this->_getListQuery();
		$items = $this->_getList($query, $this->getStart(), $this->getState('list.limit'));

		$app = JFactory::getApplication();
		$params = clone $this->getState('params');

		// Lets load the content if it doesn't already exist
		if ($items) {

			foreach ($items as $item) {

				// Create image information
				$item->limage = JEMImage::flyercreator($item->locimage, 'venue');

				//Generate Venuedescription
				if (!$item->locdescription == '' || !$item->locdescription == '<br />') {
					//execute plugins
					$item->text	= $item->locdescription;
					$item->title 	= $item->venue;
					JPluginHelper::importPlugin('content');
					$app->triggerEvent('onContentPrepare', array('com_jem.venue', &$item, &$params, 0));
					$item->locdescription = $item->text;
				}

				//build the url
				if (!empty($item->url) && !preg_match('%^http(s)?://%', $item->url)) {
					$item->url = 'http://'.$item->url;
				}


				//prepare the url for output
				// TODO: Should be part of view! Then use $this->escape()
				if (strlen($item->url) > 35) {
					$item->urlclean = htmlspecialchars(substr($item->url, 0 , 35)).'...';
				} else {
					$item->urlclean = htmlspecialchars($item->url);
				}

				//create flag
				if ($item->country) {
					$item->countryimg = JemHelperCountries::getCountryFlag($item->country);
				}

				//create target link
				$item->linkEventsArchived = JRoute::_(JEMHelperRoute::getVenueRoute($item->venueslug.'&task=archive'));
				$item->linkEventsPublished = JRoute::_(JEMHelperRoute::getVenueRoute($item->venueslug));

				$item->EventsPublished = $this->AssignedEvents($item->locid,'1');
				$item->EventsArchived = $this->AssignedEvents($item->locid,'2');
			}

			// Add the items to the internal cache.
			$this->cache[$store] = $items;
			return $this->cache[$store];
		}

		return array();

	}
Esempio n. 5
0
 /**
  * Method to get the events
  *
  * @access public
  * @return array
  */
 public static function getList(&$params)
 {
     mb_internal_encoding('UTF-8');
     // Retrieve Eventslist model for the data
     $model = JModelLegacy::getInstance('Eventslist', 'JemModel', array('ignore_request' => true));
     // Set params for the model
     // has to go before the getItems function
     $model->setState('params', $params);
     $model->setState('filter.access', true);
     // filter published
     //  0: unpublished
     //  1: published
     //  2: archived
     // -2: trashed
     $type = $params->get('type');
     $offset_hourss = $params->get('offset_hours', 0);
     // all upcoming or unfinished events
     if ($type == 0 || $type == 1) {
         $offset_minutes = $offset_hourss * 60;
         $model->setState('filter.published', 1);
         $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC'));
         $cal_from = "((TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > {$offset_minutes}) ";
         $cal_from .= $type == 1 ? " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > {$offset_minutes})) " : ") ";
     } elseif ($type == 2) {
         $model->setState('filter.published', 2);
         $model->setState('filter.orderby', array('a.dates DESC', 'a.times DESC'));
         $cal_from = "";
     } elseif ($type == 3) {
         $offset_days = (int) round($offset_hourss / 24);
         $model->setState('filter.published', 1);
         $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC'));
         $cal_from = " ((DATEDIFF(a.dates, CURDATE()) <= {$offset_days}) AND (DATEDIFF(IFNULL(a.enddates,a.dates), CURDATE()) >= {$offset_days}))";
     }
     $model->setState('filter.calendar_from', $cal_from);
     $model->setState('filter.groupby', 'a.id');
     // clean parameter data
     $catids = $params->get('catid');
     $venids = $params->get('venid');
     $eventids = $params->get('eventid');
     // filter category's
     if ($catids) {
         $model->setState('filter.category_id', $catids);
         $model->setState('filter.category_id.include', true);
     }
     // filter venue's
     if ($venids) {
         $model->setState('filter.venue_id', $venids);
         $model->setState('filter.venue_id.include', true);
     }
     // filter event id's
     if ($eventids) {
         $model->setState('filter.event_id', $eventids);
         $model->setState('filter.event_id.include', true);
     }
     // count
     $count = $params->get('count', '2');
     $model->setState('list.limit', $count);
     if ($params->get('use_modal', 0)) {
         JHtml::_('behavior.modal', 'a.flyermodal');
     }
     // Retrieve the available Events
     $events = $model->getItems();
     if (!$events) {
         return array();
     }
     // define list-array
     // in here we collect the row information
     $lists = array();
     $i = 0;
     $FixItemID = $params->get('FixItemID', '');
     $eventimg = $params->get('eventimg', 1);
     $venueimg = $params->get('venueimg', 1);
     /**
      * DEFINE FOREACH
      */
     foreach ($events as $row) {
         // create thumbnails if needed and receive imagedata
         if ($row->datimage) {
             $dimage = JEMImage::flyercreator($row->datimage, 'event');
         } else {
             $dimage = null;
         }
         if ($row->locimage) {
             $limage = JEMImage::flyercreator($row->locimage, 'venue');
         } else {
             $limage = null;
         }
         // cut titel
         $length = mb_strlen($row->title);
         $maxlength = $params->get('cuttitle', '18');
         if ($length > $maxlength && $maxlength > 0) {
             $row->title = mb_substr($row->title, 0, $maxlength);
             $row->title = $row->title . '...';
         }
         $lists[$i] = new stdClass();
         $lists[$i]->title = htmlspecialchars($row->title, ENT_COMPAT, 'UTF-8');
         $lists[$i]->venue = htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8');
         $lists[$i]->state = htmlspecialchars($row->state, ENT_COMPAT, 'UTF-8');
         list($lists[$i]->date, $lists[$i]->time) = modJEMwideHelper::_format_date_time($row, $params);
         if ($FixItemID) {
             $lists[$i]->eventlink = $params->get('linkevent', 1) ? JRoute::_('index.php?option=com_jem&view=event&id=' . $row->slug . '&Itemid=' . $FixItemID) : '';
             $lists[$i]->venuelink = $params->get('linkvenue', 1) ? JRoute::_('index.php?option=com_jem&view=venue&id=' . $row->venueslug . '&Itemid=' . $FixItemID) : '';
         } else {
             $lists[$i]->eventlink = $params->get('linkevent', 1) ? JRoute::_(JEMHelperRoute::getEventRoute($row->slug)) : '';
             $lists[$i]->venuelink = $params->get('linkvenue', 1) ? JRoute::_(JEMHelperRoute::getVenueRoute($row->venueslug)) : '';
         }
         $lists[$i]->catname = implode(", ", JemOutput::getCategoryList($row->categories, $params->get('linkcategory', 1), false, $FixItemID));
         // images
         if ($eventimg) {
             if ($dimage == null) {
                 $lists[$i]->eventimage = '';
                 $lists[$i]->eventimageorig = '';
             } else {
                 $lists[$i]->eventimage = JURI::base(true) . '/' . $dimage['thumb'];
                 $lists[$i]->eventimageorig = JURI::base(true) . '/' . $dimage['original'];
             }
         } else {
             $lists[$i]->eventimage = '';
             $lists[$i]->eventimageorig = '';
         }
         if ($venueimg) {
             if ($limage == null) {
                 $lists[$i]->venueimage = '';
                 $lists[$i]->venueimageorig = '';
             } else {
                 $lists[$i]->venueimage = JURI::base(true) . '/' . $limage['thumb'];
                 $lists[$i]->venueimageorig = JURI::base(true) . '/' . $limage['original'];
             }
         } else {
             $lists[$i]->venueimage = '';
             $lists[$i]->venueimageorig = '';
         }
         $lists[$i]->eventdescription = strip_tags($row->fulltext);
         $lists[$i]->venuedescription = strip_tags($row->locdescription);
         $i++;
     }
     return $lists;
 }
Esempio n. 6
0
	/**
	 * upload files for the specified object
	 *
	 * @param array data from JInput 'files'
	 * @param string object identification (should be event<eventid>, category<categoryid>, etc...)
	 */
	static function postUpload($post_files, $object)
	{
		require_once JPATH_SITE.'/components/com_jem/classes/image.class.php';

		$user = JemFactory::getUser();
		$jemsettings = JEMHelper::config();

		$path = JPATH_SITE.'/'.$jemsettings->attachments_path.'/'.$object;

		if (!(is_array($post_files) && count($post_files))) {
			return false;
		}

		$allowed = explode(",", $jemsettings->attachments_types);
		foreach ($allowed as $k => $v) {
			$allowed[$k] = trim($v);
		}

		$maxsizeinput = $jemsettings->attachments_maxsize*1024; //size in kb

		foreach ($post_files['name'] as $k => $file)
		{
			if (empty($file)) {
				continue;
			}

			// check if the filetype is valid
			$fileext = strtolower(JFile::getExt($file));
			if (!in_array($fileext, $allowed)) {
				JError::raiseWarning(0, JText::_('COM_JEM_ERROR_ATTACHEMENT_EXTENSION_NOT_ALLOWED').': '.$file);
				continue;
			}
			// check size
			if ($post_files['size'][$k] > $maxsizeinput) {
				JError::raiseWarning(0, JText::sprintf('COM_JEM_ERROR_ATTACHEMENT_FILE_TOO_BIG', $file, $post_files['size'][$k], $maxsizeinput));
				continue;
			}

			if (!JFolder::exists($path)) {
				// try to create it
				$res = JFolder::create($path);
				if (!$res) {
					JError::raiseWarning(0, JText::_('COM_JEM_ERROR_COULD_NOT_CREATE_FOLDER').': '.$path);
					return false;
				}
			}

			// TODO: Probably move this to a helper class

			$sanitizedFilename = JEMImage::sanitize($path, $file);

			// Make sure that the full file path is safe.
			$filepath = JPath::clean( $path.'/'.$sanitizedFilename);
			// Since Joomla! 3.4.0 JFile::upload has some more params to control new security parsing
			// Unfortunately this parsing is partially stupid so it may reject archives for non-understandable reason.
			if (version_compare(JVERSION, '3.4', 'lt')) {
				JFile::upload($post_files['tmp_name'][$k], $filepath);
			} else {
				// switch off parsing archives for byte sequences looking like a script file extension
				// but keep all other checks running
				JFile::upload($post_files['tmp_name'][$k], $filepath, false, false, array('fobidden_ext_in_content' => false));
			}

			$table = JTable::getInstance('jem_attachments', '');
			$table->file = $sanitizedFilename;
			$table->object = $object;
			if (isset($post_files['customname'][$k]) && !empty($post_files['customname'][$k])) {
				$table->name = $post_files['customname'][$k];
			}
			if (isset($post_files['description'][$k]) && !empty($post_files['description'][$k])) {
				$table->description = $post_files['description'][$k];
			}
			if (isset($post_files['access'][$k])) {
				$table->access = intval($post_files['access'][$k]);
			}
			$table->added = strftime('%F %T');
			$table->added_by = $user->get('id');

			if (!($table->check() && $table->store())) {
				JError::raiseWarning(0, JText::_('COM_JEM_ATTACHMENT_ERROR_SAVING_TO_DB').': '.$table->getError());
			}
		}

		return true;
	}
Esempio n. 7
0
 /**
  * Method to get the events
  *
  * @access public
  * @return array
  */
 public static function getList(&$params)
 {
     mb_internal_encoding('UTF-8');
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $levels = $user->getAuthorisedViewLevels();
     # Retrieve Eventslist model for the data
     $model = JModelLegacy::getInstance('Eventslist', 'JemModel', array('ignore_request' => true));
     # Set params for the model
     # has to go before the getItems function
     $model->setState('params', $params);
     # filter published
     #  0: unpublished
     #  1: published
     #  2: archived
     # -2: trashed
     $type = (int) $params->get('type');
     $offset_hours = (int) $params->get('offset_hours', 0);
     $max_title_length = (int) $params->get('cuttitle', '25');
     # clean parameter data
     $catids = JemHelper::getValidIds($params->get('catid'));
     $venids = JemHelper::getValidIds($params->get('venid'));
     # all upcoming or unfinished events
     if ($type == 0 || $type == 1) {
         $offset_minutes = $offset_hours * 60;
         $model->setState('filter.published', 1);
         $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC'));
         $cal_from = "((TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'23:59:59'))) > {$offset_minutes}) ";
         $cal_from .= $type == 1 ? " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > {$offset_minutes})) " : ") ";
     } elseif ($type == 2) {
         $model->setState('filter.published', 2);
         $model->setState('filter.orderby', array('a.dates DESC', 'a.times DESC'));
         $cal_from = "";
     } elseif ($type == 3) {
         $offset_days = (int) round($offset_hours / 24);
         $model->setState('filter.published', 1);
         $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC'));
         $cal_from = " ((DATEDIFF(a.dates, CURDATE()) <= {$offset_days}) AND (DATEDIFF(IFNULL(a.enddates,a.dates), CURDATE()) >= {$offset_days}))";
     }
     $model->setState('filter.calendar_from', $cal_from);
     $model->setState('filter.groupby', 'a.id');
     # filter category's
     if ($catids) {
         $model->setState('filter.category_id', $catids);
         $model->setState('filter.category_id.include', true);
     }
     # filter venue's
     if ($venids) {
         $model->setState('filter.venue_id', $venids);
         $model->setState('filter.venue_id.include', true);
     }
     # count
     $count = $params->get('count', '2');
     $model->setState('list.limit', $count);
     if ($params->get('use_modal', 0)) {
         JHtml::_('behavior.modal', 'a.flyermodal');
     }
     # date/time
     $dateFormat = $params->get('formatdate', '');
     $timeFormat = $params->get('formattime', '');
     $addSuffix = empty($timeFormat);
     // if we use component's default time format we can also add corresponding suffix
     # Retrieve the available Events
     $events = $model->getItems();
     # Loop through the result rows and prepare data
     $lists = array();
     $i = 0;
     foreach ($events as $row) {
         # create thumbnails if needed and receive imagedata
         $dimage = $row->datimage ? JEMImage::flyercreator($row->datimage, 'event') : null;
         $limage = $row->locimage ? JEMImage::flyercreator($row->locimage, 'venue') : null;
         #################
         ## DEFINE LIST ##
         #################
         $lists[$i] = new stdClass();
         # cut titel
         $fulltitle = htmlspecialchars($row->title, ENT_COMPAT, 'UTF-8');
         if (mb_strlen($fulltitle) > $max_title_length) {
             $title = mb_substr($fulltitle, 0, $max_title_length) . '...';
         } else {
             $title = $fulltitle;
         }
         ## Also trim venue name to same as title
         $fullvenuename = htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8');
         if (mb_strlen($fullvenuename) > $max_title_length) {
             $venue = mb_substr($fullvenuename, 0, $max_title_length) . '...';
         } else {
             $venue = $fullvenuename;
         }
         $lists[$i]->title = $title;
         $lists[$i]->fulltitle = $fulltitle;
         $lists[$i]->venue = $venue;
         $lists[$i]->fullvenue = $fullvenuename;
         $lists[$i]->catname = implode(", ", JemOutput::getCategoryList($row->categories, $params->get('linkcategory', 1)));
         $lists[$i]->state = htmlspecialchars($row->state, ENT_COMPAT, 'UTF-8');
         $lists[$i]->city = htmlspecialchars($row->city, ENT_COMPAT, 'UTF-8');
         $lists[$i]->eventlink = $params->get('linkevent', 1) ? JRoute::_(JEMHelperRoute::getEventRoute($row->slug)) : '';
         $lists[$i]->venuelink = $params->get('linkvenue', 1) ? JRoute::_(JEMHelperRoute::getVenueRoute($row->venueslug)) : '';
         # time/date
         list($lists[$i]->date, $lists[$i]->time) = self::_format_date_time($row, $params->get('datemethod', 1), $dateFormat, $timeFormat, $addSuffix);
         $lists[$i]->dateinfo = JEMOutput::formatDateTime($row->dates, $row->times, $row->enddates, $row->endtimes, $dateFormat, $timeFormat, $addSuffix);
         if ($dimage == null) {
             $lists[$i]->eventimage = JUri::base(true) . '/media/system/images/blank.png';
             $lists[$i]->eventimageorig = JUri::base(true) . '/media/system/images/blank.png';
         } else {
             $lists[$i]->eventimage = JUri::base(true) . '/' . $dimage['thumb'];
             $lists[$i]->eventimageorig = JUri::base(true) . '/' . $dimage['original'];
         }
         if ($limage == null) {
             $lists[$i]->venueimage = JUri::base(true) . '/media/system/images/blank.png';
             $lists[$i]->venueimageorig = JUri::base(true) . '/media/system/images/blank.png';
         } else {
             $lists[$i]->venueimage = JUri::base(true) . '/' . $limage['thumb'];
             $lists[$i]->venueimageorig = JUri::base(true) . '/' . $limage['original'];
         }
         $lists[$i]->eventdescription = strip_tags($row->fulltext);
         $lists[$i]->venuedescription = strip_tags($row->locdescription);
         $i++;
     }
     // foreach ($events as $row)
     return $lists;
 }
Esempio n. 8
0
 /**
  * Method to get the events
  *
  * @access public
  * @return array
  */
 public static function getList(&$params)
 {
     mb_internal_encoding('UTF-8');
     // Retrieve Eventslist model for the data
     $model = JModelLegacy::getInstance('Eventslist', 'JemModel', array('ignore_request' => true));
     // Set params for the model
     // has to go before the getItems function
     $model->setState('params', $params);
     $model->setState('filter.access', true);
     // filter published
     //  0: unpublished
     //  1: published
     //  2: archived
     // -2: trashed
     $type = $params->get('type');
     $offset_hourss = $params->get('offset_hours', 0);
     // all upcoming events
     if ($type == 0 || $type == 1) {
         $offset_minutes = $offset_hourss * 60;
         $model->setState('filter.published', 1);
         $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC'));
         $cal_from = "((TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > {$offset_minutes}) ";
         $cal_from .= $type == 1 ? " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > {$offset_minutes})) " : ") ";
     } elseif ($type == 2) {
         $model->setState('filter.published', 2);
         $model->setState('filter.orderby', array('a.dates DESC', 'a.times DESC'));
         $cal_from = "";
     } elseif ($type == 3) {
         $offset_days = (int) round($offset_hourss / 24);
         $model->setState('filter.published', 1);
         $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC'));
         $cal_from = " ((DATEDIFF(a.dates, CURDATE()) <= {$offset_days}) AND (DATEDIFF(IFNULL(a.enddates,a.dates), CURDATE()) >= {$offset_days}))";
     } elseif ($type == 4) {
         $offset_minutes = $offset_hourss * 60;
         $model->setState('filter.featured', 1);
         $model->setState('filter.orderby', array('a.dates ASC', 'a.times ASC'));
         $cal_from = "((TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(a.dates,' ',IFNULL(a.times,'00:00:00'))) > {$offset_minutes}) ";
         $cal_from .= " OR (TIMESTAMPDIFF(MINUTE, NOW(), CONCAT(IFNULL(a.enddates,a.dates),' ',IFNULL(a.endtimes,'23:59:59'))) > {$offset_minutes})) ";
     }
     $model->setState('filter.calendar_from', $cal_from);
     $model->setState('filter.groupby', 'a.id');
     // clean parameter data
     $catids = $params->get('catid');
     $venids = $params->get('venid');
     $eventids = $params->get('eventid');
     // filter category's
     if ($catids) {
         $model->setState('filter.category_id', $catids);
         $model->setState('filter.category_id.include', true);
     }
     // filter venue's
     if ($venids) {
         $model->setState('filter.venue_id', $venids);
         $model->setState('filter.venue_id.include', true);
     }
     // filter event id's
     if ($eventids) {
         $model->setState('filter.event_id', $eventids);
         $model->setState('filter.event_id.include', true);
     }
     // count
     $count = $params->get('count', '2');
     if ($params->get('use_modal', 0)) {
         JHtml::_('behavior.modal', 'a.flyermodal');
     }
     $model->setState('list.limit', $count);
     // Retrieve the available Events
     $events = $model->getItems();
     if (!$events) {
         return array();
     }
     // Loop through the result rows and prepare data
     $i = 0;
     $lists = array();
     $FixItemID = $params->get('FixItemID', '');
     $eventimg = $params->get('eventimg', 1);
     $venueimg = $params->get('venueimg', 1);
     foreach ($events as $row) {
         // create thumbnails if needed and receive imagedata
         if ($row->datimage) {
             $dimage = JEMImage::flyercreator($row->datimage, 'event');
         } else {
             $dimage = null;
         }
         if ($row->locimage) {
             $limage = JEMImage::flyercreator($row->locimage, 'venue');
         } else {
             $limage = null;
         }
         // cut titel
         $length = mb_strlen($row->title);
         $maxlength = $params->get('cuttitle', '18');
         if ($length > $maxlength && $maxlength > 0) {
             $row->title = mb_substr($row->title, 0, $maxlength);
             $row->title = $row->title . '...';
         }
         /**
          * DEFINE LIST
          **/
         $settings = JEMHelper::globalattribs();
         $access = !$settings->get('show_noauth', '0');
         $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id'));
         $lists[$i] = new stdClass();
         $lists[$i]->title = htmlspecialchars($row->title, ENT_COMPAT, 'UTF-8');
         $lists[$i]->venue = htmlspecialchars($row->venue, ENT_COMPAT, 'UTF-8');
         $lists[$i]->state = htmlspecialchars($row->state, ENT_COMPAT, 'UTF-8');
         $lists[$i]->city = htmlspecialchars($row->city, ENT_COMPAT, 'UTF-8');
         // time/date
         $lists[$i]->date = modJEMteaserHelper::_format_date($row, $params);
         $lists[$i]->day = modJEMteaserHelper::_format_day($row, $params);
         $lists[$i]->dayname = modJEMteaserHelper::_format_dayname($row);
         $lists[$i]->daynum = modJEMteaserHelper::_format_daynum($row);
         $lists[$i]->month = modJEMteaserHelper::_format_month($row);
         $lists[$i]->year = modJEMteaserHelper::_format_year($row);
         $lists[$i]->time = $row->times ? modJEMteaserHelper::_format_time($row->dates, $row->times, $params) : '';
         if ($access || in_array($row->access, $authorised)) {
             // We know that user has the privilege to view the event
             if ($FixItemID) {
                 $lists[$i]->link = JRoute::_('index.php?option=com_jem&view=event&id=' . $row->slug . '&Itemid=' . $FixItemID);
             } else {
                 $lists[$i]->link = JRoute::_(JEMHelperRoute::getEventRoute($row->slug));
             }
             $lists[$i]->linkText = JText::_('MOD_JEM_TEASER_READMORE');
         } else {
             $lists[$i]->link = JRoute::_('index.php?option=com_users&view=login');
             $lists[$i]->linkText = JText::_('MOD_JEM_TEASER_READMORE_REGISTER');
         }
         if ($FixItemID) {
             $lists[$i]->eventlink = $params->get('linkevent', 1) ? JRoute::_('index.php?option=com_jem&view=event&id=' . $row->slug . '&Itemid=' . $FixItemID) : '';
             $lists[$i]->venuelink = $params->get('linkvenue', 1) ? JRoute::_('index.php?option=com_jem&view=venue&id=' . $row->venueslug . '&Itemid=' . $FixItemID) : '';
         } else {
             $lists[$i]->eventlink = $params->get('linkevent', 1) ? JRoute::_(JEMHelperRoute::getEventRoute($row->slug)) : '';
             $lists[$i]->venuelink = $params->get('linkvenue', 1) ? JRoute::_(JEMHelperRoute::getVenueRoute($row->venueslug)) : '';
         }
         $lists[$i]->catname = implode(", ", JemOutput::getCategoryList($row->categories, $params->get('linkcategory', 1), false, $FixItemID));
         // images
         if ($eventimg) {
             if ($dimage == null) {
                 $lists[$i]->eventimage = '';
                 $lists[$i]->eventimageorig = '';
             } else {
                 $lists[$i]->eventimage = JURI::base(true) . '/' . $dimage['thumb'];
                 $lists[$i]->eventimageorig = JURI::base(true) . '/' . $dimage['original'];
             }
         } else {
             $lists[$i]->eventimage = '';
             $lists[$i]->eventimageorig = '';
         }
         if ($venueimg) {
             if ($limage == null) {
                 $lists[$i]->venueimage = '';
                 $lists[$i]->venueimageorig = '';
             } else {
                 $lists[$i]->venueimage = JURI::base(true) . '/' . $limage['thumb'];
                 $lists[$i]->venueimageorig = JURI::base(true) . '/' . $limage['original'];
             }
         } else {
             $lists[$i]->venueimage = '';
             $lists[$i]->venueimageorig = '';
         }
         $length = $params->get('descriptionlength');
         $length2 = 1;
         $etc = '...';
         $etc2 = JText::_('MOD_JEM_TEASER_NO_DESCRIPTION');
         //strip html tags but leave <br /> tags
         $description = strip_tags($row->introtext, "<br>");
         //switch <br /> tags to space character
         if ($params->get('br') == 0) {
             $description = str_replace('<br />', ' ', $description);
         }
         //
         if (strlen($description) > $length) {
             $length -= strlen($etc);
             $description = preg_replace('/\\s+?(\\S+)?$/', '', substr($description, 0, $length + 1));
             $lists[$i]->eventdescription = substr($description, 0, $length) . $etc;
         } else {
             if (strlen($description) < $length2) {
                 $length -= strlen($etc2);
                 $description = preg_replace('/\\s+?(\\S+)?$/', '', substr($description, 0, $length + 1));
                 $lists[$i]->eventdescription = substr($description, 0, $length) . $etc2;
             } else {
                 $lists[$i]->eventdescription = $description;
             }
         }
         $lists[$i]->readmore = strlen(trim($row->fulltext));
         $i++;
     }
     return $lists;
 }
Esempio n. 9
0
 /**
  * Store
  */
 public function store($updateNulls = false)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     $app = JFactory::getApplication();
     $jinput = JFactory::getApplication()->input;
     $jemsettings = JEMHelper::config();
     // Check if we're in the front or back
     if ($app->isAdmin()) {
         $backend = true;
     } else {
         $backend = false;
     }
     if ($this->id) {
         // Existing event
         $this->modified = $date->toSql();
         $this->modified_by = $user->get('id');
     } else {
         // New event
         if (!intval($this->created)) {
             $this->created = $date->toSql();
         }
         if (empty($this->created_by)) {
             $this->created_by = $user->get('id');
         }
     }
     // Check if image was selected
     jimport('joomla.filesystem.file');
     $image_dir = JPATH_SITE . '/images/jem/venues/';
     $allowable = array('gif', 'jpg', 'png');
     // get image (frontend) - allow "removal on save" (Hoffi, 2014-06-07)
     if (!$backend) {
         if ($jemsettings->imageenabled == 2 || $jemsettings->imageenabled == 1) {
             $file = JFactory::getApplication()->input->files->get('userfile', '', 'array');
             $removeimage = JFactory::getApplication()->input->get('removeimage', '', 'int');
             if (!empty($file['name'])) {
                 //check the image
                 $check = JEMImage::check($file, $jemsettings);
                 if ($check !== false) {
                     //sanitize the image filename
                     $filename = JemHelper::sanitize($image_dir, $file['name']);
                     $filepath = $image_dir . $filename;
                     if (JFile::upload($file['tmp_name'], $filepath)) {
                         $image_to_delete = $this->locimage;
                         // delete previous image
                         $this->locimage = $filename;
                     }
                 }
             } elseif (!empty($removeimage)) {
                 // if removeimage is non-zero remove image from venue
                 // (file will be deleted later (e.g. housekeeping) if unused)
                 $image_to_delete = $this->locimage;
                 $this->locimage = '';
             }
         }
         // end image if
     }
     // if (!backend)
     $format = JFile::getExt($image_dir . $this->locimage);
     if (!in_array($format, $allowable)) {
         $this->locimage = '';
     }
     /*
     if (!$backend) {
     	#	check if the user has the required rank for autopublish
     	$autopublgroups = JEMUser::venuegroups('publish');
     	$autopublloc 	= JEMUser::validate_user($jemsettings->locpubrec, $jemsettings->autopublocate);
     	if (!($autopublloc || $autopublgroups || $user->authorise('core.edit','com_jem'))) {
     		$this->published = 0;
     	}
     }
     */
     return parent::store($updateNulls);
 }
Esempio n. 10
0
		<?php 
    echo $this->escape($this->params->get('page_heading'));
    ?>
		</h1>
	<?php 
}
?>
	<div class="clr"> </div>

	<?php 
foreach ($this->rows as $row) {
    ?>

		<?php 
    // Create image information
    $row->limage = JEMImage::flyercreator($row->locimage, 'venue');
    //Generate Venuedescription
    if (!$row->locdescription == '' || !$row->locdescription == '<br />') {
        //execute plugins
        $row->text = $row->locdescription;
        $row->title = $row->venue;
        JPluginHelper::importPlugin('content');
        $this->app->triggerEvent('onContentPrepare', array('com_jem.venue', &$row, &$params, 0));
        $row->locdescription = $row->text;
    }
    //prepare the url for output
    // TODO: Should be part of view! Then use $this->escape()
    if (strlen($row->url) > 35) {
        $row->urlclean = htmlspecialchars(substr($row->url, 0, 35)) . '...';
    } else {
        $row->urlclean = htmlspecialchars($row->url);
Esempio n. 11
0
	/**
	 * Overloaded store method for the Venue table.
	 */
	public function store($updateNulls = false)
	{
		$date        = JFactory::getDate();
		$user        = JemFactory::getUser();
		$userid      = $user->get('id');
		$app         = JFactory::getApplication();
		$jinput      = $app->input;
		$jemsettings = JEMHelper::config();

		// Check if we're in the front or back
		if ($app->isAdmin())
			$backend = true;
		else
			$backend = false;


		if ($this->id) {
			// Existing event
			$this->modified = $date->toSql();
			$this->modified_by = $userid;
		}
		else
		{
			// New event
			if (!intval($this->created)){
				$this->created = $date->toSql();
			}
			if (empty($this->created_by)){
				$this->created_by = $userid;
			}
		}


		// Check if image was selected
		jimport('joomla.filesystem.file');
		$image_dir = JPATH_SITE.'/images/jem/venues/';
		$allowable = array ('gif', 'jpg', 'png');
		$image_to_delete = false;

		// get image (frontend) - allow "removal on save" (Hoffi, 2014-06-07)
		if (!$backend) {
			if (($jemsettings->imageenabled == 2 || $jemsettings->imageenabled == 1)) {
				$file = $jinput->files->get('userfile', array(), 'array');
				$removeimage = $jinput->getInt('removeimage', 0);

				if (!empty($file['name'])) {
					//check the image
					$check = JEMImage::check($file, $jemsettings);

					if ($check !== false) {
						//sanitize the image filename
						$filename = JEMImage::sanitize($image_dir, $file['name']);
						$filepath = $image_dir . $filename;

						if (JFile::upload($file['tmp_name'], $filepath)) {
							$image_to_delete = $this->locimage; // delete previous image
							$this->locimage = $filename;
						}
					}
				} elseif (!empty($removeimage)) {
					// if removeimage is non-zero remove image from venue
					// (file will be deleted later (e.g. housekeeping) if unused)
					$image_to_delete = $this->locimage;
					$this->locimage = '';
				}
			} // end image if
		} // if (!backend)

		$format = JFile::getExt($image_dir . $this->locimage);
		if (!in_array($format, $allowable))
		{
			$this->locimage = '';
		}

		if (!$backend) {
			/* check if the user has the required rank for autopublish new venues */
			if (!$this->id && !$user->can('publish', 'venue', $this->id, $this->created_by)) {
				$this->published = 0;
			}
		}

		// item must be stored BEFORE image deletion
		$ret = parent::store($updateNulls);
		if ($ret && $image_to_delete) {
			JemHelper::delete_unused_image_files('venue', $image_to_delete);
		}

		return $ret;
	}
Esempio n. 12
0
 /**
  * Store
  */
 public function store($updateNulls = true)
 {
     $date = JFactory::getDate();
     $user = JFactory::getUser();
     $jinput = JFactory::getApplication()->input;
     $app = JFactory::getApplication();
     $jemsettings = JEMHelper::config();
     $settings = JemHelper::globalattribs();
     $valguest = JEMUser::validate_guest();
     $guest_fldstatus = $settings->get('guest_fldstatus', '0');
     // Check if we're in the front or back
     if ($app->isAdmin()) {
         $backend = true;
     } else {
         $backend = false;
     }
     if ($this->id) {
         // Existing event
         $this->modified = $date->toSql();
         $this->modified_by = $user->get('id');
     } else {
         // New event
         if (!intval($this->created)) {
             $this->created = $date->toSql();
         }
         if (empty($this->created_by)) {
             $this->created_by = $user->get('id');
         }
     }
     // Check if image was selected
     jimport('joomla.filesystem.file');
     $image_dir = JPATH_SITE . '/images/jem/events/';
     $allowable = array('gif', 'jpg', 'png');
     $image_to_delete = false;
     // get image (frontend) - allow "removal on save" (Hoffi, 2014-06-07)
     if (!$backend) {
         if ($jemsettings->imageenabled == 2 || $jemsettings->imageenabled == 1) {
             $file = JFactory::getApplication()->input->files->get('userfile', '', 'array');
             $removeimage = JFactory::getApplication()->input->get('removeimage', '', 'int');
             if (!empty($file['name'])) {
                 //check the image
                 $check = JEMImage::check($file, $jemsettings);
                 if ($check !== false) {
                     //sanitize the image filename
                     $filename = JemHelper::sanitize($image_dir, $file['name']);
                     $filepath = $image_dir . $filename;
                     if (JFile::upload($file['tmp_name'], $filepath)) {
                         $image_to_delete = $this->datimage;
                         // delete previous image
                         $this->datimage = $filename;
                     }
                 }
             } elseif (!empty($removeimage)) {
                 // if removeimage is non-zero remove image from event
                 // (file will be deleted later (e.g. housekeeping) if unused)
                 $image_to_delete = $this->datimage;
                 $this->datimage = '';
             }
         }
         // end image if
     }
     // if (!backend)
     $format = JFile::getExt($image_dir . $this->datimage);
     if (!in_array($format, $allowable)) {
         $this->datimage = '';
     }
     if (!$backend) {
         /*	check if the user has the required rank for autopublish	*/
         $maintainer = JEMUser::ismaintainer('publish');
         $autopubev = JEMUser::validate_user($jemsettings->evpubrec, $jemsettings->autopubl);
         if (!($autopubev || $maintainer || $user->authorise('core.edit', 'com_jem'))) {
             if ($valguest) {
                 $this->published = $guest_fldstatus;
             } else {
                 $this->published = 0;
             }
         }
     }
     ################
     ## RECURRENCE ##
     ################
     # check if recurrence_groupcheck is true
     $rec_groupcheck = $jinput->getInt('recurrence_check');
     if ($rec_groupcheck) {
         # the check returned true, so it's considered as an edit
         # Retrieve id of current event from recurrence_table
         # as the check was true we can skip the groupid=groupid_ref from the where statement
         # but to be sure it's added here too
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select('id');
         $query->from($db->quoteName('#__jem_recurrence'));
         $query->where(array('groupid = groupid_ref ', 'itemid= ' . $this->id));
         $db->setQuery($query);
         $recurrenceid = $db->loadResult();
         if ($recurrenceid) {
             # Retrieve recurrence-table
             $recurrence_table = JTable::getInstance('Recurrence', 'JEMTable');
             # Load row-data
             $recurrence_table->load($recurrenceid);
             # We want to skip this event from Ical output
             /* $recurrence_table->exdate = $this->dates.'T'.$this->times; */
             # it's a delete of the set so groupid_ref will be blanked
             /* $recurrence_table->groupid_ref = ""; */
             # it's an edit and not a delete so groupid_ref won't be adjusted
             # but we will set the recurrence_id field, as this event has been adjusted and contains
             # info that's not inline with original recurrence-info
             $var2 = $recurrence_table->startdate_org;
             $var3 = new JDate($var2);
             $var4 = $var3->format('Ymd\\THis\\Z');
             $recurrence_table->recurrence_id = $var4;
             # Store fields
             $recurrence_table->store();
         }
     }
     # check if the field recurrence_group is filled and if the recurrence_type has been set
     # if the type has been set then it's part of recurrence and we should have a recurrence_group number
     if (empty($this->recurrence_group) && $this->recurrence_freq) {
         $this->recurrence_group = mt_rand(0, 9999);
     }
     ## END RECURRENCE ##
     return parent::store($updateNulls);
 }
Esempio n. 13
0
	/**
	 * Creates image information of an image
	 *
	 * @param string $image The image name
	 * @param array $settings
	 * @param string $type event or venue
	 *
	 * @return imagedata if available
	 */
	static function flyercreator($image, $type)
	{
		$settings = JEMHelper::config();

		//define the environment based on the type
		if ($type == 'event') {
			$folder = 'events';
		} else if ($type == 'category') {
			$folder = 'categories';
		} else if ($type == 'venue') {
			$folder = 'venues';
		}

		if ($image) {
			//Create thumbnail if enabled and it does not exist already
			if ($settings->gddisabled == 1 && !file_exists(JPATH_SITE.'/images/jem/'.$folder.'/small/'.$image)) {

				$filepath 	= JPATH_SITE.'/images/jem/'.$folder.'/'.$image;
				$save 		= JPATH_SITE.'/images/jem/'.$folder.'/small/'.$image;

				JEMImage::thumb($filepath, $save, $settings->imagewidth, $settings->imagehight);
			}

			//set paths
			$dimage['original'] = 'images/jem/'.$folder.'/'.$image;
			$dimage['thumb'] 	= 'images/jem/'.$folder.'/small/'.$image;

			//TODO: What is "limage" and "cimage" for?
			//set paths
			$limage['original'] = 'images/jem/'.$folder.'/'.$image;
			$limage['thumb'] 	= 'images/jem/'.$folder.'/small/'.$image;

			//set paths
			$cimage['original'] = 'images/jem/'.$folder.'/'.$image;
			$cimage['thumb'] 	= 'images/jem/'.$folder.'/small/'.$image;

			//get imagesize of the original
			$iminfo = @getimagesize('images/jem/'.$folder.'/'.$image);

			//if the width or height is too large this formula will resize them accordingly
			if (($iminfo[0] > $settings->imagewidth) || ($iminfo[1] > $settings->imagehight)) {

				$iRatioW = $settings->imagewidth / $iminfo[0];
				$iRatioH = $settings->imagehight / $iminfo[1];

				if ($iRatioW < $iRatioH) {
					$dimage['width'] 	= round($iminfo[0] * $iRatioW);
					$dimage['height'] 	= round($iminfo[1] * $iRatioW);
					$limage['width'] 	= round($iminfo[0] * $iRatioW);
					$limage['height'] 	= round($iminfo[1] * $iRatioW);
					$cimage['width'] 	= round($iminfo[0] * $iRatioW);
					$cimage['height'] 	= round($iminfo[1] * $iRatioW);
				} else {
					$dimage['width'] 	= round($iminfo[0] * $iRatioH);
					$dimage['height'] 	= round($iminfo[1] * $iRatioH);
					$limage['width'] 	= round($iminfo[0] * $iRatioH);
					$limage['height'] 	= round($iminfo[1] * $iRatioH);
					$cimage['width'] 	= round($iminfo[0] * $iRatioH);
					$cimage['height'] 	= round($iminfo[1] * $iRatioH);
				}
			} else {
				$dimage['width'] 	= $iminfo[0];
				$dimage['height'] 	= $iminfo[1];
				$limage['width'] 	= $iminfo[0];
				$limage['height'] 	= $iminfo[1];
				$cimage['width'] 	= $iminfo[0];
				$cimage['height'] 	= $iminfo[1];
			}

			if (JFile::exists(JPATH_SITE.'/images/jem/'.$folder.'/small/'.$image)) {
				//get imagesize of the thumbnail
				$thumbiminfo = @getimagesize('images/jem/'.$folder.'/small/'.$image);
				$dimage['thumbwidth'] 	= $thumbiminfo[0];
				$dimage['thumbheight'] 	= $thumbiminfo[1];
				$limage['thumbwidth'] 	= $thumbiminfo[0];
				$limage['thumbheight'] 	= $thumbiminfo[1];
				$cimage['thumbwidth'] 	= $thumbiminfo[0];
				$cimage['thumbheight'] 	= $thumbiminfo[1];
			}
			return $dimage;
			return $limage;
			return $cimage;
		}
		return false;
	}