/** * Execute the controller. * * @return boolean True if controller finished execution, false if the controller did not * finish execution. A controller might return false if some precondition for * the controller to run has not been satisfied. * * @since 12.1 * @throws LogicException * @throws RuntimeException */ public function execute() { $app = JFactory::getApplication(); $id = $this->input->getInt('id'); $model = new MonitorModelIssue($app); $user = JFactory::getUser(); if (!$model->canEdit($user, $id)) { throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $issue_id = $model->save($this->input); if ($issue_id === false) { $url = 'index.php?option=com_monitor&task=issue.edit'; if ($id) { $url .= '&id=' . $id; } $app->redirect(JRoute::_($url, false)); return false; } $app->enqueueMessage(\JText::_('COM_MONITOR_ISSUE_SAVED')); if (!$id) { // Send notification mails for new issues. $project_id = $this->input->get('project_id'); $modelSubscription = new MonitorModelSubscription(); $modelSubscription->notifyProject($project_id, $user, $issue_id); // Mark issue as unread. $modelNotification = new MonitorModelNotifications(); $modelNotification->markUnread($issue_id); } if ($app->isAdmin()) { $app->redirect(JRoute::_('index.php?option=com_monitor&view=issues', false)); } else { $app->redirect(JRoute::_('index.php?option=com_monitor&view=issue&id=' . $issue_id, false)); } return true; }
/** * Execute the controller. * * @return boolean True if controller finished execution, false if the controller did not * finish execution. A controller might return false if some precondition for * the controller to run has not been satisfied. * * @since 12.1 * @throws LogicException * @throws RuntimeException */ public function execute() { $id = $this->input->getInt('id'); $user = JFactory::getUser(); if ($user->guest) { $this->app->enqueueMessage(JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'), 'error'); } else { $model = new MonitorModelSubscription(); if ($model->isSubscriberIssue($id, $user->id)) { $model->unsubscribeIssue($id, $user->id); $this->app->enqueueMessage(JText::_('COM_MONITOR_SUBSCRIPTION_ISSUE_UNSUBSCRIBED'), 'message'); } } $this->app->redirect(JRoute::_('index.php?option=com_monitor&view=issue&id=' . $id, false)); }
/** * Execute the controller. * * @return boolean True if controller finished execution, false if the controller did not * finish execution. A controller might return false if some precondition for * the controller to run has not been satisfied. * * @since 12.1 * @throws LogicException * @throws RuntimeException */ public function execute() { $id = $this->input->getInt('id'); $user = JFactory::getUser(); if ($user->guest) { $this->app->enqueueMessage(JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'), 'error'); } else { $model = new MonitorModelSubscription(); if (!$model->isSubscriberProject($id, $user->id)) { $model->subscribeProject($id, $user->id); $this->app->enqueueMessage(JText::_('COM_MONITOR_SUBSCRIPTION_PROJECT'), 'message'); } } $return = base64_decode($this->app->input->get('return', '', 'BASE64')); if (!JUri::isInternal($return)) { $return = 'index.php?option=com_monitor&view=project&id=' . $id; } $this->app->redirect(JRoute::_($return, false)); }
/** * Method to render the view. * * @return string The rendered view. * * @since 12.1 * @throws RuntimeException */ public function render() { $project = $this->model->getProject(); $this->modelSubscription = new MonitorModelSubscription(); $this->item = $project; $this->setLayout('default'); if ($this->item) { $this->defaultTitle = $this->escape($this->item->name); $this->buttons['issues'] = array('url' => 'index.php?option=com_monitor&view=issues&project_id=' . $this->item->id, 'text' => 'COM_MONITOR_GO_TO_ISSUES', 'title' => 'COM_MONITOR_GO_TO_ISSUES', 'icon' => 'icon-chevron-right'); $this->buttons['new-issue'] = array('url' => 'index.php?option=com_monitor&task=issue.edit&project_id=' . $this->item->id, 'text' => 'COM_MONITOR_CREATE_ISSUE', 'title' => 'COM_MONITOR_CREATE_ISSUE', 'icon' => 'icon-new'); $user = JFactory::getUser(); if ($this->params->get('enable_notifications', 1) && !$user->guest) { $subscribed = $this->modelSubscription->isSubscriberProject($this->item->id, $user->id); $task = $subscribed ? 'unsubscribe' : 'subscribe'; $this->buttons['subscribe'] = array('url' => 'index.php?option=com_monitor&task=project.' . $task . '&id=' . $this->item->id, 'text' => $subscribed ? 'COM_MONITOR_UNSUBSCRIBE_PROJECT' : 'COM_MONITOR_SUBSCRIBE_PROJECT', 'title' => $subscribed ? 'COM_MONITOR_UNSUBSCRIBE_PROJECT_DESC' : 'COM_MONITOR_SUBSCRIBE_PROJECT_DESC', 'icon' => $subscribed ? 'icon-star' : 'icon-star-empty'); } } return parent::render(); }
/** * Method to render the view. * * @return string The rendered view. * * @since 12.1 * @throws RuntimeException */ public function render() { $this->items = $this->model->getIssues(); $this->filterForm = $this->model->getFilterForm(); $this->defaultTitle = JText::_('COM_MONITOR_ISSUES'); $this->setLayout('default'); $projectId = $this->model->getProjectId(); if ($projectId !== null) { $this->buttons['new-issue'] = array('url' => 'index.php?option=com_monitor&task=issue.edit&project_id=' . $projectId, 'text' => 'COM_MONITOR_CREATE_ISSUE', 'title' => 'COM_MONITOR_CREATE_ISSUE', 'icon' => 'icon-new'); $user = JFactory::getUser(); if (!$user->guest) { $this->modelSubscription = new MonitorModelSubscription(); $this->modelNotifications = new MonitorModelNotifications(); if ($this->params->get('enable_notifications', 1)) { $subscribed = $this->modelSubscription->isSubscriberProject($projectId, $user->id); $task = $subscribed ? 'unsubscribe' : 'subscribe'; $this->buttons['subscribe'] = array('url' => 'index.php?option=com_monitor&task=project.' . $task . '&id=' . $projectId . '&return=' . base64_encode(JUri::getInstance()->toString()), 'text' => $subscribed ? 'COM_MONITOR_UNSUBSCRIBE_PROJECT' : 'COM_MONITOR_SUBSCRIBE_PROJECT', 'title' => $subscribed ? 'COM_MONITOR_UNSUBSCRIBE_PROJECT_DESC' : 'COM_MONITOR_SUBSCRIBE_PROJECT_DESC', 'icon' => $subscribed ? 'icon-star' : 'icon-star-empty'); } $this->buttons['all-read'] = array('url' => 'index.php?option=com_monitor&task=project.read&id=' . $projectId, 'text' => 'COM_MONITOR_PROJECT_MARK_ALL_READ', 'title' => 'COM_MONITOR_PROJECT_MARK_ALL_READ_DESC', 'icon' => 'icon-eye'); } } return parent::render(); }
/** * Method to render the view. * * @return string The rendered view. * * @throws RuntimeException */ public function render() { $this->item = $this->model->getIssue(); $user = JFactory::getUser(); $app = JFactory::getApplication(); if ($this->item) { if (!in_array($this->item->access, $user->getAuthorisedViewLevels())) { if ($user->guest && $this->params->get('redirect_login', 1)) { $app->enqueueMessage(JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'), 'error'); $app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode(JUri::getInstance()->toString()), '403')); } else { throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403); } } $this->canEditIssue = $this->model->canEdit($user, $this->item->id); // Title if ($this->layout === 'edit') { $this->defaultTitle = JText::sprintf('COM_MONITOR_EDIT_ISSUE', $this->item->title); } else { $this->defaultTitle = $this->escape($this->item->title); } // Avatar if (JPluginHelper::isEnabled('user', 'cmavatar')) { // Include the CMAvatar plugin. require_once JPATH_PLUGINS . '/user/cmavatar/helper.php'; $this->avatars = array(); $this->avatars[$this->item->author_id] = PlgUserCMAvatarHelper::getAvatar($this->item->author_id); } // Buttons if ($this->getLayout() === 'default') { if ($this->canEditIssue) { $this->buttons['edit'] = array('url' => 'index.php?option=com_monitor&task=issue.edit&id=' . $this->item->id, 'text' => 'JGLOBAL_EDIT', 'title' => 'JGLOBAL_EDIT', 'icon' => 'icon-pencil-2'); } if ($this->params->get('enable_notifications', 1) && !$user->guest) { $subscribed = $this->modelSubscription->isSubscriberIssue($this->item->id, $user->id); $task = $subscribed ? 'unsubscribe' : 'subscribe'; $this->buttons['subscribe'] = array('url' => 'index.php?option=com_monitor&task=issue.' . $task . '&id=' . $this->item->id, 'text' => $subscribed ? 'COM_MONITOR_UNSUBSCRIBE_ISSUE' : 'COM_MONITOR_SUBSCRIBE_ISSUE', 'title' => $subscribed ? 'COM_MONITOR_UNSUBSCRIBE_ISSUE_DESC' : 'COM_MONITOR_SUBSCRIBE_ISSUE_DESC', 'icon' => $subscribed ? 'icon-star' : 'icon-star-empty'); } } } else { $this->canEditIssue = $this->model->canEdit($user); $this->defaultTitle = JText::_('COM_MONITOR_CREATE_ISSUE'); } $this->canDeleteComments = $user->authorise('comment.delete', 'com_monitor'); $this->canEditComments = $user->authorise('comment.edit', 'com_monitor'); $this->canEditOwnComments = $user->authorise('comment.edit.own', 'com_monitor'); // Comments if ($this->modelComment) { $this->comments = $this->modelComment->getIssueComments($this->item->id); foreach ($this->comments as $comment) { // Avatars if ($this->avatars !== null) { if (!isset($this->avatars[$comment->author_id])) { $this->avatars[$comment->author_id] = PlgUserCMAvatarHelper::getAvatar($comment->author_id); } } // Attachments $comment->attachments = $this->modelComment->getCommentAttachments($comment->id); } // Pagination $this->pagination = $this->modelComment->getPagination(); // Ordering $this->listOrder = $this->escape($this->modelComment->getState()->get('list.ordering')); $this->listDir = $this->escape($this->modelComment->getState()->get('list.direction')); } $this->status = $this->model->getStatus(); $this->defaultStatus = $this->model->getDefaultStatus(); // Attachments $this->attachments = $this->model->getAttachments(); // Process the content plugins. $dispatcher = JEventDispatcher::getInstance(); JPluginHelper::importPlugin('content'); if ($this->item && $this->getLayout() === 'default') { $dispatcher->trigger('onContentPrepare', array('com_monitor.issue', &$this->item, &$this->params, 0)); $this->item->event = new stdClass(); $results = $dispatcher->trigger('onContentAfterTitle', array('com_monitor.issue', &$this->item, &$this->params, 0)); $this->item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_monitor.issue', &$this->item, &$this->params, 0)); $this->item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_monitor.issue', &$this->item, &$this->params, 0)); $this->item->event->afterDisplayContent = trim(implode("\n", $results)); if ($this->comments) { foreach ($this->comments as $comment) { $dispatcher->trigger('onContentPrepare', array('com_monitor.comment', &$comment, &$this->params, 0)); } } } return parent::render(); }