diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index d996d6d4c..7c38fbdb6 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -26,6 +26,8 @@ class ApiController extends Zend_Controller_Action ->addActionContext('update-liquidsoap-status', 'json') ->addActionContext('library-init', 'json') ->addActionContext('live-chat', 'json') + ->addActionContext('update-file-system-mount', 'json') + ->addActionContext('handle-watched-dir-missing', 'json') ->initContext(); } @@ -560,16 +562,15 @@ class ApiController extends Zend_Controller_Action // update import timestamp Application_Model_Preference::SetImportTimestamp(); - Logging::log("mode: ".$mode); if ($mode == "create") { $filepath = $md['MDATA_KEY_FILEPATH']; $filepath = str_replace("\\", "", $filepath); + $filepath = str_replace("//", "/", $filepath); $file = Application_Model_StoredFile::RecallByFilepath($filepath); - + if (is_null($file)) { $file = Application_Model_StoredFile::Insert($md); - Logging::log("file: ".print_r($file, true)); } else { // path already exist @@ -815,5 +816,78 @@ class ApiController extends Zend_Controller_Action "numEntries"=>Application_Model_Preference::GetLibraryNumEntries() ); } + + // handles addition/deletion of mount point which watched dirs reside + public function updateFileSystemMountAction(){ + global $CC_CONFIG; + + $request = $this->getRequest(); + $api_key = $request->getParam('api_key'); + if (!in_array($api_key, $CC_CONFIG["apiKey"])) + { + header('HTTP/1.0 401 Unauthorized'); + print 'You are not allowed to access this resource.'; + exit; + } + + $params = $request->getParams(); + + $temp_list = $params['mount_list']; + $mount_list = explode(',',$temp_list); + + // get all watched dirs + $dirs = Application_Model_MusicDir::getWatchedDirs(null, null); + + // dirs to be added to watch list again + $addedDirs = array(); + // dirs to be deleted from watch list + $removedDirs = array(); + + $tempDirs = Application_Model_MusicDir::getWatchedDirs(true,null); + foreach( $tempDirs as $d) + { + $removedDirs[$d->getDirectory()] = $d; + } + foreach( $dirs as $dir){ + // set Exsits as false as default + foreach($mount_list as $mount_path){ + if($mount_path == '/'){ + continue; + } + // if dir contaions mount_path + if(strstr($dir->getDirectory(),$mount_path)){ + if($dir->getExistsFlag() == false){ + $addedDirs[] = $dir; + }else{ + unset($removedDirs[$dir->getDirector()]); + } + } + } + } + + foreach($addedDirs as $ad){ + Application_Model_MusicDir::addWatchedDir($ad->getDirectory(), false); + } + foreach($removedDirs as $rd){ + Application_Model_MusicDir::removeWatchedDir($rd->getDirectory(), false); + } + } + + // handles case where watched dir is missing + public function handleWatchedDirMissingAction(){ + global $CC_CONFIG; + + $request = $this->getRequest(); + $api_key = $request->getParam('api_key'); + if (!in_array($api_key, $CC_CONFIG["apiKey"])) + { + header('HTTP/1.0 401 Unauthorized'); + print 'You are not allowed to access this resource.'; + exit; + } + + $dir = base64_decode($request->getParam('dir')); + Application_Model_MusicDir::removeWatchedDir($dir, false); + } } diff --git a/airtime_mvc/application/models/MusicDir.php b/airtime_mvc/application/models/MusicDir.php index cb2a0cea2..d440f6096 100644 --- a/airtime_mvc/application/models/MusicDir.php +++ b/airtime_mvc/application/models/MusicDir.php @@ -40,19 +40,28 @@ class Application_Model_MusicDir { $this->_dir->save(); } - public function setRemoved($flag){ + public function setExistsFlag($flag){ + $this->_dir->setExists($flag); + $this->_dir->save(); + } + + public function setRemovedFlag($flag){ $this->_dir->setRemoved($flag); $this->_dir->save(); } - public function getRemoved(){ + public function getRemovedFlag(){ return $this->_dir->getRemoved(); } - public function remove() + public function getExistsFlag(){ + return $this->_dir->getExists(); + } + + public function remove($setRemovedFlag=true) { global $CC_DBC; -Logging::log("remove!!"); + $music_dir_id = $this->getId(); $sql = "SELECT DISTINCT s.instance_id from cc_music_dirs as md LEFT JOIN cc_files as f on f.directory = md.id @@ -66,24 +75,24 @@ Logging::log("remove!!"); // set file_exist flag to false foreach( $files as $file_row ){ - Logging::log(print_r($file_row['id'], true)); $temp_file = Application_Model_StoredFile::Recall($file_row['id']); - $temp_file->setFileExistFlag(false); + if($temp_file != null){ + $temp_file->setFileExistFlag(false); + } } - -Logging::log("remove!!222222"); -Logging::log(print_r($this->_dir,true)); - // set Removed flat to true - self::setRemoved(true); + // set RemovedFlag to true + if($setRemovedFlag){ + self::setRemovedFlag(true); + }else{ + self::setExistsFlag(false); + } //$res = $this->_dir->delete(); -Logging::log("remove!!44444"); foreach ($show_instances as $show_instance_row) { $temp_show = new Application_Model_ShowInstance($show_instance_row["instance_id"]); $temp_show->updateScheduledTime(); } -Logging::log("remove end!!"); Application_Model_RabbitMq::PushSchedule(); } @@ -119,7 +128,7 @@ Logging::log("remove end!!"); public static function isPathValid($p_path){ $dirs = self::getWatchedDirs(); $dirs[] = self::getStorDir(); -Logging::log("dirs: ".print_r($dirs, true)); + foreach ($dirs as $dirObj){ $dir = $dirObj->getDirectory(); $diff = strlen($dir) - strlen($p_path); @@ -139,7 +148,7 @@ Logging::log("dirs: ".print_r($dirs, true)); } } - public static function addDir($p_path, $p_type) + public static function addDir($p_path, $p_type, $setRemovedFlag=true) { if(!is_dir($p_path)){ return array("code"=>2, "error"=>"'$p_path' is not a valid directory."); @@ -148,14 +157,13 @@ Logging::log("dirs: ".print_r($dirs, true)); if($real_path != "/"){ $p_path = $real_path; } - Logging::log("dir:".print_r($p_path, true)); + $exist_dir = self::getDirByPath($p_path); - Logging::log(print_r($exist_dir, true)); + if( $exist_dir == NULL ){ - Logging::log("new"); - $dir = new CcMusicDirs(); + $temp_dir = new CcMusicDirs(); + $dir = new Application_Model_MusicDir($temp_dir); }else{ - Logging::log("exist"); $dir = $exist_dir; } @@ -167,12 +175,13 @@ Logging::log("dirs: ".print_r($dirs, true)); /* isPathValid() checks if path is a substring or a superstring of an * existing dir and if not, throws NestedDirectoryException */ self::isPathValid($p_path); - $dir->setRemoved(false); - $dir->setDirectory($p_path); - Logging::log("dir obj:".print_r($dir, true)); - if( $exist_dir == NULL ){ - $dir->save(); + if($setRemovedFlag){ + $dir->setRemovedFlag(false); + }else{ + $dir->setExistsFlag(true); } + $dir->setDirectory($p_path); + return array("code"=>0); } catch (NestedDirectoryException $nde){ $msg = $nde->getMessage(); @@ -183,9 +192,20 @@ Logging::log("dirs: ".print_r($dirs, true)); } - public static function addWatchedDir($p_path) + /** There are 2 cases where this function can be called. + * 1. When watched dir was added + * 2. When some dir was watched, but it was unmounted somehow, but gets mounted again + * + * In case of 1, $setRemovedFlag should be true + * In case of 2, $setRemovedFlag should be false + * + * When $setRemovedFlag is true, it will set "Removed" flag to false + * otherwise, it will set "Exists" flag to true + **/ + public static function addWatchedDir($p_path, $setRemovedFlag=true) { - $res = self::addDir($p_path, "watched"); + $res = self::addDir($p_path, "watched", $setRemovedFlag); + if ($res['code'] == 0){ //convert "linked" files (Airtime <= 1.8.2) to watched files. @@ -243,7 +263,6 @@ Logging::log("dirs: ".print_r($dirs, true)); public static function getDirByPath($p_path) { - Logging::log($p_path); $dir = CcMusicDirsQuery::create() ->filterByDirectory($p_path) ->findOne(); @@ -256,15 +275,26 @@ Logging::log("dirs: ".print_r($dirs, true)); return $mus_dir; } } - - public static function getWatchedDirs() + + /** + * Search and returns watched dirs + * + * @param $exists search condition with exists flag + * @param $removed search condition with removed flag + */ + public static function getWatchedDirs($exists=true, $removed=false) { $result = array(); $dirs = CcMusicDirsQuery::create() - ->filterByType("watched") - ->filterByRemoved(false) - ->find(); + ->filterByType("watched"); + if($exists !== null){ + $dirs = $dirs->filterByExists($exists); + } + if($removed !== null){ + $dirs = $dirs->filterByRemoved($removed); + } + $dirs = $dirs->find(); foreach($dirs as $dir) { $result[] = new Application_Model_MusicDir($dir); @@ -311,7 +341,7 @@ Logging::log("dirs: ".print_r($dirs, true)); { $dirs = CcMusicDirsQuery::create() ->filterByType(array("watched", "stor")) - ->filterByRemoved(false) + ->filterByExists(true) ->find(); foreach($dirs as $dir) { @@ -325,17 +355,27 @@ Logging::log("dirs: ".print_r($dirs, true)); return null; } - public static function removeWatchedDir($p_dir){ + /** There are 2 cases where this function can be called. + * 1. When watched dir was removed + * 2. When some dir was watched, but it was unmounted + * + * In case of 1, $setRemovedFlag should be true + * In case of 2, $setRemovedFlag should be false + * + * When $setRemovedFlag is true, it will set "Removed" flag to false + * otherwise, it will set "Exists" flag to true + **/ + public static function removeWatchedDir($p_dir, $setRemovedFlag=true){ $real_path = realpath($p_dir)."/"; if($real_path != "/"){ $p_dir = $real_path; } $dir = Application_Model_MusicDir::getDirByPath($p_dir); - Logging::log(print_r($dir,true)); + if($dir == NULL){ return array("code"=>1,"error"=>"'$p_dir' doesn't exist in the watched list."); }else{ - $dir->remove(); + $dir->remove($setRemovedFlag); $data = array(); $data["directory"] = $p_dir; Application_Model_RabbitMq::SendMessageToMediaMonitor("remove_watch", $data); @@ -346,7 +386,7 @@ Logging::log("dirs: ".print_r($dirs, true)); public static function splitFilePath($p_filepath) { $mus_dir = self::getWatchedDirFromFilepath($p_filepath); -Logging::log("mus_dir:".print_r($mus_dir, true)); + if(is_null($mus_dir)) { return null; } @@ -354,7 +394,7 @@ Logging::log("mus_dir:".print_r($mus_dir, true)); $length_dir = strlen($mus_dir->getDirectory()); $fp = substr($p_filepath, $length_dir); - return array($mus_dir->getDirectory(), $fp); + return array($mus_dir->getDirectory(), trim($fp)); } } diff --git a/airtime_mvc/application/models/StoredFile.php b/airtime_mvc/application/models/StoredFile.php index 48c0daa12..95e99556f 100644 --- a/airtime_mvc/application/models/StoredFile.php +++ b/airtime_mvc/application/models/StoredFile.php @@ -431,7 +431,7 @@ class Application_Model_StoredFile { public function setFilePath($p_filepath) { $path_info = Application_Model_MusicDir::splitFilePath($p_filepath); - Logging::log("path_info:".print_r($path_info, true)); + if (is_null($path_info)) { return -1; } @@ -499,7 +499,9 @@ class Application_Model_StoredFile { $storedFile->_file = $file; if(isset($md['MDATA_KEY_FILEPATH'])) { - $res = $storedFile->setFilePath($md['MDATA_KEY_FILEPATH']); + // removed "//" in the path. Always use '/' for path separator + $filepath = str_replace("//", "/", $md['MDATA_KEY_FILEPATH']); + $res = $storedFile->setFilePath($filepath); if ($res === -1) { return null; } diff --git a/airtime_mvc/application/models/airtime/map/CcMusicDirsTableMap.php b/airtime_mvc/application/models/airtime/map/CcMusicDirsTableMap.php index dcd3d3ba1..469a87390 100644 --- a/airtime_mvc/application/models/airtime/map/CcMusicDirsTableMap.php +++ b/airtime_mvc/application/models/airtime/map/CcMusicDirsTableMap.php @@ -41,6 +41,7 @@ class CcMusicDirsTableMap extends TableMap { $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); $this->addColumn('DIRECTORY', 'Directory', 'LONGVARCHAR', false, null, null); $this->addColumn('TYPE', 'Type', 'VARCHAR', false, 255, null); + $this->addColumn('EXISTS', 'Exists', 'BOOLEAN', false, null, true); $this->addColumn('REMOVED', 'Removed', 'BOOLEAN', false, null, false); // validators } // initialize() diff --git a/airtime_mvc/application/models/airtime/om/BaseCcMusicDirs.php b/airtime_mvc/application/models/airtime/om/BaseCcMusicDirs.php index 62dc92a81..b3ebe3c13 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcMusicDirs.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcMusicDirs.php @@ -42,6 +42,13 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent */ protected $type; + /** + * The value for the exists field. + * Note: this column has a database default value of: true + * @var boolean + */ + protected $exists; + /** * The value for the removed field. * Note: this column has a database default value of: false @@ -76,6 +83,7 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent */ public function applyDefaultValues() { + $this->exists = true; $this->removed = false; } @@ -119,6 +127,16 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent return $this->type; } + /** + * Get the [exists] column value. + * + * @return boolean + */ + public function getExists() + { + return $this->exists; + } + /** * Get the [removed] column value. * @@ -189,6 +207,27 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent return $this; } // setType() + /** + * Set the value of [exists] column. + * + * @param boolean $v new value + * @return CcMusicDirs The current object (for fluent API support) + */ + public function setExists($v) + { + Logging::log("setting exists to ".print_r($v, true)); + if ($v !== null) { + $v = (boolean) $v; + } + + if ($this->exists !== $v || $this->isNew()) { + $this->exists = $v; + $this->modifiedColumns[] = CcMusicDirsPeer::EXISTS; + } + + return $this; + } // setExists() + /** * Set the value of [removed] column. * @@ -219,6 +258,10 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent */ public function hasOnlyDefaultValues() { + if ($this->exists !== true) { + return false; + } + if ($this->removed !== false) { return false; } @@ -248,7 +291,8 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent $this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; $this->directory = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; $this->type = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null; - $this->removed = ($row[$startcol + 3] !== null) ? (boolean) $row[$startcol + 3] : null; + $this->exists = ($row[$startcol + 3] !== null) ? (boolean) $row[$startcol + 3] : null; + $this->removed = ($row[$startcol + 4] !== null) ? (boolean) $row[$startcol + 4] : null; $this->resetModified(); $this->setNew(false); @@ -257,7 +301,7 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent $this->ensureConsistency(); } - return $startcol + 4; // 4 = CcMusicDirsPeer::NUM_COLUMNS - CcMusicDirsPeer::NUM_LAZY_LOAD_COLUMNS). + return $startcol + 5; // 5 = CcMusicDirsPeer::NUM_COLUMNS - CcMusicDirsPeer::NUM_LAZY_LOAD_COLUMNS). } catch (Exception $e) { throw new PropelException("Error populating CcMusicDirs object", $e); @@ -584,6 +628,9 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent return $this->getType(); break; case 3: + return $this->getExists(); + break; + case 4: return $this->getRemoved(); break; default: @@ -612,7 +659,8 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent $keys[0] => $this->getId(), $keys[1] => $this->getDirectory(), $keys[2] => $this->getType(), - $keys[3] => $this->getRemoved(), + $keys[3] => $this->getExists(), + $keys[4] => $this->getRemoved(), ); return $result; } @@ -654,6 +702,9 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent $this->setType($value); break; case 3: + $this->setExists($value); + break; + case 4: $this->setRemoved($value); break; } // switch() @@ -683,7 +734,8 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); if (array_key_exists($keys[1], $arr)) $this->setDirectory($arr[$keys[1]]); if (array_key_exists($keys[2], $arr)) $this->setType($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setRemoved($arr[$keys[3]]); + if (array_key_exists($keys[3], $arr)) $this->setExists($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setRemoved($arr[$keys[4]]); } /** @@ -698,6 +750,7 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent if ($this->isColumnModified(CcMusicDirsPeer::ID)) $criteria->add(CcMusicDirsPeer::ID, $this->id); if ($this->isColumnModified(CcMusicDirsPeer::DIRECTORY)) $criteria->add(CcMusicDirsPeer::DIRECTORY, $this->directory); if ($this->isColumnModified(CcMusicDirsPeer::TYPE)) $criteria->add(CcMusicDirsPeer::TYPE, $this->type); + if ($this->isColumnModified(CcMusicDirsPeer::EXISTS)) $criteria->add(CcMusicDirsPeer::EXISTS, $this->exists); if ($this->isColumnModified(CcMusicDirsPeer::REMOVED)) $criteria->add(CcMusicDirsPeer::REMOVED, $this->removed); return $criteria; @@ -762,6 +815,7 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent { $copyObj->setDirectory($this->directory); $copyObj->setType($this->type); + $copyObj->setExists($this->exists); $copyObj->setRemoved($this->removed); if ($deepCopy) { @@ -962,6 +1016,7 @@ abstract class BaseCcMusicDirs extends BaseObject implements Persistent $this->id = null; $this->directory = null; $this->type = null; + $this->exists = null; $this->removed = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; diff --git a/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsPeer.php b/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsPeer.php index 11363ec59..00869ea7a 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsPeer.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsPeer.php @@ -26,7 +26,7 @@ abstract class BaseCcMusicDirsPeer { const TM_CLASS = 'CcMusicDirsTableMap'; /** The total number of columns. */ - const NUM_COLUMNS = 4; + const NUM_COLUMNS = 5; /** The number of lazy-loaded columns. */ const NUM_LAZY_LOAD_COLUMNS = 0; @@ -40,6 +40,9 @@ abstract class BaseCcMusicDirsPeer { /** the column name for the TYPE field */ const TYPE = 'cc_music_dirs.TYPE'; + /** the column name for the EXISTS field */ + const EXISTS = 'cc_music_dirs.EXISTS'; + /** the column name for the REMOVED field */ const REMOVED = 'cc_music_dirs.REMOVED'; @@ -59,12 +62,12 @@ abstract class BaseCcMusicDirsPeer { * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ private static $fieldNames = array ( - BasePeer::TYPE_PHPNAME => array ('Id', 'Directory', 'Type', 'Removed', ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'directory', 'type', 'removed', ), - BasePeer::TYPE_COLNAME => array (self::ID, self::DIRECTORY, self::TYPE, self::REMOVED, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID', 'DIRECTORY', 'TYPE', 'REMOVED', ), - BasePeer::TYPE_FIELDNAME => array ('id', 'directory', 'type', 'removed', ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + BasePeer::TYPE_PHPNAME => array ('Id', 'Directory', 'Type', 'Exists', 'Removed', ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id', 'directory', 'type', 'exists', 'removed', ), + BasePeer::TYPE_COLNAME => array (self::ID, self::DIRECTORY, self::TYPE, self::EXISTS, self::REMOVED, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID', 'DIRECTORY', 'TYPE', 'EXISTS', 'REMOVED', ), + BasePeer::TYPE_FIELDNAME => array ('id', 'directory', 'type', 'exists', 'removed', ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) ); /** @@ -74,12 +77,12 @@ abstract class BaseCcMusicDirsPeer { * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 */ private static $fieldKeys = array ( - BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Directory' => 1, 'Type' => 2, 'Removed' => 3, ), - BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'directory' => 1, 'type' => 2, 'removed' => 3, ), - BasePeer::TYPE_COLNAME => array (self::ID => 0, self::DIRECTORY => 1, self::TYPE => 2, self::REMOVED => 3, ), - BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'DIRECTORY' => 1, 'TYPE' => 2, 'REMOVED' => 3, ), - BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'directory' => 1, 'type' => 2, 'removed' => 3, ), - BasePeer::TYPE_NUM => array (0, 1, 2, 3, ) + BasePeer::TYPE_PHPNAME => array ('Id' => 0, 'Directory' => 1, 'Type' => 2, 'Exists' => 3, 'Removed' => 4, ), + BasePeer::TYPE_STUDLYPHPNAME => array ('id' => 0, 'directory' => 1, 'type' => 2, 'exists' => 3, 'removed' => 4, ), + BasePeer::TYPE_COLNAME => array (self::ID => 0, self::DIRECTORY => 1, self::TYPE => 2, self::EXISTS => 3, self::REMOVED => 4, ), + BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'DIRECTORY' => 1, 'TYPE' => 2, 'EXISTS' => 3, 'REMOVED' => 4, ), + BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'directory' => 1, 'type' => 2, 'exists' => 3, 'removed' => 4, ), + BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) ); /** @@ -154,11 +157,13 @@ abstract class BaseCcMusicDirsPeer { $criteria->addSelectColumn(CcMusicDirsPeer::ID); $criteria->addSelectColumn(CcMusicDirsPeer::DIRECTORY); $criteria->addSelectColumn(CcMusicDirsPeer::TYPE); + $criteria->addSelectColumn(CcMusicDirsPeer::EXISTS); $criteria->addSelectColumn(CcMusicDirsPeer::REMOVED); } else { $criteria->addSelectColumn($alias . '.ID'); $criteria->addSelectColumn($alias . '.DIRECTORY'); $criteria->addSelectColumn($alias . '.TYPE'); + $criteria->addSelectColumn($alias . '.EXISTS'); $criteria->addSelectColumn($alias . '.REMOVED'); } } diff --git a/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsQuery.php b/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsQuery.php index 5cd9149bd..d65d23194 100644 --- a/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsQuery.php +++ b/airtime_mvc/application/models/airtime/om/BaseCcMusicDirsQuery.php @@ -9,11 +9,13 @@ * @method CcMusicDirsQuery orderById($order = Criteria::ASC) Order by the id column * @method CcMusicDirsQuery orderByDirectory($order = Criteria::ASC) Order by the directory column * @method CcMusicDirsQuery orderByType($order = Criteria::ASC) Order by the type column + * @method CcMusicDirsQuery orderByExists($order = Criteria::ASC) Order by the exists column * @method CcMusicDirsQuery orderByRemoved($order = Criteria::ASC) Order by the removed column * * @method CcMusicDirsQuery groupById() Group by the id column * @method CcMusicDirsQuery groupByDirectory() Group by the directory column * @method CcMusicDirsQuery groupByType() Group by the type column + * @method CcMusicDirsQuery groupByExists() Group by the exists column * @method CcMusicDirsQuery groupByRemoved() Group by the removed column * * @method CcMusicDirsQuery leftJoin($relation) Adds a LEFT JOIN clause to the query @@ -30,11 +32,13 @@ * @method CcMusicDirs findOneById(int $id) Return the first CcMusicDirs filtered by the id column * @method CcMusicDirs findOneByDirectory(string $directory) Return the first CcMusicDirs filtered by the directory column * @method CcMusicDirs findOneByType(string $type) Return the first CcMusicDirs filtered by the type column + * @method CcMusicDirs findOneByExists(boolean $exists) Return the first CcMusicDirs filtered by the exists column * @method CcMusicDirs findOneByRemoved(boolean $removed) Return the first CcMusicDirs filtered by the removed column * * @method array findById(int $id) Return CcMusicDirs objects filtered by the id column * @method array findByDirectory(string $directory) Return CcMusicDirs objects filtered by the directory column * @method array findByType(string $type) Return CcMusicDirs objects filtered by the type column + * @method array findByExists(boolean $exists) Return CcMusicDirs objects filtered by the exists column * @method array findByRemoved(boolean $removed) Return CcMusicDirs objects filtered by the removed column * * @package propel.generator.airtime.om @@ -206,6 +210,23 @@ abstract class BaseCcMusicDirsQuery extends ModelCriteria return $this->addUsingAlias(CcMusicDirsPeer::TYPE, $type, $comparison); } + /** + * Filter the query on the exists column + * + * @param boolean|string $exists The value to use as filter. + * Accepts strings ('false', 'off', '-', 'no', 'n', and '0' are false, the rest is true) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return CcMusicDirsQuery The current query, for fluid interface + */ + public function filterByExists($exists = null, $comparison = null) + { + if (is_string($exists)) { + $exists = in_array(strtolower($exists), array('false', 'off', '-', 'no', 'n', '0')) ? false : true; + } + return $this->addUsingAlias(CcMusicDirsPeer::EXISTS, $exists, $comparison); + } + /** * Filter the query on the removed column * diff --git a/airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml b/airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml index f384eb752..29637502e 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_watched_dirs.phtml @@ -33,12 +33,12 @@ - + 0): ?>