Пример #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();
		}

	}
Пример #2
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);
 }
Пример #3
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;
	}
Пример #4
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);
 }