Code

Updated registration process
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Nov 2010 07:27:55 +0000 (07:27 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Nov 2010 07:27:55 +0000 (07:27 +0000)
-

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

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

index be319f2f10a7e7ffcf19785feeeb6f073cfe9313..c8d0ff71f99abf27f8645e537de307e5a7ca311f 100644 (file)
@@ -36,6 +36,15 @@ class RegistrationDialog extends plugin
         $smarty = get_smarty();
         $smarty->assign("error", "");
 
+        // Tell GOsa not to ask for a regsitration again.
+        if(isset($_POST['registerComplete'])){
+            if($this->selectedRegistrationType == "dontWant"){
+                $prop =  $this->config->configRegistry->getProperty('GOsaRegistration','askForRegistration');
+                $prop->setValue(-1);
+                $prop->save();
+            }
+        }
+
         // Registration page one filled in, next step requested.
         if(isset($_POST['registerPage1'])){
             $msgs = $this->check();
@@ -59,6 +68,9 @@ class RegistrationDialog extends plugin
                         }
                     }else{
                         $this->step = 2;
+                        $prop =  $this->config->configRegistry->getProperty('GOsaRegistration','askForRegistration');
+                        $prop->setValue(0);
+                        $prop->save();
                     }
                 } 
             }
@@ -83,13 +95,6 @@ class RegistrationDialog extends plugin
         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['stepBack'])) $this->step -= 1;
     }
index acec1156bbf68c35bb86d40b4cac5701ad5c8319..0289b8bca479cc729a071f54998f16ac8781c130 100644 (file)
@@ -16,22 +16,35 @@ class dashBoard extends plugin
     {
         plugin::plugin($config, NULL);
 
-        // Instantiate child classes
-        $this->dbPluginStatus = new dbPluginStatus($config);
-        $this->dbChannelStatus = new dbChannelStatus($config);
-        $this->dbNotifications = new dbNotifications($config);
-        $this->dbInformation = new dbInformation($config);
-
         // Check if we've access to the registration server
         if($this->config->registration->registrationRequired() && $config->registration->isServerAccessible()){
             if(!$config->registration->isInstanceRegistered()){
                 $this->dialog = new RegistrationDialog($config);
             }
         }
+
+        $this->initialized = FALSE;
+    }
+
+    function init()
+    {
+        // Instantiate child classes
+        if($this->config->registration->isInstanceRegistered()){
+            $this->dbPluginStatus = new dbPluginStatus($config);
+            $this->dbChannelStatus = new dbChannelStatus($config);
+            $this->dbNotifications = new dbNotifications($config);
+            $this->dbInformation = new dbInformation($config);
+            $this->initialized = TRUE;
+        }
     }
 
     function execute()
     {
+        // The wants to registrate his instance of GOsa now!
+        if(isset($_POST['registerNow']) && $this->config->registration->isServerAccessible()){
+            $this->dialog = new RegistrationDialog($this->config);
+        }
+
         // Seems that we haven't registered our GOsa instance yet.
         // Ask the user to do so, now.
         if($this->dialog instanceOf RegistrationDialog){
@@ -44,21 +57,31 @@ class dashBoard extends plugin
             }
         }
 
+        $this->init();
+
         $smarty = get_smarty();
-        $smarty->assign('dbPluginStatus', $this->dbPluginStatus->execute());
-        $smarty->assign('dbChannelStatus', $this->dbChannelStatus->execute());
-        $smarty->assign('dbNotifications', $this->dbNotifications->execute());
-        $smarty->assign('dbInformation', $this->dbInformation->execute());
+        $smarty->assign('instanceRegistered', $this->config->registration->isInstanceRegistered());
+        $smarty->assign('registrationServerAvailable', $this->config->registration->isServerAccessible());
+
+        if($this->initialized){
+            $smarty->assign('dbPluginStatus', $this->dbPluginStatus->execute());
+            $smarty->assign('dbChannelStatus', $this->dbChannelStatus->execute());
+            $smarty->assign('dbNotifications', $this->dbNotifications->execute());
+            $smarty->assign('dbInformation', $this->dbInformation->execute());
+        }
         return($smarty->fetch(get_template_path('dashBoard.tpl', TRUE)));
     }
 
     function check()
     {
         $messages = plugin::check();
-        $messages = array_merge($this->dbPluginStatus->check());    
-        $messages = array_merge($this->dbChannelStatus->check());    
-        $messages = array_merge($this->dbNotifications->check());    
-        $messages = array_merge($this->dbInformation->check());    
+
+        if($this->initialized){
+            $messages = array_merge($this->dbPluginStatus->check());    
+            $messages = array_merge($this->dbChannelStatus->check());    
+            $messages = array_merge($this->dbNotifications->check());    
+            $messages = array_merge($this->dbInformation->check());    
+        }
         return($messages);
     }
 
