Code

Updated distribution list plugin
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 11 Oct 2010 10:19:49 +0000 (10:19 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 11 Oct 2010 10:19:49 +0000 (10:19 +0000)
-Added error handling

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

gosa-plugins/groupware/admin/ogroups/DistributionList/class_DistributionList.inc

index d5330f4e144ac7ea8f144c25333d90f9102c1878..36a4381ec1e447ec4f4fb6825438952f7f576ac7 100644 (file)
@@ -7,9 +7,11 @@ class DistributionList extends plugin
     private $rpcError = FALSE;
     private $rpcErrorMessage = "";
 
-    function __construct($config, $dn, $attrs)
+    public $view_logged = FALSE;
+
+    function __construct($config, $dn, $attrs = NULL)
     {
-        plugin::plugin($config, $dn, $attr);
+        plugin::plugin($config, $dn, $attrs);
 
         // Get attributes from parent object
         foreach(array("uid","cn") as $attr){
@@ -29,12 +31,13 @@ class DistributionList extends plugin
         // Check whether a mathing distribution-list exsits or not?
         $rpc = $this->config->getRpcHandle();
         $is_account = $rpc->gwDistExists($this->cn);
-        
+        $this->rpcError = FALSE;
+         
         // An error occured abort here
         if(!$rpc->success()){
             $this->rpcError = TRUE;
             $this->rpcErrorMessage = $rpc->get_error();
-            msg_dialog::display(msgPool::rpcError($this->rpcErrorMessage));
+            msg_dialog::display(_("Error"),msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
             return;
         }
 
@@ -50,7 +53,7 @@ class DistributionList extends plugin
             if(!$rpc->success()){
                 $this->rpcError = TRUE;
                 $this->rpcErrorMessage = $rpc->get_error();
-                msg_dialog::display(msgPool::rpcError($this->rpcErrorMessage));
+                msg_dialog::display(_("Error"),msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
                 return;
             }
 
@@ -59,7 +62,7 @@ class DistributionList extends plugin
             if(!$rpc->success()){
                 $this->rpcError = TRUE;
                 $this->rpcErrorMessage = $rpc->get_error();
-                msg_dialog::display(msgPool::rpcError($this->rpcErrorMessage));
+                msg_dialog::display(_("Error"),msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
                 return;
             }
 
@@ -68,7 +71,7 @@ class DistributionList extends plugin
             if(!$rpc->success()){
                 $this->rpcError = TRUE;
                 $this->rpcErrorMessage = $rpc->get_error();
-                msg_dialog::display(msgPool::rpcError($this->rpcErrorMessage));
+                msg_dialog::display(_("Error"),msgPool::rpcError($this->rpcErrorMessage), ERROR_DIALOG);
                 return;
             }
             
@@ -78,6 +81,7 @@ class DistributionList extends plugin
         $this->memberList = $memberList;
         $this->primaryMailAddress = $primaryMailAddress;
         $this->alternateAddresses = $alternateAddresses;
+        $this->initialized = TRUE;
     }
 
 
@@ -85,6 +89,16 @@ class DistributionList extends plugin
     {
         plugin::execute();
 
+        // Initialization failed - Display a stripped template which allows 
+        //  to retry initialization
+        if(!$this->initialized){
+            $smarty = get_smarty();
+            $smarty->assign('rpcError' , $this->rpcError);
+            $smarty->assign('rpcErrorMessage' , $this->rpcErrorMessage);
+            return($smarty->fetch(get_template_path('DistributionList/initFailed.tpl', TRUE)));
+        }
+
+
         // Log account access
         if($this->is_account && !$this->view_logged){
             $this->view_logged = TRUE;
@@ -113,6 +127,15 @@ class DistributionList extends plugin
         }
         return($display);
     }
+
+
+    function save_object()
+    {
+    
+        if(isset($_POST['retryInit'])){
+            $this->init();
+        }
+    }
 }
 
 ?>