getDbCuein(); $cueout = $this->getDbCueout(); $cueinSec = Application_Common_DateHelper::calculateLengthInSeconds($cuein); $cueoutSec = Application_Common_DateHelper::calculateLengthInSeconds($cueout); $lengthSec = bcsub($cueoutSec, $cueinSec, 6); $length = Application_Common_DateHelper::secondsToPlaylistTime($lengthSec); return $length; } public function setDbTrackNumber($v) { $max = pow(2, 31)-1; $v = ($v > $max) ? $max : $v; return parent::setDbTrackNumber($v); } // returns true if the file exists and is not hidden public function visible() { return $this->getDbFileExists() && !$this->getDbHidden(); } public function reassignTo($user) { $this->setDbOwnerId( $user->getDbId() ); $this->save(); } /** * * Strips out the private fields we do not want to send back in API responses * @param $file a CcFiles object */ //TODO: rename this function? public static function sanitizeResponse($file) { $response = $file->toArray(BasePeer::TYPE_FIELDNAME); foreach (self::$privateFields as $key) { unset($response[$key]); } return $response; } public function getFileSize() { return filesize($this->getAbsoluteFilePath()); } public function getFilename() { $info = pathinfo($this->getAbsoluteFilePath()); return $info['filename']; } public function getAbsoluteFilePath() { $music_dir = Application_Model_MusicDir::getDirByPK($this->getDbDirectory()); if (!$music_dir) { throw new Exception("Invalid music_dir for file in database."); } $directory = $music_dir->getDirectory(); $filepath = $this->_file->getDbFilepath(); return Application_Common_OsPath::join($directory, $filepath); } public function isValidFile() { return is_file($this->getAbsoluteFilePath()); } public function deletePhysicalFile() { unlink($this->getAbsoluteFilePath()); } } // CcFiles