示例#1
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;
	}
示例#2
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;
	}
示例#3
0
文件: event.php 项目: JKoelman/JEM-3
 /**
  * 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;
 }
示例#4
0
文件: venue.php 项目: JKoelman/JEM-3
 /**
  * Method to save the form data.
  *
  * @param $data array
  */
 public function save($data)
 {
     // Variables
     $app = JFactory::getApplication();
     $date = JFactory::getDate();
     $jinput = $app->input;
     $user = JFactory::getUser();
     $fileFilter = new JInput($_FILES);
     $table = $this->getTable();
     // Check if we're in the front or back
     if ($app->isAdmin()) {
         $backend = true;
     } else {
         $backend = false;
     }
     // uppercase needed by mapservices
     if ($data['country']) {
         $data['country'] = JString::strtoupper($data['country']);
     }
     $data['author_ip'] = $jinput->getString('author_ip');
     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;
 }