Example #1
0
	/**
	 * Constructor
	 *
	 */
	public function __construct()
	{
		parent::__construct();

		$app = JFactory::getApplication();
		$jemsettings = JEMHelper::config();

		//get the number of events from database
		$limit		= $app->getUserStateFromRequest('com_jem.search.limit', 'limit', $jemsettings->display_num, 'int');
		$limitstart	= $app->input->getInt('limitstart', 0);
		// correct start value if required
		$limitstart = $limit ? (int)(floor($limitstart / $limit) * $limit) : 0;

		$this->setState('limit', $limit);
		$this->setState('limitstart', $limitstart);

		// Get the filter request variables
		$filter_order = $app->input->getCmd('filter_order', 'a.dates');
		$this->setState('filter_order', $filter_order);

		$filter_order_DirDefault = 'ASC';
		// Reverse default order for dates in archive mode
		$task = $app->input->get('task', '');
		if (($task == 'archive') && ($filter_order == 'a.dates')) {
			$filter_order_DirDefault = 'DESC';
		}
		$this->setState('filter_order_Dir', $app->input->getCmd('filter_order_Dir', $filter_order_DirDefault));
	}
Example #2
0
	/**
	 * Constructor
	 *
	 */
	public function __construct()
	{
		parent::__construct();

		$app         = JFactory::getApplication();
		$jemsettings = JEMHelper::config();
		$settings    = JEMHelper::globalattribs();

		$id = $app->input->getInt('id', 0);
		$this->setId((int)$id);

		$this->_reguser = $settings->get('global_regname', '1');

		/* in J! 3.3.6 limitstart is removed from request - but we need it! */
		if ($app->input->getInt('limitstart', null) === null) {
			$app->setUserState('com_jem.attendees.limitstart', 0);
		}

		$limit		= $app->getUserStateFromRequest( 'com_jem.attendees.limit', 'limit', $jemsettings->display_num, 'int');
		$limitstart = $app->getUserStateFromRequest( 'com_jem.attendees.limitstart', 'limitstart', 0, 'int' );
		// correct start value if required
		$limitstart = $limit ? (int)(floor($limitstart / $limit) * $limit) : 0;

		$this->setState('limit', $limit);
		$this->setState('limitstart', $limitstart);

		//set unlimited if export or print action | task=export or task=print
		$task = $app->input->get('task', '');
		$this->setState('unlimited', ($task == 'export' || $task == 'print') ? '1' : '');
	}
Example #3
0
 public function display($tpl = null)
 {
     // Initialise variables.
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     JHtml::_('behavior.framework');
     // initialise variables
     $jemsettings = JEMHelper::config();
     $document = JFactory::getDocument();
     $this->settings = JEMAdmin::config();
     $task = JFactory::getApplication()->input->get('task');
     $this->task = $task;
     $url = JUri::root();
     // Load css
     JHtml::_('stylesheet', 'com_jem/backend.css', array(), true);
     // JQuery noConflict
     $document->addCustomTag('<script type="text/javascript">jQuery.noConflict();</script>');
     $document->addScript('http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js');
     $document->addScript('http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js');
     $this->jemsettings = $jemsettings;
     $this->addToolbar();
     parent::display($tpl);
 }
Example #4
0
 public function display($tpl = null)
 {
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseError(500, implode("\n", $errors));
         return false;
     }
     $jemsettings = JEMHelper::config();
     $document = JFactory::getDocument();
     $this->settings = JEMAdmin::config();
     $task = JFactory::getApplication()->input->get('task');
     $this->task = $task;
     $url = JUri::root();
     // Load css
     JHtml::_('stylesheet', 'com_jem/backend.css', array(), true);
     $maintainers = $this->get('Members');
     $available_users = $this->get('Available');
     //make data safe
     JFilterOutput::objectHTMLSafe($this->item);
     //create selectlists
     $lists = array();
     $lists['maintainers'] = JHtml::_('select.genericlist', $maintainers, 'maintainers[]', array('class' => 'inputbox', 'size' => '20', 'onDblClick' => 'moveOptions(document.adminForm[\'maintainers[]\'], document.adminForm[\'available_users\'])', 'multiple' => 'multiple', 'style' => 'padding: 6px; width: 250px;'), 'value', 'text');
     $lists['available_users'] = JHtml::_('select.genericlist', $available_users, 'available_users', array('class' => 'inputbox', 'size' => '20', 'onDblClick' => 'moveOptions(document.adminForm[\'available_users\'], document.adminForm[\'maintainers[]\'])', 'multiple' => 'multiple', 'style' => 'padding: 6px; width: 250px;'), 'value', 'text');
     $this->jemsettings = $jemsettings;
     $this->lists = $lists;
     $this->addToolbar();
     parent::display($tpl);
 }
Example #5
0
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     $app = JFactory::getApplication();
     $jemsettings = JEMHelper::config();
     $jinput = JFactory::getApplication()->input;
     $itemid = $jinput->getInt('id', 0) . ':' . $jinput->getInt('Itemid', 0);
     $limit = $app->getUserStateFromRequest('com_jem.myvenues.' . $itemid . '.limit', 'limit', $jemsettings->display_num, 'uint');
     $limitstart = $app->input->get('limitstart', 0, 'uint');
     $this->setState('limit', $limit);
     $this->setState('limitstart', $limitstart);
 }
Example #6
0
	/**
	 * Method to get venue data.
	 *
	 * @param integer	The id of the venue.
	 * @return mixed item data object on success, false on failure.
	 */
	public function getItem($itemId = null)
	{
		$jemsettings = JEMHelper::config();

		// Initialise variables.
		$itemId = (int) (!empty($itemId)) ? $itemId : $this->getState('venue.id');

		// Get a row instance.
		$table = $this->getTable();

		// Attempt to load the row.
		$return = $table->load($itemId);

		// Check for a table object error.
		if ($return === false && $table->getError()) {
			$this->setError($table->getError());
			return false;
		}

		$properties = $table->getProperties(1);
		$value = JArrayHelper::toObject($properties, 'JObject');

		// Convert attrib field to Registry.
		//$registry = new JRegistry();
		//$registry->loadString($value->attribs);

		$globalregistry = JemHelper::globalattribs();

		$value->params = clone $globalregistry;
		//$value->params->merge($registry);

		// Compute selected asset permissions.
		$user = JemFactory::getUser();

		// Check edit permission.
		$value->params->set('access-edit', $user->can('edit', 'venue', $value->id, $value->created_by));

		// Check edit state permission.
		$value->params->set('access-change', $user->can('publish', 'venue', $value->id, $value->created_by));

		$value->author_ip = $jemsettings->storeip ? JemHelper::retrieveIP() : false;

		$files = JemAttachment::getAttachments('venue' . $itemId);
		$value->attachments = $files;

		if (empty($itemId)) {
			$value->country = $jemsettings->defaultCountry;
		}

		return $value;
	}
 /**
  * Constructor
  */
 public function __construct()
 {
     $app = JFactory::getApplication();
     $jemsettings = JEMHelper::config();
     $itemid = $app->input->getInt('id', 0) . ':' . $app->input->getInt('Itemid', 0);
     // Get the parameters of the active menu item
     $params = $app->getParams();
     $id = $app->input->getInt('id', 0);
     if (empty($id)) {
         $id = $params->get('id', 1);
     }
     $this->setId((int) $id);
     parent::__construct();
 }
