/** * 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; }
/** * Method to get the selected members * * @access public * @return string * */ protected function _members() { $item = parent::getItem(); //get selected members if ($item->id == null) { $this->_members = null; } else { if ($item->id) { $query = 'SELECT member' . ' FROM #__jem_groupmembers' . ' WHERE group_id = '.(int)$item->id; $this->_db->setQuery ($query); $member_ids = $this->_db->loadColumn(); if (is_array($member_ids)) { $this->_members = implode(',', $member_ids); } } } return $this->_members; }
/** * 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; }