Skip to content

Commit

Permalink
Added application parameter "service_override": when valued all jobs …
Browse files Browse the repository at this point in the history
…executions are redirected to this service
  • Loading branch information
tvannini committed Oct 19, 2017
1 parent 4127c35 commit 5c55c1b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 28 deletions.
65 changes: 37 additions & 28 deletions lib/jxapp.inc
Expand Up @@ -53,30 +53,31 @@ class o2_app {
/**
* @var o2_runtime
*/
public $runtime = null; /* Running o2_runtime object */
public $nome = ''; /* Application name */
public $alias = ''; /* Application alias (in the form .../[alias]/) */
public $referer = ''; /* <alias>/<name>.php ($_SERVER['PHP_SELF']) */
public $versione = ''; /* Version (in the form v.s.r) */
public $titolo = ''; /* Text to write in the browser title bar */
public $chr_encoding = ''; /* Character encoding (default windows-1252) */
public $default = ''; /* Document to be included when nothing to do */
public $no_login = ''; /* Failed login page */
public $lock_page = ''; /* Access denied for Under Maintanance page */
public $sess_error = ''; /* Failed session validation page */
public $pagina_prima = ''; /* Document to prepend to pages */
public $pagina_dopo = ''; /* Document to append to pages */
public $css = ''; /* CSS documents string (separated by ",") */
public $client_width = 0; /* Browser window width */
public $client_height = 0; /* Browser window height */
public $vars = array(); /* Application variables (o2_appvar) list */
public $page_mark = 0; /* Last sent page mark for page expiring */
public $relocate_now = false; /* Views relocating immediate executing */
public $caret_position = array(); /* Programs scripts for caret reposition list */
public $js_file = ''; /* Javascript file to be included */
public $favicon = ''; /* "Favorite icon" for application */
public $rpc_server = false; /* If app is used as an RPC Server */
public $services = array(); /* List of defined services */
public $runtime = null; /* Running o2_runtime object */
public $nome = ''; /* Application name */
public $alias = ''; /* Application alias (in the form .../[alias]/) */
public $referer = ''; /* <alias>/<name>.php ($_SERVER['PHP_SELF']) */
public $versione = ''; /* Version (in the form v.s.r) */
public $titolo = ''; /* Text to write in the browser title bar */
public $chr_encoding = ''; /* Character encoding (default windows-1252) */
public $default = ''; /* Document to be included when nothing to do */
public $no_login = ''; /* Failed login page */
public $lock_page = ''; /* Access denied for Under Maintanance page */
public $sess_error = ''; /* Failed session validation page */
public $pagina_prima = ''; /* Document to prepend to pages */
public $pagina_dopo = ''; /* Document to append to pages */
public $css = ''; /* CSS documents string (separated by ",") */
public $client_width = 0; /* Browser window width */
public $client_height = 0; /* Browser window height */
public $vars = array(); /* Application variables (o2_appvar) list */
public $page_mark = 0; /* Last sent page mark for page expiring */
public $relocate_now = false; /* Views relocating immediate executing */
public $caret_position = array(); /* Programs scripts for caret reposition list */
public $js_file = ''; /* Javascript file to be included */
public $favicon = ''; /* "Favorite icon" for application */
public $rpc_server = false; /* If app is used as an RPC Server */
public $services = array(); /* List of defined services */
public $service_redirect = false; /* If set all jobs are assigned to this service */
/* _____ Session ______________________________________________________________ */
public $validazione = 0; /* Validation level (0=none,1=full,2=mixed))*/
public $session_name = ''; /* Session name (PHPSESSID) */
Expand Down Expand Up @@ -1332,11 +1333,14 @@ class o2_app {
if (isset($conf['host'])) {
$this->host = strtoupper($conf['host']);
}
if (isset($conf['service_redirect'])) {
$this->service_redirect = strtoupper($conf['service_redirect']);
}
if (isset($conf['services'])) {
$this->services = array();
foreach (preg_split('/[,; ]+/', $conf['services']) as $service) {
$service = strtoupper($service);
if ($service != 'default') {
if ($service != 'DEFAULT') {
$this->services[] = $service;
}
}
Expand Down Expand Up @@ -3561,6 +3565,7 @@ class o2_job {
$disabled = false,
$service = false) {

$app = $_SESSION['o2_app'];
$this->id = intval($id);
$this->name = $name;
$this->prg = $prg;
Expand All @@ -3574,7 +3579,10 @@ class o2_job {
$this->disabled = ($disabled ? true : false);
// _______________________________________________________________ Set service ___
$service = strtoupper($service);
if ($service && in_array($service, $_SESSION['o2_app']->services)) {
if ($app->service_redirect) {
$this->service = $app->service_redirect;
}
elseif ($service && in_array($service, $_SESSION['o2_app']->services)) {
$this->service = $service;
}
else {
Expand Down Expand Up @@ -4270,8 +4278,9 @@ class o2_run_job {
$run_job->aspid = ($aspid ? $aspid : '');
$run_job->status = 'Q';
$service = strtoupper($service);
$run_job->service = ($service && in_array($service, $app->services) ?
$service : $job->service);
$run_job->service = ($app->service_redirect ? $app->service_redirect :
($service && in_array($service, $app->services) ?
$service : $job->service));
if ($at_date || $at_time) {
$ad = ($at_date ? $at_date : date('Ymd'));
$at = ($at_time ? $at_time : date('His'));
Expand Down
9 changes: 9 additions & 0 deletions lib/prgs/o2sys_iniconf.prf
Expand Up @@ -877,6 +877,14 @@ $list = array(
"desc" => " *** Services ***\n\n".
"List of �-separated names of services enabled for application deferred executions.",
"default" => "_internal"),
"service_redirect" => array("rntval" => null,
"appval" => null,
"desc" => " *** Service redirect ***\n\n".
"Specifies a service to work as a service overriding for all executions.\n".
"When this parameter is set all jobs executions (run and queue) will be assigned ".
"to this service, regardless all other logics.\n".
"To use this parameter set it to the name of a registered service.",
"default" => ""),
"rpc_server" => array("rntval" => null,
"appval" => null,
"desc" => " *** Remote Procedure Call (RPC) Server ***\n\n".
Expand Down Expand Up @@ -1217,6 +1225,7 @@ function o2sys_iniconf_exp_34() {
"startprg",
"reqprg",
"services",
"service_redirect",
"rpc_server",
"data_chunk",
"tables_create",
Expand Down

0 comments on commit 5c55c1b

Please sign in to comment.