From 8a5ae9f186139ce3b4e56df14eee169ab1516382 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 9 Nov 2010 16:10:13 +0000 Subject: [PATCH] Updated the dashBoard -Updated server accessibility detection -Updated registration handling git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20208 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../Register/class_RegistrationDialog.inc | 35 +++++++++++------- .../generic/dashBoard/Register/register.tpl | 24 +++++++++++- .../generic/dashBoard/class_dashBoard.inc | 37 +++++++++++++------ 3 files changed, 70 insertions(+), 26 deletions(-) diff --git a/gosa-core/plugins/generic/dashBoard/Register/class_RegistrationDialog.inc b/gosa-core/plugins/generic/dashBoard/Register/class_RegistrationDialog.inc index 81ea9ae6a..fd87e6bd8 100644 --- a/gosa-core/plugins/generic/dashBoard/Register/class_RegistrationDialog.inc +++ b/gosa-core/plugins/generic/dashBoard/Register/class_RegistrationDialog.inc @@ -15,6 +15,13 @@ class RegistrationDialog extends plugin protected $values = array(); public $attrs = array('username','password'); + protected $finished = FALSE; + + function finished() + { + return($this->finished); + } + function __construct(&$config) { $this->config = $config; @@ -30,7 +37,7 @@ class RegistrationDialog extends plugin $smarty->assign("error", ""); // Registration page one filled in, next step requested. - if(isset($_POST['registerPage2'])){ + if(isset($_POST['registerPage1'])){ $msgs = $this->check(); if(count($msgs)){ msg_dialog::displayChecks($msgs); @@ -38,19 +45,10 @@ class RegistrationDialog extends plugin if($this->selectedRegistrationType == "registered"){ - // Try to login with the given username / password - $rpcHandle = $this->config->getRpcHandle( - "http://10.3.64.59:4000", - $this->values['username'], - $this->values['password'], - TRUE, FALSE); - - // Register instance + // Try to registrate the instance with the given username and password. + $rpcHandle = $this->config->registration->getConnection($this->values['username'],$this->values['password']); $rpcHandle->registerInstance($this->config->getInstanceUuid()); - - // Check if we're able to connect. if(!$rpcHandle->success()){ - $code = $rpcHandle->getHTTPstatusCode(); if($code == 0){ $smarty->assign("error", _("Communciation with the backend failed! Please check your internet connection!")); @@ -59,6 +57,8 @@ class RegistrationDialog extends plugin }elseif($code == 403){ $smarty->assign("error", _("Internal server error, please try again later. If the problem persists contact the GOsa-Team!")); } + }else{ + $this->step = 2; } } } @@ -78,7 +78,16 @@ class RegistrationDialog extends plugin } if(isset($_POST['registrationType'])) $this->selectedRegistrationType = get_post('registrationType'); - if(isset($_POST['startRegistration'])) $this->step = 1; + + // Registration type selected and next page choosen. + if(isset($_POST['startRegistration'])){ + if($this->selectedRegistrationType == "none"){ + $this->step = 100; + }else{ + $this->step = 1; + } + } + if(isset($_POST['registerComplete'])) $this->finished = TRUE; if(isset($_POST['stepBack'])) $this->step -= 1; } } diff --git a/gosa-core/plugins/generic/dashBoard/Register/register.tpl b/gosa-core/plugins/generic/dashBoard/Register/register.tpl index 24a6813f7..c4c532963 100644 --- a/gosa-core/plugins/generic/dashBoard/Register/register.tpl +++ b/gosa-core/plugins/generic/dashBoard/Register/register.tpl @@ -42,7 +42,7 @@ {/if} -{if $step == 1 || $step == -1} +{if $step == 1} @@ -60,8 +60,28 @@
- +
{/if} +{if $step == 2} +

{t}Registration complete{/t}

+

+ {t}GOsa instance sucessfully registered{/t} +

+
+
+ +
+{/if} +{if $step == 100} +

{t}Registration complete{/t}

+

+ {t}GOsa instance will not be registered{/t} +

+
+
+ +
+{/if} diff --git a/gosa-core/plugins/generic/dashBoard/class_dashBoard.inc b/gosa-core/plugins/generic/dashBoard/class_dashBoard.inc index b0e8e7f46..8d1e791a1 100644 --- a/gosa-core/plugins/generic/dashBoard/class_dashBoard.inc +++ b/gosa-core/plugins/generic/dashBoard/class_dashBoard.inc @@ -22,15 +22,27 @@ class dashBoard extends plugin $this->dbNotifications = new dbNotifications($config); $this->dbInformation = new dbInformation($config); - - // Detect registration status - $this->RegistrationDialog = new RegistrationDialog($config); + // Check if we've access to the registration server + if($config->registration->isServerAccessible()){ + if(!$config->registration->isInstanceRegistered()){ + $this->dialog = new RegistrationDialog($config); + } + } } function execute() { - if(!$this->config->registration->isRegistered()){ - return($this->RegistrationDialog->execute()); + // Seems that we haven't registered our GOsa instance yet. + // Ask the user to do so, now. + if($this->dialog instanceOf RegistrationDialog){ + $this->dialog->save_object(); + + // Check if the registration is complete/canceled + if(!$this->dialog->finished()){ + return($this->dialog->execute()); + }else{ + $this->dialog = NULL; + } } $smarty = get_smarty(); @@ -54,13 +66,16 @@ class dashBoard extends plugin function save_object() { plugin::save_object(); - - if(!$this->config->registration->isRegistered()) $this->RegistrationDialog->save_object(); + + if($this->dialog instanceOf RegistrationDialog){ + $this->dialog->save_object(); + }else{ - $this->dbPluginStatus->save_object(); - $this->dbChannelStatus->save_object(); - $this->dbNotifications->save_object(); - $this->dbInformation->save_object(); + $this->dbPluginStatus->save_object(); + $this->dbChannelStatus->save_object(); + $this->dbNotifications->save_object(); + $this->dbInformation->save_object(); + } } function save() -- 2.30.2