Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
75d0e64bdd
|
@ -6,10 +6,6 @@ require_once __DIR__."/configs/ACL.php";
|
|||
require_once 'propel/runtime/lib/Propel.php';
|
||||
Propel::init(__DIR__."/configs/airtime-conf.php");
|
||||
|
||||
//DateTime in PHP 5.3.0+ need a default timezone set.
|
||||
$tz = ini_get('date.timezone') ? ini_get('date.timezone') : 'UTC';
|
||||
date_default_timezone_set($tz);
|
||||
|
||||
require_once __DIR__."/logging/Logging.php";
|
||||
require_once __DIR__."/configs/constants.php";
|
||||
require_once __DIR__."/configs/conf.php";
|
||||
|
@ -20,6 +16,7 @@ require_once 'MusicDir.php';
|
|||
require_once 'Playlist.php';
|
||||
require_once 'StoredFile.php';
|
||||
require_once 'Schedule.php';
|
||||
require_once 'Preference.php';
|
||||
require_once 'Shows.php';
|
||||
require_once 'Users.php';
|
||||
require_once 'RabbitMq.php';
|
||||
|
@ -31,17 +28,24 @@ $dsn = $CC_CONFIG['dsn'];
|
|||
|
||||
$CC_DBC = DB::connect($dsn, FALSE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
echo "ERROR: ".$CC_DBC->getMessage()." ".$CC_DBC->getUserInfo()."\n";
|
||||
exit(1);
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
//DateTime in PHP 5.3.0+ need a default timezone set.
|
||||
date_default_timezone_set(Application_Model_Preference::GetTimezone());
|
||||
|
||||
Logging::setLogPath('/var/log/airtime/zendphp.log');
|
||||
|
||||
Zend_Validate::setDefaultNamespaces("Zend");
|
||||
|
||||
$front = Zend_Controller_Front::getInstance();
|
||||
$front->registerPlugin(new RabbitMqPlugin());
|
||||
$front->registerPlugin(new RabbitMqPlugin());
|
||||
|
||||
|
||||
/* The bootstrap class should only be used to initialize actions that return a view.
|
||||
Actions that return JSON will not use the bootstrap class! */
|
||||
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
||||
{
|
||||
protected function _initDoctype()
|
||||
|
@ -89,6 +93,5 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
$view = $this->getResource('view');
|
||||
$view->headTitle(Application_Model_Preference::GetHeadTitle());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ class PreferenceController extends Zend_Controller_Action
|
|||
Application_Model_Preference::SetDefaultFade($values["preferences_general"]["stationDefaultFade"]);
|
||||
Application_Model_Preference::SetStreamLabelFormat($values["preferences_general"]["streamFormat"]);
|
||||
Application_Model_Preference::SetAllow3rdPartyApi($values["preferences_general"]["thirdPartyApi"]);
|
||||
Application_Model_Preference::SetTimezone($values["preferences_general"]["timezone"]);
|
||||
|
||||
Application_Model_Preference::SetDoSoundCloudUpload($values["preferences_soundcloud"]["UseSoundCloud"]);
|
||||
Application_Model_Preference::SetSoundCloudUser($values["preferences_soundcloud"]["SoundCloudUser"]);
|
||||
|
|
|
@ -4,6 +4,9 @@ class RabbitMqPlugin extends Zend_Controller_Plugin_Abstract
|
|||
{
|
||||
public function dispatchLoopShutdown()
|
||||
{
|
||||
RabbitMq::PushScheduleFinal();
|
||||
if (RabbitMq::$doPush) {
|
||||
$md = array('schedule' => Schedule::GetScheduledPlaylists());
|
||||
RabbitMq::SendMessageToPypo("update_schedule", $md);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -58,7 +58,38 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
|||
$third_party_api->setValue(Application_Model_Preference::GetAllow3rdPartyApi());
|
||||
$third_party_api->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($third_party_api);
|
||||
|
||||
/* Form Element for setting the Timezone */
|
||||
$timezone = new Zend_Form_Element_Select("timezone");
|
||||
$timezone->setLabel("Timezone");
|
||||
$timezone->setMultiOptions($this->getTimezones());
|
||||
$timezone->setValue(Application_Model_Preference::GetTimezone());
|
||||
$timezone->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($timezone);
|
||||
}
|
||||
|
||||
private function getTimezones(){
|
||||
$regions = array(
|
||||
'Africa' => DateTimeZone::AFRICA,
|
||||
'America' => DateTimeZone::AMERICA,
|
||||
'Antarctica' => DateTimeZone::ANTARCTICA,
|
||||
'Aisa' => DateTimeZone::ASIA,
|
||||
'Atlantic' => DateTimeZone::ATLANTIC,
|
||||
'Europe' => DateTimeZone::EUROPE,
|
||||
'Indian' => DateTimeZone::INDIAN,
|
||||
'Pacific' => DateTimeZone::PACIFIC
|
||||
);
|
||||
|
||||
$tzlist = array();
|
||||
|
||||
foreach ($regions as $name => $mask){
|
||||
$ids = DateTimeZone::listIdentifiers($mask);
|
||||
foreach ($ids as $id){
|
||||
$tzlist[$id] = str_replace("_", " ", $id);
|
||||
}
|
||||
}
|
||||
|
||||
return $tzlist;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -59,7 +59,6 @@ class Application_Model_Preference
|
|||
$result = $CC_DBC->GetOne($sql);
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function GetHeadTitle(){
|
||||
|
@ -260,6 +259,17 @@ class Application_Model_Preference
|
|||
public static function GetStationDescription(){
|
||||
return Application_Model_Preference::GetValue("description");
|
||||
}
|
||||
|
||||
public static function SetTimezone($timezone){
|
||||
Application_Model_Preference::SetValue("timezone", $timezone);
|
||||
date_default_timezone_set($timezone);
|
||||
$md = array("timezone" => $timezone);
|
||||
RabbitMq::SendMessageToPypo("update_timezone", $md);
|
||||
}
|
||||
|
||||
public static function GetTimezone(){
|
||||
return Application_Model_Preference::GetValue("timezone");
|
||||
}
|
||||
|
||||
public static function SetStationLogo($imagePath){
|
||||
if(!empty($imagePath)){
|
||||
|
|
|
@ -3,7 +3,7 @@ require_once 'php-amqplib/amqp.inc';
|
|||
|
||||
class RabbitMq
|
||||
{
|
||||
static private $doPush = FALSE;
|
||||
static public $doPush = FALSE;
|
||||
|
||||
/**
|
||||
* Sets a flag to push the schedule at the end of the request.
|
||||
|
@ -17,7 +17,7 @@ class RabbitMq
|
|||
* Will push the schedule in the range from 24 hours ago to 24 hours
|
||||
* in the future.
|
||||
*/
|
||||
public static function PushScheduleFinal()
|
||||
/* public static function PushScheduleFinal()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
if (RabbitMq::$doPush) {
|
||||
|
@ -42,6 +42,32 @@ class RabbitMq
|
|||
|
||||
self::SendMessageToShowRecorder("update_schedule");
|
||||
}
|
||||
} */
|
||||
|
||||
public static function SendMessageToPypo($event_type, $md)
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
$md["event_type"] = $event_type;
|
||||
|
||||
$conn = new AMQPConnection($CC_CONFIG["rabbitmq"]["host"],
|
||||
$CC_CONFIG["rabbitmq"]["port"],
|
||||
$CC_CONFIG["rabbitmq"]["user"],
|
||||
$CC_CONFIG["rabbitmq"]["password"]);
|
||||
$channel = $conn->channel();
|
||||
$channel->access_request($CC_CONFIG["rabbitmq"]["vhost"], false, false, true, true);
|
||||
|
||||
$EXCHANGE = 'airtime-schedule';
|
||||
$channel->exchange_declare($EXCHANGE, 'direct', false, true);
|
||||
|
||||
$data = json_encode($md);
|
||||
$msg = new AMQPMessage($data, array('content_type' => 'text/plain'));
|
||||
|
||||
$channel->basic_publish($msg, $EXCHANGE);
|
||||
$channel->close();
|
||||
$conn->close();
|
||||
|
||||
self::SendMessageToShowRecorder("update_schedule");
|
||||
}
|
||||
|
||||
public static function SendMessageToMediaMonitor($event_type, $md)
|
||||
|
|
|
@ -96,7 +96,11 @@ while ($showTime < $endDate) {
|
|||
}
|
||||
$showNumber = $showNumber + 1;
|
||||
}
|
||||
RabbitMq::PushScheduleFinal();
|
||||
|
||||
if (RabbitMq::$doPush) {
|
||||
$md = array('schedule' => Schedule::GetScheduledPlaylists());
|
||||
RabbitMq::SendMessageToPypo("update_schedule", $md);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -75,5 +75,20 @@
|
|||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<dt id="timezone-label" class="block-display">
|
||||
<label class="required" for="timezone"><?php echo $this->element->getElement('timezone')->getLabel() ?>
|
||||
<span class="info-text-small">(Required)</span> :
|
||||
</label>
|
||||
</dt>
|
||||
<dd id="timezone-element" class="block-display">
|
||||
<?php echo $this->element->getElement('timezone') ?>
|
||||
<?php if($this->element->getElement('timezone')->hasErrors()) : ?>
|
||||
<ul class='errors'>
|
||||
<?php foreach($this->element->getElement('timezone')->getMessages() as $error): ?>
|
||||
<li><?php echo $error; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
|
|
@ -2,7 +2,6 @@ php_value post_max_size 500M
|
|||
php_value upload_max_filesize 500M
|
||||
php_value request_order "GPC"
|
||||
php_value session.gc_probability 0
|
||||
php_value date.timezone "America/Toronto"
|
||||
php_value phar.readonly Off
|
||||
|
||||
RewriteEngine On
|
||||
|
|
|
@ -294,6 +294,18 @@ class AirtimeInstall
|
|||
return true;
|
||||
}
|
||||
|
||||
public static function SetDefaultTimezone()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', 'America/Toronto')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function SetImportTimestamp()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
|
|
@ -50,6 +50,7 @@ AirtimeInstall::SetAirtimeVersion(AIRTIME_VERSION);
|
|||
// set up some keys in DB
|
||||
AirtimeInstall::SetUniqueId();
|
||||
AirtimeInstall::SetImportTimestamp();
|
||||
AirtimeInstall::SetDefaultTimezone();
|
||||
|
||||
if (AirtimeInstall::$databaseTablesCreated) {
|
||||
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Airtime
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2010 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*/
|
||||
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/library/pear' . PATH_SEPARATOR . get_include_path());
|
||||
set_include_path(__DIR__.'/../../../airtime_mvc/application/models' . PATH_SEPARATOR . get_include_path());
|
||||
require_once 'conf.php';
|
||||
require_once 'DB.php';
|
||||
|
||||
require_once 'propel/runtime/lib/Propel.php';
|
||||
Propel::init(__DIR__."/../../../airtime_mvc/application/configs/airtime-conf.php");
|
||||
|
||||
class AirtimeInstall{
|
||||
|
||||
public static function SetDefaultTimezone()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', 'America/Toronto')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
class Airtime200Upgrade{
|
||||
|
||||
public static function connectToDatabase(){
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
|
||||
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
|
||||
|
||||
// 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_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Airtime200Upgrade::connectToDatabase();
|
||||
AirtimeInstall::SetDefaultTimezone();
|
|
@ -55,6 +55,11 @@ def handle_message(body, message):
|
|||
|
||||
if(command == 'update_schedule'):
|
||||
SCHEDULE_PUSH_MSG = m['schedule']
|
||||
elif (command == 'update_timezone'):
|
||||
logger.info("Setting timezone to %s", m['timezone'])
|
||||
os.environ['TZ'] = m['timezone']
|
||||
time.tzset()
|
||||
|
||||
# ACK the message to take it off the queue
|
||||
message.ack()
|
||||
|
||||
|
|
Loading…
Reference in New Issue