Example #8
0
 /**
  * Constructor
  *
  */
 public function __construct()
 {
     parent::__construct();
     $app = JFactory::getApplication();
     $jinput = JFactory::getApplication()->input;
     $jemsettings = JEMHelper::config();
     $itemid = $jinput->getInt('id', 0) . ':' . $jinput->getInt('Itemid', 0);
     $id = $jinput->getInt('id');
     $this->setId($id);
     $limit = $app->getUserStateFromRequest('com_jem.attendees.' . $itemid . '.limit', 'limit', $jemsettings->display_num, 'uint');
     $limitstart = $app->input->get('limitstart', 0, 'uint');
     $this->setState('limit', $limit);
     $this->setState('limitstart', $limitstart);
     //set unlimited if export or print action | task=export or task=print
     $this->setState('unlimited', $jinput->getCmd('task'));
 }
Example #9
0
	/**
	 * Constructor
	 */
	public function __construct()
	{
		$app         = JFactory::getApplication();
		$jemsettings = JEMHelper::config();
		$jinput      = $app->input;
		$params      = $app->getParams();

		$id = $jinput->getInt('id', 0);
		if (empty($id)) {
			$id = $params->get('id', 0);
		}

		$this->setdate(time());
		$this->setId((int)$id);

		parent::__construct();
	}
Example #10
0
 /**
  * Constructor
  */
 public function __construct()
 {
     if (empty($config['filter_fields'])) {
         $config['filter_fields'] = array('id', 'a.id', 'title', 'a.title', 'dates', 'a.dates', 'times', 'a.times', 'alias', 'a.alias', 'venue', 'l.venue', 'venue_title', 'city', 'l.city', 'venue_city');
     }
     $app = JFactory::getApplication();
     $jinput = JFactory::getApplication()->input;
     $jemsettings = JEMHelper::config();
     $itemid = $jinput->getInt('id', 0) . ':' . $jinput->getInt('Itemid', 0);
     // Get the parameters of the active menu item
     $params = $app->getParams();
     if ($jinput->getInt('id')) {
         $id = $jinput->getInt('id');
     } else {
         $id = $params->get('id', 1);
     }
     $this->setId((int) $id);
     parent::__construct();
 }
Example #11
0
	/**
	 * Constructor
	 */
	public function __construct()
	{
		parent::__construct();

		$app = JFactory::getApplication();
		$jemsettings = JEMHelper::config();

		//get the number of events

		/* in J! 3.3.6 limitstart is removed from request - but we need it! */
		if ($app->input->getInt('limitstart', null) === null) {
			$app->setUserState('com_jem.myvenues.limitstart', 0);
		}

		$limit		= $app->getUserStateFromRequest('com_jem.myvenues.limit', 'limit', $jemsettings->display_num, 'int');
		$limitstart = $app->getUserStateFromRequest('com_jem.myvenues.limitstart', 'limitstart', 0, 'int');
		// correct start value if required
		$limitstart = $limit ? (int)(floor($limitstart / $limit) * $limit) : 0;

		$this->setState('limit', $limit);
		$this->setState('limitstart', $limitstart);
	}
Example #12
0
 /**
  * Constructor
  *
  */
 public function __construct()
 {
     parent::__construct();
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $jemsettings = JEMHelper::config();
     $itemid = $jinput->getInt('id', 0) . ':' . $jinput->getInt('Itemid', 0);
     //get the number of events from database
     $limit = $app->getUserStateFromRequest('com_jem.search.' . $itemid . '.limit', 'limit', $jemsettings->display_num, 'uint');
     $limitstart = $app->input->get('limitstart', 0, 'uint');
     $this->setState('limit', $limit);
     $this->setState('limitstart', $limitstart);
     // Get the filter request variables
     $filter_order = $jinput->getCmd('filter_order', 'a.dates');
     $this->setState('filter_order', $filter_order);
     $filter_order_DirDefault = 'ASC';
     // Reverse default order for dates in archive mode
     $task = $jinput->getCmd('task');
     if ($task == 'archive' && $filter_order == 'a.dates') {
         $filter_order_DirDefault = 'DESC';
     }
     $this->setState('filter_order_Dir', $jinput->getCmd('filter_order_Dir', $filter_order_DirDefault));
 }
Example #13
0
 /**
  * Method to save the form data.
  *
  * @param $data array
  */
 public function save($data)
 {
     // Variables
     $date = JFactory::getDate();
     $jinput = JFactory::getApplication()->input;
     $user = JFactory::getUser();
     $jemsettings = JEMHelper::config();
     $app = JFactory::getApplication();
     $fileFilter = new JInput($_FILES);
     $table = $this->getTable();
     // Check if we're in the front or back
     if ($app->isAdmin()) {
         $backend = true;
     } else {
         $backend = false;
     }
     if (parent::save($data)) {
         // At this point we do have an id.
         $pk = $this->getState($this->getName() . '.id');
         return true;
     }
     return false;
 }
