/**
  * Return the Filepath for the $fid.
  * If $verifypath is TRUE, the method will check whether the path exists on the filesystem and return an empty string if path is not found.
  *
  * @param int $fid
  * @param boolean $verifypath   Verify whether path exists.
  * @return string
  */
 public static function getManagedFilepath($fid, $verifypath = false)
 {
     $managedfile = ManagedfileQuery::create()->findPk($fid);
     $path = $managedfile ? $managedfile->getFilepath() : '';
     if ($verifypath && '' !== $path) {
         // Verify whether file exists.
         $fullpath = Curry_Core::$config->curry->wwwPath . DIRECTORY_SEPARATOR . $path;
         if (!file_exists($fullpath)) {
             $path = '';
         }
     }
     return $path;
 }
示例#2
0
 protected function purge()
 {
     $nbDeleted = ManagedfileQuery::create()->filterByDeleted(true)->delete();
     $this->addMessage("{$nbDeleted} Managedfile records purged.");
 }
 protected function getManagedfilesFromCache($ttl = 1800)
 {
     $cacheName = __CLASS__ . '_' . md5(__METHOD__);
     try {
         if (($ret = Curry_Core::$cache->load($cacheName)) === false) {
             trace('Rebuilding Managedfiles cache.');
             $colManagedfile = ManagedfileQuery::create()->find();
             $ret = Curry_Array::objectsToArray($colManagedfile, 'getFilepath');
             Curry_Core::$cache->save($ret, $cacheName, array(), $ttl);
         }
     } catch (Exception $e) {
         throw $e;
     }
     return $ret;
 }