Exemplo n.º 1
0
 /**
  * Fetch instance of StoreFile object.<br>
  * Should be supplied with only ONE parameter, all the rest should
  * be NULL.
  *
  * @param int $p_id
  * 		local id
  * @param string $p_gunid
  * 		global unique id of file
  * @param string $p_md5sum
  *    MD5 sum of the file
  * @return StoredFile|NULL
  *    Return NULL if the object doesnt exist in the DB.
  */
 public static function Recall($p_id = null, $p_gunid = null, $p_md5sum = null, $p_filepath = null)
 {
     if (isset($p_id)) {
         $file = CcFilesQuery::create()->findPK(intval($p_id));
     } else {
         if (isset($p_gunid)) {
             $file = CcFilesQuery::create()->filterByDbGunid($p_gunid)->findOne();
         } else {
             if (isset($p_md5sum)) {
                 $file = CcFilesQuery::create()->filterByDbMd5($p_md5sum)->findOne();
             } else {
                 if (isset($p_filepath)) {
                     $path_info = MusicDir::splitFilePath($p_filepath);
                     if (is_null($path_info)) {
                         return null;
                     }
                     $music_dir = MusicDir::getDirByPath($path_info[0]);
                     $file = CcFilesQuery::create()->filterByDbDirectory($music_dir->getId())->filterByDbFilepath($path_info[1])->findOne();
                 } else {
                     return null;
                 }
             }
         }
     }
     if (isset($file)) {
         $storedFile = new StoredFile();
         $storedFile->_file = $file;
         return $storedFile;
     } else {
         return null;
     }
 }
Exemplo n.º 2
0
 public static function removeWatchedDir($p_dir)
 {
     $p_dir = realpath($p_dir) . "/";
     $dir = MusicDir::getDirByPath($p_dir);
     if ($dir == NULL) {
         return array("code" => 1, "error" => "'{$p_dir}' doesn't exist in the watched list.");
     } else {
         $dir->remove();
         $data = array();
         $data["directory"] = $p_dir;
         RabbitMq::SendMessageToMediaMonitor("remove_watch", $data);
         return array("code" => 0);
     }
 }