Example #14
0
	/**
	 * Creates the Venue View
	 */
	function display($tpl = null)
	{
		if ($this->getLayout() == 'calendar')
		{
			### Venue Calendar view ###

			$app = JFactory::getApplication();

			// Load tooltips behavior
			JHtml::_('behavior.tooltip');

			// initialize variables
			$document 		= JFactory::getDocument();
			$menu 			= $app->getMenu();
			$menuitem		= $menu->getActive();
			$jemsettings	= JEMHelper::config();
			$params 		= $app->getParams();
			$uri 			= JFactory::getURI();
			$pathway 		= $app->getPathWay();
			$jinput 		= $app->input;
			$print			= $jinput->getBool('print', false);
			$user			= JemFactory::getUser();

			// Load css
			JemHelper::loadCss('jem');
			JemHelper::loadCss('calendar');
			JemHelper::loadCustomCss();
			JemHelper::loadCustomTag();

			if ($print) {
				JemHelper::loadCss('print');
				$document->setMetaData('robots', 'noindex, nofollow');
			}

			$evlinkcolor = $params->get('eventlinkcolor');
			$evbackgroundcolor = $params->get('eventbackgroundcolor');
			$currentdaycolor = $params->get('currentdaycolor');
			$eventandmorecolor = $params->get('eventandmorecolor');

			$style = '
			div#jem .eventcontentinner a, div#jem .eventandmore a {color:' . $evlinkcolor . ';}
			.eventcontentinner {background-color:'.$evbackgroundcolor .';}
			.eventandmore {background-color:' . $eventandmorecolor . ';}
			.today .daynum {background-color:' . $currentdaycolor . ';}';
			$document->addStyleDeclaration ($style);

			// add javascript (using full path - see issue #590)
			JHtml::_('script', 'media/com_jem/js/calendar.js');

			// Retrieve year/month variables
			$year = $jinput->get('yearID', strftime("%Y"),'int');
			$month = $jinput->get('monthID', strftime("%m"),'int');

			// get data from model and set the month
			$model = $this->getModel('VenueCal');
			$model->setDate(mktime(0, 0, 1, $month, 1, $year));
			$rows = $this->get('Items','VenueCal');

			// Set Page title
			$pagetitle = $params->def('page_title', $menuitem->title);
			$params->def('page_heading', $params->get('page_title'));
			$pageclass_sfx = $params->get('pageclass_sfx');

			// Add site name to title if param is set
			if ($app->getCfg('sitename_pagetitles', 0) == 1) {
				$pagetitle = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $pagetitle);
			}
			elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
				$pagetitle = JText::sprintf('JPAGETITLE', $pagetitle, $app->getCfg('sitename'));
			}

			$document->setTitle($pagetitle);
			$document->setMetaData('title', $pagetitle);

			// Check if the user has permission to add things
			$permissions = new stdClass();
			$permissions->canAddEvent = $user->can('add', 'event');
			$permissions->canAddVenue = $user->can('add', 'venue');

			$itemid  = $jinput->getInt('Itemid', 0);
			$venueID = $jinput->getInt('id', $params->get('id'));

			$partItemid = ($itemid > 0) ? '&Itemid=' . $itemid : '';
			$partVenid = ($venueID > 0) ? '&id=' . $venueID : '';
			$partLocid = ($venueID > 0) ? '&locid=' . $venueID : '';
			$partDate = ($year ? ('&yearID=' . $year) : '') . ($month ? ('&monthID=' . $month) : '');
			$url_base = 'index.php?option=com_jem&view=venue&layout=calendar' . $partVenid . $partItemid;

			$print_link = JRoute::_($url_base . $partDate . '&print=1&tmpl=component');

			// init calendar
			$cal = new JEMCalendar($year, $month, 0);
			$cal->enableMonthNav($url_base . ($print ? '&print=1&tmpl=component' : ''));
			$cal->setFirstWeekDay($params->get('firstweekday',1));
			$cal->enableDayLinks('index.php?option=com_jem&view=day'.$partLocid);

			// map variables
			$this->rows          = $rows;
			$this->locid         = $venueID;
			$this->params        = $params;
			$this->jemsettings   = $jemsettings;
			$this->permissions   = $permissions;
			$this->cal           = $cal;
			$this->pageclass_sfx = htmlspecialchars($pageclass_sfx);
			$this->print_link    = $print_link;

		} else
		{
			### Venue List view ###

			// initialize variables
			$app         = JFactory::getApplication();
			$document    = JFactory::getDocument();
			$menu        = $app->getMenu();
			$menuitem    = $menu->getActive();
			$jemsettings = JemHelper::config();
			$settings    = JemHelper::globalattribs();
			$params      = $app->getParams('com_jem');
			$pathway     = $app->getPathWay ();
			$uri         = JFactory::getURI();
			$jinput      = $app->input;
			$task        = $jinput->getCmd('task', '');
			$print       = $jinput->getBool('print', false);
			$user        = JemFactory::getUser();
			$itemid      = $app->input->getInt('id', 0) . ':' . $app->input->getInt('Itemid', 0);

			// Load css
			JemHelper::loadCss('jem');
			JemHelper::loadCustomCss();
			JemHelper::loadCustomTag();

			if ($print) {
				JemHelper::loadCss('print');
				$document->setMetaData('robots', 'noindex, nofollow');
			}

			// get data from model
			$rows	= $this->get('Items');
			$venue	= $this->get('Venue');

			// check for data error
			if (empty($venue)) {
				$app->enqueueMessage(JText::_('COM_JEM_VENUE_ERROR_VENUE_NOT_FOUND'), 'error');
				return false;
			}

			// are events available?
			$noevents = (!$rows) ? 1 : 0;

			// Decide which parameters should take priority
			$useMenuItemParams = ($menuitem && $menuitem->query['option'] == 'com_jem'
			                                && $menuitem->query['view']   == 'venue'
			                                && (!isset($menuitem->query['layout']) || $menuitem->query['layout'] == 'default')
			                                && $menuitem->query['id']     == $venue->id);

			// get search & user-state variables
			$filter_order = $app->getUserStateFromRequest('com_jem.venue.'.$itemid.'.filter_order', 'filter_order', 'a.dates', 'cmd');
			$filter_order_DirDefault = 'ASC';
			// Reverse default order for dates in archive mode
			if($task == 'archive' && $filter_order == 'a.dates') {
				$filter_order_DirDefault = 'DESC';
			}
			$filter_order_Dir = $app->getUserStateFromRequest('com_jem.venue.'.$itemid.'.filter_order_Dir', 'filter_order_Dir', $filter_order_DirDefault, 'word');
			$filter_type      = $app->getUserStateFromRequest('com_jem.venue.'.$itemid.'.filter_type', 'filter_type', '', 'int');
			$search           = $app->getUserStateFromRequest('com_jem.venue.'.$itemid.'.filter_search', 'filter_search', '', 'string');

			// table ordering
			$lists['order_Dir'] = $filter_order_Dir;
			$lists['order']     = $filter_order;

			// Get image
			$limage = JemImage::flyercreator($venue->locimage,'venue');

			// Add feed links
			$link = '&format=feed&id='.$venue->id.'&limitstart=';
			$attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
			$this->document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs);
			$attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
			$this->document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs);

			// pathway, page title, page heading
			if ($useMenuItemParams) {
				$pagetitle   = $params->get('page_title', $menuitem->title ? $menuitem->title : $venue->venue);
				$pageheading = $params->get('page_heading', $pagetitle);
				$pathway->setItemName(1, $menuitem->title);
			} else {
				$pagetitle   = $venue->venue;
				$pageheading = $pagetitle;
				$params->set('show_page_heading', 1); // ensure page heading is shown
				$pathway->addItem($pagetitle, JRoute::_(JemHelperRoute::getVenueRoute($venue->slug)));
			}
			$pageclass_sfx = $params->get('pageclass_sfx');

			// create the pathway
			if ($task == 'archive') {
				$pathway->addItem (JText::_('COM_JEM_ARCHIVE'), JRoute::_(JemHelperRoute::getVenueRoute($venue->slug).'&task=archive'));
				$print_link = JRoute::_(JEMHelperRoute::getVenueRoute($venue->slug).'&task=archive&print=1&tmpl=component');
				$pagetitle   .= ' - ' . JText::_('COM_JEM_ARCHIVE');
				$pageheading .= ' - ' . JText::_('COM_JEM_ARCHIVE');
			} else {
				//$pathway->addItem($venue->venue, JRoute::_(JEMHelperRoute::getVenueRoute($venue->slug)));
				$print_link = JRoute::_(JemHelperRoute::getVenueRoute($venue->slug).'&print=1&tmpl=component');
			}

			$params->set('page_heading', $pageheading);

			// Add site name to title if param is set
			if ($app->getCfg('sitename_pagetitles', 0) == 1) {
				$pagetitle = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $pagetitle);
			}
			elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
				$pagetitle = JText::sprintf('JPAGETITLE', $pagetitle, $app->getCfg('sitename'));
			}

			// set Page title & Meta data
			$document->setTitle($pagetitle);
			$document->setMetaData('title', $pagetitle);
			$document->setMetadata('keywords', $venue->meta_keywords);
			$document->setDescription(strip_tags($venue->meta_description));

			// Check if the user has permission to add things
			$permissions = new stdClass();
			$permissions->canAddEvent = $user->can('add', 'event');
			$permissions->canAddVenue = $user->can('add', 'venue');

			// Check if the user has permission to edit-this venue
			$permissions->canEditVenue = $user->can('edit', 'venue', $venue->id, $venue->created_by);
			$permissions->canEditPublishVenue = $user->can(array('edit', 'publish'), 'venue', $venue->id, $venue->created_by);

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

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

			// prepare the url for output
			if (strlen($venue->url) > 35) {
				$venue->urlclean = $this->escape(substr($venue->url, 0, 35 )) . '...';
			} else {
				$venue->urlclean = $this->escape($venue->url);
			}

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

			// Create the pagination object
			$pagination = $this->get('Pagination');

			// filters
			$filters = array ();

			// ALL events have the same venue - so hide this from filter and list
			$jemsettings->showlocate = 0;

			if ($jemsettings->showtitle == 1) {
				$filters[] = JHtml::_('select.option', '1', JText::_('COM_JEM_TITLE'));
			}
			if ($jemsettings->showlocate == 1) {
				$filters[] = JHtml::_('select.option', '2', JText::_('COM_JEM_VENUE'));
			}
			if ($jemsettings->showcity == 1) {
				$filters[] = JHtml::_('select.option', '3', JText::_('COM_JEM_CITY'));
			}
			if ($jemsettings->showcat == 1) {
				$filters[] = JHtml::_('select.option', '4', JText::_('COM_JEM_CATEGORY'));
			}
			if ($jemsettings->showstate == 1) {
				$filters[] = JHtml::_('select.option', '5', JText::_('COM_JEM_STATE'));
			}
			$lists['filter'] = JHtml::_('select.genericlist', $filters, 'filter_type', array('size'=>'1','class'=>'inputbox'), 'value', 'text', $filter_type);
			$lists['search'] = $search;

			// mapping variables
			$this->lists            = $lists;
			$this->action           = $uri->toString();
			$this->rows             = $rows;
			$this->noevents         = $noevents;
			$this->venue            = $venue;
			$this->print_link       = $print_link;
			$this->params           = $params;
			$this->limage           = $limage;
			$this->venuedescription = $venuedescription;
			$this->pagination       = $pagination;
			$this->jemsettings      = $jemsettings;
			$this->settings         = $settings;
			$this->permissions      = $permissions;
			$this->show_status      = $permissions->canEditPublishVenue;
			$this->item             = $menuitem;
			$this->pagetitle        = $pagetitle;
			$this->task             = $task;
			$this->pageclass_sfx    = htmlspecialchars($pageclass_sfx);
		}

		parent::display($tpl);
	}
