Merge branch 'saas-dev' into saas-3.x-sessionoptimizations

This commit is contained in:
Albert Santoni 2015-10-14 14:50:54 -04:00
commit 2713bd7beb
26 changed files with 4349 additions and 185 deletions

View file

@ -4,6 +4,7 @@ define('PRODUCT_NAME' , 'Airtime');
define('PRODUCT_SITE_URL' , 'http://airtime.sourcefabric.org');
define('SAAS_PRODUCT_BRANDING_NAME', 'Airtime Pro');
define('SAAS_LOGIN_REFERRER', 'https://www.airtime.pro/');
define('COMPANY_NAME' , 'Sourcefabric');
define('COMPANY_SUFFIX' , 'z.ú.');

View file

@ -213,10 +213,6 @@ class PreferenceController extends Zend_Controller_Action
$values["s4_data"] = $s4_data;
if ($form->isValid($values)) {
$values['icecast_vorbis_metadata'] = $form->getValue('icecast_vorbis_metadata');
$values['streamFormat'] = $form->getValue('streamFormat');
Application_Model_StreamSetting::setStreamSetting($values);
/* If the admin password values are empty then we should not

View file

@ -107,10 +107,11 @@ class ShowbuilderController extends Zend_Controller_Action
$CC_CONFIG = Config::getConfig();
$baseUrl = Application_Common_OsPath::getBaseDir();
$setupComplete = Application_Model_Preference::getLangTimezoneSetupComplete();
$previousPage = $request->getHeader('Referer');
$previousPage = strtolower($request->getHeader('Referer'));
$userService = new Application_Service_UserService();
$currentUser = $userService->getCurrentUser();
$previousPageWasLoginScreen = strpos(strtolower($previousPage), 'login') !== false;
$previousPageWasLoginScreen = (strpos($previousPage, 'login') !== false) ||
(strpos($previousPage, SAAS_LOGIN_REFERRER) !== false);
// If current user is Super Admin, and they came from the login page,
// and they have not seen the setup popup before

View file

@ -63,12 +63,16 @@ class WebstreamController extends Zend_Controller_Action
if (!$isAdminOrPM && $webstream->getDbCreatorId() != $user->getId()) {
$this->view->objType = "webstream";
$this->view->type = "webstream";
$this->view->obj = $obj;
$this->view->id = $id;
$this->view->html = $this->view->render('playlist/permission-denied.phtml');
return;
}
$this->view->obj = $obj;
$this->view->type = "webstream";
$this->view->id = $id;
$this->view->action = "edit";
$this->view->html = $this->view->render('webstream/webstream.phtml');
}

View file

@ -85,7 +85,11 @@ class Application_Form_ShowBuilder extends Zend_Form_SubForm
private function getShowNames()
{
$showNames = array("0" => _("Filter by Show"));
$user = Application_Model_User::getCurrentUser();
$showNames = array("0" => _("Filter by Show"));
if ($user->getType() === 'H') {
$showNames["-1"] = _("My Shows");
}
$shows = CcShowQuery::create()
->setFormatter(ModelCriteria::FORMAT_ON_DEMAND)

View file

@ -80,7 +80,7 @@ class Application_Model_Scheduler
*
* @param array $items, an array containing pks of cc_schedule items.
*/
private function validateRequest($items, $addAction=false)
private function validateRequest($items, $addRemoveAction=false)
{
//$items is where tracks get inserted (they are schedule locations)
@ -164,7 +164,7 @@ class Application_Model_Scheduler
* currently playing?
* If yes, throw an exception
*/
if ($addAction) {
if ($addRemoveAction) {
$ccShow = $instance->getCcShow();
if ($ccShow->isLinked()) {
//get all the linked shows instances and check if
@ -175,7 +175,7 @@ class Application_Model_Scheduler
if ($ccShowInstance->getDbStarts() <= $timeNowUTC &&
$ccShowInstance->getDbEnds() > $timeNowUTC) {
throw new Exception(_("Content in linked shows must be scheduled before or after any one is broadcasted"));
throw new Exception(_("Content in linked shows cannot be changed while on air!"));
}
}
}
@ -1091,7 +1091,7 @@ class Application_Model_Scheduler
try {
$this->validateRequest($scheduledItems);
$this->validateRequest($scheduledItems, true);
$scheduledIds = array();
foreach ($scheduledItems as $item) {

View file

@ -234,63 +234,65 @@ class Application_Service_SchedulerService
//with content from $linkedShowSchedule.
try {
$con->beginTransaction();
foreach ($instanceIdsToFill as $id)
{
//Start by clearing the show instance that needs to be filling. This ensure
//we're not going to get in trouble in case there's an programming error somewhere else.
self::clearShowInstanceContents($id);
// Now fill the show instance with the same content that $linkedShowSchedule has.
$instanceStart_sql = "SELECT starts FROM cc_show_instances " .
"WHERE id = {$id} " . "ORDER BY starts";
//What's tricky here is that when we copy the content, we have to adjust
//the start and end times of each track so they're inside the new show instance's time slot.
$nextStartDT = new DateTime(
Application_Common_Database::prepareAndExecute(
$instanceStart_sql, array(),
Application_Common_Database::COLUMN),
new DateTimeZone("UTC"));
$defaultCrossfadeDuration = Application_Model_Preference::GetDefaultCrossfadeDuration();
unset($values);
$values = array();
foreach ($linkedShowSchedule as $item) {
$endTimeDT = self::findEndTime($nextStartDT,
$item["clip_length"]);
if (is_null($item["file_id"])) {
$item["file_id"] = "null";
}
if (is_null($item["stream_id"])) {
$item["stream_id"] = "null";
}
$values[] = "(" . "'{$nextStartDT->format(DEFAULT_TIMESTAMP_FORMAT)}', " .
"'{$endTimeDT->format(DEFAULT_TIMESTAMP_FORMAT)}', " .
"'{$item["clip_length"]}', " .
"'{$item["fade_in"]}', " . "'{$item["fade_out"]}', " .
"'{$item["cue_in"]}', " . "'{$item["cue_out"]}', " .
"{$item["file_id"]}, " . "{$item["stream_id"]}, " .
"{$id}, " . "{$item["position"]})";
$nextStartDT = self::findTimeDifference($endTimeDT,
$defaultCrossfadeDuration);
} //foreach show item
if (!empty($values)) {
$insert_sql = "INSERT INTO cc_schedule (starts, ends, ".
"clip_length, fade_in, fade_out, cue_in, cue_out, ".
"file_id, stream_id, instance_id, position) VALUES ".
implode($values, ",");
Application_Common_Database::prepareAndExecute(
$insert_sql, array(), Application_Common_Database::EXECUTE);
}
//update cc_schedule status column
$instance = CcShowInstancesQuery::create()->findPk($id);
$instance->updateScheduleStatus($con);
} //foreach linked instance
if (!empty($linkedShowSchedule)) {
foreach ($instanceIdsToFill as $id) {
//Start by clearing the show instance that needs to be filling. This ensure
//we're not going to get in trouble in case there's an programming error somewhere else.
self::clearShowInstanceContents($id);
// Now fill the show instance with the same content that $linkedShowSchedule has.
$instanceStart_sql = "SELECT starts FROM cc_show_instances " .
"WHERE id = {$id} " . "ORDER BY starts";
//What's tricky here is that when we copy the content, we have to adjust
//the start and end times of each track so they're inside the new show instance's time slot.
$nextStartDT = new DateTime(
Application_Common_Database::prepareAndExecute(
$instanceStart_sql, array(),
Application_Common_Database::COLUMN),
new DateTimeZone("UTC"));
$defaultCrossfadeDuration = Application_Model_Preference::GetDefaultCrossfadeDuration();
unset($values);
$values = array();
foreach ($linkedShowSchedule as $item) {
$endTimeDT = self::findEndTime($nextStartDT,
$item["clip_length"]);
if (is_null($item["file_id"])) {
$item["file_id"] = "null";
}
if (is_null($item["stream_id"])) {
$item["stream_id"] = "null";
}
$values[] = "(" . "'{$nextStartDT->format(DEFAULT_TIMESTAMP_FORMAT)}', " .
"'{$endTimeDT->format(DEFAULT_TIMESTAMP_FORMAT)}', " .
"'{$item["clip_length"]}', " .
"'{$item["fade_in"]}', " . "'{$item["fade_out"]}', " .
"'{$item["cue_in"]}', " . "'{$item["cue_out"]}', " .
"{$item["file_id"]}, " . "{$item["stream_id"]}, " .
"{$id}, " . "{$item["position"]})";
$nextStartDT = self::findTimeDifference($endTimeDT,
$defaultCrossfadeDuration);
} //foreach show item
if (!empty($values)) {
$insert_sql = "INSERT INTO cc_schedule (starts, ends, " .
"clip_length, fade_in, fade_out, cue_in, cue_out, " .
"file_id, stream_id, instance_id, position) VALUES " .
implode($values, ",");
Application_Common_Database::prepareAndExecute(
$insert_sql, array(), Application_Common_Database::EXECUTE);
}
//update cc_schedule status column
$instance = CcShowInstancesQuery::create()->findPk($id);
$instance->updateScheduleStatus($con);
} //foreach linked instance
}
//update time_filled and last_scheduled in cc_show_instances
$now = gmdate(DEFAULT_TIMESTAMP_FORMAT);

View file

@ -9,7 +9,7 @@
<?php echo $this->element->getElement('setup_timezone')->render(); ?>
</dl>
</fieldset>
<p style="margin-bottom: 0px; text-align: center;">You can change these later in your preferences and user settings.</p>
<p style="margin-bottom: 0px; text-align: center;"><?php echo _("You can change these later in your preferences and user settings.");?></p>
</form>
</div>

View file

@ -9,8 +9,8 @@
<?php echo $this->element->getElement('sb_show_filter') ?>
<?php if ($this->element->getElement('sb_my_shows')):?>
<label><?php echo $this->element->getElement('sb_my_shows')->getLabel(); ?></label>
<?php echo $this->element->getElement('sb_my_shows'); ?>
<?php endif;?>
<!-- --><?php //if ($this->element->getElement('sb_my_shows')):?>
<!-- <label>--><?php //echo $this->element->getElement('sb_my_shows')->getLabel(); ?><!--</label>-->
<!-- --><?php //echo $this->element->getElement('sb_my_shows'); ?>
<!-- --><?php //endif;?>
</div>