Пример #1
0
 /**
  * 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();
 }
Пример #2
0
 /**
  * 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();
 }
Пример #3
0
 /**
  * Builds an URL for the "project" view.
  *
  * @param   array  &$query     An array of URL arguments.
  * @param   array  $menuQuery  The query for the active menu item.
  *
  * @return  array  The URL arguments to use to assemble the subsequent URL.
  */
 private function buildProject(&$query, $menuQuery)
 {
     $url = array();
     $menuView = isset($menuQuery['view']) ? $menuQuery['view'] : null;
     if (isset($query['id'])) {
         $this->modelProject->setProjectId($query['id']);
         $project = $this->modelProject->getProject();
         if ($project) {
             if (!($menuView === 'project' && $query['id'] === $menuQuery['id'])) {
                 $url[0] = $project->alias;
             }
             unset($query['id']);
         }
     }
     unset($query['view']);
     return $url;
 }
Пример #4
0
 /**
  * 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();
     }
 }