public function save() { // check for request forgeries YRequest::checkToken() or jexit('Invalid Token'); // init vars $post = YRequest::get('post'); $cid = YRequest::getArray('cid.0', '', 'int'); try { // get item table $table = YTable::getInstance('submission'); // get item if ($cid) { $submission = $table->get($cid); } else { $submission = new Submission(); $submission->application_id = $this->application->id; } // bind submission data $submission->bind($post, array('params')); // generate unique slug $submission->alias = SubmissionHelper::getUniqueAlias($submission->id, YString::sluggify($submission->alias)); // set params $submission->params = $submission->getParams()->clear()->set('form.', @$post['params']['form'])->set('trusted_mode', @$post['params']['trusted_mode'])->set('show_tooltip', @$post['params']['show_tooltip'])->toString(); // save submission $table->save($submission); // set redirect message $msg = JText::_('Submission Saved'); } catch (YException $e) { // raise notice on exception JError::raiseNotice(0, JText::_('Error Saving Submission') . ' (' . $e . ')'); $this->_task = 'apply'; $msg = null; } $link = $this->baseurl; switch ($this->getTask()) { case 'apply': $link .= '&task=edit&cid[]=' . $submission->id; break; case 'saveandnew': $link .= '&task=add'; break; } $this->setRedirect($link, $msg); }