Example #15
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);
 }
Example #16
0
	/**
	 * Copies the Eventlist (v1.1) attachments to JEM folder
	 */
	public function copyAttachments()
	{
		jimport('joomla.filesystem.file');
		jimport('joomla.filesystem.folder');

		$jemsettings = JEMHelper::config();

		$fromFolder = JPATH_SITE.'/media/com_eventlist/attachments/';
		$toFolder   = JPATH_SITE.'/'.$jemsettings->attachments_path.'/';

		if (!JFolder::exists($toFolder)) {
			JFolder::create($toFolder);
		}

		if (JFolder::exists($fromFolder) && JFolder::exists($toFolder)) {
			$files = JFolder::files($fromFolder, null, false, false);
			foreach ($files as $file) {
				if (!JFile::exists($toFolder.$file)) {
					JFile::copy($fromFolder.$file, $toFolder.$file);
				}
			}

			// attachments are stored in folders like "event123"
			// so we need to walk through all these subfolders
			$folders = JFolder::folders($fromFolder, null, false, false);
			foreach ($folders as $folder) {
				if (!JFolder::exists($toFolder.$folder)) {
					JFolder::create($toFolder.$folder);
				}

				$files = JFolder::files($fromFolder.$folder, null, false, false);
				$folder .= '/';
				foreach ($files as $file) {
					if (!JFile::exists($toFolder.$folder.$file)) {
						JFile::copy($fromFolder.$folder.$file, $toFolder.$folder.$file);
					}
				}
			}
		}
	}
Example #17
0
 /**
  * logic to get the categories
  *
  * @return void
  */
 public function getCategories()
 {
     $user = JFactory::getUser();
     $jemsettings = JEMHelper::config();
     $userid = (int) $user->get('id');
     $superuser = JEMUser::superuser();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select(array('c.*'));
     $query->from($db->quoteName('#__jem_categories') . ' AS c');
     $query->where(array('c.published = 1 '));
     $query->order(array('c.parent_id', 'c.ordering'));
     $db->setQuery($query);
     $mitems = $db->loadObjectList();
     # Check for a database error.
     if ($db->getErrorNum()) {
         JError::raiseNotice(500, $db->getErrorMsg());
     }
     if (!$mitems) {
         $mitems = array();
         $children = array();
         $parentid = $mitems;
     } else {
         $mitems_temp = $mitems;
         $children = array();
         # First pass - collect children
         foreach ($mitems as $v) {
             $pt = $v->parent_id;
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $v);
             $children[$pt] = $list;
         }
         $parentid = intval($mitems[0]->parent_id);
     }
     # get list of the items
     $list = JemCategories::treerecurse($parentid, '', array(), $children, 9999, 0, 0);
     return $list;
 }
