From b8d6132b52eb65f305b36f113fc8f45ba4dfbf1f Mon Sep 17 00:00:00 2001 From: James Date: Tue, 23 Oct 2012 18:47:15 -0400 Subject: [PATCH] - saas patch #1 --- .../application/controllers/ApiController.php | 16 +++++++ .../controllers/PreferenceController.php | 1 - .../forms/SoundcloudPreferences.php | 10 ----- airtime_mvc/application/models/RabbitMq.php | 42 +++++++++++++++++++ airtime_mvc/application/models/User.php | 12 +++++- .../scripts/form/preferences_soundcloud.phtml | 13 ------ 6 files changed, 69 insertions(+), 25 deletions(-) diff --git a/airtime_mvc/application/controllers/ApiController.php b/airtime_mvc/application/controllers/ApiController.php index 1a1876ce9..5d07d250a 100644 --- a/airtime_mvc/application/controllers/ApiController.php +++ b/airtime_mvc/application/controllers/ApiController.php @@ -686,6 +686,22 @@ class ApiController extends Zend_Controller_Action Logging::info("Registered Component: ".$component."@".$remoteAddr); Application_Model_ServiceRegister::Register($component, $remoteAddr); + + //send ip, subdomain + if (Application_Model_Preference::GetPlanLevel() != 'disabled'){ + if ($component == "pypo"){ + $split = explode('.', $_SERVER['SERVER_NAME']); + if (count($split) > 0){ + $subDomain = $split[0]; + + $md = array(); + $md["sub_domain"] = $subDomain; + $md["pypo_ip"] = $remoteAddr; + + Application_Model_RabbitMq::SendMessageToHaproxyConfigDaemon($md); + } + } + } } public function updateLiquidsoapStatusAction() diff --git a/airtime_mvc/application/controllers/PreferenceController.php b/airtime_mvc/application/controllers/PreferenceController.php index 5c375deab..c1ffda4ad 100644 --- a/airtime_mvc/application/controllers/PreferenceController.php +++ b/airtime_mvc/application/controllers/PreferenceController.php @@ -53,7 +53,6 @@ class PreferenceController extends Zend_Controller_Action Application_Model_Preference::SetMailServerRequiresAuth($values["preferences_email_server"]["msRequiresAuth"]); } - Application_Model_Preference::SetAutoUploadRecordedShowToSoundcloud($values["preferences_soundcloud"]["UseSoundCloud"]); Application_Model_Preference::SetUploadToSoundcloudOption($values["preferences_soundcloud"]["UploadToSoundcloudOption"]); Application_Model_Preference::SetSoundCloudDownloadbleOption($values["preferences_soundcloud"]["SoundCloudDownloadbleOption"]); Application_Model_Preference::SetSoundCloudUser($values["preferences_soundcloud"]["SoundCloudUser"]); diff --git a/airtime_mvc/application/forms/SoundcloudPreferences.php b/airtime_mvc/application/forms/SoundcloudPreferences.php index d3840cbbf..848368697 100644 --- a/airtime_mvc/application/forms/SoundcloudPreferences.php +++ b/airtime_mvc/application/forms/SoundcloudPreferences.php @@ -11,16 +11,6 @@ class Application_Form_SoundcloudPreferences extends Zend_Form_SubForm array('ViewScript', array('viewScript' => 'form/preferences_soundcloud.phtml')) )); - //enable soundcloud uploads - $this->addElement('checkbox', 'UseSoundCloud', array( - 'label' => 'Automatically Upload Recorded Shows', - 'required' => false, - 'value' => Application_Model_Preference::GetAutoUploadRecordedShowToSoundcloud(), - 'decorators' => array( - 'ViewHelper' - ) - )); - //enable soundcloud uploads option $this->addElement('checkbox', 'UploadToSoundcloudOption', array( 'label' => 'Enable SoundCloud Upload', diff --git a/airtime_mvc/application/models/RabbitMq.php b/airtime_mvc/application/models/RabbitMq.php index d92975413..7fea88348 100644 --- a/airtime_mvc/application/models/RabbitMq.php +++ b/airtime_mvc/application/models/RabbitMq.php @@ -71,4 +71,46 @@ class Application_Model_RabbitMq self::sendMessage($exchange, $data); } + + public static function SendMessageToHaproxyConfigDaemon($md){ + $config = parse_ini_file("/etc/airtime-saas/rabbitmq.ini", true); + $conn = new AMQPConnection($config["rabbitmq"]["host"], + $config["rabbitmq"]["port"], + $config["rabbitmq"]["user"], + $config["rabbitmq"]["password"], + $config["rabbitmq"]["vhost"]); + + $exchange = $config["rabbitmq"]["queue"]; + $queue = $config["rabbitmq"]["queue"]; + + $ch = $conn->channel(); + + + /* + name: $queue + passive: false + durable: true // the queue will survive server restarts + exclusive: false // the queue can be accessed in other channels + auto_delete: false //the queue won't be deleted once the channel is closed. + */ + $ch->queue_declare($queue, false, true, false, false); + + /* + name: $exchange + type: direct + passive: false + durable: true // the exchange will survive server restarts + auto_delete: false //the exchange won't be deleted once the channel is closed. + */ + + $ch->exchange_declare($exchange, 'direct', false, true, false); + $ch->queue_bind($queue, $exchange); + + $data = json_encode($md).PHP_EOL; + $msg = new AMQPMessage($data, array('content_type' => 'application/json')); + + $ch->basic_publish($msg, $exchange); + $ch->close(); + $conn->close(); + } } diff --git a/airtime_mvc/application/models/User.php b/airtime_mvc/application/models/User.php index 63b82820a..48a4c3e2f 100644 --- a/airtime_mvc/application/models/User.php +++ b/airtime_mvc/application/models/User.php @@ -329,14 +329,24 @@ class Application_Model_User $res = Application_Model_Datatables::findEntries($con, $displayColumns, $fromTable, $datatables); // mark record which is for the current user - foreach ($res['aaData'] as &$record) { + foreach($res['aaData'] as $key => &$record){ if ($record['login'] == $username) { $record['delete'] = "self"; } else { $record['delete'] = ""; } + + if($record['login'] == 'sourcefabric_admin'){ + //arrays in PHP are basically associative arrays that can be iterated in order. + //Deleting an earlier element does not change the keys of elements that come after it. --MK + unset($res['aaData'][$key]); + $res['iTotalDisplayRecords']--; + $res['iTotalRecords']--; + } } + $res['aaData'] = array_values($res['aaData']); + return $res; } diff --git a/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml b/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml index 20bcc92c9..8a007c10d 100644 --- a/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml +++ b/airtime_mvc/application/views/scripts/form/preferences_soundcloud.phtml @@ -13,19 +13,6 @@ -
- - element->getElement('UseSoundCloud')->hasErrors()) : ?> - - -