setupMusicDirectory(); } else { self::$message = "Invalid path!"; self::$errors[] = self::MEDIA_FOLDER; } return array( "message" => self::$message, "errors" => self::$errors ); } /** * Add the given directory to cc_music_dirs * TODO Should we check for an existing entry in cc_music_dirs? */ function setupMusicDirectory() { try { $_SERVER['AIRTIME_CONF'] = AIRTIME_CONF_TEMP_PATH; Propel::init(CONFIG_PATH . "airtime-conf-production.php"); $con = Propel::getConnection(); } catch(Exception $e) { self::$message = "Failed to insert media folder; database isn't configured properly!"; self::$errors[] = self::MEDIA_FOLDER; return; } $this->runMusicDirsQuery($con); } function runMusicDirsQuery($con) { try { if ($this->checkMusicDirectoryExists($con)) { $dir = CcMusicDirsQuery::create()->findPk(1, $con); } else { $dir = new CcMusicDirs(); } $dir->setDirectory(self::$path) ->setType("stor") ->save(); self::$message = "Successfully set up media folder!"; Propel::close(); unset($_SERVER['AIRTIME_CONF']); } catch (Exception $e) { self::$message = "Failed to insert " . self::$path . " into cc_music_dirs"; self::$errors[] = self::MEDIA_FOLDER; } } function checkMusicDirectoryExists($con) { $entry = CcMusicDirsQuery::create()->findPk(1, $con); return isset($entry) && $entry; } }