Merge branch 'cc-4274' into devel

This commit is contained in:
Rudi Grinberg 2012-08-28 17:25:11 -04:00
commit c67ad44699
4 changed files with 32 additions and 6 deletions
airtime_mvc/application

View File

@ -689,7 +689,8 @@ class ApiController extends Zend_Controller_Action
$request = $this->getRequest(); $request = $this->getRequest();
$dir_id = $request->getParam('dir_id'); $dir_id = $request->getParam('dir_id');
$this->view->files = Application_Model_StoredFile::listAllFiles($dir_id); $this->view->files =
Application_Model_StoredFile::listAllFiles($dir_id,$all=true);
} }
public function listAllWatchedDirsAction() public function listAllWatchedDirsAction()
@ -862,7 +863,8 @@ class ApiController extends Zend_Controller_Action
$watchDir = Application_Model_MusicDir::getDirByPath($rd); $watchDir = Application_Model_MusicDir::getDirByPath($rd);
// get all the files that is under $dirPath // get all the files that is under $dirPath
$files = Application_Model_StoredFile::listAllFiles($dir->getId(), true); $files = Application_Model_StoredFile::listAllFiles(
$dir->getId(),$all=false, true);
foreach ($files as $f) { foreach ($files as $f) {
// if the file is from this mount // if the file is from this mount
if (substr($f->getFilePath(), 0, strlen($rd)) === $rd) { if (substr($f->getFilePath(), 0, strlen($rd)) === $rd) {

View File

@ -1003,19 +1003,21 @@ class Application_Model_StoredFile
* @param $dir_id - if this is not provided, it returns all files with full path constructed. * @param $dir_id - if this is not provided, it returns all files with full path constructed.
* @param $propelObj - if this is true, it returns array of proepl obj * @param $propelObj - if this is true, it returns array of proepl obj
*/ */
public static function listAllFiles($dir_id=null, $propelObj=false) public static function listAllFiles($dir_id=null, $all, $propelObj=false)
{ {
$con = Propel::getConnection(); $con = Propel::getConnection();
$file_exists = $all ? "" : "and f.file_exists = 'TRUE'";
if ($propelObj) { if ($propelObj) {
$sql = "SELECT m.directory || f.filepath as fp" $sql = "SELECT m.directory || f.filepath as fp"
." FROM CC_MUSIC_DIRS m" ." FROM CC_MUSIC_DIRS m"
." LEFT JOIN CC_FILES f" ." LEFT JOIN CC_FILES f"
." ON m.id = f.directory WHERE m.id = $dir_id and f.file_exists = 'TRUE'"; ." ON m.id = f.directory WHERE m.id = $dir_id $file_exists";
} else { } else {
$sql = "SELECT filepath as fp" $sql = "SELECT filepath as fp"
." FROM CC_FILES" ." FROM CC_FILES as f"
." WHERE directory = $dir_id and file_exists = 'TRUE'"; ." WHERE f.directory = $dir_id $file_exists";
} }
$rows = $con->query($sql)->fetchAll(); $rows = $con->query($sql)->fetchAll();

View File

@ -230,6 +230,25 @@ class Application_Model_User
$this->_userInstance->delete(); $this->_userInstance->delete();
} }
} }
public function getOwnedFiles()
{
$user = $this->_userInstance;
// do we need a find call at the end here?
return $user->getCcFilessRelatedByDbOwnerId();
}
public function donateFilesTo($user)
{
$my_files = $this->getOwnedFiles();
foreach ($my_files as $file) {
$file->reassignTo($user);
}
}
public function deleteAllFiles()
{
$my_files = $this->getOwnedFiles();
}
private function createUser() private function createUser()
{ {

View File

@ -40,5 +40,8 @@ class CcFiles extends BaseCcFiles {
return $this; return $this;
} }
public function reassignTo($user) {
$this->setDbOwnerId( $user->getDbId() );
}
} // CcFiles } // CcFiles