Example #18
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);
 }
Example #19
0
 protected function getOptions()
 {
     // Initialise variables.
     $options = array();
     $published = $this->element['published'] ? $this->element['published'] : array(0, 1);
     $name = (string) $this->element['name'];
     $action = (string) $this->element['action'];
     $frontedit = $this->element['frontedit'];
     $jinput = JFactory::getApplication()->input;
     $db = JFactory::getDbo();
     $a_id = $jinput->get('a_id', null);
     // retrieve data
     if ($frontedit) {
         $user = JFactory::getUser();
         $jemsettings = JEMHelper::config();
         $userid = (int) $user->get('id');
         $superuser = JEMUser::superuser();
         $levels = $user->getAuthorisedViewLevels();
         $settings = JemHelper::globalattribs();
         $guestcat = $settings->get('guest_category', '0');
         $jinput = JFactory::getApplication()->input;
         $valguest = JEMUser::validate_guest();
         $name = (string) $this->element['name'];
         $db = JFactory::getDbo();
         $auth_joomlagr = $user->getAuthorisedGroups();
         $oldCat = 0;
         $query = $db->getQuery(true)->select('a.id AS value, a.catname AS text, a.level, a.published')->from('#__jem_categories AS a')->join('LEFT', $db->quoteName('#__jem_categories') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
         if (is_numeric($published)) {
             $query->where('a.published = ' . (int) $published);
         } elseif (is_array($published)) {
             JArrayHelper::toInteger($published);
             $query->where('a.published IN (' . implode(',', $published) . ')');
         }
         // specific code
         if (!$valguest) {
             $validated = false;
             if ($superuser) {
                 // no need to restrict to category's
                 $validated = true;
             }
             if (!$validated) {
                 // in this case it's going to be difficult
                 // catch the groupnumber of the user+add rights
                 $query2 = $db->getQuery(true);
                 $query2->select(array('gr.id'));
                 $query2->from($db->quoteName('#__jem_groups') . ' AS gr');
                 $query2->join('LEFT', '#__jem_groupmembers AS g ON g.group_id = gr.id');
                 $query2->where(array('g.member = ' . (int) $user->get('id'), $db->quoteName('gr.addevent') . ' =1', 'g.member NOT LIKE 0'));
                 $db->setQuery($query2);
                 $groupnumber = $db->loadColumn();
                 // is the user member of a group with edit rights?
                 if ($groupnumber) {
                     // restrict submission into maintained categories only
                     $query->where(array('a.groupid IN (' . implode(',', $groupnumber) . ')'));
                 } else {
                     return false;
                 }
             }
         } else {
             // $specified guest category
             $query->where(array('a.id = ' . $guestcat));
         }
         $query->group('a.id, a.catname, a.level, a.lft, a.rgt, a.parent_id, a.published')->order('a.lft ASC');
         $db->setQuery($query);
     }
     try {
         $options = $db->loadObjectList();
     } catch (RuntimeException $e) {
         JError::raiseWarning(500, $e->getMessage);
     }
     // Pad the option text with spaces using depth level as a multiplier.
     for ($i = 0, $n = count($options); $i < $n; $i++) {
         // remove root
         if ($this->element['removeroot'] == true) {
             if ($options[$i]->level == 0) {
                 unset($options[$i]);
                 continue;
             }
             $options[$i]->level = $options[$i]->level - 1;
         }
         if ($options[$i]->published == 1) {
             $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
         } else {
             $options[$i]->text = str_repeat('- ', $options[$i]->level) . '[' . $options[$i]->text . ']';
         }
     }
     // Merge any additional options in the XML definition.
     $options = array_merge(parent::getOptions(), $options);
     return $options;
 }
Example #20
0
	/**
	 * remove attachment for objects
	 *
	 * @param id from db
	 * @param string object identification (should be event<eventid>, category<categoryid>, etc...)
	 * @return boolean
	 */
	static function remove($id)
	{
		$jemsettings = JEMHelper::config();

		// then get info for files from db
		$db = JFactory::getDBO();

		$query = ' SELECT file, object '
			   . ' FROM #__jem_attachments '
			   . ' WHERE id = ' . $db->Quote($id);
		$db->setQuery($query);
		$res = $db->loadObject();
		if (!$res) {
			return false;
		}

		$path = JPATH_SITE.'/'.$jemsettings->attachments_path.'/'.$res->object.'/'.$res->file;
		if (file_exists($path)) {
			JFile::delete($path);
		}

		$query = ' DELETE FROM #__jem_attachments '
			   . ' WHERE id = '. $db->Quote($id);
		$db->setQuery($query);
		$res = $db->execute();
		if (!$res) {
			return false;
		}

		return true;
	}
Example #21
0
	/**
	 * Method to save the form data.
	 *
	 * @param $data array
	 */
	public function save($data)
	{
		// Variables
		$date        = JFactory::getDate();
		$app         = JFactory::getApplication();
		$jinput      = $app->input;
		$jemsettings = JEMHelper::config();
		$fileFilter  = new JInput($_FILES);
		$table       = $this->getTable();

		// Check if we're in the front or back
		$backend = (bool)$app->isAdmin();
		$new     = (bool)empty($data['id']);

		// Variables
		$cats             = $jinput->get('cid', array(), 'array');
		$recurrencenumber = $jinput->get('recurrence_number', '', 'int');
		$recurrencebyday  = $jinput->get('recurrence_byday', '', 'string');
		$metakeywords     = $jinput->get('meta_keywords', '', '');
		$metadescription  = $jinput->get('meta_description', '', '');
		$task             = $jinput->get('task', '', 'cmd');

		// event maybe first of recurrence set -> dissolve complete set
		if (JemHelper::dissolve_recurrence($data['id'])) {
			$this->cleanCache();
		}

		if ($data['dates'] == null || $data['recurrence_type'] == '0')
		{
			$data['recurrence_number']		= '';
			$data['recurrence_byday']		= '';
			$data['recurrence_counter'] 	= '';
			$data['recurrence_type']		= '';
			$data['recurrence_limit']		= '';
			$data['recurrence_limit_date']	= '';
			$data['recurrence_first_id']	= '';
		} else {
			if (!$new) {
				// edited event maybe part of a recurrence set
				// -> drop event from set
				$data['recurrence_first_id']	= '';
				$data['recurrence_counter'] 	= '';
			}

			$data['recurrence_number']		= $recurrencenumber;
			$data['recurrence_byday']		= $recurrencebyday;
		}

		$data['meta_keywords'] 		= $metakeywords;
		$data['meta_description']	= $metadescription;

		// Store IP of author only.
		if ($new) {
			$author_ip = $jinput->get('author_ip', '', 'string');
			$data['author_ip'] = $author_ip;
		}

		// Store as copy - reset creation date, modification fields, hit counter, version
		if ($task == 'save2copy') {
			unset($data['created']);
			unset($data['modified']);
			unset($data['modified_by']);
			unset($data['version']);
			unset($data['hits']);
		}

		// Save the event
		$saved = parent::save($data);

		if ($saved) {
			// At this point we do have an id.
			$pk = $this->getState($this->getName() . '.id');

			if (isset($data['featured'])) {
				$this->featured($pk, $data['featured']);
			}

			// attachments, new ones first
			$attachments 				= array();
			$attachments 				= $fileFilter->get('attach', array(), 'array');
			$attachments['customname']	= $jinput->post->get('attach-name', array(), 'array');
			$attachments['description'] = $jinput->post->get('attach-desc', array(), 'array');
			$attachments['access'] 		= $jinput->post->get('attach-access', array(), 'array');
			JEMAttachment::postUpload($attachments, 'event' . $pk);

			// and update old ones
			$old				= array();
			$old['id'] 			= $jinput->post->get('attached-id', array(), 'array');
			$old['name'] 		= $jinput->post->get('attached-name', array(), 'array');
			$old['description'] = $jinput->post->get('attached-desc', array(), 'array');
			$old['access'] 		= $jinput->post->get('attached-access', array(), 'array');

			foreach ($old['id'] as $k => $id) {
				$attach 				= array();
				$attach['id'] 			= $id;
				$attach['name'] 		= $old['name'][$k];
				$attach['description'] 	= $old['description'][$k];
				$attach['access'] 		= $old['access'][$k];
				JEMAttachment::update($attach);
			}

			// Store cats
			$saved |= $this->_storeCategoriesSelected($pk, $cats, !$backend, $new);

			// check for recurrence
			// when filled it will perform the cleanup function
			$table->load($pk);
			if (($table->recurrence_number > 0) && ($table->dates != null)) {
				JEMHelper::cleanup(2); // 2 = force on save, needs special attention
			}
		}

		return $saved;
	}
Example #22
0
 /**
  * Method to save the form data.
  *
  * @param $data array
  */
 public function save($data)
 {
     $date = JFactory::getDate();
     $app = JFactory::getApplication();
     $jinput = $app->input;
     $user = JFactory::getUser();
     $jemsettings = JEMHelper::config();
     $settings = JemHelper::globalattribs();
     $veditevent = JemHelper::viewSettings('veditevent');
     $fileFilter = new JInput($_FILES);
     $table = $this->getTable();
     # Check if we're in the front or back
     if ($app->isAdmin()) {
         $backend = true;
     } else {
         $backend = false;
     }
     $cats = $data['cats'];
     $data['author_ip'] = $jinput->getString('author_ip');
     ## Recurrence - check option ##
     # if the option to hide the recurrence/other tab has been set (front) then
     # we should ignore the recurrence variables.
     $option_othertab = $veditevent->get('editevent_show_othertab');
     if ($option_othertab) {
         $hide_othertab = false;
     } else {
         $hide_othertab = true;
     }
     if ($backend || $hide_othertab == false) {
         ##############
         ## HOLIDAYS ##
         ##############
         if (isset($data['activated'])) {
             if ($data['activated'] == null) {
                 $holidays = array();
             } else {
                 $holidays = $data['activated'];
             }
         } else {
             $holidays = array();
         }
         $countryholiday = $jinput->getInt('recurrence_country_holidays', '');
         ################
         ## RECURRENCE ##
         ################
         # check if a startdate has been set
         if (isset($data['dates'])) {
             if ($data['dates'] == null) {
                 $dateSet = false;
             } else {
                 $dateSet = true;
             }
         } else {
             $dateSet = false;
         }
         if (!isset($data['recurrence_freq'])) {
             $data['recurrence_freq'] = 0;
         }
         # implode weekday values
         # @todo implement check to see if days have been selected in case of freq week
         if (isset($data['recurrence_weekday'])) {
             $data['recurrence_weekday'] = implode(',', $data['recurrence_weekday']);
         }
         # blank recurrence-fields
         #
         # if we don't have a startdate or a recurrence-type then
         # the recurrence-fields within the event-table will be blanked.
         #
         # but the recurrence_group field will stay filled as it's not removed by the user.
         if (empty($data['dates']) || $data['recurrence_freq'] == '0') {
             $data['recurrence_count'] = '';
             $data['recurrence_freq'] = '';
             $data['recurrence_interval'] = '';
             $data['recurrence_until'] = '';
             $data['recurrence_weekday'] = '';
             $data['recurrence_exdates'] = '';
         }
         # the exdates are not stored in the event-table but they are trown in an variable
         if (isset($data['recurrence_exdates'])) {
             $exdates = $data['recurrence_exdates'];
         } else {
             $exdates = false;
         }
     }
     # parent-Save
     if (parent::save($data)) {
         // At this point we do have an id.
         $pk = $this->getState($this->getName() . '.id');
         if (isset($data['featured'])) {
             $this->featured($pk, $data['featured']);
         }
         $checkAttachName = $jinput->post->get('attach-name', '', 'array');
         if ($checkAttachName) {
             # attachments, new ones first
             $attachments = array();
             $attachments = $fileFilter->get('attach', array(), 'array');
             $attachments['customname'] = $jinput->post->get('attach-name', array(), 'array');
             $attachments['description'] = $jinput->post->get('attach-desc', array(), 'array');
             $attachments['access'] = $jinput->post->get('attach-access', array(), 'array');
             JEMAttachment::postUpload($attachments, 'event' . $pk);
             # and update old ones
             $old = array();
             $old['id'] = $jinput->post->get('attached-id', array(), 'array');
             $old['name'] = $jinput->post->get('attached-name', array(), 'array');
             $old['description'] = $jinput->post->get('attached-desc', array(), 'array');
             $old['access'] = $jinput->post->get('attached-access', array(), 'array');
             foreach ($old['id'] as $k => $id) {
                 $attach = array();
                 $attach['id'] = $id;
                 $attach['name'] = $old['name'][$k];
                 $attach['description'] = $old['description'][$k];
                 $attach['access'] = $old['access'][$k];
                 JEMAttachment::update($attach);
             }
         }
         # Store categories
         $cats = $data['cats'];
         $db = $this->getDbo();
         $query = $db->getQuery(true);
         $query->delete($db->quoteName('#__jem_cats_event_relations'));
         $query->where('itemid = ' . $pk);
         $db->setQuery($query);
         $db->execute();
         foreach ($cats as $cat) {
             $db = $this->getDbo();
             $query = $db->getQuery(true);
             // Insert columns.
             $columns = array('catid', 'itemid');
             // Insert values.
             $values = array($cat, $pk);
             // Prepare the insert query.
             $query->insert($db->quoteName('#__jem_cats_event_relations'))->columns($db->quoteName($columns))->values(implode(',', $values));
             // Reset the query using our newly populated query object.
             $db->setQuery($query);
             $db->execute();
         }
         if ($backend || $hide_othertab == false) {
             # check for recurrence
             # when part of a recurrence_set it will not perform the generating function
             /*
             $db = JFactory::getDbo();
             $query = $db->getQuery(true);
             $query->select('id');
             $query->from($db->quoteName('#__jem_recurrence'));
             $query->where(array('exdate IS NULL','itemid ='.$pk));
             $db->setQuery($query);
             $recurrence_set = $db->loadResult();
             */
             $table->load($pk);
             # check recurrence
             if ($table->recurrence_group) {
                 # this event is part of a recurrence-group
                 #
                 # check for groupid & groupid_ref (recurrence_table)
                 # - groupid		= $item->recurrence_group
                 # - groupid_ref	= $item->recurrence_group
                 # - Itemid		= $item->id
                 $db = JFactory::getDbo();
                 $query = $db->getQuery(true);
                 $query->select(array('count(id)'));
                 $query->from('#__jem_recurrence');
                 $query->where(array('groupid= ' . $table->recurrence_group, 'itemid= ' . $pk, 'groupid = groupid_ref'));
                 $db->setQuery($query);
                 $rec_groupset_check = $db->loadResult();
                 if ($rec_groupset_check == '1') {
                     $recurrence_set = true;
                 } else {
                     $recurrence_set = false;
                 }
             } else {
                 $recurrence_set = false;
             }
             ## check values, pass check before we continue to generate additional events ##
             # - do we have an interval?
             # - does the event has a date?
             # - is the event part of a recurrenceset?
             if ($table->recurrence_interval > 0 && !$table->dates == null && $recurrence_set == null) {
                 # recurrence_interval is bigger then 0
                 # we do have a startdate
                 # the event is not part of a recurrence-set
                 # we passed the check but now we'll pass some variables to the generating functions
                 # exdates: the dates filled
                 # table: the row info
                 if ($this->state->task == 'apply' || $this->state->task == 'save') {
                     JemHelper::generate_events($table, $exdates, $holidays);
                 }
             }
         }
         return true;
     }
     return false;
 }
Example #23
0
 /**
  * Method override to check if you can edit an existing record.
  * @todo: check if the user is allowed to edit/save
  *
  * @param	array	$data	An array of input data.
  * @param	string	$key	The name of the key for the primary key.
  *
  * @return	boolean
  */
 protected function allowEdit($data = array(), $key = 'id')
 {
     // Initialise variables.
     $recordId = (int) isset($data[$key]) ? $data[$key] : 0;
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $asset = 'com_jem.event.' . $recordId;
     // Check general edit permission first.
     if ($user->authorise('core.edit', $asset)) {
         return true;
     }
     // Fallback on edit.own.
     // First test if the permission is available.
     if ($user->authorise('core.edit.own', $asset)) {
         // Now test the owner is the user.
         $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
         if (empty($ownerId) && $recordId) {
             // Need to do a lookup from the model.
             $record = $this->getModel()->getItem($recordId);
             if (empty($record)) {
                 return false;
             }
             $ownerId = $record->created_by;
         }
         // If the owner matches 'me' then do the test.
         if ($ownerId == $userId) {
             return true;
         }
     }
     $record = $this->getModel()->getItem($recordId);
     $jemsettings = JEMHelper::config();
     $editaccess = JEMUser::editaccess($jemsettings->eventowner, $record->created_by, $jemsettings->eventeditrec, $jemsettings->eventedit);
     $maintainer = JEMUser::ismaintainer('edit', $record->id);
     if ($maintainer || $editaccess) {
         return true;
     }
     // Since there is no asset tracking, revert to the component permissions.
     return parent::allowEdit($data, $key);
 }
Example #24
0
 /**
  * Saves the registration to the database
  *
  * @access public
  * @return int register id on success, else false
  *
  */
 function userregister()
 {
     $user = JFactory::getUser();
     $jemsettings = JEMHelper::config();
     $eventid = (int) $this->_registerid;
     $uid = (int) $user->get('id');
     $onwaiting = 0;
     // Must be logged in
     if ($uid < 1) {
         JError::raiseError(403, JText::_('COM_JEM_ALERTNOTAUTH'));
         return;
     }
     try {
         $event = $this->getItem($eventid);
     } catch (Exception $e) {
         $event = false;
     }
     if (empty($event)) {
         $this->setError(JText::_('COM_JEM_EVENT_ERROR_EVENT_NOT_FOUND'));
         return false;
     }
     if ($event->maxplaces > 0) {
         // check if the user should go on waiting list
         if ($event->booked >= $event->maxplaces) {
             if (!$event->waitinglist) {
                 $this->setError(JText::_('COM_JEM_ERROR_REGISTER_EVENT_IS_FULL'));
                 return false;
             }
             $onwaiting = 1;
         }
     }
     // IP
     $uip = $jemsettings->storeip ? JemHelper::retrieveIP() : false;
     $obj = new stdClass();
     $obj->event = (int) $eventid;
     $obj->waiting = $onwaiting;
     $obj->uid = (int) $uid;
     $obj->uregdate = gmdate('Y-m-d H:i:s');
     $obj->uip = $uip;
     $this->_db->insertObject('#__jem_register', $obj);
     return $this->_db->insertid();
 }
Example #25
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;
	}
