diff --git a/src/modules/htmlUI/var/formmask/generic.inc.php b/src/modules/htmlUI/var/formmask/generic.inc.php
index 38c4a9c69..64bc99f24 100644
--- a/src/modules/htmlUI/var/formmask/generic.inc.php
+++ b/src/modules/htmlUI/var/formmask/generic.inc.php
@@ -771,8 +771,8 @@ $ui_fmask = array(
'label' => 'Time',
'options' => array('format' => 'His'),
),
- 'gunid_duration' => array(
- 'element' => 'gunid_duration',
+ 'id_duration' => array(
+ 'element' => 'id_duration',
'type' => 'select',
'label' => 'Playlist',
'required' => TRUE,
diff --git a/src/modules/htmlUI/var/html/ui_browser.php b/src/modules/htmlUI/var/html/ui_browser.php
index 35c949998..32c87a327 100644
--- a/src/modules/htmlUI/var/html/ui_browser.php
+++ b/src/modules/htmlUI/var/html/ui_browser.php
@@ -153,6 +153,7 @@ if (isset($_REQUEST['popup']) && is_array($_REQUEST['popup'])){
break;
case "SCHEDULER.addItem":
+ $uiHandler->SCHEDULER->setScheduleAtTime($_REQUEST);
$Smarty->display('popup/SCHEDULER.addItem.tpl');
break;
diff --git a/src/modules/htmlUI/var/html/ui_handler.php b/src/modules/htmlUI/var/html/ui_handler.php
index 41e7625e3..6ddc91c86 100644
--- a/src/modules/htmlUI/var/html/ui_handler.php
+++ b/src/modules/htmlUI/var/html/ui_handler.php
@@ -1,5 +1,7 @@
SCHEDULER->set($_REQUEST);
- $uiHandler->SCHEDULER->setReload();
+ //$uiHandler->SCHEDULER->setReload();
+ $NO_REDIRECT = true;
+ $_REQUEST["act"] = "SCHEDULER";
+ include("ui_browser.php");
break;
case "SCHEDULER.setScheduleAtTime":
@@ -415,9 +420,16 @@ switch ($_REQUEST['act']) {
break;
case "SCHEDULER.addItem":
- $uiHandler->SCHEDULER->uploadPlaylistMethod($_REQUEST);
- $uiHandler->SCHEDULER->setReload();
- break;
+ $groupId = $uiHandler->SCHEDULER->addItem($_REQUEST);
+ if (PEAR::isError($groupId) && $groupId->getCode() == 555) {
+ $Smarty->assign("USER_ERROR", "Scheduling conflict.");
+ }
+
+ //$uiHandler->SCHEDULER->setReload();
+ $NO_REDIRECT = true;
+ $_REQUEST["act"] = "SCHEDULER";
+ include("ui_browser.php");
+ break;
case "SCHEDULER.removeItem":
$uiHandler->SCHEDULER->removeFromScheduleMethod($_REQUEST['scheduleId']);
diff --git a/src/modules/htmlUI/var/init_load_once.php b/src/modules/htmlUI/var/init_load_once.php
new file mode 100644
index 000000000..fe0da9fc8
--- /dev/null
+++ b/src/modules/htmlUI/var/init_load_once.php
@@ -0,0 +1,60 @@
+init();
+
+$uiHandler = new uiHandler($CC_CONFIG);
+$uiHandler->init();
+$uiBase =& $uiHandler;
+
+$uiBase =& $uiBrowser;
+$jscom = new jscom(array("jscom_wrapper"));
+$jscom->handler();
+
+
+// load Smarty+filters ##############################################
+require_once(dirname(__FILE__).'/ui_smartyExtensions.inc.php');
+//$Smarty->load_filter('output', 'trimwhitespace');
+//$Smarty->load_filter('post', 'template_marker');
+$Smarty->load_filter('output', 'localizer');
+
+
+// some basic things ################################################
+foreach (get_defined_constants() as $k=>$v) {
+ $Smarty->assign($k, $v);
+}
+
+if (isset($_SESSION["USER_ERROR"])) {
+ $Smarty->assign('USER_ERROR', $_SESSION["USER_ERROR"]);
+ unset($_SESSION["USER_ERROR"]);
+}
+$Smarty->assign('ACT', isset($_REQUEST['act'])?$_REQUEST['act']:null);
+$Smarty->assign('CONFIG', $CC_CONFIG);
+$Smarty->assign('START', array(
+ 'id' => &$uiBrowser->id,
+ //'pid' => &$uiBrowser->pid,
+ //'fid' => &$uiBrowser->fid,
+ 'sessid' => &$uiBrowser->sessid)
+ );
+$Smarty->assign('USER', array(
+ 'sessid' => &$uiBrowser->sessid,
+ 'userid' => &$uiBrowser->userid,
+ 'login' => &$uiBrowser->login)
+ );
+$uiBrowser->loadStationPrefs($ui_fmask['stationPrefs']);
+$Smarty->assign('STATIONPREFS', $uiBrowser->STATIONPREFS);
+$Smarty->assign_by_ref('_REQUEST', $_REQUEST);
+$Smarty->assign_by_ref('_SESSION', $_SESSION);
+// retransfer incomplete formdata from SESSION to POST-data #########
+if (isset($_SESSION['retransferFormData']) && is_array($_SESSION['retransferFormData'])) {
+ foreach($_SESSION['retransferFormData'] as $k=>$v){
+ $_POST[$k] = $v;
+ }
+ unset($_SESSION['retransferFormData']);
+}
+
+?>
\ No newline at end of file
diff --git a/src/modules/htmlUI/var/templates/menu.tpl b/src/modules/htmlUI/var/templates/menu.tpl
index 6a5c721f0..e6a4f943a 100644
--- a/src/modules/htmlUI/var/templates/menu.tpl
+++ b/src/modules/htmlUI/var/templates/menu.tpl
@@ -49,10 +49,10 @@ if (window.attachEvent) window.attachEvent("onload", sfHover);
##Scheduler##
- - ##Month##
- - ##Week##
- - ##Day##
- ##Today##
+ - ##Day##
+ - ##Week##
+ - ##Month##
{* if Alib::CheckPerm($SUBJECTS->Base->userid, 'schedulerStatus') *}
- ##Status##
{* /if *}
diff --git a/src/modules/htmlUI/var/templates/popup/SCHEDULER.addItem.tpl b/src/modules/htmlUI/var/templates/popup/SCHEDULER.addItem.tpl
index 350755c53..f1e2579eb 100644
--- a/src/modules/htmlUI/var/templates/popup/SCHEDULER.addItem.tpl
+++ b/src/modules/htmlUI/var/templates/popup/SCHEDULER.addItem.tpl
@@ -25,8 +25,12 @@
{literal}
function SCHEDULE_submit()
{
- document.forms["schedule"].elements["playlist"].value = SCHEDULE_selectedGunid();
+ document.forms["schedule"].elements["playlist"].value = SCHEDULE_selectedId();
document.forms["schedule"].submit();
+ if (window.opener && !window.opener.closed) {
+ window.opener.location.reload();
+ }
+ window.close();
}
function SCHEDULE_snap2Hour()
@@ -110,7 +114,7 @@ function SCHEDULE_selectedDuration()
return arr[1].slice(0, 8);
}
-function SCHEDULE_selectedGunid()
+function SCHEDULE_selectedId()
{
var arr = document.forms["schedule"].elements["id_duration"].value.split("|");
return arr[0];
diff --git a/src/modules/htmlUI/var/templates/scheduler/main.tpl b/src/modules/htmlUI/var/templates/scheduler/main.tpl
index a58452466..b6ce64235 100644
--- a/src/modules/htmlUI/var/templates/scheduler/main.tpl
+++ b/src/modules/htmlUI/var/templates/scheduler/main.tpl
@@ -8,18 +8,18 @@
diff --git a/src/modules/htmlUI/var/templates/script/contextmenu.js.tpl b/src/modules/htmlUI/var/templates/script/contextmenu.js.tpl
index 77cda9cdc..801d65b3f 100644
--- a/src/modules/htmlUI/var/templates/script/contextmenu.js.tpl
+++ b/src/modules/htmlUI/var/templates/script/contextmenu.js.tpl
@@ -33,11 +33,11 @@ function contextmenu(param) {
case "PL.addItem":
contextmenuHtml = contextmenuHtml + "";
break;
-
+
case "PL.addStream":
contextmenuHtml = contextmenuHtml + "";
break;
-
+
case "PL.setCliplength":
contextmenuHtml = contextmenuHtml + "";
break;
@@ -95,7 +95,8 @@ function contextmenu(param) {
break;
case "SCHEDULER.addItem":
- contextmenuHtml = contextmenuHtml + "";
+ //contextmenuHtml = contextmenuHtml + "";
+ contextmenuHtml = contextmenuHtml + "";
break;
case "SCHEDULER.removeItem":
@@ -103,11 +104,16 @@ function contextmenu(param) {
break;
case "SCHEDULER.addPL":
- contextmenuHtml = contextmenuHtml + "";
+// contextmenuHtml = contextmenuHtml + "";
break;
case "SUBJECTS.chgPasswd":
diff --git a/src/modules/htmlUI/var/ui_browser_init.php b/src/modules/htmlUI/var/ui_browser_init.php
index 0825df4a6..b6613d0b0 100644
--- a/src/modules/htmlUI/var/ui_browser_init.php
+++ b/src/modules/htmlUI/var/ui_browser_init.php
@@ -22,62 +22,9 @@ require_once(dirname(__FILE__).'/ui_transfers.class.php');
require_once(dirname(__FILE__).'/ui_calendar.class.php');
require_once(dirname(__FILE__).'/ui_jscom.php');
require_once(dirname(__FILE__).'/ui_twitter.class.php');
-
+require_once(dirname(__FILE__).'/init_load_once.php');
if (isset($WHITE_SCREEN_OF_DEATH) && ($WHITE_SCREEN_OF_DEATH == TRUE)) {
echo __FILE__.':line '.__LINE__.": All includes loaded
";
}
-# NOTE: You have to load all classes that use session variables BEFORE you make a call to session_start()!!!
-session_start();
-
-// initialize objects ###############################################
-$Smarty = new Smarty;
-$uiBrowser = new uiBrowser($CC_CONFIG);
-$uiBrowser->init();
-
-$uiBase =& $uiBrowser;
-$jscom = new jscom(array("jscom_wrapper"));
-$jscom->handler();
-
-
-// load Smarty+filters ##############################################
-require_once(dirname(__FILE__).'/ui_smartyExtensions.inc.php');
-//$Smarty->load_filter('output', 'trimwhitespace');
-//$Smarty->load_filter('post', 'template_marker');
-$Smarty->load_filter('output', 'localizer');
-
-
-// some basic things ################################################
-foreach (get_defined_constants() as $k=>$v) {
- $Smarty->assign($k, $v);
-}
-
-$Smarty->assign('ACT', isset($_REQUEST['act'])?$_REQUEST['act']:null);
-$Smarty->assign('CONFIG', $CC_CONFIG);
-$Smarty->assign('START', array(
- 'id' => &$uiBrowser->id,
- //'pid' => &$uiBrowser->pid,
- //'fid' => &$uiBrowser->fid,
- 'sessid' => &$uiBrowser->sessid)
- );
-$Smarty->assign('USER', array(
- 'sessid' => &$uiBrowser->sessid,
- 'userid' => &$uiBrowser->userid,
- 'login' => &$uiBrowser->login)
- );
-$uiBrowser->loadStationPrefs($ui_fmask['stationPrefs']);
-$Smarty->assign('STATIONPREFS', $uiBrowser->STATIONPREFS);
-$Smarty->assign_by_ref('_REQUEST', $_REQUEST);
-$Smarty->assign_by_ref('_SESSION', $_SESSION);
-// retransfer incomplete formdata from SESSION to POST-data #########
-if (isset($_SESSION['retransferFormData']) && is_array($_SESSION['retransferFormData'])) {
- foreach($_SESSION['retransferFormData'] as $k=>$v){
- $_POST[$k] = $v;
- }
- unset($_SESSION['retransferFormData']);
-}
-
-if (isset($WHITE_SCREEN_OF_DEATH) && ($WHITE_SCREEN_OF_DEATH == TRUE)) {
- echo __FILE__.':line '.__LINE__.": end of file
";
-}
?>
\ No newline at end of file
diff --git a/src/modules/htmlUI/var/ui_handler_init.php b/src/modules/htmlUI/var/ui_handler_init.php
deleted file mode 100644
index e7b6e52e2..000000000
--- a/src/modules/htmlUI/var/ui_handler_init.php
+++ /dev/null
@@ -1,30 +0,0 @@
-init();
-$uiBase =& $uiHandler;
-
-//include("../templates/loader/index.tpl");
-ob_start();
-?>
\ No newline at end of file
diff --git a/src/modules/htmlUI/var/ui_scheduler.class.php b/src/modules/htmlUI/var/ui_scheduler.class.php
index b944c61d3..b9a547fe6 100644
--- a/src/modules/htmlUI/var/ui_scheduler.class.php
+++ b/src/modules/htmlUI/var/ui_scheduler.class.php
@@ -1032,11 +1032,11 @@ class uiScheduler extends uiCalendar {
/**
- * Upload a playlist to the scheduler.
+ * Add an item to the scheduler.
*
* @param array $formdata
* Must have the following keys set:
- * ['playlist'] -> gunid of playlist
+ * ['playlist'] -> id of playlist
* ['date']['Y'] - Year
* ['date']['m'] - month
* ['date']['d'] - day
@@ -1044,12 +1044,12 @@ class uiScheduler extends uiCalendar {
* ['date']['i'] - minute
* ['date']['s'] - second
*
- * @return boolean
- * TRUE on success, FALSE on failure.
+ * @return int|PEAR_Error
+ *
*/
- function uploadPlaylistMethod(&$formdata)
+ function addItem(&$formdata)
{
- $gunid = $formdata['playlist'];
+ $playlistId = $formdata['playlist'];
$datetime = $formdata['date']['Y']
.'-'
.sprintf('%02d', $formdata['date']['m'])
@@ -1060,15 +1060,10 @@ class uiScheduler extends uiCalendar {
.':'.sprintf('%02d', $formdata['time']['s']);
$item = new ScheduleGroup();
- $groupId = $item->add($datetime, null, $gunid);
+ $groupId = $item->add($datetime, null, $playlistId);
//$_SESSION["debug"] = $groupId;
- return is_numeric($groupId);
-// $r = $this->spc->UploadPlaylistMethod($this->Base->sessid, $gunid, $datetime);
-// if ($this->_isError($r)) {
-// return FALSE;
-// }
-// return TRUE;
- } // fn uploadPlaylistMethod
+ return $groupId;
+ }
/**
diff --git a/src/modules/storageServer/var/Schedule.php b/src/modules/storageServer/var/Schedule.php
index 9d84a7464..040890256 100644
--- a/src/modules/storageServer/var/Schedule.php
+++ b/src/modules/storageServer/var/Schedule.php
@@ -57,6 +57,7 @@ class ScheduleGroup {
*
* @return int|PEAR_Error
* Return PEAR_Error if the item could not be added.
+ * Error code 555 is a scheduling conflict.
*/
public function add($p_datetime, $p_audioFileId = null, $p_playlistId = null, $p_options = null) {
global $CC_CONFIG, $CC_DBC;
@@ -76,7 +77,7 @@ class ScheduleGroup {
return new PEAR_Error("Length is empty.");
}
if (!Schedule::isScheduleEmptyInRange($p_datetime, $length)) {
- return new PEAR_Error("Schedule conflict.");
+ return new PEAR_Error("Schedule conflict.", 555);
}
// Insert into the table
@@ -110,7 +111,7 @@ class ScheduleGroup {
return new PEAR_Error("Length is empty.");
}
if (!Schedule::isScheduleEmptyInRange($p_datetime, $length)) {
- return new PEAR_Error("Schedule conflict.");
+ return new PEAR_Error("Schedule conflict.", 555);
}
// Insert all items into the schedule
@@ -219,8 +220,9 @@ class Schedule {
return new PEAR_Error("Schedule::isSchedulerEmptyInRange: param p_length is empty.");
}
$sql = "SELECT COUNT(*) FROM ".$CC_CONFIG["scheduleTable"]
- ." WHERE (starts <= '$p_datetime') "
- ." AND (ends >= (TIMESTAMP '$p_datetime' + INTERVAL '$p_length'))";
+ ." WHERE (starts >= '$p_datetime') "
+ ." AND (ends <= (TIMESTAMP '$p_datetime' + INTERVAL '$p_length'))";
+ //$_SESSION["debug"] = $sql;
$count = $CC_DBC->GetOne($sql);
return ($count == '0');
}