diff --git a/airtime_mvc/application/controllers/NowplayingController.php b/airtime_mvc/application/controllers/NowplayingController.php index 7c4815ae5..257b354a2 100644 --- a/airtime_mvc/application/controllers/NowplayingController.php +++ b/airtime_mvc/application/controllers/NowplayingController.php @@ -24,10 +24,10 @@ class NowplayingController extends Zend_Controller_Action $refer_sses = new Zend_Session_Namespace('referrer'); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $user = new User($userInfo->id); - - $form = new Application_Form_RegisterAirtime(); - + if ($request->isPost()) { + $form = new Application_Form_RegisterAirtime(); + $values = $request->getPost(); if ($values["Publicise"] != 1){ Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]); @@ -64,6 +64,10 @@ class NowplayingController extends Zend_Controller_Action //popup if previous page was login if($refer_sses->referrer == 'login' && Application_Model_Nowplaying::ShouldShowPopUp() && !Application_Model_Preference::GetSupportFeedback() && $user->isAdmin()){ + + $form = new Application_Form_RegisterAirtime(); + + $logo = Application_Model_Preference::GetStationLogo(); if($logo){ $this->view->logoImg = $logo; diff --git a/install/DoctrineMigrations/Version20110711161043.php b/install/DoctrineMigrations/Version20110711161043.php index d10c76c00..c21f097fb 100644 --- a/install/DoctrineMigrations/Version20110711161043.php +++ b/install/DoctrineMigrations/Version20110711161043.php @@ -3,8 +3,9 @@ namespace DoctrineMigrations; /* -update cc_files table to include to "directory" column as well as add foreign key relation to -cc_music_dirs table. +1) update cc_files table to include to "directory" column +2) create a foreign key relationship from cc_files to cc_music_dirs +3) create a foreign key relationship from cc_schedule to cc_files */ use Doctrine\DBAL\Migrations\AbstractMigration, @@ -14,21 +15,22 @@ class Version20110711161043 extends AbstractMigration { public function up(Schema $schema) { - - //CREATE the default value of "/srv/airtime/stor", this can be updated later in the upgrade script. + /* 1) update cc_files table to include to "directory" column */ $this->_addSql("INSERT INTO cc_music_dirs (type, directory) VALUES ('stor', '/srv/airtime/stor');"); $this->_addSql("INSERT INTO cc_music_dirs (type, directory) VALUES ('upgrade', '');"); $cc_music_dirs = $schema->getTable('cc_music_dirs'); - //start cc_files modifications + /* 2) create a foreign key relationship from cc_files to cc_music_dirs */ $cc_files = $schema->getTable('cc_files'); $cc_files->addColumn('directory', 'integer', array('default'=> 2)); $cc_files->addNamedForeignKeyConstraint('cc_music_dirs_folder_fkey', $cc_music_dirs, array('directory'), array('id'), array('onDelete' => 'CASCADE')); - //end cc_files modifications - + + /* 3) create a foreign key relationship from cc_schedule to cc_files */ + $cc_schedule = $schema->getTable('cc_schedule'); + $cc_schedule->addNamedForeignKeyConstraint('cc_files_folder_fkey', $cc_files, array('file_id'), array('id'), array('onDelete' => 'CASCADE')); } public function down(Schema $schema) diff --git a/install/include/airtime-upgrade.php b/install/include/airtime-upgrade.php index ce7ac7077..eb0dd2aa0 100644 --- a/install/include/airtime-upgrade.php +++ b/install/include/airtime-upgrade.php @@ -8,7 +8,9 @@ //Pear classes. set_include_path(__DIR__.'/../../airtime_mvc/library/pear' . PATH_SEPARATOR . get_include_path()); + require_once('DB.php'); +require_once(__DIR__.'/../../airtime_mvc/application/configs/constants.php'); require_once(dirname(__FILE__).'/AirtimeIni.php'); if(exec("whoami") != "root"){ @@ -87,7 +89,9 @@ if (strcmp($version, "1.9.0") < 0){ //set the new version in the database. $sql = "DELETE FROM cc_pref WHERE keystr = 'system_version'"; $CC_DBC->query($sql); -$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '1.9.0-devel')"; + +$newVersion = AIRTIME_VERSION; +$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '$newVersion')"; $CC_DBC->query($sql); diff --git a/install/upgrades/airtime-1.9.0/conf.php b/install/upgrades/airtime-1.9.0/conf.php new file mode 100644 index 000000000..0653af60b --- /dev/null +++ b/install/upgrades/airtime-1.9.0/conf.php @@ -0,0 +1,83 @@ + 'cc_', + + /* ================================================ storage configuration */ + + 'soundcloud-client-id' => '2CLCxcSXYzx7QhhPVHN4A', + 'soundcloud-client-secret' => 'pZ7beWmF06epXLHVUP1ufOg2oEnIt9XhE8l8xt0bBs', + + "rootDir" => __DIR__."/../..", + 'pearPath' => dirname(__FILE__).'/../../../airtime_mvc/library/pear', + 'zendPath' => dirname(__FILE__).'/../../../airtime_mvc/library/Zend', + 'phingPath' => dirname(__FILE__).'/../../../airtime_mvc/library/phing' +); + +$CC_CONFIG = Config::loadConfig($CC_CONFIG); + +// Add database table names +$CC_CONFIG['playListTable'] = $CC_CONFIG['tblNamePrefix'].'playlist'; +$CC_CONFIG['playListContentsTable'] = $CC_CONFIG['tblNamePrefix'].'playlistcontents'; +$CC_CONFIG['filesTable'] = $CC_CONFIG['tblNamePrefix'].'files'; +$CC_CONFIG['accessTable'] = $CC_CONFIG['tblNamePrefix'].'access'; +$CC_CONFIG['permTable'] = $CC_CONFIG['tblNamePrefix'].'perms'; +$CC_CONFIG['sessTable'] = $CC_CONFIG['tblNamePrefix'].'sess'; +$CC_CONFIG['subjTable'] = $CC_CONFIG['tblNamePrefix'].'subjs'; +$CC_CONFIG['smembTable'] = $CC_CONFIG['tblNamePrefix'].'smemb'; +$CC_CONFIG['prefTable'] = $CC_CONFIG['tblNamePrefix'].'pref'; +$CC_CONFIG['scheduleTable'] = $CC_CONFIG['tblNamePrefix'].'schedule'; +$CC_CONFIG['playListTimeView'] = $CC_CONFIG['tblNamePrefix'].'playlisttimes'; +$CC_CONFIG['showSchedule'] = $CC_CONFIG['tblNamePrefix'].'show_schedule'; +$CC_CONFIG['showDays'] = $CC_CONFIG['tblNamePrefix'].'show_days'; +$CC_CONFIG['showTable'] = $CC_CONFIG['tblNamePrefix'].'show'; +$CC_CONFIG['showInstances'] = $CC_CONFIG['tblNamePrefix'].'show_instances'; + +$CC_CONFIG['playListSequence'] = $CC_CONFIG['playListTable'].'_id'; +$CC_CONFIG['filesSequence'] = $CC_CONFIG['filesTable'].'_id'; +$CC_CONFIG['prefSequence'] = $CC_CONFIG['prefTable'].'_id'; +$CC_CONFIG['permSequence'] = $CC_CONFIG['permTable'].'_id'; +$CC_CONFIG['subjSequence'] = $CC_CONFIG['subjTable'].'_id'; +$CC_CONFIG['smembSequence'] = $CC_CONFIG['smembTable'].'_id'; + +// Add libs to the PHP path +$old_include_path = get_include_path(); +set_include_path('.'.PATH_SEPARATOR.$CC_CONFIG['pearPath'] + .PATH_SEPARATOR.$CC_CONFIG['zendPath'] + .PATH_SEPARATOR.$old_include_path); + +class Config { + public static function loadConfig($CC_CONFIG) { + $values = parse_ini_file('/etc/airtime/airtime.conf', true); + + // Name of the web server user + $CC_CONFIG['webServerUser'] = $values['general']['web_server_user']; + $CC_CONFIG['rabbitmq'] = $values['rabbitmq']; + + $CC_CONFIG['baseUrl'] = $values['general']['base_url']; + $CC_CONFIG['basePort'] = $values['general']['base_port']; + + // Database config + $CC_CONFIG['dsn']['username'] = $values['database']['dbuser']; + $CC_CONFIG['dsn']['password'] = $values['database']['dbpass']; + $CC_CONFIG['dsn']['hostspec'] = $values['database']['host']; + $CC_CONFIG['dsn']['phptype'] = 'pgsql'; + $CC_CONFIG['dsn']['database'] = $values['database']['dbname']; + + $CC_CONFIG['apiKey'] = array($values['general']['api_key']); + + $CC_CONFIG['soundcloud-connection-retries'] = $values['soundcloud']['connection_retries']; + $CC_CONFIG['soundcloud-connection-wait'] = $values['soundcloud']['time_between_retries']; + + return $CC_CONFIG; + } +} diff --git a/utils/airtime-import/airtime-import.py b/utils/airtime-import/airtime-import.py index be1a5f9c5..6abde083b 100644 --- a/utils/airtime-import/airtime-import.py +++ b/utils/airtime-import/airtime-import.py @@ -47,10 +47,10 @@ def copy_or_move_files_to(paths, dest, flag): if( 'mp3' in ext or 'ogg' in ext ): destfile = dest+os.path.basename(path) if(flag == 'copy'): - print "Copying %(src)s to %(dest)s....." % {'src':path, 'dest':destfile} + print "Copying %(src)s to %(dest)s..." % {'src':path, 'dest':destfile} shutil.copy2(path, destfile) elif(flag == 'move'): - print "Moving %(src)s to %(dest)s....." % {'src':path, 'dest':destfile} + print "Moving %(src)s to %(dest)s..." % {'src':path, 'dest':destfile} shutil.move(path, destfile) else: print "Cannot find file or path: %s" % path @@ -95,7 +95,7 @@ def printHelp(): ======================== There are two ways to import audio files into Airtime: -1) Copy or move files into the storage folder +1) Use airtime-import to copy or move files into the storage folder. Copied or moved files will be placed into the folder: %s @@ -103,12 +103,12 @@ There are two ways to import audio files into Airtime: Files will be automatically organized into the structure "Artist/Album/TrackNumber-TrackName-Bitrate.file_extension". -2) Add a folder to the Airtime library("watch" a folder) +2) Use airtime-import to add a folder to the Airtime library ("watch" a folder). All the files in the watched folder will be imported to Airtime and the folder will be monitored to automatically detect any changes. Hence any changes done in the folder(add, delete, edit a file) will trigger - updates in Airtime libarary. + updates in Airtime library. """ % storage_dir parser.print_help() print "" @@ -117,7 +117,7 @@ def CopyAction(option, opt, value, parser): errorIfMultipleOption(parser.rargs) stor = helper_get_stor_dir() if(stor is None): - exit("Unable to connect to the server.") + exit("Unable to connect to the Airtime server.") dest = stor+"organize/" copy_or_move_files_to(parser.rargs, dest, 'copy') @@ -125,16 +125,16 @@ def MoveAction(option, opt, value, parser): errorIfMultipleOption(parser.rargs) stor = helper_get_stor_dir() if(stor is None): - exit("Unable to connect to the server.") + exit("Unable to connect to the Airtime server.") dest = stor+"organize/" copy_or_move_files_to(parser.rargs, dest, 'move') def WatchAddAction(option, opt, value, parser): errorIfMultipleOption(parser.rargs) if(len(parser.rargs) > 1): - raise OptionValueError("Too many arguments. This option need exactly one argument.") + raise OptionValueError("Too many arguments. This option requires exactly one argument.") elif(len(parser.rargs) == 0 ): - raise OptionValueError("No argument found. This option need exactly one argument.") + raise OptionValueError("No argument found. This option requires exactly one argument.") path = parser.rargs[0] if(os.path.isdir(path)): res = api_client.add_watched_dir(path) @@ -144,17 +144,17 @@ def WatchAddAction(option, opt, value, parser): if(res['msg']['code'] == 0): print "%s added to watched folder list successfully" % path else: - print "Adding a watched folder failed. : %s" % res['msg']['error'] + print "Adding a watched folder failed: %s" % res['msg']['error'] else: print "Given path is not a directory: %s" % path def WatchListAction(option, opt, value, parser): errorIfMultipleOption(parser.rargs) if(len(parser.rargs) > 0): - raise OptionValueError("This option doesn't take any argument.") + raise OptionValueError("This option doesn't take any arguments.") res = api_client.list_all_watched_dirs() if(res is None): - exit("Unable to connect to the server.") + exit("Unable to connect to the Airtime server.") dirs = res["dirs"].items() # there will be always 1 which is storage folder if(len(dirs) == 1): @@ -167,21 +167,21 @@ def WatchListAction(option, opt, value, parser): def WatchRemoveAction(option, opt, value, parser): errorIfMultipleOption(parser.rargs) if(len(parser.rargs) > 1): - raise OptionValueError("Too many arguments. This option need exactly one argument.") + raise OptionValueError("Too many arguments. This option requires exactly one argument.") elif(len(parser.rargs) == 0 ): - raise OptionValueError("No argument found. This option need exactly one argument.") + raise OptionValueError("No argument found. This option requires exactly one argument.") path = parser.rargs[0] if(os.path.isdir(path)): res = api_client.remove_watched_dir(path) if(res is None): - exit("Unable to connect to the server.") + exit("Unable to connect to the Airtime server.") # sucess if(res['msg']['code'] == 0): - print "%s removed from watched folder list successfully" % path + print "%s removed from watch folder list successfully." % path else: - print "Removing a watched folder failed. : %s" % res['msg']['error'] + print "Removing the watch folder failed: %s" % res['msg']['error'] else: - print "Given path is not a directory: %s" % path + print "The given path is not a directory: %s" % path def StorageSetAction(option, opt, value, parser): bypass = False @@ -195,37 +195,42 @@ def StorageSetAction(option, opt, value, parser): parser.rargs.remove('--force') if(not bypass): errorIfMultipleOption(parser.rargs, "Only [-f] and [--force] option is allowed with this option.") - confirm = raw_input("Are you sure you want to change the storage direcory? (Y/n)") - confirm = confirm or 'Y' - if(confirm != 'Y'): + possibleInput = {'y','Y','n','N'} + confirm = raw_input("Are you sure you want to change the storage direcory? (y/N) ") + confirm = confirm or 'N' + while(confirm not in possibleInput): + print "Not an acceptable input: %s\n" % confirm + confirm = raw_input("Are you sure you want to change the storage direcory? (y/N) ") + confirm = confirm or 'N' + if(confirm == 'n' or confirm =='N'): sys.exit(1) if(len(parser.rargs) > 1): - raise OptionValueError("Too many arguments. This option need exactly one argument.") + raise OptionValueError("Too many arguments. This option requires exactly one argument.") elif(len(parser.rargs) == 0 ): - raise OptionValueError("No argument found. This option need exactly one argument.") + raise OptionValueError("No argument found. This option requires exactly one argument.") path = parser.rargs[0] if(os.path.isdir(path)): res = api_client.set_storage_dir(path) if(res is None): - exit("Unable to connect to the server.") + exit("Unable to connect to the Airtime server.") # sucess if(res['msg']['code'] == 0): print "Successfully set storage folder to %s" % path else: - print "Setting storage folder to failed.: %s" % res['msg']['error'] + print "Setting storage folder failed: %s" % res['msg']['error'] else: - print "Given path is not a directory: %s" % path + print "The given path is not a directory: %s" % path def StorageGetAction(option, opt, value, parser): errorIfMultipleOption(parser.rargs) if(len(parser.rargs) > 0): - raise OptionValueError("This option doesn't take any argument.") + raise OptionValueError("This option does not take any arguments.") print helper_get_stor_dir() usage = """[-c|--copy FILE/DIR [FILE/DIR...]] [-m|--move FILE/DIR [FILE/DIR...]] - [--watch-add DIR] [--watch-list] [--watch-remve DIR] + [--watch-add DIR] [--watch-list] [--watch-remove DIR] [--storage-dir-set DIR] [--storage-dir-get]""" parser = OptionParser(usage=usage, add_help_option=False)