Example #26
0
	/**
	 * Method to save the form data.
	 *
	 * @param $data array
	 */
	public function save($data)
	{
		// Variables
		$date        = JFactory::getDate();
		$app         = JFactory::getApplication();
		$jinput      = $app->input;
		$user        = JemFactory::getUser();
		$jemsettings = JEMHelper::config();
		$fileFilter  = new JInput($_FILES);
		$table       = $this->getTable();
		$task        = $jinput->get('task', '', 'cmd');

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

		// Store IP of author only.
		if (!$data['id']) {
			$author_ip = $jinput->get('author_ip', '', 'string');
			$data['author_ip'] = $author_ip;
		}

		// Store as copy - reset creation date, modification fields, hit counter, version
		if ($task == 'save2copy') {
			unset($data['created']);
			unset($data['modified']);
			unset($data['modified_by']);
			unset($data['version']);
		//	unset($data['hits']);
		}

		//uppercase needed by mapservices
		if ($data['country']) {
			$data['country'] = JString::strtoupper($data['country']);
		}

		if (parent::save($data)){
			// At this point we do have an id.
			$pk = $this->getState($this->getName() . '.id');

			// attachments, new ones first
			$attachments 				= array();
			$attachments 				= $fileFilter->get('attach', array(), 'array');
			$attachments['customname']	= $jinput->post->get('attach-name', array(), 'array');
			$attachments['description'] = $jinput->post->get('attach-desc', array(), 'array');
			$attachments['access'] 		= $jinput->post->get('attach-access', array(), 'array');
			JEMAttachment::postUpload($attachments, 'venue' . $pk);

			// and update old ones
			$old				= array();
			$old['id'] 			= $jinput->post->get('attached-id', array(), 'array');
			$old['name'] 		= $jinput->post->get('attached-name', array(), 'array');
			$old['description'] = $jinput->post->get('attached-desc', array(), 'array');
			$old['access'] 		= $jinput->post->get('attached-access', array(), 'array');

			foreach ($old['id'] as $k => $id){
				$attach 				= array();
				$attach['id'] 			= $id;
				$attach['name'] 		= $old['name'][$k];
				$attach['description'] 	= $old['description'][$k];
				$attach['access'] 		= $old['access'][$k];
				JEMAttachment::update($attach);
			}

			return true;
		}

		return false;
	}
