Code

Updated the dashBoard
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 9 Nov 2010 16:10:13 +0000 (16:10 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 9 Nov 2010 16:10:13 +0000 (16:10 +0000)
-Updated server accessibility detection
-Updated registration handling

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@20208 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/plugins/generic/dashBoard/Register/class_RegistrationDialog.inc
gosa-core/plugins/generic/dashBoard/Register/register.tpl
gosa-core/plugins/generic/dashBoard/class_dashBoard.inc

index 81ea9ae6aeb875f8a844f07070d65eb48782b30b..fd87e6bd825570de015012db373c2577846ee510 100644 (file)
@@ -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;
     }
 }
index 24a6813f7a43053142abd4c779c27bc65990f982..c4c532963016be776bddbd7b7d4e1af01d4b457a 100644 (file)
@@ -42,7 +42,7 @@
 
 {/if}
 
-{if $step == 1 || $step == -1}
+{if $step == 1}
     <table>
         <tr>
             <td><LABEL for="username">{t}Login{/t}</LABEL></td>
     <hr>
     <div class="plugin-actions">
         <button name='stepBack'>{msgPool type=backButton}</button>        
-        <button name='registerPage2'>{msgPool type=okButton}</button>        
+        <button name='registerPage1'>{msgPool type=okButton}</button>        
     </div>
 {/if}
 
+{if $step == 2}
+    <h3>{t}Registration complete{/t}</h3>
+    <p>
+        {t}GOsa instance sucessfully registered{/t}
+    </p>
+    <hr>
+    <div class="plugin-actions">
+        <button name='registerComplete'>{msgPool type=okButton}</button>        
+    </div>
+{/if}
 
+{if $step == 100}
+    <h3>{t}Registration complete{/t}</h3>
+    <p>
+        {t}GOsa instance will not be registered{/t}
+    </p>
+    <hr>
+    <div class="plugin-actions">
+        <button name='registerComplete'>{msgPool type=okButton}</button>        
+    </div>
+{/if}
index b0e8e7f4630d887a5537fd451b8e7bae0c948f5e..8d1e791a1d0797149822bcdf60796a1ee0934548 100644 (file)
@@ -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()