Merge branch 'devel' of dev.sourcefabric.org:airtime into devel

This commit is contained in:
Martin Konecny 2012-08-29 11:05:14 -04:00
commit 8b5f94fa9f
10 changed files with 87 additions and 21 deletions

View file

@ -686,7 +686,8 @@ class ApiController extends Zend_Controller_Action
$request = $this->getRequest();
$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()
@ -859,7 +860,8 @@ class ApiController extends Zend_Controller_Action
$watchDir = Application_Model_MusicDir::getDirByPath($rd);
// 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) {
// if the file is from this mount
if (substr($f->getFilePath(), 0, strlen($rd)) === $rd) {

View file

@ -13,6 +13,7 @@ class UsersettingsController extends Zend_Controller_Action
->addActionContext('get-timeline-datatable', 'json')
->addActionContext('set-timeline-datatable', 'json')
->addActionContext('remindme', 'json')
->addActionContext('remindme-never', 'json')
->addActionContext('donotshowregistrationpopup', 'json')
->initContext();
}
@ -88,6 +89,13 @@ class UsersettingsController extends Zend_Controller_Action
Zend_Session::namespaceUnset('referrer');
Application_Model_Preference::SetRemindMeDate();
}
public function remindmeNeverAction()
{
Zend_Session::namespaceUnset('referrer');
//pass in true to indicate 'Remind me never' was clicked
Application_Model_Preference::SetRemindMeDate(true);
}
public function donotshowregistrationpopupAction()
{

View file

@ -35,7 +35,7 @@ class Application_Model_Email
);
} else {
$config = array(
'ssl' => 'ssl'
'ssl' => 'tls'
);
}

View file

@ -587,10 +587,14 @@ class Application_Model_Preference
}
}
public static function SetRemindMeDate()
public static function SetRemindMeDate($p_never = false)
{
$weekAfter = mktime(0, 0, 0, gmdate("m"), gmdate("d")+7, gmdate("Y"));
self::setValue("remindme", $weekAfter);
if ($p_never) {
self::setValue("remindme", -1);
} else {
$weekAfter = mktime(0, 0, 0, gmdate("m"), gmdate("d")+7, gmdate("Y"));
self::setValue("remindme", $weekAfter);
}
}
public static function GetRemindMeDate()
@ -1105,9 +1109,13 @@ class Application_Model_Preference
{
$today = mktime(0, 0, 0, gmdate("m"), gmdate("d"), gmdate("Y"));
$remindDate = Application_Model_Preference::GetRemindMeDate();
if ($remindDate == NULL || $today >= $remindDate) {
return true;
$retVal = false;
if ($remindDate == NULL || ($remindDate != -1 && $today >= $remindDate)) {
$retVal = true;
}
return $retVal;
}
public static function getCurrentLibraryTableSetting()

View file

@ -1006,19 +1006,21 @@ class Application_Model_StoredFile
* @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
*/
public static function listAllFiles($dir_id=null, $propelObj=false)
public static function listAllFiles($dir_id=null, $all, $propelObj=false)
{
$con = Propel::getConnection();
$file_exists = $all ? "" : "and f.file_exists = 'TRUE'";
if ($propelObj) {
$sql = "SELECT m.directory || f.filepath as fp"
." FROM CC_MUSIC_DIRS m"
." 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 {
$sql = "SELECT filepath as fp"
." FROM CC_FILES"
." WHERE directory = $dir_id and file_exists = 'TRUE'";
." FROM CC_FILES as f"
." WHERE f.directory = $dir_id $file_exists";
}
$rows = $con->query($sql)->fetchAll();

View file

@ -231,6 +231,25 @@ class Application_Model_User
$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()
{

View file

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