From 801773b9bc159ff6318e6d418e65357fa3f9bba4 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 10 Nov 2010 06:45:48 +0000 Subject: [PATCH] Updated registration process git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20209 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-core/include/class_GOsaRegistration.inc | 70 ++++++++++++++++++- .../Register/class_RegistrationDialog.inc | 19 ++--- .../generic/dashBoard/Register/register.tpl | 16 +++-- .../generic/dashBoard/class_dashBoard.inc | 3 +- .../generic/statistics/class_statistics.inc | 16 +++-- .../plugins/generic/statistics/statistics.tpl | 8 ++- 6 files changed, 104 insertions(+), 28 deletions(-) diff --git a/gosa-core/include/class_GOsaRegistration.inc b/gosa-core/include/class_GOsaRegistration.inc index efadc48b3..7609fe5ee 100644 --- a/gosa-core/include/class_GOsaRegistration.inc +++ b/gosa-core/include/class_GOsaRegistration.inc @@ -2,18 +2,84 @@ class GOsaRegistration { + private $config; + private $server = "http://10.3.64.59:4000"; + private $user = "gosa"; + private $password = "gosa"; + + private $isRegistered = NULL; function __construct(&$config) { $this->config = $config; } - + + function getRegistrationServer() + { + return($this->server); + } + + function getConnection($user = NULL, $password ="") + { + if($user === NULL){ + return($this->config->getRpcHandle($this->server, $this->user,$this->password, TRUE, FALSE)); + }else{ + return($this->config->getRpcHandle($this->server, $user,$password, TRUE, FALSE)); + } + } + + function isServerAccessible() + { + $con = $this->getConnection(); + $res = $con->isInstanceRegistered("dummy"); + if($con->success()){ + return(TRUE); + }else{ + return(FALSE); + } + } + + function registrationRequired() + { + $date = $this->config->configRegistry->getPropertyValue('GOsaRegistration','askForRegistration'); + if($date == -1){ + return(FALSE); + }else{ + return($date < time()); + } + } function isInstanceRegistered() { - return(FALSE); + if($this->isRegistered === NULL){ + $con = $this->getConnection(); + $res = $con->isInstanceRegistered($this->config->getInstanceUuid()); + if($con->success()){ + $this->isRegistered = $res; + }else{ + return(FALSE); + } + } + return($this->isRegistered); + } + + + static function plInfo() + { + return (array( + "plProperties" => array( + array( + "name" => "askForRegistration", + "type" => "integer", + "default" => "0", + "description" => _("Represents a unix-timestamp which points to the date, GOsa will ask for a registration again. -1 = Never, 0 = Now else once we reached the gieven timestamp"), + "check" => "gosaProperty::isInteger", + "migrate" => "", + "group" => "registration", + "mandatory" => FALSE), + ))); } } diff --git a/gosa-core/plugins/generic/dashBoard/Register/class_RegistrationDialog.inc b/gosa-core/plugins/generic/dashBoard/Register/class_RegistrationDialog.inc index fd87e6bd8..be319f2f1 100644 --- a/gosa-core/plugins/generic/dashBoard/Register/class_RegistrationDialog.inc +++ b/gosa-core/plugins/generic/dashBoard/Register/class_RegistrationDialog.inc @@ -8,7 +8,7 @@ class RegistrationDialog extends plugin { - protected $selectedRegistrationType = "registered"; + protected $selectedRegistrationType = "registrate"; protected $isRegistered = FALSE; protected $step = 0; @@ -43,7 +43,7 @@ class RegistrationDialog extends plugin msg_dialog::displayChecks($msgs); }else{ - if($this->selectedRegistrationType == "registered"){ + if($this->selectedRegistrationType == "registrate"){ // Try to registrate the instance with the given username and password. $rpcHandle = $this->config->registration->getConnection($this->values['username'],$this->values['password']); @@ -80,14 +80,17 @@ class RegistrationDialog extends plugin if(isset($_POST['registrationType'])) $this->selectedRegistrationType = get_post('registrationType'); // 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['startRegistration'])) $this->step = 1; + if(isset($_POST['registerComplete'])){ + $this->finished = TRUE; + + // Tell GOsa not to ask for a regsitration again. + if($this->selectedRegistrationType == "dontWant"){ + $prop = $this->config->configRegistry->getProperty('GOsaRegistration','askForRegistration'); + $prop->setValue(-1); + $prop->save(); } } - 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 c4c532963..7d0bbe753 100644 --- a/gosa-core/plugins/generic/dashBoard/Register/register.tpl +++ b/gosa-core/plugins/generic/dashBoard/Register/register.tpl @@ -6,14 +6,15 @@ {t}Do you want to register GOsa and benefit from the features it brings?{/t}

- + +

- +

{t}Additionally to the 'Annonomous' account you can:{/t}