public function save() { // check for request forgeries YRequest::checkToken() or jexit('Invalid Token'); // init vars $post = YRequest::get('post'); try { // bind post $this->application->bind($post, array('params')); // set params $params = $this->application->getParams()->remove('global.')->set('group', @$post['group'])->set('template', @$post['template'])->set('global.config.', @$post['params']['config'])->set('global.template.', @$post['params']['template']); if (isset($post['addons']) && is_array($post['addons'])) { foreach ($post['addons'] as $addon => $value) { $params->set("global.{$addon}.", $value); } } $this->application->params = $params->toString(); // save application YTable::getInstance('application')->save($this->application); // set redirect $msg = JText::_('Application Saved'); $link = $this->link_base . '&changeapp=' . $this->application->id; } catch (YException $e) { // raise notice on exception JError::raiseNotice(0, JText::_('Error Saving Application') . ' (' . $e . ')'); // set redirect $msg = null; $link = $this->baseurl . '&task=add'; } $this->setRedirect($link, $msg); }
public function save() { // check for request forgeries YRequest::checkToken() or jexit('Invalid Token'); // init vars $post = YRequest::get('post'); $post['description'] = YRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW); try { // bind post $this->application->bind($post, array('params')); // set params $this->application->params = $this->application->getParams()->remove('content.')->remove('config.')->remove('template.')->set('content.', @$post['params']['content'])->set('config.', @$post['params']['config'])->set('template.', @$post['params']['template'])->toString(); // save application YTable::getInstance('application')->save($this->application); // set redirect message $msg = JText::_('Frontpage Saved'); } catch (YException $e) { // raise notice on exception JError::raiseNotice(0, JText::_('Error Saving Frontpage') . ' (' . $e . ')'); $msg = null; } $this->setRedirect($this->baseurl, $msg); }
public function saveElements() { // check for request forgeries YRequest::checkToken() or jexit('Invalid Token'); // init vars $post = YRequest::get('post'); $cid = YRequest::getArray('cid.0', '', 'string'); try { // get type $type = $this->application->getType($cid); // save elements ElementHelper::saveElements($post, $type); // save type $type->save(); // reset related item search data $table = YTable::getInstance('item'); $items = $table->getByType($type->id, $this->application->id); foreach ($items as $item) { $table->save($item); } $msg = JText::_('Elements Saved'); } catch (YException $e) { JError::raiseNotice(0, JText::_('Error Saving Elements') . ' (' . $e . ')'); $this->_task = 'applyelements'; $msg = null; } switch ($this->getTask()) { case 'applyelements': $link = $this->baseurl . '&task=editelements&cid[]=' . $type->id; break; case 'saveelements': default: $link = $this->baseurl . '&task=types'; break; } $this->setRedirect($link, $msg); }
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); }
public function save() { // check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); // init vars $post = YRequest::get('post'); $cid = YRequest::getArray('cid.0', '', 'int'); $pid = YRequest::getInt('parent_id', 0); $now = JFactory::getDate(); try { // get content as raw and filter it $post['content'] = YRequest::getVar('content', null, '', 'string', JREQUEST_ALLOWRAW); $post['content'] = CommentHelper::filterContentInput($post['content']); // get comment table $table = YTable::getInstance('comment'); // get comment or create reply if ($cid) { $comment = $table->get($cid); } else { $parent = $table->get($pid); $comment = new Comment(); $comment->item_id = $parent->getItem()->id; $comment->user_id = $this->user->id; $comment->author = $this->user->name; $comment->email = $this->user->email; $comment->ip = CommentHelper::getClientIP(); $comment->created = $now->toMySQL(); $comment->state = Comment::STATE_APPROVED; } // bind post data $comment->bind($post); // save comment $table->save($comment); // get view $view = $this->getView(); // set view vars $view->option = $this->option; $view->comment = $comment; // display view $view->setLayout('_row'); $view->display(); } catch (YException $e) { // raise error on exception echo json_encode(array('group' => 'error', 'title' => JText::_('Error Saving Comment'), 'text' => (string) $e)); } }
public function docopy() { // check for request forgeries YRequest::checkToken() or jexit('Invalid Token'); // init vars $now = JFactory::getDate(); $post = YRequest::get('post'); $cid = YRequest::getArray('cid', array(), 'int'); if (count($cid) < 1) { JError::raiseError(500, JText::_('Select a item to copy')); } try { // get item table $item_table = YTable::getInstance('item'); $tag_table = YTable::getInstance('tag'); // get database $db = YDatabase::getInstance(); // copy items foreach ($cid as $id) { // get item $item = $item_table->get($id); $elements = $item->getElements(); $categories = $item->getRelatedCategoryIds(); // copy item $item->id = 0; // set id to 0, to force new item $item->name .= ' (' . JText::_('Copy') . ')'; // set copied name $item->alias = ItemHelper::getUniqueAlias($id, $item->alias . '-copy'); // set copied alias $item->state = 0; // unpublish item $item->created = $now->toMySQL(); $item->created_by = $this->user->get('id'); $item->modified = $now->toMySQL(); $item->modified_by = $this->user->get('id'); $item->hits = 0; // copy tags $item->setTags($tag_table->getItemTags($id)); // save copied item/element data $item_table->save($item); // save category relations CategoryHelper::saveCategoryItemRelations($item->id, $categories); } // set redirect message $msg = JText::_('Item Copied'); } catch (YException $e) { // raise notice on exception JError::raiseNotice(0, JText::_('Error Copying Item') . ' (' . $e . ')'); $msg = null; } $this->setRedirect($this->baseurl, $msg); }
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'); // set application $post['application_id'] = $this->application->id; // get raw description from post data $post['description'] = YRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW); try { // get category table $table = YTable::getInstance('category'); // get category and bind post data $category = $cid ? $table->get($cid) : new Category(); $category->bind($post, array('params')); $category->alias = CategoryHelper::getUniqueAlias($category->id, YString::sluggify($category->alias)); $category->params = $category->getParams()->remove('content.')->remove('config.')->remove('template.')->set('content.', @$post['params']['content'])->set('config.', @$post['params']['config'])->set('template.', @$post['params']['template'])->toString(); // save category and update category ordering $table->save($category); $table->updateorder($this->application->id, $category->parent); // set redirect message $msg = JText::_('Category Saved'); } catch (YException $e) { // raise notice on exception JError::raiseNotice(0, JText::_('Error Saving Category') . ' (' . $e . ')'); $this->_task = 'apply'; $msg = null; } $link = $this->baseurl; switch ($this->getTask()) { case 'apply': $link .= '&task=edit&cid[]=' . $category->id; break; case 'saveandnew': $link .= '&task=edit&cid[]='; break; } $this->setRedirect($link, $msg); }