Merge remote-tracking branch 'sf/devel' into mm_refactor_for_saas
This commit is contained in:
commit
af51ddca79
|
@ -178,7 +178,7 @@ class LibraryController extends Zend_Controller_Action
|
|||
if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
|
||||
if ($obj_sess->type === "playlist") {
|
||||
$menu["pl_add"] = array("name"=> "Add to Playlist", "icon" => "add-playlist", "icon" => "copy");
|
||||
} elseif ($obj_sess->type === "block") {
|
||||
} elseif ($obj_sess->type === "block" && $obj->isStatic()) {
|
||||
$menu["pl_add"] = array("name"=> "Add to Smart Block", "icon" => "add-playlist", "icon" => "copy");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -513,7 +513,7 @@ class PlaylistController extends Zend_Controller_Action
|
|||
} catch (BlockNotFoundException $e) {
|
||||
$this->playlistNotFound('block', true);
|
||||
} catch (Exception $e) {
|
||||
//Logging::info($e);
|
||||
Logging::info($e);
|
||||
$this->playlistUnknownError($e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ class PreferenceController extends Zend_Controller_Action
|
|||
public function indexAction()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
$request = $this->getRequest();
|
||||
|
||||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||
|
@ -48,16 +47,14 @@ class PreferenceController extends Zend_Controller_Action
|
|||
Application_Model_Preference::SetTimezone($values["timezone"]);
|
||||
Application_Model_Preference::SetWeekStartDay($values["weekStartDay"]);
|
||||
|
||||
if (!$isSaas) {
|
||||
Application_Model_Preference::SetEnableSystemEmail($values["enableSystemEmail"]);
|
||||
Application_Model_Preference::SetSystemEmail($values["systemEmail"]);
|
||||
Application_Model_Preference::SetMailServerConfigured($values["configureMailServer"]);
|
||||
Application_Model_Preference::SetMailServer($values["mailServer"]);
|
||||
Application_Model_Preference::SetMailServerEmailAddress($values["email"]);
|
||||
Application_Model_Preference::SetMailServerPassword($values["ms_password"]);
|
||||
Application_Model_Preference::SetMailServerPort($values["port"]);
|
||||
Application_Model_Preference::SetMailServerRequiresAuth($values["msRequiresAuth"]);
|
||||
}
|
||||
Application_Model_Preference::SetEnableSystemEmail($values["preferences_email_server"]["enableSystemEmail"]);
|
||||
Application_Model_Preference::SetSystemEmail($values["preferences_email_server"]["systemEmail"]);
|
||||
Application_Model_Preference::SetMailServerConfigured($values["preferences_email_server"]["configureMailServer"]);
|
||||
Application_Model_Preference::SetMailServer($values["preferences_email_server"]["mailServer"]);
|
||||
Application_Model_Preference::SetMailServerEmailAddress($values["preferences_email_server"]["email"]);
|
||||
Application_Model_Preference::SetMailServerPassword($values["preferences_email_server"]["ms_password"]);
|
||||
Application_Model_Preference::SetMailServerPort($values["preferences_email_server"]["port"]);
|
||||
Application_Model_Preference::SetMailServerRequiresAuth($values["preferences_email_server"]["msRequiresAuth"]);
|
||||
|
||||
Application_Model_Preference::SetAutoUploadRecordedShowToSoundcloud($values["UseSoundCloud"]);
|
||||
Application_Model_Preference::SetUploadToSoundcloudOption($values["UploadToSoundcloudOption"]);
|
||||
|
@ -91,13 +88,12 @@ class PreferenceController extends Zend_Controller_Action
|
|||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/support-setting.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
$this->view->statusMsg = "";
|
||||
|
||||
$isSass = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||
|
||||
$form = new Application_Form_SupportSettings();
|
||||
if ($request->isPost()) {
|
||||
$values = $request->getPost();
|
||||
if ($form->isValid($values)) {
|
||||
if (!$isSass && $values["Publicise"] != 1) {
|
||||
if ($values["Publicise"] != 1) {
|
||||
Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]);
|
||||
Application_Model_Preference::SetPublicise($values["Publicise"]);
|
||||
if (isset($values["Privacy"])) {
|
||||
|
@ -108,10 +104,8 @@ class PreferenceController extends Zend_Controller_Action
|
|||
Application_Model_Preference::SetPhone($values["Phone"]);
|
||||
Application_Model_Preference::SetEmail($values["Email"]);
|
||||
Application_Model_Preference::SetStationWebSite($values["StationWebSite"]);
|
||||
if (!$isSass) {
|
||||
Application_Model_Preference::SetSupportFeedback($values["SupportFeedback"]);
|
||||
Application_Model_Preference::SetPublicise($values["Publicise"]);
|
||||
}
|
||||
|
||||
$form->Logo->receive();
|
||||
$imagePath = $form->Logo->getFileName();
|
||||
|
@ -120,7 +114,7 @@ class PreferenceController extends Zend_Controller_Action
|
|||
Application_Model_Preference::SetStationCity($values["City"]);
|
||||
Application_Model_Preference::SetStationDescription($values["Description"]);
|
||||
Application_Model_Preference::SetStationLogo($imagePath);
|
||||
if (!$isSass && isset($values["Privacy"])) {
|
||||
if (isset($values["Privacy"])) {
|
||||
Application_Model_Preference::SetPrivacyPolicyCheck($values["Privacy"]);
|
||||
}
|
||||
}
|
||||
|
@ -168,7 +162,6 @@ class PreferenceController extends Zend_Controller_Action
|
|||
|
||||
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/preferences/streamsetting.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||
|
||||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||
|
||||
// get current settings
|
||||
$temp = Application_Model_StreamSetting::getStreamSetting();
|
||||
|
@ -248,10 +241,8 @@ class PreferenceController extends Zend_Controller_Action
|
|||
|
||||
$error = false;
|
||||
if ($form->isValid($values)) {
|
||||
if (!$isSaas) {
|
||||
$values['output_sound_device'] = $form->getValue('output_sound_device');
|
||||
$values['output_sound_device_type'] = $form->getValue('output_sound_device_type');
|
||||
}
|
||||
|
||||
$values['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata');
|
||||
$values['streamFormat'] = $form->getValue('streamFormat');
|
||||
|
@ -266,7 +257,6 @@ class PreferenceController extends Zend_Controller_Action
|
|||
Application_Model_Preference::SetAutoTransition($values["auto_transition"]);
|
||||
Application_Model_Preference::SetAutoSwitch($values["auto_switch"]);
|
||||
|
||||
if (!$isSaas) {
|
||||
if (!Application_Model_Preference::GetMasterDjConnectionUrlOverride()) {
|
||||
$master_connection_url = "http://".$_SERVER['SERVER_NAME'].":".$values["master_harbor_input_port"]."/".$values["master_harbor_input_mount_point"];
|
||||
if (empty($values["master_harbor_input_port"]) || empty($values["master_harbor_input_mount_point"])) {
|
||||
|
@ -294,7 +284,6 @@ class PreferenceController extends Zend_Controller_Action
|
|||
Application_Model_StreamSetting::setMasterLiveStreamMountPoint($values["master_harbor_input_mount_point"]);
|
||||
Application_Model_StreamSetting::setDjLiveStreamPort($values["dj_harbor_input_port"]);
|
||||
Application_Model_StreamSetting::setDjLiveStreamMountPoint($values["dj_harbor_input_mount_point"]);
|
||||
}
|
||||
|
||||
// store stream update timestamp
|
||||
Application_Model_Preference::SetStreamUpdateTimestamp();
|
||||
|
|
|
@ -527,8 +527,6 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$userInfo = Zend_Auth::getInstance()->getStorage()->read();
|
||||
$user = new Application_Model_User($userInfo->id);
|
||||
|
||||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||
|
||||
$showInstanceId = $this->_getParam('id');
|
||||
|
||||
$this->view->action = "edit-show";
|
||||
|
@ -633,7 +631,6 @@ class ScheduleController extends Zend_Controller_Action
|
|||
|
||||
$formLive->populate($show->getLiveStreamInfo());
|
||||
|
||||
if (!$isSaas) {
|
||||
$formRecord = new Application_Form_AddShowRR();
|
||||
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
||||
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
||||
|
@ -677,7 +674,6 @@ class ScheduleController extends Zend_Controller_Action
|
|||
$formAbsoluteRebroadcast->disable();
|
||||
$formRebroadcast->disable();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isAdminOrPM) {
|
||||
$formWhat->disable();
|
||||
|
|
|
@ -4,15 +4,12 @@ require_once 'customvalidators/PasswordNotEmpty.php';
|
|||
|
||||
class Application_Form_EmailServerPreferences extends Zend_Form_SubForm
|
||||
{
|
||||
private $isSaas;
|
||||
|
||||
public function init()
|
||||
{
|
||||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||
$this->isSaas = $isSaas;
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/preferences_email_server.phtml', "isSaas" => $isSaas))
|
||||
array('ViewScript', array('viewScript' => 'form/preferences_email_server.phtml'))
|
||||
));
|
||||
|
||||
// Enable system emails
|
||||
|
|
|
@ -2,15 +2,12 @@
|
|||
|
||||
class Application_Form_GeneralPreferences extends Zend_Form_SubForm
|
||||
{
|
||||
private $isSaas;
|
||||
|
||||
public function init()
|
||||
{
|
||||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||
$this->isSaas = $isSaas;
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/preferences_general.phtml', "isSaas" => $isSaas))
|
||||
array('ViewScript', array('viewScript' => 'form/preferences_general.phtml'))
|
||||
));
|
||||
|
||||
$defaultFade = Application_Model_Preference::GetDefaultFade();
|
||||
|
|
|
@ -9,7 +9,6 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
$isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1;
|
||||
$isStreamConfigable = Application_Model_Preference::GetEnableStreamConf() == "true";
|
||||
|
||||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||
$defaultFade = Application_Model_Preference::GetDefaultTransitionFade();
|
||||
if ($defaultFade == "") {
|
||||
$defaultFade = '00.000000';
|
||||
|
@ -82,7 +81,6 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
$this->addElement($live_dj_connection_url);
|
||||
|
||||
//liquidsoap harbor.input port
|
||||
if (!$isSaas) {
|
||||
$m_port = Application_Model_StreamSetting::getMasterLiveStreamPort();
|
||||
$master_dj_port = new Zend_Form_Element_Text('master_harbor_input_port');
|
||||
$master_dj_port->setLabel("Master Source Port")
|
||||
|
@ -119,7 +117,6 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
array('regex', false, array('/^[^ &<>]+$/', 'messages' => 'Invalid character entered'))))
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($live_dj_mount);
|
||||
}
|
||||
// demo only code
|
||||
if (!$isStreamConfigable) {
|
||||
$elements = $this->getElements();
|
||||
|
@ -135,21 +132,18 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||
$isDemo = isset($CC_CONFIG['demo']) && $CC_CONFIG['demo'] == 1;
|
||||
$master_dj_connection_url = Application_Model_Preference::GetMasterDJSourceConnectionURL();
|
||||
$live_dj_connection_url = Application_Model_Preference::GetLiveDJSourceConnectionURL();
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml', 'master_dj_connection_url'=>$master_dj_connection_url, 'live_dj_connection_url'=>$live_dj_connection_url, 'isSaas' => $isSaas, 'isDemo' => $isDemo))
|
||||
array('ViewScript', array('viewScript' => 'form/preferences_livestream.phtml', 'master_dj_connection_url'=>$master_dj_connection_url, 'live_dj_connection_url'=>$live_dj_connection_url, 'isDemo' => $isDemo))
|
||||
));
|
||||
}
|
||||
|
||||
public function isValid($data)
|
||||
{
|
||||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||
$isValid = parent::isValid($data);
|
||||
if (!$isSaas) {
|
||||
$master_harbor_input_port = $data['master_harbor_input_port'];
|
||||
$dj_harbor_input_port = $data['dj_harbor_input_port'];
|
||||
|
||||
|
@ -193,7 +187,6 @@ class Application_Form_LiveStreamingPreferences extends Zend_Form_SubForm
|
|||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $isValid;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
class Application_Form_Preferences extends Zend_Form
|
||||
{
|
||||
private $isSaas;
|
||||
|
||||
public function init()
|
||||
{
|
||||
|
@ -10,20 +9,16 @@ class Application_Form_Preferences extends Zend_Form
|
|||
|
||||
$this->setMethod('post');
|
||||
|
||||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||
$this->isSaas = $isSaas;
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/preferences.phtml', "isSaas" => $this->isSaas))
|
||||
array('ViewScript', array('viewScript' => 'form/preferences.phtml'))
|
||||
));
|
||||
|
||||
$general_pref = new Application_Form_GeneralPreferences();
|
||||
$this->addSubForm($general_pref, 'preferences_general');
|
||||
|
||||
if (!$isSaas) {
|
||||
$email_pref = new Application_Form_EmailServerPreferences();
|
||||
$this->addSubForm($email_pref, 'preferences_email_server');
|
||||
}
|
||||
|
||||
$soundcloud_pref = new Application_Form_SoundcloudPreferences();
|
||||
$this->addSubForm($soundcloud_pref, 'preferences_soundcloud');
|
||||
|
|
|
@ -4,16 +4,13 @@ require_once 'customfilters/ImageSize.php';
|
|||
|
||||
class Application_Form_SupportSettings extends Zend_Form
|
||||
{
|
||||
private $isSass;
|
||||
|
||||
public function init()
|
||||
{
|
||||
$country_list = Application_Model_Preference::GetCountryList();
|
||||
$isSass = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||
$this->isSass = $isSass;
|
||||
|
||||
$this->setDecorators(array(
|
||||
array('ViewScript', array('viewScript' => 'form/support-setting.phtml', "isSaas" => $isSass)),
|
||||
array('ViewScript', array('viewScript' => 'form/support-setting.phtml')),
|
||||
array('File', array('viewScript' => 'form/support-setting.phtml', 'placement' => false)))
|
||||
);
|
||||
|
||||
|
@ -109,7 +106,6 @@ class Application_Form_SupportSettings extends Zend_Form
|
|||
$upload->setAttrib('accept', 'image/*');
|
||||
$this->addElement($upload);
|
||||
|
||||
if (!$isSass) {
|
||||
//enable support feedback
|
||||
$this->addElement('checkbox', 'SupportFeedback', array(
|
||||
'label' => 'Send support feedback',
|
||||
|
@ -150,7 +146,6 @@ class Application_Form_SupportSettings extends Zend_Form
|
|||
$checkboxPrivacy->setLabel("By checking this box, I agree to Sourcefabric's <a id=\"link_to_privacy\" href=\"http://www.sourcefabric.org/en/about/policy/\" onclick=\"window.open(this.href); return false;\">privacy policy</a>.")
|
||||
->setDecorators(array('ViewHelper'));
|
||||
$this->addElement($checkboxPrivacy);
|
||||
}
|
||||
|
||||
// submit button
|
||||
$submit = new Zend_Form_Element_Submit("submit");
|
||||
|
@ -165,7 +160,6 @@ class Application_Form_SupportSettings extends Zend_Form
|
|||
public function isValid ($data)
|
||||
{
|
||||
$isValid = parent::isValid($data);
|
||||
if (!$this->isSass) {
|
||||
if ($data['Publicise'] != 1) {
|
||||
$isValid = true;
|
||||
}
|
||||
|
@ -176,7 +170,6 @@ class Application_Form_SupportSettings extends Zend_Form
|
|||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $isValid;
|
||||
}
|
||||
|
|
|
@ -210,10 +210,23 @@ FROM cc_blockcontents AS pc
|
|||
LEFT JOIN cc_files AS f ON pc.file_id=f.id
|
||||
LEFT JOIN cc_block AS bl ON pc.block_id = bl.id
|
||||
WHERE pc.block_id = :block_id
|
||||
ORDER BY pc.position
|
||||
|
||||
SQL;
|
||||
|
||||
$rows = Application_Common_Database::prepareAndExecute($sql, array(':block_id'=>$this->id));
|
||||
if ($filterFiles) {
|
||||
$sql .= <<<SQL
|
||||
AND f.file_exists = :file_exists
|
||||
SQL;
|
||||
}
|
||||
$sql .= <<<SQL
|
||||
|
||||
ORDER BY pc.position
|
||||
SQL;
|
||||
$params = array(':block_id'=>$this->id);
|
||||
if ($filterFiles) {
|
||||
$params[':file_exists'] = $filterFiles;
|
||||
}
|
||||
$rows = Application_Common_Database::prepareAndExecute($sql, $params);
|
||||
|
||||
$offset = 0;
|
||||
foreach ($rows as &$row) {
|
||||
|
@ -310,6 +323,7 @@ SQL;
|
|||
$hour = "00";
|
||||
$mins = "00";
|
||||
if ($modifier == "minutes") {
|
||||
$mins = $value;
|
||||
if ($value >59) {
|
||||
$hour = intval($value/60);
|
||||
$mins = $value%60;
|
||||
|
@ -1173,7 +1187,7 @@ SQL;
|
|||
$sizeOfInsert = count($insertList);
|
||||
|
||||
// if block is not full and reapeat_track is check, fill up more
|
||||
while (!$isBlockFull && $repeat == 1) {
|
||||
while (!$isBlockFull && $repeat == 1 && $sizeOfInsert > 0) {
|
||||
$randomEleKey = array_rand(array_slice($insertList, 0, $sizeOfInsert));
|
||||
$insertList[] = $insertList[$randomEleKey];
|
||||
$totalTime += $insertList[$randomEleKey]['length'];
|
||||
|
|
|
@ -176,6 +176,14 @@ class Application_Model_Playlist implements Application_Model_LibraryEditable
|
|||
FROM cc_playlistcontents AS pc
|
||||
JOIN cc_files AS f ON pc.file_id=f.id
|
||||
WHERE pc.playlist_id = :playlist_id1
|
||||
SQL;
|
||||
|
||||
if ($filterFiles) {
|
||||
$sql .= <<<SQL
|
||||
AND f.file_exists = :file_exists
|
||||
SQL;
|
||||
}
|
||||
$sql .= <<<SQL
|
||||
AND TYPE = 0)
|
||||
UNION ALL
|
||||
(SELECT pc.id AS id,
|
||||
|
@ -220,7 +228,13 @@ class Application_Model_Playlist implements Application_Model_LibraryEditable
|
|||
ORDER BY temp.position;
|
||||
SQL;
|
||||
|
||||
$rows = Application_Common_Database::prepareAndExecute($sql, array(':playlist_id1'=>$this->id, ':playlist_id2'=>$this->id, ':playlist_id3'=>$this->id));
|
||||
$params = array(
|
||||
':playlist_id1'=>$this->id, ':playlist_id2'=>$this->id, ':playlist_id3'=>$this->id);
|
||||
if ($filterFiles) {
|
||||
$params[':file_exists'] = $filterFiles;
|
||||
}
|
||||
|
||||
$rows = Application_Common_Database::prepareAndExecute($sql, $params);
|
||||
|
||||
$offset = 0;
|
||||
foreach ($rows as &$row) {
|
||||
|
|
|
@ -883,8 +883,6 @@ SQL;
|
|||
|
||||
public static function createNewFormSections($p_view)
|
||||
{
|
||||
$isSaas = Application_Model_Preference::GetPlanLevel() == 'disabled'?false:true;
|
||||
|
||||
$formWhat = new Application_Form_AddShowWhat();
|
||||
$formWho = new Application_Form_AddShowWho();
|
||||
$formWhen = new Application_Form_AddShowWhen();
|
||||
|
@ -916,7 +914,6 @@ SQL;
|
|||
|
||||
$formRepeats->populate(array('add_show_end_date' => date("Y-m-d")));
|
||||
|
||||
if (!$isSaas) {
|
||||
$formRecord = new Application_Form_AddShowRR();
|
||||
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
||||
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
||||
|
@ -928,7 +925,6 @@ SQL;
|
|||
$p_view->rr = $formRecord;
|
||||
$p_view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||
$p_view->rebroadcast = $formRebroadcast;
|
||||
}
|
||||
$p_view->addNewShow = true;
|
||||
}
|
||||
|
||||
|
@ -939,8 +935,6 @@ SQL;
|
|||
* 2.1 deadline looming, this is OK for now. -Martin */
|
||||
public static function updateShowInstance($data, $controller)
|
||||
{
|
||||
$isSaas = (Application_Model_Preference::GetPlanLevel() != 'disabled');
|
||||
|
||||
$formWhat = new Application_Form_AddShowWhat();
|
||||
$formWhen = new Application_Form_AddShowWhen();
|
||||
$formRepeats = new Application_Form_AddShowRepeats();
|
||||
|
@ -955,7 +949,6 @@ SQL;
|
|||
$formStyle->removeDecorator('DtDdWrapper');
|
||||
$formLive->removeDecorator('DtDdWrapper');
|
||||
|
||||
if (!$isSaas) {
|
||||
$formRecord = new Application_Form_AddShowRR();
|
||||
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
||||
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
||||
|
@ -963,7 +956,6 @@ SQL;
|
|||
$formRecord->removeDecorator('DtDdWrapper');
|
||||
$formAbsoluteRebroadcast->removeDecorator('DtDdWrapper');
|
||||
$formRebroadcast->removeDecorator('DtDdWrapper');
|
||||
}
|
||||
$when = $formWhen->isValid($data);
|
||||
|
||||
if ($when && $formWhen->checkReliantFields($data, true, null, true)) {
|
||||
|
@ -997,7 +989,6 @@ SQL;
|
|||
$controller->view->who = $formWho;
|
||||
$controller->view->style = $formStyle;
|
||||
$controller->view->live = $formLive;
|
||||
if (!$isSaas) {
|
||||
$controller->view->rr = $formRecord;
|
||||
$controller->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||
$controller->view->rebroadcast = $formRebroadcast;
|
||||
|
@ -1005,7 +996,6 @@ SQL;
|
|||
//$formRecord->disable();
|
||||
//$formAbsoluteRebroadcast->disable();
|
||||
//$formRebroadcast->disable();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -1026,7 +1016,6 @@ SQL;
|
|||
$user = new Application_Model_User($userInfo->id);
|
||||
$isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
|
||||
|
||||
$isSaas = (Application_Model_Preference::GetPlanLevel() != 'disabled');
|
||||
$record = false;
|
||||
|
||||
$formWhat = new Application_Form_AddShowWhat();
|
||||
|
@ -1072,7 +1061,6 @@ SQL;
|
|||
|
||||
$data["add_show_duration"] = $hValue.":".$mValue;
|
||||
|
||||
if (!$isSaas) {
|
||||
$formRecord = new Application_Form_AddShowRR();
|
||||
$formAbsoluteRebroadcast = new Application_Form_AddShowAbsoluteRebroadcastDates();
|
||||
$formRebroadcast = new Application_Form_AddShowRebroadcastDates();
|
||||
|
@ -1083,14 +1071,12 @@ SQL;
|
|||
|
||||
|
||||
$record = $formRecord->isValid($data);
|
||||
}
|
||||
|
||||
if ($data["add_show_repeats"]) {
|
||||
$repeats = $formRepeats->isValid($data);
|
||||
if ($repeats) {
|
||||
$repeats = $formRepeats->checkReliantFields($data);
|
||||
}
|
||||
if (!$isSaas) {
|
||||
$formAbsoluteRebroadcast->reset();
|
||||
//make it valid, results don't matter anyways.
|
||||
$rebroadAb = 1;
|
||||
|
@ -1103,10 +1089,8 @@ SQL;
|
|||
} else {
|
||||
$rebroad = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$repeats = 1;
|
||||
if (!$isSaas) {
|
||||
$formRebroadcast->reset();
|
||||
//make it valid, results don't matter anyways.
|
||||
$rebroad = 1;
|
||||
|
@ -1119,13 +1103,11 @@ SQL;
|
|||
} else {
|
||||
$rebroadAb = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$who = $formWho->isValid($data);
|
||||
$style = $formStyle->isValid($data);
|
||||
if ($what && $when && $repeats && $who && $style && $live) {
|
||||
if (!$isSaas) {
|
||||
if ($record && $rebroadAb && $rebroad) {
|
||||
if ($isAdminOrPM) {
|
||||
Application_Model_Show::create($data);
|
||||
|
@ -1152,17 +1134,6 @@ SQL;
|
|||
return false;
|
||||
|
||||
}
|
||||
} else {
|
||||
if ($isAdminOrPM) {
|
||||
Application_Model_Show::create($data);
|
||||
}
|
||||
|
||||
//send back a new form for the user.
|
||||
Application_Model_Schedule::createNewFormSections($controller->view);
|
||||
|
||||
//$controller->view->newForm = $controller->view->render('schedule/add-show-form.phtml');
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
$controller->view->what = $formWhat;
|
||||
$controller->view->when = $formWhen;
|
||||
|
@ -1171,11 +1142,9 @@ SQL;
|
|||
$controller->view->style = $formStyle;
|
||||
$controller->view->live = $formLive;
|
||||
|
||||
if (!$isSaas) {
|
||||
$controller->view->rr = $formRecord;
|
||||
$controller->view->absoluteRebroadcast = $formAbsoluteRebroadcast;
|
||||
$controller->view->rebroadcast = $formRebroadcast;
|
||||
}
|
||||
//$controller->view->addNewShow = !$editShow;
|
||||
//$controller->view->form = $controller->view->render('schedule/add-show-form.phtml');
|
||||
return false;
|
||||
|
|
|
@ -193,7 +193,8 @@ class Application_Model_Scheduler
|
|||
}
|
||||
} else {
|
||||
$dynamicFiles = $bl->getListOfFilesUnderLimit();
|
||||
foreach ($dynamicFiles as $fileId=>$f) {
|
||||
foreach ($dynamicFiles as $f) {
|
||||
$fileId = $f['id'];
|
||||
$file = CcFilesQuery::create()->findPk($fileId);
|
||||
if (isset($file) && $file->visible()) {
|
||||
$data["id"] = $file->getDbId();
|
||||
|
@ -250,7 +251,8 @@ class Application_Model_Scheduler
|
|||
}
|
||||
} else {
|
||||
$dynamicFiles = $bl->getListOfFilesUnderLimit();
|
||||
foreach ($dynamicFiles as $fileId=>$f) {
|
||||
foreach ($dynamicFiles as $f) {
|
||||
$fileId = $f['id'];
|
||||
$file = CcFilesQuery::create()->findPk($fileId);
|
||||
if (isset($file) && $file->visible()) {
|
||||
$data["id"] = $file->getDbId();
|
||||
|
@ -445,7 +447,6 @@ class Application_Model_Scheduler
|
|||
} else {
|
||||
$sched = new CcSchedule();
|
||||
}
|
||||
Logging::info($file);
|
||||
$sched->setDbStarts($nextStartDT)
|
||||
->setDbEnds($endTimeDT)
|
||||
->setDbCueIn($file['cuein'])
|
||||
|
|
|
@ -359,9 +359,27 @@ SQL;
|
|||
Application_Model_RabbitMq::SendMessageToMediaMonitor("file_delete", $data);
|
||||
}
|
||||
|
||||
// set file_exists falg to false
|
||||
|
||||
// set hidden falg to true
|
||||
$this->_file->setDbHidden(true);
|
||||
$this->_file->save();
|
||||
|
||||
// need to explicitly update any playlist's and block's length
|
||||
// that contains the file getting deleted
|
||||
$fileId = $this->_file->getDbId();
|
||||
$plRows = CcPlaylistcontentsQuery::create()->filterByDbFileId()->find();
|
||||
foreach ($plRows as $row) {
|
||||
$pl = CcPlaylistQuery::create()->filterByDbId($row->getDbPlaylistId($fileId))->findOne();
|
||||
$pl->setDbLength($pl->computeDbLength(Propel::getConnection(CcPlaylistPeer::DATABASE_NAME)));
|
||||
$pl->save();
|
||||
}
|
||||
|
||||
$blRows = CcBlockcontentsQuery::create()->filterByDbFileId($fileId)->find();
|
||||
foreach ($blRows as $row) {
|
||||
$bl = CcBlockQuery::create()->filterByDbId($row->getDbBlockId())->findOne();
|
||||
$bl->setDbLength($bl->computeDbLength(Propel::getConnection(CcBlockPeer::DATABASE_NAME)));
|
||||
$bl->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -86,8 +86,14 @@ class CcBlock extends BaseCcBlock {
|
|||
*/
|
||||
public function computeDbLength(PropelPDO $con)
|
||||
{
|
||||
$stmt = $con->prepare('SELECT SUM(cliplength) FROM "cc_blockcontents" WHERE cc_blockcontents.BLOCK_ID = :p1');
|
||||
$stmt->bindValue(':p1', $this->getDbId());
|
||||
$sql = <<<SQL
|
||||
SELECT SUM(cliplength) FROM cc_blockcontents as bc
|
||||
JOIN cc_files as f ON bc.file_id = f.id
|
||||
WHERE BLOCK_ID = :b1
|
||||
AND f.file_exists = true
|
||||
SQL;
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':b1', $this->getDbId());
|
||||
$stmt->execute();
|
||||
$length = $stmt->fetchColumn();
|
||||
|
||||
|
|
|
@ -87,7 +87,13 @@ class CcPlaylist extends BaseCcPlaylist {
|
|||
*/
|
||||
public function computeDbLength(PropelPDO $con)
|
||||
{
|
||||
$stmt = $con->prepare('SELECT SUM(cliplength) FROM "cc_playlistcontents" WHERE cc_playlistcontents.PLAYLIST_ID = :p1');
|
||||
$sql = <<<SQL
|
||||
SELECT SUM(cliplength) FROM cc_playlistcontents as pc
|
||||
JOIN cc_files as f ON pc.file_id = f.id
|
||||
WHERE PLAYLIST_ID = :p1
|
||||
AND f.file_exists = true
|
||||
SQL;
|
||||
$stmt = $con->prepare($sql);
|
||||
$stmt->bindValue(':p1', $this->getDbId());
|
||||
$stmt->execute();
|
||||
$length = $stmt->fetchColumn();
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
|
||||
class Airtime_View_Helper_IsSaas extends Zend_View_Helper_Abstract{
|
||||
public function isSaas(){
|
||||
$plan = Application_Model_Preference::GetPlanLevel();
|
||||
if($plan == 'disabled'){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,16 +2,14 @@
|
|||
|
||||
<?php echo $this->element->getSubform('preferences_general') ?>
|
||||
|
||||
<?php if (!$this->isSaas) { ?>
|
||||
<h3 class="collapsible-header" id="email-server-heading"><span class="arrow-icon"></span>Email / Mail Server Settings</h3>
|
||||
<div class="collapsible-content" id="email-server-settings" style="display: none;">
|
||||
<?php echo $this->element->getSubform('preferences_email_server') ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<h3 class="collapsible-header" id="email-server-heading"><span class="arrow-icon"></span>Email / Mail Server Settings</h3>
|
||||
<div class="collapsible-content" id="email-server-settings">
|
||||
<?php echo $this->element->getSubform('preferences_email_server') ?>
|
||||
</div>
|
||||
|
||||
<h3 class="collapsible-header" id="soundcloud-heading"><span class="arrow-icon"></span>SoundCloud Settings</h3>
|
||||
|
||||
<div class="collapsible-content" id="soundcloud-settings" style="display: none;">
|
||||
<div class="collapsible-content" id="soundcloud-settings">
|
||||
<?php echo $this->element->getSubform('preferences_soundcloud') ?>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<fieldset class="padded">
|
||||
<dl class="zend_form">
|
||||
<!-- Enable System Email option -->
|
||||
<?php if( !$this->isSaas ){?>
|
||||
|
||||
<dd id="enableSystemEmail-element" class="block-display">
|
||||
<label class="required" for="timezone">
|
||||
|
@ -103,6 +102,5 @@
|
|||
</dd>
|
||||
|
||||
|
||||
<?php } ?>
|
||||
</dl>
|
||||
</fieldset>
|
||||
|
|
|
@ -76,7 +76,6 @@
|
|||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<?php if( !$this->isSaas ){?>
|
||||
<dt id="master_harbor_input_port-label">
|
||||
<label class="optional" for="master_harbor_input_port"><?php echo $this->element->getElement('master_harbor_input_port')->getLabel() ?> :
|
||||
</label>
|
||||
|
@ -105,14 +104,13 @@
|
|||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<?php } ?>
|
||||
<dt id="master_dj_connection_url-label">
|
||||
<label class="optional" for="master_dj_connection_url" style="white-space: nowrap">Master Source Connection URL:
|
||||
</label>
|
||||
</dt>
|
||||
<dd id="master_dj_connection_url-element">
|
||||
<span id="stream_url"><?php echo $this->element->getElement('master_dj_connection_url')->setValue($this->master_dj_connection_url) ?></span>
|
||||
<?php if( !$this->isSaas && !$this->isDemo){?>
|
||||
<?php if(!$this->isDemo){?>
|
||||
<a href=# id="connection_url_override" style="font-size: 12px;">Override</a>
|
||||
<span class="override_help_icon">
|
||||
</span><br>
|
||||
|
@ -121,7 +119,6 @@
|
|||
<a href=# id="ok" style="font-size: 12px;">OK</a> <a href=# id="reset" style="font-size: 12px;">RESET</a>
|
||||
</div>
|
||||
</dd>
|
||||
<?php if( !$this->isSaas ){?>
|
||||
<dt id="dj_harbor_input_port-label">
|
||||
<label class="optional" for="dj_harbor_input_port"><?php echo $this->element->getElement('dj_harbor_input_port')->getLabel() ?> :
|
||||
</label>
|
||||
|
@ -150,14 +147,13 @@
|
|||
</ul>
|
||||
<?php endif; ?>
|
||||
</dd>
|
||||
<?php } ?>
|
||||
<dt id="live_dj_connection_url-label">
|
||||
<label class="optional" for="live_dj_connection_url" style="white-space: nowrap">Show Source Connection URL:
|
||||
</label>
|
||||
</dt>
|
||||
<dd id="live_dj_connection_url-element">
|
||||
<span id="stream_url"><?php echo $this->element->getElement('live_dj_connection_url')->setValue($this->live_dj_connection_url) ?></span>
|
||||
<?php if( !$this->isSaas && !$this->isDemo ){?>
|
||||
<?php if( !$this->isDemo ){?>
|
||||
<a href=# id="connection_url_override" style="font-size: 12px;">Override</a>
|
||||
<span class="override_help_icon">
|
||||
</span><br>
|
||||
|
|
|
@ -29,16 +29,22 @@
|
|||
</dd>
|
||||
|
||||
<dd id='sp_criteria-element' class='criteria-element'>
|
||||
<?php for ($i = 0; $i < $this->criteriasLength; $i++) {?>
|
||||
<?php for ($i = 0; $i < $this->criteriasLength; $i++) {
|
||||
// modRowMap holds the number of modifier rows for each criteria element
|
||||
// i.e. if we have 'Album contains 1' and 'Album contains 2' the modRowMap
|
||||
// for Album is 2
|
||||
?>
|
||||
<?php for ($j = 0; $j < $this->modRowMap[$i]; $j++) {
|
||||
// determine if logic label should be 'and' or 'or'
|
||||
if ($this->modRowMap[$i] > 1 && $j != $this->modRowMap[$i]-1) $logicLabel = 'or';
|
||||
else $logicLabel = 'and';
|
||||
|
||||
$disabled = $this->element->getElement("sp_criteria_field_".$i."_".$j)->getAttrib('disabled') == 'disabled'?true:false;
|
||||
// determine if the next row is disabled and only display the logic label if it isn't
|
||||
if ($j == $this->modRowMap[$i]-1 && $i < 25) {
|
||||
$n = $i+1;
|
||||
$nextIndex = $n."_0";
|
||||
} elseif ($j+1 < $this->modRowMap[$i]-1) {
|
||||
} elseif ($j+1 <= $this->modRowMap[$i]-1) {
|
||||
$n = $j+1;
|
||||
$nextIndex = $i."_".$n;
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<fieldset class="padded">
|
||||
<?php if( !$this->isSaas ){?>
|
||||
<dl class="zend_form">
|
||||
<dd id="SupportFeedback-element" style="width:90%;">
|
||||
<div class="info-text">
|
||||
|
@ -38,8 +37,7 @@
|
|||
</dd>
|
||||
</dl>
|
||||
<div class="info-text" style="clear: both;padding: 4px 0 4px 15px;">(In order to promote your station, "Send support feedback" must be enabled).<br /><br /></div>
|
||||
<?php }?>
|
||||
<dl id="public-info" style="display:<?php echo !$this->isSaas?"none":"block"?>;">
|
||||
<dl id="public-info" style="display:<?php echo "none"?>;">
|
||||
<dt id="stationName-label" class="block-display">
|
||||
<label class="required" for="stationName"><?php echo $this->element->getElement('stationName')->getLabel() ?>
|
||||
<span class="info-text-small">(Required)</span>:
|
||||
|
@ -154,7 +152,6 @@
|
|||
<?php endif; ?>
|
||||
</dd>
|
||||
</dl>
|
||||
<?php if( !$this->isSaas ){?>
|
||||
<div id="show_what_sending" style="display: block;">
|
||||
<fieldset class="display_field toggle closed">
|
||||
<legend style="cursor: pointer;"><span class="ui-icon ui-icon-triangle-2-n-s"></span>Show me what I am sending </legend>
|
||||
|
@ -182,5 +179,4 @@
|
|||
<a id="link_to_terms_and_condition" href="http://www.sourcefabric.org/en/about/policy/" onclick="window.open(this.href); return false;">Sourcefabric Privacy Policy</a>
|
||||
<?php }?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</fieldset>
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
<?php
|
||||
$isSaas = true;
|
||||
if(Application_Model_Preference::GetPlanLevel() == "disabled"){
|
||||
$isSaas = false;
|
||||
}
|
||||
?>
|
||||
<ul id="nav">
|
||||
<?php foreach ($this->container as $page) : ?>
|
||||
<?php if($this->navigation()->accept($page)) : ?>
|
||||
|
@ -13,10 +7,7 @@
|
|||
<span class="down"><?php echo $page->getLabel(); ?></span>
|
||||
</a>
|
||||
<ul class="sub">
|
||||
<?php foreach ($page->getPages() as $sub) :
|
||||
if($isSaas && $sub->getId() == "manage_folder"){
|
||||
continue;
|
||||
} ?>
|
||||
<?php foreach ($page->getPages() as $sub) : ?>
|
||||
<li>
|
||||
<a href="<?php echo $sub->getHref(); ?>" <?php echo ($sub->getTarget() != "")?"target=\"".$sub->getTarget()."\"":""; ?>><?php echo $sub->getLabel(); ?></a>
|
||||
</li>
|
||||
|
|
|
@ -20,14 +20,12 @@
|
|||
<div id="live-stream-override" class="collapsible-content">
|
||||
<?php echo $this->live; ?>
|
||||
</div>
|
||||
<?php if(!$this->isSaas()){?>
|
||||
<h3 class="collapsible-header"><span class="arrow-icon"></span>Record & Rebroadcast</h3>
|
||||
<div id="schedule-record-rebroadcast" class="collapsible-content">
|
||||
<?php echo $this->rr; ?>
|
||||
<?php echo $this->absoluteRebroadcast; ?>
|
||||
<?php echo $this->rebroadcast; ?>
|
||||
</div>
|
||||
<?php }?>
|
||||
<h3 class="collapsible-header"><span class="arrow-icon"></span>Who</h3>
|
||||
<div id="schedule-show-who" class="collapsible-content">
|
||||
<?php echo $this->who; ?>
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
<li id='lib-new-ws'><a href="#">New Webstream</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<?php if (isset($this->obj)) : ?>
|
||||
<div class="btn-group pull-right">
|
||||
<button class="btn btn-inverse" type="submit" id="webstream_save" name="submit">Save</button>
|
||||
</div>
|
||||
<?php if (isset($this->obj)) : ?>
|
||||
<div class="btn-group pull-right">
|
||||
<button id="ws_delete" class="btn" <?php if ($this->action == "new"): ?>style="display:none;"<?php endif; ?>aria-disabled="false">Delete</button>
|
||||
</div>
|
||||
|
|
|
@ -8,10 +8,16 @@ var AIRTIME = (function(AIRTIME) {
|
|||
mod = AIRTIME.library;
|
||||
|
||||
mod.checkAddButton = function() {
|
||||
var selected = mod.getChosenItemsLength(), sortable = $('#spl_sortable'), check = false;
|
||||
|
||||
// make sure audioclips are selected and a playlist is currently open.
|
||||
if (selected !== 0 && sortable.length !== 0) {
|
||||
var selected = mod.getChosenItemsLength(),
|
||||
sortable = $('#spl_sortable:visible'),
|
||||
check = false,
|
||||
blockType = $('input[name=sp_type]:checked', '#smart-block-form').val();
|
||||
|
||||
// make sure audioclips are selected and a playlist or static block is currently open.
|
||||
// static blocks have value of 0
|
||||
// dynamic blocks have value of 1
|
||||
if (selected !== 0 && (sortable.length !== 0 || blockType === "0")) {
|
||||
check = true;
|
||||
}
|
||||
|
||||
|
@ -96,6 +102,10 @@ var AIRTIME = (function(AIRTIME) {
|
|||
return container;
|
||||
},
|
||||
cursor : 'pointer',
|
||||
cursorAt: {
|
||||
top: 30,
|
||||
left: 100
|
||||
},
|
||||
connectToSortable : '#spl_sortable'
|
||||
});
|
||||
};
|
||||
|
|
|
@ -201,7 +201,8 @@ function setSmartBlockEvents() {
|
|||
|
||||
/********** CHANGE PLAYLIST TYPE **********/
|
||||
form.find('dd[id="sp_type-element"]').live("change", function(){
|
||||
setupUI();
|
||||
setupUI();
|
||||
AIRTIME.library.checkAddButton();
|
||||
});
|
||||
|
||||
/********** CRITERIA CHANGE **********/
|
||||
|
|
|
@ -715,7 +715,7 @@
|
|||
* =================================== */
|
||||
|
||||
$(document)
|
||||
//menu options don't work on tablet so trying this hack for now:
|
||||
// menu options don't work on tablet so trying this hack for now:
|
||||
// https://github.com/twitter/bootstrap/issues/4550
|
||||
//.on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
|
||||
.on('click.dropdown.data-api', clearMenus)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import os
|
||||
import abc
|
||||
import re
|
||||
import media.monitor.pure as mmp
|
||||
import media.monitor.owners as owners
|
||||
from media.monitor.pure import LazyProperty
|
||||
|
@ -101,6 +102,12 @@ class BaseEvent(Loggable):
|
|||
self.path = os.path.normpath(raw_event.pathname)
|
||||
else: self.path = raw_event
|
||||
self.owner = owners.get_owner(self.path)
|
||||
owner_re = re.search('stor/imported/(?P<owner>\d+)/', self.path)
|
||||
if owner_re:
|
||||
self.logger.info("matched path: %s" % self.path)
|
||||
self.owner = owner_re.group('owner')
|
||||
else:
|
||||
self.logger.info("did not match path: %s" % self.path)
|
||||
self._pack_hook = lambda: None # no op
|
||||
# into another event
|
||||
|
||||
|
|
|
@ -5,26 +5,22 @@ log = get_logger()
|
|||
owners = {}
|
||||
|
||||
def reset_owners():
|
||||
"""
|
||||
Wipes out all file => owner associations
|
||||
"""
|
||||
""" Wipes out all file => owner associations """
|
||||
global owners
|
||||
owners = {}
|
||||
|
||||
|
||||
def get_owner(f):
|
||||
"""
|
||||
Get the owner id of the file 'f'
|
||||
"""
|
||||
return owners[f] if f in owners else -1
|
||||
""" Get the owner id of the file 'f' """
|
||||
o = owners[f] if f in owners else -1
|
||||
log.info("Received owner for %s. Owner: %s" % (f, o))
|
||||
return o
|
||||
|
||||
|
||||
def add_file_owner(f,owner):
|
||||
"""
|
||||
Associate file f with owner. If owner is -1 then do we will not record it
|
||||
because -1 means there is no owner. Returns True if f is being stored after
|
||||
the function. False otherwise.
|
||||
"""
|
||||
""" Associate file f with owner. If owner is -1 then do we will not record
|
||||
it because -1 means there is no owner. Returns True if f is being stored
|
||||
after the function. False otherwise. """
|
||||
if owner == -1: return False
|
||||
if f in owners:
|
||||
if owner != owners[f]: # check for fishiness
|
||||
|
@ -35,16 +31,12 @@ def add_file_owner(f,owner):
|
|||
return True
|
||||
|
||||
def has_owner(f):
|
||||
"""
|
||||
True if f is owned by somebody. False otherwise.
|
||||
"""
|
||||
""" True if f is owned by somebody. False otherwise. """
|
||||
return f in owners
|
||||
|
||||
def remove_file_owner(f):
|
||||
"""
|
||||
Try and delete any association made with file f. Returns true if the the
|
||||
association was actually deleted. False otherwise.
|
||||
"""
|
||||
""" Try and delete any association made with file f. Returns true if
|
||||
the the association was actually deleted. False otherwise. """
|
||||
if f in owners:
|
||||
del owners[f]
|
||||
return True
|
||||
|
|
|
@ -52,8 +52,6 @@ class RequestSync(Loggable):
|
|||
self.logger.info("ApiController.php probably crashed, we \
|
||||
diagnose this from the fact that it did not return \
|
||||
valid json")
|
||||
self.logger.info("Trying again after %f seconds" %
|
||||
self.request_wait)
|
||||
except Exception as e: self.unexpected_exception(e)
|
||||
else: self.logger.info("Request was successful")
|
||||
self.watcher.flag_done() # poor man's condition variable
|
||||
|
|
|
@ -71,8 +71,10 @@ def get_file_type(file_path):
|
|||
|
||||
def calculate_replay_gain(file_path):
|
||||
"""
|
||||
This function accepts files of type mp3/ogg/flac and returns a calculated ReplayGain value in dB.
|
||||
If the value cannot be calculated for some reason, then we default to 0 (Unity Gain).
|
||||
This function accepts files of type mp3/ogg/flac and returns a calculated
|
||||
ReplayGain value in dB.
|
||||
If the value cannot be calculated for some reason, then we default to 0
|
||||
(Unity Gain).
|
||||
|
||||
http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1.0_specification
|
||||
"""
|
||||
|
@ -92,20 +94,37 @@ def calculate_replay_gain(file_path):
|
|||
if file_type:
|
||||
if file_type == 'mp3':
|
||||
if run_process("which mp3gain > /dev/null") == 0:
|
||||
out = get_process_output('nice -n %s mp3gain -q "%s" 2> /dev/null' % (nice_level, temp_file_path))
|
||||
search = re.search(r'Recommended "Track" dB change: (.*)', out)
|
||||
command = 'nice -n %s mp3gain -q "%s" 2> /dev/null' \
|
||||
% (nice_level, temp_file_path)
|
||||
out = get_process_output(command)
|
||||
search = re.search(r'Recommended "Track" dB change: (.*)', \
|
||||
out)
|
||||
else:
|
||||
logger.warn("mp3gain not found")
|
||||
elif file_type == 'vorbis':
|
||||
if run_process("which vorbisgain > /dev/null && which ogginfo > /dev/null") == 0:
|
||||
run_process('nice -n %s vorbisgain -q -f "%s" 2>/dev/null >/dev/null' % (nice_level,temp_file_path))
|
||||
command = "which vorbisgain > /dev/null && which ogginfo > \
|
||||
/dev/null"
|
||||
if run_process(command) == 0:
|
||||
command = 'nice -n %s vorbisgain -q -f "%s" 2>/dev/null \
|
||||
>/dev/null' % (nice_level,temp_file_path)
|
||||
run_process(command)
|
||||
|
||||
out = get_process_output('ogginfo "%s"' % temp_file_path)
|
||||
search = re.search(r'REPLAYGAIN_TRACK_GAIN=(.*) dB', out)
|
||||
else:
|
||||
logger.warn("vorbisgain/ogginfo not found")
|
||||
elif file_type == 'flac':
|
||||
if run_process("which metaflac > /dev/null") == 0:
|
||||
out = get_process_output('nice -n %s metaflac --show-tag=REPLAYGAIN_TRACK_GAIN "%s"' % (nice_level, temp_file_path))
|
||||
|
||||
command = 'nice -n %s metaflac --add-replay-gain "%s"' \
|
||||
% (nice_level, temp_file_path)
|
||||
run_process(command)
|
||||
|
||||
command = 'nice -n %s metaflac \
|
||||
--show-tag=REPLAYGAIN_TRACK_GAIN "%s"' \
|
||||
% (nice_level, temp_file_path)
|
||||
|
||||
out = get_process_output(command)
|
||||
search = re.search(r'REPLAYGAIN_TRACK_GAIN=(.*) dB', out)
|
||||
else: logger.warn("metaflac not found")
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import unittest
|
||||
import media.monitor.owners as owners
|
||||
from media.monitor import owners
|
||||
|
||||
class TestMMP(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in New Issue