/**
  * Show file details
  *
  * @param void
  * @return null
  */
 function view()
 {
     if ($this->active_file->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_file->canView($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $last_revision = $this->active_file->getLastRevision();
     if (!instance_of($last_revision, 'Attachment')) {
         flash_error('Invalid file - last revision was not found');
         $this->redirectToUrl(files_module_url($this->active_project));
     }
     // if
     ProjectObjectViews::log($this->active_file, $this->logged_user);
     if ($this->request->isApiCall()) {
         $this->serveData($this->active_file, 'file', array('describe_revisions' => true));
     } else {
         $page = (int) $this->request->get('page');
         if ($page < 1) {
             $page = 1;
         }
         // if
         list($comments, $pagination) = $this->active_file->paginateComments($page, $this->active_file->comments_per_page, $this->logged_user->getVisibility());
         $this->smarty->assign(array('revisions' => $this->active_file->getRevisions(), 'last_revision' => $last_revision, 'comments' => $comments, 'pagination' => $pagination, 'counter' => ($page - 1) * $this->active_file->comments_per_page));
     }
     // if
 }
 /**
  * View the file
  *
  */
 function view()
 {
     if ($this->active_file->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_file->canView($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     $last_revision = $this->active_file->getLastRevision();
     if (!instance_of($last_revision, 'Attachment')) {
         flash_error('Invalid file - last revision was not found');
         $this->redirectToUrl(assemble_url('mobile_access'));
     }
     // if
     ProjectObjectViews::log($this->active_file, $this->logged_user);
     ProjectObjectViews::log($last_revision, $this->logged_user);
     $this->smarty->assign(array('revisions' => $this->active_file->getRevisions(), 'last_revision' => $last_revision, 'page_back_url' => assemble_url('mobile_access_view_files', array('project_id' => $this->active_project->getId()))));
     $this->addBreadcrumb(str_excerpt(clean($this->active_file->getName()), 10), mobile_access_module_get_view_url($this->active_file));
     $this->addBreadcrumb(lang('View'));
 }
 /**
  * Serves up the details for the file bound to this controller
  * 
  * @param  SS_HTTPRequest $r
  * @return SS_HTTPResponse
  */
 public function handleRead(SS_HTTPRequest $r)
 {
     if (!$this->file->canView()) {
         return $this->httpError(403);
     }
     return $this->JSONResponse($this->buildJSON());
 }
 public function canDownloadFile(File $file = null)
 {
     if ($file instanceof File) {
         // Implement a FileExtension with canDownload(), and we'll test that first
         $results = $file->extend('canDownload');
         if ($results && is_array($results)) {
             if (!min($results)) {
                 return false;
             } else {
                 return true;
             }
         }
         // If an extension with canDownload() can't be found, fallback to using canView
         if ($file->canView()) {
             return true;
         }
         return false;
     }
     return false;
 }