Partial fix for #2009 - fatal error on scheduler import: the parameters given to the XML-RPC method were in the wrong order. Added documentation. Code formatting tweaks. Warning message for scheduler was fixed.

This commit is contained in:
paul 2006-11-27 18:17:37 +00:00
parent f54fd605c0
commit e4d0811d86
1 changed files with 35 additions and 21 deletions

View File

@ -14,6 +14,11 @@ class uiScheduler extends uiCalendar {
public $scheduleNext; public $scheduleNext;
public $error; public $error;
/**
* @var SchedulerPhpClient
*/
public $spc;
/** /**
* @var uiBase * @var uiBase
*/ */
@ -85,10 +90,10 @@ class uiScheduler extends uiCalendar {
$this->scriptError = null; $this->scriptError = null;
if (!isset($this->Base->STATIONPREFS['schedulerStartupScript']) if (!isset($this->Base->STATIONPREFS['schedulerStartupScript'])
|| empty($this->Base->STATIONPREFS['schedulerStartupScript'])) { || empty($this->Base->STATIONPREFS['schedulerStartupScript'])) {
$this->scriptError = 'Scheduler startup script has not been defined. Please set this value in the Preferences->System Settings.'; $this->scriptError = 'Scheduler startup script has not been defined. Please set this value in the "Preferences->System Settings".';
return FALSE; return FALSE;
} elseif (!file_exists($this->Base->STATIONPREFS['schedulerStartupScript'])) { } elseif (!file_exists($this->Base->STATIONPREFS['schedulerStartupScript'])) {
$this->scriptError = sprintf('The scheduler startup script you defined does not exist. You can set this value in Preferences->System Settings the current value is "%s"', $this->Base->STATIONPREFS['schedulerStartupScript']); $this->scriptError = sprintf('The scheduler startup script you defined does not exist. You can set this value in "Preferences->System Settings". The current value is "%s"', $this->Base->STATIONPREFS['schedulerStartupScript']);
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
@ -613,7 +618,7 @@ class uiScheduler extends uiCalendar {
} // fn getNowNextClip } // fn getNowNextClip
function getNowNextClip4jscom() public function getNowNextClip4jscom()
{ {
// just use methods which work without valid authentification // just use methods which work without valid authentification
@ -668,14 +673,14 @@ class uiScheduler extends uiCalendar {
// } // fn OneOrMore // } // fn OneOrMore
function _scheduledDays($period) protected function _scheduledDays($period)
{ {
if ($period === 'month') { if ($period === 'month') {
require_once 'Calendar/Month/Weekdays.php'; require_once('Calendar/Month/Weekdays.php');
$Period = new Calendar_Month_Weekdays($this->curr['year'], $this->curr['month'], $this->firstDayOfWeek); $Period = new Calendar_Month_Weekdays($this->curr['year'], $this->curr['month'], $this->firstDayOfWeek);
$Period->build(); $Period->build();
} elseif ($period === 'week') { } elseif ($period === 'week') {
require_once 'Calendar/Week.php'; require_once('Calendar/Week.php');
$Period = new Calendar_Week ($this->curr['year'], $this->curr['month'], $this->curr['day'], $this->firstDayOfWeek); $Period = new Calendar_Week ($this->curr['year'], $this->curr['month'], $this->curr['day'], $this->firstDayOfWeek);
$Period->build(); $Period->build();
} else { } else {
@ -686,8 +691,7 @@ class uiScheduler extends uiCalendar {
$corrYear = $d->thisMonth()<=12 ? $d->thisYear() : $d->thisYear()+1; ## Calendar_Month_Weekdays $corrYear = $d->thisMonth()<=12 ? $d->thisYear() : $d->thisYear()+1; ## Calendar_Month_Weekdays
$first = array('day' => sprintf('%02d', $d->thisDay()), $first = array('day' => sprintf('%02d', $d->thisDay()),
'month' => $corrMonth, 'month' => $corrMonth,
'year' => $corrYear 'year' => $corrYear);
);
while ($l = $Period->fetch()) { while ($l = $Period->fetch()) {
$d = $l; $d = $l;
@ -699,8 +703,6 @@ class uiScheduler extends uiCalendar {
'year' => $corrYear 'year' => $corrYear
); );
#echo "F:".$first['year'].$first['month'].$first['day']." L:".$last['year'].$last['month'].$last['day'];
$days = $this->_receiveScheduledDays($first['year'].$first['month'].$first['day'], $last['year'].$last['month'].$last['day']); $days = $this->_receiveScheduledDays($first['year'].$first['month'].$first['day'], $last['year'].$last['month'].$last['day']);
foreach ($days as $val) { foreach ($days as $val) {
$selections[] = new Calendar_Day($val['year'], $val['month'], $val['day']); $selections[] = new Calendar_Day($val['year'], $val['month'], $val['day']);
@ -709,22 +711,20 @@ class uiScheduler extends uiCalendar {
} // fn _scheduledDays } // fn _scheduledDays
function _receiveScheduledDays($dfrom, $dto) private function _receiveScheduledDays($dfrom, $dto)
{ {
$dfrom = $dfrom.'T00:00:00'; $dfrom = $dfrom.'T00:00:00';
$dto = $dto.'T23:59:59'; $dto = $dto.'T23:59:59';
if (($pArr = $this->displayScheduleMethod($dfrom, $dto)) === FALSE) { if (($pArr = $this->displayScheduleMethod($dfrom, $dto)) === FALSE) {
return array(FALSE); return array(FALSE);
} }
$pStampArr = null; $pStampArr = null;
foreach ($pArr as $val) { foreach ($pArr as $val) {
#print_r($val);
$pStampArr[] = array('start' => uiScheduler::datetimeToTimestamp($val['start']), $pStampArr[] = array('start' => uiScheduler::datetimeToTimestamp($val['start']),
'end' => uiScheduler::datetimeToTimestamp($val['end'])); 'end' => uiScheduler::datetimeToTimestamp($val['end']));
} }
if (is_array($pStampArr)) { if (is_array($pStampArr)) {
#print_r($pStampArr);
for ($n = uiScheduler::datetimeToTimestamp($dfrom); $n <= uiScheduler::datetimeToTimestamp($dto); $n+=86400) { for ($n = uiScheduler::datetimeToTimestamp($dfrom); $n <= uiScheduler::datetimeToTimestamp($dto); $n+=86400) {
foreach ($pStampArr as $val) { foreach ($pStampArr as $val) {
if ($val['start'] < $n+86400 && $val['end'] >= $n) { if ($val['start'] < $n+86400 && $val['end'] >= $n) {
@ -740,6 +740,14 @@ class uiScheduler extends uiCalendar {
} // fn _receiveScheduledDays } // fn _receiveScheduledDays
/**
* Return true if the argument is an array and has a key index "error"
* which is an array. If it is an error, set the internal error
* message, which can be retrieved with getErrorMsg().
*
* @param mixed $r
* @return boolean
*/
function _isError($r) function _isError($r)
{ {
if (isset($r['error']) && is_array($r['error'])) { if (isset($r['error']) && is_array($r['error'])) {
@ -756,7 +764,13 @@ class uiScheduler extends uiCalendar {
} // fn getErrorMsg } // fn getErrorMsg
function setErrorMSg($msg) /**
* Set the internal error message.
*
* @param string $msg
* @return void
*/
public function setErrorMsg($msg)
{ {
$this->error = $msg; $this->error = $msg;
} // fn setErrorMsg } // fn setErrorMsg
@ -765,7 +779,7 @@ class uiScheduler extends uiCalendar {
## XML-RPC wrapper methods ############################################################################################ ## XML-RPC wrapper methods ############################################################################################
function initXmlRpc() function initXmlRpc()
{ {
include_once dirname(__FILE__).'/ui_schedulerPhpClient.class.php'; include_once(dirname(__FILE__).'/ui_schedulerPhpClient.class.php');
$this->spc =& SchedulerPhpClient::factory($this->Base->dbc, $mdefs, $this->Base->config, FALSE, FALSE); $this->spc =& SchedulerPhpClient::factory($this->Base->dbc, $mdefs, $this->Base->config, FALSE, FALSE);
} // fn initXmlRpc } // fn initXmlRpc
@ -784,9 +798,9 @@ class uiScheduler extends uiCalendar {
if ($this->_isError($r)) { if ($this->_isError($r)) {
return FALSE; return FALSE;
} }
if (isset($r['scheduleEntryId'])) { // if (isset($r['scheduleEntryId'])) {
$this->Base->_retMsg('Entry added at $1 with ScheduleId $2.', strftime("%Y-%m-%d %H:%M:%S", uiScheduler::datetimeToTimestamp($datetime)), $r['scheduleEntryId']); // $this->Base->_retMsg('Entry added at $1 with ScheduleId $2.', strftime("%Y-%m-%d %H:%M:%S", uiScheduler::datetimeToTimestamp($datetime)), $r['scheduleEntryId']);
} // }
} // fn uploadPlaylistMethod } // fn uploadPlaylistMethod
@ -831,7 +845,7 @@ class uiScheduler extends uiCalendar {
function scheduleExportOpen($from,$to) function scheduleExportOpen($from,$to)
{ {
$criteria = array('filetype' => UI_FILETYPE_ANY); $criteria = array('filetype' => UI_FILETYPE_ANY);
$token = $this->spc->exportOpenMethod($this->Base->sessid, $criteria,$from, $to); $token = $this->spc->exportOpenMethod($this->Base->sessid, $from, $to, $criteria);
if (PEAR::isError($token)) { if (PEAR::isError($token)) {
$this->Base->_retMsg('Error initializing scheduler export: $1', $token->getMessage()); $this->Base->_retMsg('Error initializing scheduler export: $1', $token->getMessage());