Beispiel #1
0
 /**
  * Gets a list of projects for a given client object, fully loaded with all 
  * sub projects and milestones too
  * 
  * @param $client
  * 			The client to get the list of child projects for
  * 
  */
 public function getProjectsForClient($client)
 {
     $clientid = $client;
     if (is_object($client)) {
         $clientid = $client->id;
     }
     $items = $this->cacheService->get($this->clientProjectsCacheKey($clientid));
     if ($items !== null) {
         return $items;
     }
     $projects = $this->getProjects(array('clientid=' => $clientid, 'parentid=' => 0));
     // now go through and load all sub projects too
     foreach ($projects as $project) {
         $this->initialiseProject($project);
     }
     // now we should be okay to cache this list out.
     $this->cacheService->store($this->clientProjectsCacheKey($clientid), $projects, 1800);
     return $projects;
 }
Beispiel #2
0
 /**
  * List files from a project
  *
  */
 public function filelistAction()
 {
     $project = $this->byId($this->_getParam('projectid'), 'Project');
     $client = $this->byId($project->clientid, 'Client');
     $folder = $this->_getParam('folder', '');
     $path = 'Clients/' . $client->title . '/Projects/' . $project->title;
     $projectPath = $path;
     $parent = '';
     if ($folder != null && mb_strlen($folder)) {
         $path = base64_decode($folder);
         $parent = dirname($path);
         if ($path == $projectPath) {
             $parent = '';
         }
     }
     $content = $this->cacheService->get($path);
     if (!$content) {
         $files = array();
         try {
             $files = $this->fileService->listDirectory($path);
         } catch (Exception $e) {
             $this->log->err("Failed loading files from {$path}");
         }
         $this->view->files = $files;
         $this->view->project = $project;
         if ($path == '/') {
             $this->view->base = '';
         } else {
             $this->view->base = trim($path, '/') . '/';
         }
         $this->view->parentPath = $parent;
         $content = $this->view->render('project/file-list.php');
         $this->cacheService->store($path, $content);
     }
     $this->getResponse()->appendBody($content);
 }