Example #27
0
	/**
	 * This method deletes attachment files if unused.
	 *
	 * @param mixed $type one of 'event', 'venue', 'category', ... or false for all
	 *
	 * @return bool true on success, false on error
	 * @access public
	 */
	static function delete_unused_attachment_files($type = false)
	{
		$jemsettings = JEMHelper::config();
		$basepath    = JPATH_SITE.'/'.$jemsettings->attachments_path;
		$db          = JFactory::getDBO();
		$res         = true;

		// Get list of all folders matching type (format is "$type$id")
		$folders = JFolder::folders($basepath, ($type ? '^'.$type : '.'), false, false, array('.', '..'));

		// Get list of all used attachments of given type
		$fnames = array();
		foreach ($folders as $f) {
			$fnames[] = $db->Quote($f);
		}
		$query = ' SELECT object, file '
			   . ' FROM #__jem_attachments ';
		if (!empty($fnames)) {
			$query .= ' WHERE object IN ('.implode(',', $fnames).')';
		}
		$db->setQuery($query);
		$files_used = $db->loadObjectList();
		$files = array();
		foreach ($files_used as $used) {
			$files[$used->object.'/'.$used->file] = true;
		}

		// Delete unused files and folders (ignore 'index.html')
		foreach ($folders as $folder) {
			$files = JFolder::files($basepath.'/'.$folder, '.', false, false, array('index.html'), array());
			if (!empty($files)) {
				foreach ($files as $file) {
					if (!array_key_exists($folder.'/'.$file, $files)) {
						$res &= JFile::delete($basepath.'/'.$folder.'/'.$file);
					}
				}
			}
			$files = JFolder::files($basepath.'/'.$folder, '.', false, true, array('index.html'), array());
			if (empty($files)) {
				$res &= JFolder::delete($basepath.'/'.$folder);
			}
		}
	}
