Code

Fixed acls for system management
[gosa.git] / plugins / admin / systems / class_goImapServer.inc
index 53e1688c46c55b0b0d9b8bd411c04a3a35185231..fa4108f8027524daa4e06f727837fac80bfc8dc4 100644 (file)
@@ -10,17 +10,15 @@ class goImapServer extends plugin{
   var $objectclasses    = array("goImapServer");
   
   /* This class can't be assigned twice so it conflicts with itsself */
-  var $conflicts        = array("goImapServer");
 
   var $DisplayName      = "";
   var $dn               = NULL;
   var $StatusFlag       = "goImapServerStatus";
-  var $attributes       = array("goImapServerStatus",
-                                "goImapName","goImapConnect","goImapAdmin","goImapPassword",
+  var $attributes       = array("goImapName","goImapConnect","goImapAdmin","goImapPassword",
                                 "goImapSieveServer","goImapSievePort",
                                 "cyrusImap","cyrusImapSSL","cyrusPop3","cyrusPop3SSL");
 
-  var $cn;
+  var $cn                   = "";
 
   var $goImapName           = "";
   var $goImapConnect        = "";
@@ -40,7 +38,8 @@ class goImapServer extends plugin{
 
   var $acl; 
 
-  var $Actions              = array();
+  var $Actions              = array();  
+  var $conflicts            = array("goImapServer","kolab");
  
   function goImapServer($config,$dn)
   {
@@ -78,6 +77,7 @@ class goImapServer extends plugin{
 
   function getListEntry()
   {
+    $this->updateStatusState();
     $flag = $this->StatusFlag;
     $fields['Status']     = $this->$flag;
     $fields['Message']    = _("Cyrus service");
@@ -92,6 +92,13 @@ class goImapServer extends plugin{
   function remove_from_parent()
   {
     plugin::remove_from_parent();
+
+    /* Remove status flag, it is not a memeber of 
+        this->attributes, so ensure that it is deleted too */
+    if(!empty($this->StatusFlag)){
+      $this->attrs[$this->StatusFlag] = array();
+    }
+
     /* Check if this is a new entry ... add/modify */
     $ldap = $this->config->get_ldap_link();
     $ldap->cat($this->dn,array("objectClass"));
@@ -102,7 +109,7 @@ class goImapServer extends plugin{
       $ldap->cd($this->dn);
       $ldap->add($this->attrs);
     }
-    show_ldap_error($ldap->get_error());
+    show_ldap_error($ldap->get_error(), sprintf(_("Removing server services/imap with dn '%s' failed."),$this->dn));
     $this->handle_post_events("remove");
   }
 
@@ -120,7 +127,7 @@ class goImapServer extends plugin{
       $ldap->cd($this->dn);
       $ldap->add($this->attrs);
     }
-    show_ldap_error($ldap->get_error());
+    show_ldap_error($ldap->get_error(), sprintf(_("Saving server services/imap with dn '%s' failed."),$this->dn));
     if($this->initially_was_account){
       $this->handle_post_events("modify");
     }else{
@@ -148,7 +155,7 @@ class goImapServer extends plugin{
       $attrs[$flag] = $value;
       $this->$flag = $value;
       $ldap->modify($attrs);
-      show_ldap_error($ldap->get_error());
+      show_ldap_error($ldap->get_error(), sprintf(_("Set status flag for server services/imap with dn '%s' failed."),$this->dn));
       $this->action_hook();
     }
   }
@@ -239,6 +246,51 @@ class goImapServer extends plugin{
     }
   }
 
+  
+  /* Get updates for status flag */
+  function updateStatusState()
+  {
+    if(empty($this->StatusFlag)) return;
+
+    $attrs = array();
+    $flag = $this->StatusFlag;
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->cn);
+    $ldap->cat($this->dn,array($flag));
+    if($ldap->count()){
+      $attrs = $ldap->fetch();
+    }
+    if(isset($attrs[$flag][0])){
+      $this->$flag = $attrs[$flag][0];
+    }
+  }
+
+
+  /* Return plugin informations for acl handling */
+  function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("Imap"),
+          "plDescription" => _("Imap service"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 0,
+          "plSection"     => array("administration"),
+          "plCategory"    => array("server"),
+
+          "plProvidedAcls"=> array(
+            "goImapName"        =>_("Server identifier"),
+            "goImapConnect"     =>_("Connect URL"),
+            "goImapAdmin"       =>_("Admin user"),
+            "goImapPassword"    =>_("Admin password"),
+            "goImapSievePort"   =>_("Sieve port"),
+            "cyrusImap"         =>_("Start IMAP service"),
+            "cyrusImapSSL"      =>_("Start IMAP SSL service"),
+            "cyrusPop3"         =>_("Start POP3 service"),
+            "cyrusPop3SSL"      =>_("Start POP3 SSL service"))
+          ));
+  }
+
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>