diff --git a/livesupport/modules/htmlUI/var/SchedulerPhpClient.class.php b/livesupport/modules/htmlUI/var/SchedulerPhpClient.class.php
new file mode 100755
index 000000000..ebfdededf
--- /dev/null
+++ b/livesupport/modules/htmlUI/var/SchedulerPhpClient.class.php
@@ -0,0 +1,489 @@
+
+ *
m full method name (include optional prefix)
+ * p array of input parameter names
+ * r array of result element names (not used there at present)
+ * e array of error codes/messages (not used there at present)
+ *
+ */
+$mdefs = array(
+ "AddAudioClipToPlaylistMethod" => array(
+ 'm'=>'AddAudioClipToPlaylistMethod',
+ 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/, 'audioClipId'/*string*/, 'relativeOffset'/*int*/),
+ 'r'=>array('playlistElementId'/*string*/),
+ 'e'=>array(
+ '301'=>'invalid argument format',
+ '302'=>'missing playlist ID argument',
+ '303'=>'missing audio clip ID argument',
+ '304'=>'missing relative offset argument',
+ '305'=>'playlist not found',
+ '306'=>'playlist has not been opened for editing',
+ '307'=>'audio clip does not exist',
+ '308'=>'two audio clips at the same relative offset',
+ '320'=>'missing session ID argument',
+ )
+ ),
+ "CreatePlaylistMethod" => array(
+ 'm'=>'CreatePlaylistMethod',
+ 'p'=>array('sessionId'/*string*/),
+ 'r'=>array('playlist'/*string*/),
+ 'e'=>array(
+ '201'=>'invalid argument format',
+ '202'=>'could not create playlist',
+ '220'=>'missing session ID argument',
+ )
+ ),
+ "DeletePlaylistMethod" => array(
+ 'm'=>'DeletePlaylistMethod',
+ 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/),
+ 'r'=>array(),
+ 'e'=>array(
+ '901'=>'invalid argument format',
+ '902'=>'missing playlist ID argument',
+ '903'=>'playlist not found',
+ '904'=>'playlist is locked',
+ '905'=>'playlist could not be deleted',
+ '920'=>'missing session ID argument',
+ )
+ ),
+ "DisplayAudioClipMethod" => array(
+ 'm'=>'DisplayAudioClipMethod',
+ 'p'=>array('sessionId'/*string*/, 'audioClipId'/*string*/),
+ 'r'=>array('audioClip'/*string*/),
+ 'e'=>array(
+ '601'=>'invalid argument format',
+ '602'=>'argument is not an audio clip ID',
+ '603'=>'audio clip not found',
+ '620'=>'missing session ID argument',
+ )
+ ),
+ "DisplayAudioClipsMethod" => array(
+ 'm'=>'DisplayAudioClipsMethod',
+ 'p'=>array('sessionId'/*string*/),
+ 'r'=>array(array('audioClip'/*string*/)),
+ 'e'=>array(
+ '1801'=>'invalid argument format',
+ '1802'=>'XML-RPC error',
+ '1820'=>'missing session ID argument',
+ )
+ ),
+ "DisplayPlaylistMethod" => array(
+ 'm'=>'DisplayPlaylistMethod',
+ 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/),
+ 'r'=>array('playlist'/*string*/),
+ 'e'=>array(
+ '1001'=>'invalid argument format',
+ '1002'=>'argument is not a playlist ID',
+ '1003'=>'playlist not found',
+ '1020'=>'missing session ID argument',
+ )
+ ),
+ "DisplayPlaylistsMethod" => array(
+ 'm'=>'DisplayPlaylistsMethod',
+ 'p'=>array('sessionId'/*string*/),
+ 'r'=>array(array('playlist'/*string*/)),
+ 'e'=>array(
+ '1701'=>'invalid argument format',
+ '1702'=>'XML-RPC error',
+ '1720'=>'missing session ID argument',
+ )
+ ),
+ "DisplayScheduleMethod" => array(
+ 'm'=>'DisplayScheduleMethod',
+ 'p'=>array('sessionId'/*string*/, 'from'/*datetime*/, 'to'/*datetime*/),
+ 'r'=>array(array('id'/*int*/, 'playlistId'/*string*/, 'start'/*datetime*/, 'end'/*datetime*/)),
+ 'e'=>array(
+ '1101'=>'invalid argument format',
+ '1102'=>"missing or invalid 'from' argument",
+ '1103'=>"missing or invalid 'to' argument",
+ '1120'=>'missing session ID argument',
+ )
+ ),
+ "GeneratePlayReportMethod" => array(
+ 'm'=>'GeneratePlayReportMethod',
+ 'p'=>array('sessionId'/*string*/, 'from'/*datetime*/, 'to'/*datetime*/),
+ 'r'=>array(array('audioClipId'/*string*/, 'timestamp'/*datetime*/)),
+ 'e'=>array(
+ '1501'=>'invalid argument format',
+ '1502'=>"missing or invalid 'from' argument",
+ '1503'=>"missing or invalid 'to' argument",
+ '1520'=>'missing session ID argument',
+ )
+ ),
+ "GetSchedulerTimeMethod" => array(
+ 'm'=>'GetSchedulerTimeMethod',
+ 'p'=>array(),
+ 'r'=>array('schedulerTime'/*datetime*/),
+ 'e'=>array(
+)
+ ),
+ "GetVersionMethod" => array(
+ 'm'=>'GetVersionMethod',
+ 'p'=>array(),
+ 'r'=>array('version'/*string*/),
+ 'e'=>array()
+ ),
+ "LoginMethod" => array(
+ 'm'=>'LoginMethod',
+ 'p'=>array('login'/*string*/, 'password'/*string*/),
+ 'r'=>array('sessionId'/*string*/),
+ 'e'=>array(
+ '2001'=>'invalid argument format',
+ '2002'=>'missing login argument',
+ '2003'=>'missing password argument',
+ '2004'=>'the authentication server reported an error',
+ )
+ ),
+ "LogoutMethod" => array(
+ 'm'=>'LogoutMethod',
+ 'p'=>array('sessionId'/*string*/),
+ 'r'=>array(),
+ 'e'=>array(
+ '2101'=>'invalid argument format',
+ '2120'=>'missing session ID argument',
+ '2104'=>'the authentication server reported an error',
+ )
+ ),
+ "OpenPlaylistForEditingMethod" => array(
+ 'm'=>'OpenPlaylistForEditingMethod',
+ 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/),
+ 'r'=>array('playlist'/*string*/),
+ 'e'=>array(
+ '101'=>'invalid argument format',
+ '102'=>'argument is not a playlist ID',
+ '104'=>'could not open playlist for editing',
+ '120'=>'missing session ID argument',
+ )
+ ),
+ "RemoveAudioClipFromPlaylistMethod" => array(
+ 'm'=>'RemoveAudioClipFromPlaylistMethod',
+ 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/, 'playlistElementId'/*string*/),
+ 'r'=>array(),
+ 'e'=>array(
+ '401'=>'invalid argument format',
+ '402'=>'missing playlist ID argument',
+ '403'=>'missing relative offset argument',
+ '404'=>'playlist does not exist',
+ '405'=>'playlist has not been opened for editing',
+ '406'=>'no audio clip at the specified relative offset',
+ '420'=>'missing session ID argument',
+ )
+ ),
+ "RemoveFromScheduleMethod" => array(
+ 'm'=>'RemoveFromScheduleMethod',
+ 'p'=>array('sessionId'/*string*/, 'scheduleEntryId'/*string*/),
+ 'r'=>array(),
+ 'e'=>array(
+ '1201'=>'invalid argument format',
+ '1202'=>'missing schedule entry ID argument',
+ '1203'=>'schedule entry not found',
+ '1220'=>'missing session ID argument',
+ )
+ ),
+ "RescheduleMethod" => array(
+ 'm'=>'RescheduleMethod',
+ 'p'=>array('sessionId'/*string*/, 'scheduleEntryId'/*string*/, 'playtime'/*datetime*/),
+ 'r'=>array(),
+ 'e'=>array(
+ '1301'=>'invalid argument format',
+ '1302'=>'missing schedule entry ID argument',
+ '1303'=>'missing playtime argument',
+ '1304'=>'schedule entry not found',
+ '1305'=>'could not reschedule entry',
+ '1320'=>'missing session ID argument',
+ )
+ ),
+ "ResetStorageMethod" => array(
+ 'm'=>'ResetStorageMethod',
+ 'p'=>array(),
+ 'r'=>array(),
+ 'e'=>array('3001'=>'storage client reported an error'),
+ ),
+ "RevertEditedPlaylistMethod" => array(
+ 'm'=>'RevertEditedPlaylistMethod',
+ 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/),
+ 'r'=>array(),
+ 'e'=>array(
+ '801'=>'invalid argument format',
+ '802'=>'argument is not a playlist ID',
+ '803'=>'playlist not found',
+ '804'=>'could not revert playlist',
+ '820'=>'missing session ID argument',
+ )
+ ),
+ "SavePlaylistMethod" => array(
+ 'm'=>'SavePlaylistMethod',
+ 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/),
+ 'r'=>array(),
+ 'e'=>array(
+ '701'=>'invalid argument format',
+ '702'=>'argument is not a playlist ID',
+ '703'=>'playlist not found',
+ '705'=>'could not save playlist',
+ '720'=>'missing session ID argument',
+ )
+ ),
+ "UpdateFadeInFadeOutMethod" => array(
+ 'm'=>'UpdateFadeInFadeOutMethod',
+ 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/, 'playlistElementId'/*string*/, 'fadeIn'/*int*/, 'fadeOut'/*int*/),
+ 'r'=>array(),
+ 'e'=>array(
+ '1601'=>'invalid argument format',
+ '1602'=>'missing playlist ID argument',
+ '1603'=>'missing playlist element ID argument',
+ '1604'=>'missing fade in argument',
+ '1605'=>'missing fade out argument',
+ '1606'=>'playlist does not exist',
+ '1607'=>'playlist has not been opened for editing',
+ '1608'=>'error executing setFadeInfo() method',
+ '1620'=>'missing session ID argument',
+ )
+ ),
+ "UploadPlaylistMethod" => array(
+ 'm'=>'UploadPlaylistMethod',
+ 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/, 'playtime'/*datetime*/),
+ 'r'=>array('scheduleEntryId'/*string*/),
+ 'e'=>array(
+ '1401'=>'invalid argument format',
+ '1402'=>'missing playlist ID argument',
+ '1403'=>'missing playtime argument',
+ '1404'=>'playlist not found',
+ '1405'=>'timeframe not available',
+ '1406'=>'could not schedule playlist',
+ '1420'=>'missing session ID argument',
+ )
+ ),
+ "ValidatePlaylistMethod" => array(
+ 'm'=>'ValidatePlaylistMethod',
+ 'p'=>array('sessionId'/*string*/, 'playlistId'/*string*/),
+ 'r'=>array('valid'/*bool*/),
+ 'e'=>array(
+ '501'=>'invalid argument format',
+ '502'=>'missing playlist ID argument',
+ '503'=>'playlist does not exist',
+ '504'=>'playlist has not been opened for editing',
+ '520'=>'missing session ID argument',
+ )
+ ),
+ "LoginGB" => array(
+ 'm'=>'locstor.login',
+ 'p'=>array('login'/*string*/, 'pass'/*string*/),
+ 'r'=>array('sessid'/*string*/),
+ 'e'=>array(
+ '2001'=>'invalid argument format',
+ '2002'=>'missing login argument',
+ '2003'=>'missing password argument',
+ '2004'=>'the authentication server reported an error',
+ )
+ ),
+ "LogoutGB" => array(
+ 'm'=>'locstor.logout',
+ 'p'=>array('sessid'/*string*/),
+ 'r'=>array('status'/*boolean*/),
+ 'e'=>array(
+ '2001'=>'invalid argument format',
+ '2002'=>'missing login argument',
+ '2003'=>'missing password argument',
+ '2004'=>'the authentication server reported an error',
+ )
+ ),
+);
+
+/* ======================================================== class definitions */
+
+class SchedulerPhpClient{
+ /**
+ * Databases object reference
+ */
+ var $dbc = NULL;
+ /**
+ * Array with methods description
+ */
+ var $mdefs = array();
+ /**
+ * Confiduration array from ../conf.php
+ */
+ var $config = array();
+ /**
+ * XMLRPC client object reference
+ */
+ var $client = NULL;
+ /**
+ * Verbosity flag
+ */
+ var $verbose = FALSE;
+ /**
+ * XMLRPC debug flag
+ */
+ var $debug = 0;
+ /**
+ * Constructor - pelase DON'T CALL IT, use factory method instead
+ *
+ * @param dbc object, database object reference
+ * @param mdefs array, hash array with methods description
+ * @param config array, hash array with configuration
+ * @param debug int, XMLRPC debug flag
+ * @param verbose boolean, verbosity flag
+ * @return this
+ */
+ function SchedulerPhpClient(
+ &$dbc, $mdefs, $config, $debug=0, $verbose=FALSE)
+ {
+ $this->dbc = $dbc;
+ $this->mdefs = $mdefs;
+ $this->config = $config;
+ $this->debug = $debug;
+ $this->verbose = $verbose;
+ $confPrefix = "scheduler";
+ #$confPrefix = "storage";
+ $serverPath =
+ "http://{$config["{$confPrefix}UrlHost"]}:{$config["{$confPrefix}UrlPort"]}".
+ "{$config["{$confPrefix}UrlPath"]}/{$config["{$confPrefix}XMLRPC"]}";
+ #$serverPath = "http://localhost:80/livesupportStorageServer/xmlrpc/xrLocStor.php";
+ if($this->verbose) echo "serverPath: $serverPath\n";
+ $url = parse_url($serverPath);
+ $this->client = new XML_RPC_Client($url['path'], $url['host'], $url['port']);
+ }
+
+ /**
+ * Factory, create object instance
+ *
+ * In fact it doesn't create instance of SchedulerPhpClient, but
+ * dynamically extend this class with set of methods based on $mdefs array
+ * (using eval function) and instantiate resulting class
+ * SchedulerPhpClientCore instead.
+ * Each new method in this subclass accepts parameters according to $mdefs
+ * array, call wrapper callMethod(methodname, parameters) and return its
+ * result.
+ *
+ * @param dbc object, database object reference
+ * @param mdefs array, hash array with methods description
+ * @param config array, hash array with configuration
+ * @param debug int, XMLRPC debug flag
+ * @param verbose boolean, verbosity flag
+ * @return object, created object instance
+ */
+ function &factory(&$dbc, $mdefs, $config, $debug=0, $verbose=FALSE){
+ $f = '';
+ foreach($mdefs as $fn=>$farr){
+ $f .=
+ ' function '.$fn.'(){'."\n".
+ ' $pars = func_get_args();'."\n".
+ ' $r = $this->callMethod("'.$fn.'", $pars);'."\n".
+ ' return $r;'."\n".
+ ' }'."\n";
+ }
+ $e =
+ "class SchedulerPhpClientCore extends SchedulerPhpClient{\n".
+ "$f\n".
+ "}\n";
+# echo $e;
+ if(FALSE === eval($e)) return $dbc->raiseError("Eval failed");
+ $spc =& new SchedulerPhpClientCore(
+ $dbc, $mdefs, $config, $debug, $verbose);
+ return $spc;
+ }
+
+ /**
+ * XMLRPC methods wrapper
+ * Encode XMLRPC request message, send it, receive and decode response.
+ *
+ * @param method string, method name
+ * @param gettedPars array, returned by func_get_args() in called method
+ * @return array, PHP hash with response
+ */
+ function callMethod($method, $gettedPars)
+ {
+ $parr = array();
+ foreach($this->mdefs[$method]['p'] as $i=>$p){
+ $parr[$p] = $gettedPars[$i];
+ }
+ $fullmethod = $this->mdefs[$method]['m'];
+ $msg = new XML_RPC_Message($fullmethod, array(XML_RPC_encode($parr)));
+ if($this->verbose){
+ echo "parr:\n";
+ var_dump($parr);
+ echo "message:\n";
+ echo $msg->serialize()."\n";
+ }
+ $this->client->setDebug($this->debug);
+ $res = $this->client->send($msg);
+ if($res->faultCode() > 0) {
+ return $this->dbc->raiseError(
+ "SchedulerPhpClient::$method:".$res->faultString()." ".
+ $res->faultCode()."\n", $res->faultCode()
+ );
+ }
+ if($verbose){
+ echo "result:\n";
+ echo $res->serialize();
+ }
+ $resp = XML_RPC_decode($res->value());
+ return $resp;
+ }
+
+}
+
+/* ======================================================== class definitions */
+
+/**
+ * Example of use:
+ *
+ */
+
+/*
+// db object handling:
+$dbc = DB::connect($config['dsn'], TRUE);
+$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
+$dbc->setErrorHandling(PEAR_ERROR_RETURN);
+
+// scheduler client instantiation:
+$spc =& SchedulerPhpClient::factory($dbc, $mdefs, $config);
+
+// call of chosen function by name according to key values in $mdefs array:
+// (for testing on storageServer XMLRPC I've changes confPrefix in
+// SchedulerPhpClient constructor from 'scheduler' to 'storage' value)
+$r = $spc->LoginGB('root', 'q'); var_dump($r);
+#$r = $spc->LogoutGB(''); var_dump($r);
+*/
+
+?>
\ No newline at end of file
diff --git a/livesupport/modules/htmlUI/var/html/ui_handler.php b/livesupport/modules/htmlUI/var/html/ui_handler.php
index ab6e03c7a..df1b4b9ac 100644
--- a/livesupport/modules/htmlUI/var/html/ui_handler.php
+++ b/livesupport/modules/htmlUI/var/html/ui_handler.php
@@ -222,16 +222,17 @@ switch($_REQUEST['act']){
$uiHandler->SCHEDULER->setReload();
break;
- case "SCHEDULER.uploadPL":
- $uiHandler->SCHEDULER->uploadPL($_REQUEST['gunid']);
+ case "SCHEDULER.displaySchedule":
+ $uiHandler->SCHEDULER->displaySchedule();
$uiHandler->SCHEDULER->setReload();
break;
default:
$_SESSION["alertMsg"] = tra("Unknown method: $1", $_REQUEST["act"]);
- header("Location: ".UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close');
+ #header("Location: ".UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close');
die();
}
if ($uiHandler->alertMsg) $_SESSION['alertMsg'] = $uiHandler->alertMsg;
-header('Location: '.$uiHandler->redirUrl);
-?>
\ No newline at end of file
+#header('Location: '.$uiHandler->redirUrl);
+?>
+
\ No newline at end of file
diff --git a/livesupport/modules/htmlUI/var/templates/scheduler/day.tpl b/livesupport/modules/htmlUI/var/templates/scheduler/day.tpl
index e69de29bb..48ce7840f 100755
--- a/livesupport/modules/htmlUI/var/templates/scheduler/day.tpl
+++ b/livesupport/modules/htmlUI/var/templates/scheduler/day.tpl
@@ -0,0 +1,13 @@
+{$SCHEDULER->buildDay()}
+
+Day View
+
+
+
+{foreach from=$SCHEDULER->Day item="_Hour"}
+
+ {$_Hour.hour} |
+
+{/foreach}
+
+
diff --git a/livesupport/modules/htmlUI/var/templates/scheduler/main.tpl b/livesupport/modules/htmlUI/var/templates/scheduler/main.tpl
index 156c78c9a..6354b5708 100755
--- a/livesupport/modules/htmlUI/var/templates/scheduler/main.tpl
+++ b/livesupport/modules/htmlUI/var/templates/scheduler/main.tpl
@@ -4,7 +4,7 @@
-
+
{include file="scheduler/calendar.tpl"}
diff --git a/livesupport/modules/htmlUI/var/templates/scheduler/week.tpl b/livesupport/modules/htmlUI/var/templates/scheduler/week.tpl
index e69de29bb..0422eaafa 100755
--- a/livesupport/modules/htmlUI/var/templates/scheduler/week.tpl
+++ b/livesupport/modules/htmlUI/var/templates/scheduler/week.tpl
@@ -0,0 +1,29 @@
+{$SCHEDULER->buildWeek()}
+
+Week View
+
+
+
+
+ {foreach from=$SCHEDULER->Week item="_Weekday"}
+ {$_Weekday.label.full} |
+ {/foreach}
+
+
+{foreach from=$SCHEDULER->Week item="_Day"}
+ {if $_Day.isFirst}
+
+ {/if}
+
+ {if $_Day.isEmpty}
+ |
+ {else}
+ {$_Day.day} |
+ {/if}
+
+ {if $_Day.isLast}
+
+ {/if}
+{/foreach}
+
+
diff --git a/livesupport/modules/htmlUI/var/ui_calendar.class.php b/livesupport/modules/htmlUI/var/ui_calendar.class.php
index f0fd260f4..22f6f872d 100755
--- a/livesupport/modules/htmlUI/var/ui_calendar.class.php
+++ b/livesupport/modules/htmlUI/var/ui_calendar.class.php
@@ -54,12 +54,14 @@ class uiCalendar
function buildDay()
{
+ if (is_array($this->Day)) return FALSE;
+
require_once 'Calendar/Day.php';
$Day = new Calendar_Day ($this->curr['year'], $this->curr['month'], $this->curr['day']);
$Day->build();
while ($Hour = $Day->fetch()) {
- $this->Day[] = $Hour->thisHour();
+ $this->Day[] = array('hour' => $Hour->thisHour());
}
}
diff --git a/livesupport/modules/htmlUI/var/ui_scheduler.class.php b/livesupport/modules/htmlUI/var/ui_scheduler.class.php
index bf6263731..d905dea59 100755
--- a/livesupport/modules/htmlUI/var/ui_scheduler.class.php
+++ b/livesupport/modules/htmlUI/var/ui_scheduler.class.php
@@ -31,14 +31,19 @@ class uiScheduler extends uiCalendar
}
- function uploadPL($gunid)
+ function displaySchedule()
{
- require_once dirname(__FILE__).'ui_xmlrpcwrapper.class.php';
+ include_once dirname(__FILE__).'/SchedulerPhpClient.class.php';
+ // scheduler client instantiation:
+ $spc =& SchedulerPhpClient::factory($this->Base->dbc, $mdefs, $this->Base->config);
+ // call of chosen function by name according to key values in $mdefs array:
+ // (for testing on storageServer XMLRPC I've changes confPrefix in
+ // SchedulerPhpClient constructor from 'scheduler' to 'storage' value)
+ $r = $spc->DisplayScheduleMethod($this->Base->sessid, '2005-01-01 00:00:00.000000', '2005-02-01 00:00:00.000000');
+ var_dump($r);
}
-
-
}
?>