Example #28
0
 /**
  * Method to get venue data.
  *
  * @param integer	The id of the venue.
  * @return mixed item data object on success, false on failure.
  */
 public function getItem($itemId = null)
 {
     $jemsettings = JEMHelper::config();
     // Initialise variables.
     $itemId = (int) (!empty($itemId)) ? $itemId : $this->getState('venue.id');
     // Get a row instance.
     $table = $this->getTable();
     // Attempt to load the row.
     $return = $table->load($itemId);
     // Check for a table object error.
     if ($return === false && $table->getError()) {
         $this->setError($table->getError());
         return false;
     }
     $properties = $table->getProperties(1);
     $value = JArrayHelper::toObject($properties, 'JObject');
     // Convert attrib field to Registry.
     //$registry = new JRegistry();
     //$registry->loadString($value->attribs);
     $globalsettings = JemHelper::globalattribs();
     $globalregistry = new JRegistry();
     $globalregistry->loadString($globalsettings);
     $value->params = clone $globalregistry;
     //$value->params->merge($registry);
     // Compute selected asset permissions.
     $user = JFactory::getUser();
     $userId = $user->get('id');
     $asset = 'com_jem.venue.' . $value->id;
     // Check general edit permission first.
     if ($user->authorise('core.edit', $asset)) {
         $value->params->set('access-edit', true);
     } elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) {
         // Check for a valid user and that they are the owner.
         if ($userId == $value->created_by) {
             $value->params->set('access-edit', true);
         }
     }
     // Check edit state permission.
     if ($itemId) {
         // Existing item
         $value->params->set('access-change', $user->authorise('core.edit.state', $asset));
     } else {
         $value->params->set('access-change', $user->authorise('core.edit.state', 'com_jem'));
     }
     $value->author_ip = $jemsettings->storeip ? JemHelper::retrieveIP() : false;
     $files = JemAttachment::getAttachments('venue' . $itemId);
     $value->attachments = $files;
     if (empty($itemId)) {
         $value->country = $jemsettings->defaultCountry;
     }
     if (!empty($value->locimage)) {
         if (strpos($value->locimage, 'images/') !== false) {
             # the image selected contains the images path
         } else {
             # the image selected doesn't have the /images/ path
             # we're looking at the locimage so we'll append the venues folder
             $value->locimage = 'images/jem/venues/' . $value->locimage;
         }
     }
     return $value;
 }
Example #29
0
?>


	<?php 
if ($this->vsettings->get('show_category_image', '1')) {
    ?>
	<h2 class="jem">
			<?php 
    echo '&nbsp';
    ?>
	</h2>
		<div class="image imagetop">
		<?php 
    // flyer
    if (empty($this->category->image)) {
        $jemsettings = JEMHelper::config();
        $imgattribs['width'] = $jemsettings->imagewidth;
        $imgattribs['height'] = $jemsettings->imagehight;
        echo JHtml::_('image', 'com_jem/noimage.png', $this->category->catname, $imgattribs, true);
    } else {
        echo JemOutput::flyer($this->category, $this->cimage, 'category');
    }
    ?>
		</div>
		<?php 
}
?>


		<h2 class="description"><?php 
echo JText::_('COM_JEM_EVENT_DESCRIPTION');
Example #30
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;
	}