Code

Added RDN support for users
[gosa.git] / plugins / admin / systems / class_servRepository.inc
index 295fe521418ad438e5403396c23bcb42e02c9767..8b9329b12c5510d698347343b3b5badaee01a7d9 100644 (file)
@@ -2,11 +2,6 @@
 
 class servrepository extends plugin
 {
-  /* CLI vars */
-  var $cli_summary          = "Manage server basic objects";
-  var $cli_description      = "Some longer text\nfor help";
-  var $cli_parameters       = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
-
   /* attribute list for save action */
   //  var $ignore_account         = TRUE;
   var $attributes             = array("FAIrepository");
@@ -20,15 +15,25 @@ class servrepository extends plugin
 
   /* Repositories */
   var $repositories           = array();
-  var $FAIrepository           = array();
+  var $FAIrepository          = array();
+
+  var $fai_activated          = FALSE;
 
   function servrepository ($config, $dn= NULL, $parent= NULL)
   {
     plugin::plugin ($config, $dn, $parent);
 
+    /* Skip this if fai is deactivated */
+    $tmp = search_config($this->config->data,"faiManagement","CLASS");
+    if(!empty($tmp)){
+      $this->fai_activated = TRUE;    
+    }else{
+      return;
+    }
+
     $ui = get_userinfo();
     $tmp= get_permissions ($this->dn, $ui->subtreeACL);
-    $this->acl= get_module_permission($tmp, "FAIclass", $this->dn);
+    $this->acl= get_module_permission($tmp, "servrepository", $this->dn);
     
     $this->repositories = array();
     if(isset($this->attrs['FAIrepository'])){
@@ -77,10 +82,21 @@ class servrepository extends plugin
     /* Call parent execute */
     plugin::execute();
 
+    if(!$this->fai_activated){
+      $str = "<h2>"._("You can't use this plugin until FAI is activated.")."</h2>";
+      return $str;
+    }
+
     /* Fill templating stuff */
     $smarty= get_smarty();
     $display= "";
 
+    $ui = get_userinfo();
+    $tmp= get_permissions ($this->dn, $ui->subtreeACL);
+    $this->acl= get_module_permission($tmp, "servrepository", $this->dn);
+    $allow_edit = !preg_match("/disabled/i",chkacl($this->acl,"FAIclass"));
+    
+
     /* Smarty vars*/
     $smarty->assign("infoimage",    get_template_path('images/info.png'));
     $smarty->assign("search_image", get_template_path('images/search.png'));
@@ -93,7 +109,15 @@ class servrepository extends plugin
 
     /* Do we need to flip is_account state? */
     if (isset($_POST['modify_state'])){
-      $this->is_account= !$this->is_account;
+
+      /* Only change account state if allowed */
+      if($this->is_account && $this->acl == "#all#"){
+        $this->is_account= !$this->is_account;
+        $this->is_modified = true;
+      }elseif(!$this->is_account && chkacl($this->acl,"create") == ""){
+        $this->is_account= !$this->is_account;
+        $this->is_modified = true;
+      }
     }
 
     /* Show tab dialog headers */
@@ -110,12 +134,6 @@ class servrepository extends plugin
        ADD / EDIT Repository
        Dialog Handling
      */
-     
-    $ui = get_userinfo();
-    $tmp= get_permissions ($this->dn, $ui->subtreeACL);
-    $this->acl= get_module_permission($tmp, "FAIclass", $this->dn);
-    $allow_edit = !preg_match("/disabled/i",chkacl($this->acl,"FAIclass"));
-    
 
     $once = false;
     if(isset($_POST['servRepository'])){
@@ -304,10 +322,13 @@ class servrepository extends plugin
 
   function remove_from_parent()
   {
+
+    if(!$this->fai_activated) return;
+    
     /* Skip if not allowed */ 
     $ui = get_userinfo();
     $tmp= get_permissions ($this->dn, $ui->subtreeACL);
-    $this->acl= get_module_permission($tmp, "FAIclass", $this->dn);
+    $this->acl= get_module_permission($tmp, "servrepository", $this->dn);
 
     if(preg_match("/disabled/",chkacl($this->acl,"FAIclass"))) return;
 
@@ -350,11 +371,12 @@ class servrepository extends plugin
   /* Save to LDAP */
   function save()
   {
-   
+    if(!$this->fai_activated) return;
+
     /* Skip if not allowed */ 
     $ui = get_userinfo();
     $tmp= get_permissions ($this->dn, $ui->subtreeACL);
-    $this->acl= get_module_permission($tmp, "FAIclass", $this->dn);
+    $this->acl= get_module_permission($tmp, "servrepository", $this->dn);
 
     if(preg_match("/disabled/",chkacl($this->acl,"FAIclass"))) return;
     plugin::save();