/** * Method to render the view. * * @return string The rendered view. * * @since 12.1 * @throws RuntimeException */ public function render() { $projects = $this->model->getProjects(); $this->items = $projects; $this->setLayout('default'); $this->defaultTitle = JText::_('COM_MONITOR_PROJECTS'); return parent::render(); }
/** * 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() { $model = new MonitorModelProject(); $id = $this->input->getInt('id'); $model->setProjectId($id); $view = new MonitorViewProjectDisplay($model); echo $view->render(); }
/** * Method to render the view. * * @return string The rendered view. * * @since 12.1 * @throws RuntimeException */ public function render() { $this->prefix = 'project'; $projects = $this->model->getProjects(); $this->items = $projects; $this->setLayout('default'); $this->addToolbar(); return parent::render(); }
/** * Method to render the view. * * @return string The rendered view. * * @throws RuntimeException */ public function render() { $this->item = $this->model->getProject(); if ($this->getLayout() == null) { $this->setLayout('default'); } $this->form = $this->model->getForm(); $this->addToolbar(); return parent::render(); }
/** * 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() { if (!JFactory::getUser()->authorise('project.delete', 'com_monitor')) { throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $app = JFactory::getApplication(); $model = new MonitorModelProject($app); $model->delete($app->input->get('cid', array(), 'array')); $app->enqueueMessage(JText::_('COM_MONITOR_PROJECT_DELETED')); $app->redirect(JRoute::_('index.php?option=com_monitor&view=projects', false)); return true; }
/** * Method to get the field input markup. * * @return string The field input markup. * * @since 11.1 */ protected function getOptions() { $options = array(); JLoader::register('MonitorModelAbstract', JPATH_ROOT . '/administrator/components/com_monitor/model/abstract.php'); JLoader::register('MonitorModelProject', JPATH_ROOT . '/administrator/components/com_monitor/model/project.php'); $model = new MonitorModelProject(null, false); $projects = $model->getProjects(); foreach ($projects as $project) { $options[] = JHtml::_('select.option', $project->id, $project->name); $selected = $this->value && $this->value == $project->id ? ' selected' : ''; } $options = array_merge(parent::getOptions(), $options); return $options; }
/** * 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() { if (!JFactory::getUser()->authorise('project.edit', 'com_monitor')) { throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $app = JFactory::getApplication(); $model = new MonitorModelProject($app); if ($model->save($app->input) === false) { $app->redirect(JRoute::_('index.php?option=com_monitor&task=project.edit&id=' . $app->input->getInt('id'), false)); } else { $app->enqueueMessage(JText::_('COM_MONITOR_PROJECT_SAVED')); $app->redirect(JRoute::_('index.php?option=com_monitor&view=projects', 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() { if (!JFactory::getUser()->authorise('project.edit', 'com_monitor')) { throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403); } $model = new MonitorModelProject(); $cid = $this->input->get('cid', array(), 'array'); $id = $cid ? $cid[0] : $this->input->getInt('id'); $model->setProjectId($id); $model->loadForm(); $view = new MonitorViewProjectHtml($model); $view->setLayout('edit'); echo $view->render(); return true; }
/** * 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(); }
/** * Parse method for URLs * This method is meant to transform the human readable URL back into * query parameters. It is only executed when SEF mode is switched on. * * @param array &$segments The segments of the URL to parse. * * @return array The URL attributes to be used by the application. * * @since 3.3 */ public function parse(&$segments) { /* * Available urls: * * projects * {project} * {project}/issues * {project}/{issue} * {project}/{issue}/edit * comment/edit/{comment} * comments */ $query = array('option' => 'com_monitor'); if (empty($query['Itemid'])) { $menuItem = $this->menu->getActive(); } else { $menuItem = $this->menu->getItem($query['Itemid']); } if (empty(array_filter($segments))) { return $menuItem->query; } $menuQuery = $menuItem !== null && $menuItem->query['option'] === self::COMPONENT ? $menuItem->query : null; self::convertTaskToView($menuQuery); $menuView = isset($menuQuery['view']) ? $menuQuery['view'] : null; if ($segments[0] == 'projects') { $query['view'] = 'projects'; } elseif ($segments[0] == 'issues') { $query['view'] = 'issues'; if ($menuView == 'project' && isset($menuQuery['id'])) { $query['project_id'] = $menuQuery['id']; } } elseif ($segments[0] == 'comment') { $query['view'] = 'comment'; $query['layout'] = $segments[1] === 'delete' ? 'delete' : 'edit'; if (isset($segments[1]) && $segments[1] == 'new' && is_numeric($segments[2])) { $query['issue_id'] = $segments[2]; } elseif (is_numeric($segments[2])) { $query['id'] = $segments[2]; } } elseif ($segments[0] == 'comments') { $query['view'] = 'comments'; } elseif (is_numeric($segments[0])) { $query['view'] = 'issue'; $query['id'] = $segments[0]; if (isset($segments[1]) && $segments[1] === 'edit') { $query['layout'] = 'edit'; } } elseif ($segments[0] === 'edit' || $segments[0] === 'new') { $query['layout'] = 'edit'; if ($menuView === 'comment') { $query['view'] = 'comment'; if (is_numeric($segments[1])) { if ($segments[0] === 'new') { $query['issue_id'] = $segments[1]; } else { $query['id'] = $segments[1]; } } } else { $query['view'] = 'issue'; if ($segments[0] === 'new') { if (isset($menuQuery['id'])) { $query['project_id'] = $menuQuery['id']; } elseif (isset($menuQuery['project_id'])) { $query['project_id'] = $menuQuery['project_id']; } } else { if (isset($menuQuery['id'])) { $query['id'] = $menuQuery['id']; } } } } else { // {project} if (!isset($segments[1])) { $id = $this->modelProject->resolveAlias($segments[0]); $query['view'] = 'project'; $query['id'] = $id; } else { // {project}/issues if ($segments[1] === 'issues') { $id = $this->modelProject->resolveAlias($segments[0]); $query['view'] = 'issues'; $query['project_id'] = $id; } else { $query['view'] = 'issue'; // {project}/new if ($segments[1] === 'new') { $id = $this->modelProject->resolveAlias($segments[0]); $query['layout'] = 'edit'; $query['project_id'] = $id; } elseif (is_numeric($segments[1])) { $query['id'] = $segments[1]; // {project}/{issue}/edit if (isset($segments[2]) && $segments[2] == 'edit') { $query['layout'] = 'edit'; } } } } } return $query; }
/** * Notifies all users who have subscribed to the project. * * @param int $projectId ID of the project. * @param JUser $author The user who created a new issue. * @param int $issueId Direct link to the newly created issue. * * @return null */ public function notifyProject($projectId, $author, $issueId) { // Get subscribing users. $query = $this->db->getQuery(true); $query->select('u.email, u.name, u.username')->from('#__monitor_subscriptions_projects AS s')->leftJoin('#__users AS u ON s.user_id = u.id')->where('s.item_id = ' . $projectId)->where('s.user_id != ' . $author->get('id')); $users = $this->db->setQuery($query)->loadObjectList(); // Set values that are common for every notification mail. $authorName = $author->get('name', $author->get('username')); $issueLink = JRoute::_('index.php?option=com_monitor&view=issue&id=' . (int) $issueId, false); $unsubscribeLink = JRoute::_('index.php?option=com_monitor&task=project.unsubscribe&id=' . (int) $projectId, false); $baseUrl = JUri::getInstance()->toString(array('scheme', 'user', 'pass', 'host', 'port')); $modelIssue = new MonitorModelIssue($this->app, false); $modelIssue->setIssueId($issueId); $issue = $modelIssue->getIssue(); $modelProject = new MonitorModelProject($this->app, false); $modelProject->setProjectId($projectId); $project = $modelProject->getProject(); foreach ($users as $user) { $recipientName = empty($user->name) ? $user->username : $user->name; $subject = JText::sprintf('COM_MONITOR_MAIL_NOTIFICATION_PROJECT_HEADER', $project->name, $issue->title); $message = JText::sprintf('COM_MONITOR_MAIL_NOTIFICATION_PROJECT_TEXT', $recipientName, $authorName, $issue->title, $project->name, $baseUrl . $issueLink, $baseUrl . $unsubscribeLink); $mail = JFactory::getMailer(); $mail->isHtml(false); $mail->setSubject($subject); $mail->setBody($message); $mail->addRecipient($user->email, $recipientName); $mail->Send(); } }