@@ -68,8 +91,8 @@ class dashBoard extends plugin
        
         if($this->dialog instanceOf RegistrationDialog){ 
             $this->dialog->save_object();
-        }else{
-
+        }
+        if($this->initialized){
             $this->dbPluginStatus->save_object();
             $this->dbChannelStatus->save_object();
             $this->dbNotifications->save_object();
@@ -80,19 +103,23 @@ class dashBoard extends plugin
     function save()
     {
         plugin::save();
-        $this->dbPluginStatus->save();
-        $this->dbChannelStatus->save();
-        $this->dbNotifications->save();
-        $this->dbInformation->save();
+        if($this->initialized){
+            $this->dbPluginStatus->save();
+            $this->dbChannelStatus->save();
+            $this->dbNotifications->save();
+            $this->dbInformation->save();
+        }
     }
 
     function remove_from_parent()
     {
         plugin::remove_from_parent();
-        $this->dbPluginStatus->remove_from_parent();
-        $this->dbChannelStatus->remove_from_parent();
-        $this->dbNotifications->remove_from_parent();
-        $this->dbInformation->remove_from_parent();
+        if($this->initialized){
+            $this->dbPluginStatus->remove_from_parent();
+            $this->dbChannelStatus->remove_from_parent();
+            $this->dbNotifications->remove_from_parent();
+            $this->dbInformation->remove_from_parent();
+        }
     }
 }
 
index 018f19f94d0e01fe21ca57a9d70aba43f4abd510..972f316798fce93acb38410ed94431ddb2889047 100644 (file)
@@ -1,44 +1,53 @@
-
-<table style='width:100%' summary="{t}GOsa dash board{/t}">
-    <tr>
-        <td style='width:50%; padding-right:5px;' class='right-border'>
-            
-            <!-- Channel -->    
-
-            {$dbChannelStatus}
-
-            <!--Chanel  END -->
-
-        </td>
-        <td>
-            
-            <!-- Plugins Status -->    
-
-            {$dbPluginStatus}
-
-            <!-- Plugins Status  END -->
-
-        </td>
-    </tr>
-    <tr><td colspan="2"><hr></td></tr>
-    <tr>
-        <td style='width:50%; padding-right:5px;' class='right-border'>
-            
-            <!-- Messages -->    
-    
-            {$dbNotifications}
-
-            <!-- Messages  END -->
-
-        </td>
-        <td>
-            
-            <!-- RSS Feeds -->    
-    
-            {$dbInformation}
-
-            <!-- RSS Feeds  END -->
-
-        </td>
-    </tr>
-</table>
+{if !$instanceRegistered}
+    <h3>{t}This feature is only accessible for registrated instances of GOsa{/t}</h3>
+
+    {if $registrationServerAvailable}
+        <button name="registerNow">{t}Registrate{/t}</button>
+    {else}
+        {t}Unfortunately the registration server cannot be reached, maybe the server is down for maintaince or you've no internet access!{/t}
+    {/if}
+{else}
+    <table style='width:100%' summary="{t}GOsa dash board{/t}">
+        <tr>
+            <td style='width:50%; padding-right:5px;' class='right-border'>
+                
+                <!-- Channel -->    
+
+                {$dbChannelStatus}
+
+                <!--Chanel  END -->
+
+            </td>
+            <td>
+                
+                <!-- Plugins Status -->    
+
+                {$dbPluginStatus}
+
+                <!-- Plugins Status  END -->
+
+            </td>
+        </tr>
+        <tr><td colspan="2"><hr></td></tr>
+        <tr>
+            <td style='width:50%; padding-right:5px;' class='right-border'>
+                
+                <!-- Messages -->    
+        
+                {$dbNotifications}
+
+                <!-- Messages  END -->
+
+            </td>
+            <td>
+                
+                <!-- RSS Feeds -->    
+        
+                {$dbInformation}
+
+                <!-- RSS Feeds  END -->
+
+            </td>
+        </tr>
+    </table>
+{/if}