public function callElement() { // get request vars $element = YRequest::getCmd('element', ''); $method = YRequest::getCmd('method', ''); $args = YRequest::getVar('args', array(), 'default', 'array'); $item_id = (int) YRequest::getInt('item_id', 0); JArrayHelper::toString($args); // get item $item = YTable::getInstance('item')->get($item_id); // raise warning when item can not be accessed if (empty($item->id) || !$item->canAccess($this->user)) { JError::raiseError(500, JText::_('Unable to access item')); return; } // raise warning when item is not published $nulldate = JFactory::getDBO()->getNullDate(); $date = JFactory::getDate()->toUnix(); $publish_up = JFactory::getDate($item->publish_up); $publish_down = JFactory::getDate($item->publish_down); if ($item->state != 1 || !(($item->publish_up == $nulldate || $publish_up->toUnix() <= $date) && ($item->publish_down == $nulldate || $publish_down->toUnix() >= $date))) { JError::raiseError(404, JText::_('Item not published')); return; } // get element and execute callback method if ($element = $item->getElement($element)) { $element->callback($method, $args); } }
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 saveSubmission() { // check for request forgeries YRequest::checkToken() or jexit('Invalid Token'); // init vars $type = YRequest::getString('type'); $template = YRequest::getString('template'); $layout = YRequest::getString('layout'); $positions = YRequest::getVar('positions', array(), 'post', 'array'); unset($positions['unassigned']); // for template, module if ($template) { $path = $this->application->getPath() . '/templates/' . $template; } // get renderer $renderer = new ItemRenderer(); $renderer->addPath($path); // clean config $config = $renderer->getConfig('item'); foreach ($config->toArray() as $key => $value) { $parts = explode('.', $key); if ($parts[0] == $this->group && !$this->application->getType($parts[1])) { $config->remove($key); } } // save config $config->set($this->group . '.' . $type . '.' . $layout, $positions); $renderer->saveConfig($config, $path . '/renderer/item/positions.config'); switch ($this->getTask()) { case 'applysubmission': $link = $this->baseurl . '&task=assignsubmission&type=' . $type . '&layout=' . $layout; $link .= $template ? '&template=' . $template : null; break; default: $link = $this->baseurl . '&task=types'; break; } $this->setRedirect($link, JText::_('Submitable Elements Assigned')); }
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 callElement() { // get request vars $element_identifier = YRequest::getString('elm_id', ''); $item_id = YRequest::getInt('item_id', 0); $type = YRequest::getString('type', ''); $this->method = YRequest::getCmd('method', ''); $this->args = YRequest::getVar('args', array(), 'default', 'array'); JArrayHelper::toString($this->args); // load element if ($item_id) { $item = YTable::getInstance('item')->get($item_id); } elseif (!empty($type)) { $item = new Item(); $item->application_id = $this->application->id; $item->type = $type; } // execute callback method if ($element = $item->getElement($element_identifier)) { echo $element->callback($this->method, $this->args); } }
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); }
public function render() { $link = YRequest::getVar('hidemainmenu') ? null : $this->_link; $html[] = '<li ' . JArrayHelper::toString($this->_attributes) . '>'; $html[] = ($link ? '<a href="' . JRoute::_($link) . '">' : '<span>') . '<span>' . JText::_($this->getName()) . '</span>' . ($link ? '</a>' : '</span>'); if (count($this->getChildren())) { $html[] = '<ul>'; foreach ($this->getChildren() as $child) { $html[] = $child->render(); } $html[] = '</ul>'; } $html[] = '</li>'; return implode("\n", $html); }
public function save() { // check for request forgeries YRequest::checkToken() or jexit('Invalid Token'); // set currently active author $this->author = CommentHelper::activeAuthor(); // init vars $redirect = YRequest::getString('redirect'); $login = YRequest::getString(CommentHelper::COOKIE_PREFIX . 'login', '', 'cookie'); if ($this->author->getUserType() == $login) { if ($this->params->get('enable_comments', false)) { // init vars $content = YRequest::getVar('content', null, '', 'string', JREQUEST_ALLOWRAW); $item_id = YRequest::getInt('item_id', 0); $parent_id = YRequest::getInt('parent_id', 0); // filter content $content = CommentHelper::filterContentInput($content); // set content in session $this->session->set('com_zoo.comment.content', $content); // set author name, email and url, if author is guest if ($this->author->isGuest()) { $this->author->name = YRequest::getString('author'); $this->author->email = YRequest::getString('email'); $this->author->url = YRequest::getString('url'); // save cookies CommentHelper::saveCookies($this->author->name, $this->author->email, $this->author->url); } try { // get comment table $table = YTable::getInstance('comment'); // get parent $parent = $table->get($parent_id); $parent_id = $parent && $parent->item_id == $item_id ? $parent->id : 0; // create comment $comment = new Comment(); $comment->parent_id = $parent_id; $comment->item_id = $item_id; $comment->ip = CommentHelper::getClientIP(); $comment->created = JFactory::getDate()->toMySQL(); $comment->content = $content; $comment->state = Comment::STATE_UNAPPROVED; // auto approve comment $approved = $this->params->get('approved', 0); if ($this->author->isJoomlaAdmin()) { $comment->state = Comment::STATE_APPROVED; } else { if ($approved == 1) { $comment->state = Comment::STATE_APPROVED; } else { if ($approved == 2 && $table->getApprovedCommentCount($this->author)) { $comment->state = Comment::STATE_APPROVED; } } } // bind Author $comment->bindAuthor($this->author); // validate comment, if not an administrator if (!$this->author->isJoomlaAdmin()) { $this->_validate($comment); } // save comment $table->save($comment); // remove content from session, if comment was saved $this->session->set('com_zoo.comment.content', ''); } catch (CommentControllerException $e) { // raise warning on exception JError::raiseWarning(0, (string) $e); } catch (YException $e) { // raise warning on exception JError::raiseWarning(0, JText::_('ERROR_SAVING_COMMENT')); // add exception details, for super administrators only if ($this->user->superadmin) { JError::raiseWarning(0, (string) $e); } } // add anchor to redirect, if comment was saved if ($comment->id) { $redirect .= '#comment-' . $comment->id; } } else { // raise warning on comments not enabled JError::raiseWarning(0, JText::_('Comments are not enabled.')); } } else { // raise warning on exception JError::raiseWarning(0, JText::_('ERROR_SAVING_COMMENT')); // add exception details, for super administrators only if ($this->user->superadmin) { JError::raiseWarning(0, JText::_('User types didn\'t match.')); } } $this->setRedirect($redirect); }