/** * Save an entry * * @return void */ public function saveTask() { // Check for request forgeries Request::checkToken(); //$offset = Config::get('offset'); // Bind the posted data to an event object $row = new Event($this->database); if (!$row->bind($_POST)) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $row->getError(), 'error'); } // New entry or existing? if ($row->id) { // Existing - update modified info $row->modified = Date::toSql(); $row->modified_by = User::get('id'); } else { // New - set created info $row->created = Date::toSql(); $row->created_by = User::get('id'); } // Set some fields and do some cleanup work if ($row->catid) { $row->catid = intval($row->catid); } elseif (!$row->catid) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('EVENT_CAL_LANG_EVENT_REQUIRED'), 'error'); } //$row->title = $this->view->escape($row->title); //$row->content = Request::getVar('econtent', '', 'post'); $row->content = $_POST['econtent']; $row->content = $this->_clean($row->content); // Get the custom fields defined in the events configuration $fields = Request::getVar('fields', array(), 'post'); $fields = array_map('trim', $fields); // Wrap up the content of the field and attach it to the event content $fs = $this->config->fields; foreach ($fields as $param => $value) { if (trim($value) != '') { $row->content .= '<ef:' . $param . '>' . $this->_clean($value) . '</ef:' . $param . '>'; } else { foreach ($fs as $f) { if ($f[0] == $param && end($f) == 1) { echo Html::alert(Lang::txt('EVENTS_REQUIRED_FIELD_CHECK', $f[1])); exit; } } } } // Clean adresse $row->adresse_info = $this->_clean($row->adresse_info); // Clean contact $row->contact_info = $this->_clean($row->contact_info); // Clean extra $row->extra_info = $this->_clean($row->extra_info); // Prepend http:// to URLs without it if ($row->extra_info != NULL) { if (substr($row->extra_info, 0, 7) != 'http://' && substr($row->extra_info, 0, 8) != 'https://') { $row->extra_info = 'http://' . $row->extra_info; } } // make sure we have a start date if (!$row->publish_up) { $row->publish_up = \Date::toSql(); } // If this is a new event, publish it, otherwise retain its state if (!$row->id) { $row->state = 1; } // Get parameters $params = Request::getVar('params', '', 'post'); if (is_array($params)) { //email is reaquired $params['show_email'] = 1; $p = new \Hubzero\Config\Registry($params); $row->params = $p->toString(); } if (!$row->check()) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $row->getError(), 'error'); } if (!$row->store()) { App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), $row->getError(), 'error'); } $row->checkin(); // Incoming tags $tags = Request::getVar('tags', '', 'post'); // Save the tags $rt = new Tags($row->id); $rt->setTags($tags, User::get('id')); // Redirect App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_EVENTS_CAL_LANG_SAVED')); }