/**
  * View a project.
  *
  */
 public function viewAction()
 {
     $__start = getmicrotime();
     $project = $this->projectService->getProject((int) $this->_getParam('id'));
     if ($project == null) {
         $this->flash("Project not found");
         $this->renderView('error.php');
         return;
     }
     $this->view->hideHeader = false;
     $totalCount = $this->projectService->getTaskCount(array('projectid =' => $project->id, 'complete=' => 0));
     $this->view->taskPagerName = 'ptasks';
     $currentPage = ifset($this->_getAllParams(), $this->view->taskPagerName, 1);
     $this->view->totalTasks = $totalCount;
     $this->view->taskListSize = za()->getConfig('project_task_list_size');
     $this->view->displayedTasks = $this->projectService->getTasks(array('projectid =' => $project->id, 'complete=' => 0), 'due asc', $currentPage, za()->getConfig('project_task_list_size'));
     $totalCompleted = $this->projectService->getTaskCount(array('projectid =' => $project->id, 'complete=' => 1));
     $this->view->completedPagerName = 'ctasks';
     $currentPage = ifset($this->_getAllParams(), $this->view->completedPagerName, 1);
     $this->view->totalCompleted = $totalCompleted;
     $this->view->completedTasks = $this->projectService->getTasks(array('projectid =' => $project->id, 'complete=' => 1), 'due asc', $currentPage, za()->getConfig('project_task_list_size'));
     $this->view->projectStatusReports = $this->projectService->getStatusReports($project);
     $this->view->project = $project;
     $this->view->title = $project->title;
     $group = $this->groupService->getGroup($project->ownerid);
     if ($group == null) {
         $this->log->warn("Invalid project owner {$project->ownerid}");
     } else {
     }
     $this->view->groupusers = $project->getUsers();
     $this->view->users = $this->userService->getUserList();
     $this->view->group = $group;
     $this->view->existingWatch = $this->notificationService->getWatch(za()->getUser(), $project);
     $this->view->projectuser = za()->getUser();
     if ($this->_getParam('projectuser')) {
         if ($this->_getParam('projectuser') == 'all') {
             $this->view->projectuser = null;
         } else {
             $this->view->projectuser = $this->userService->getUser($this->_getParam('projectuser'));
         }
     }
     if ($this->view->projectuser && !isset($this->view->groupusers[$this->view->projectuser->id])) {
         $this->view->projectuser = null;
     }
     $where = array('projectid =' => $project->id);
     $new = $this->issueService->getIssues(array('projectid =' => $project->id, 'status =' => Issue::STATUS_NEW));
     if (count($new)) {
         $this->view->newIssues = true;
     } else {
         $this->view->newIssues = false;
     }
     $this->view->issues = $this->issueService->getIssues($where);
     za()->recordStat('projectcontroller::setupview', getmicrotime() - $__start);
     $__start = getmicrotime();
     if ($this->_getParam('_ajax')) {
         $this->renderRawView('project/ajaxView.php');
     } else {
         $this->renderView('project/view.php');
     }
     za()->recordStat('projectcontroller::viewrendered', getmicrotime() - $__start);
 }