Пример #1
0
 /**
  * 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();
 }
Пример #2
0
 /**
  * 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;
 }
Пример #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();
     }
 }