Code

Some changes repository plugin
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 9 Dec 2005 06:11:51 +0000 (06:11 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 9 Dec 2005 06:11:51 +0000 (06:11 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2263 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_servRepository.inc
plugins/admin/systems/class_servRepositorySetup.inc

index a205138978ce365e7101111a40332dcb8d283084..21aa551ace56f4b17612120b5093686235d93f9e 100644 (file)
@@ -8,7 +8,7 @@ class servrepository extends plugin
   var $cli_parameters       = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
 
   /* attribute list for save action */
-//  var $ignore_account         = TRUE;
+  //  var $ignore_account         = TRUE;
   var $attributes             = array("FAIrepository");
   var $objectclasses          = array("FAIrepositoryServer");
   
@@ -26,22 +26,26 @@ class servrepository extends plugin
   {
     plugin::plugin ($config, $dn);
     $this->repositories = array();
-    for($i = 0; $i < $this->attrs['FAIrepository']['count']; $i++){
-      $tmp = split("\|",$this->attrs['FAIrepository'][$i]);
-      $tmp2 = array();  
-      $tmp3 = array();   
-      $tmp2['ParentServer'] = $tmp[1];
-      $tmp2['Url']          = $tmp[0];
-      $tmp2['Release']      = $tmp[2];
-      
-      $tmp3 = split(",",$tmp[3]);
-    
-      foreach($tmp3 as $sec){
-        $tmp2['Sections'][$sec]=$sec;
-      }    
-      $this->repositories[$tmp[2]]=$tmp2;      
-      
+    if(isset($this->attrs['FAIrepository'])){
+      for($i = 0; $i < $this->attrs['FAIrepository']['count']; $i++){
+        $tmp = split("\|",$this->attrs['FAIrepository'][$i]);
+        $tmp2 = array();  
+        $tmp3 = array();   
+
+        $tmp2['ParentServer'] = $tmp[1];
+        if(empty($tmp[1])){
+          $tmp2['ParentServer'] = "none";
+        }
+        $tmp2['Url']          = $tmp[0];
+        $tmp2['Release']      = $tmp[2];
+
+        $tmp3 = split(",",$tmp[3]);
+
+        foreach($tmp3 as $sec){
+          $tmp2['Sections'][$sec]=$sec;
+        }    
+        $this->repositories[$tmp[2]]=$tmp2;      
+      }
     }
   }
 
@@ -85,6 +89,13 @@ class servrepository extends plugin
     
     $once = false;
     foreach($_POST as $name => $value){
+      if((preg_match("/^delete_/",$name))&&(!$once)){
+        if(isset($this->repositories[$value])){
+          $once = true;
+          unset($this->repositories[$value]);
+        }
+      }
+
       if((preg_match("/^edit_/",$name))&&(!$once)){
         if(isset($this->repositories[$value])){
           $once = true;
@@ -97,6 +108,13 @@ class servrepository extends plugin
         }
       }
     }
+
+    if((isset($_GET['act']))&&($_GET['act']=="open")&&(isset($_GET['id']))){
+      $obj = $this->repositories[$_GET['id']];
+      $obj['initialy_was'] = $obj['Release'];
+      $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj);
+      $this->dialog->acl = $this->acl;
+    }
  
     if(isset($_POST['AddRepository'])){
       $this->dialog = new servRepositorySetup($this->config,$this->dn);
@@ -138,8 +156,9 @@ class servrepository extends plugin
 
     $divlist = new divSelectBox("repositories");
     $divlist->setHeight(400);
-
-    $edit = "<input type='image' value='%s' name='edit_%s' src='images/edit.png'>";
+    $link   = "<a href='?plug=".$_GET['plug']."&act=open&id=%s'>%s</a>";
+    $edit   = "<input type='image' value='%s' name='edit_%s'   src='images/edit.png'>&nbsp;";
+    $delete = "<input type='image' value='%s' name='delete_%s' src='images/edittrash.png'>";
    
     foreach($this->repositories as $name => $reps){
       $str = " ";
@@ -148,9 +167,9 @@ class servrepository extends plugin
       }    
   
       $divlist->AddEntry(array(
-                              array("string"=>$name),
-                              array("string"=>_("Sections")." :".$str),
-                              array("string"=>preg_replace("/%s/",$name,$edit),"attach"=>"style='border-right:0px;'")
+                              array("string"=>preg_replace("/%s/",$name,$link)),
+                              array("string"=>sprintf($link,$name,_("Sections")." :".$str)),
+                              array("string"=>preg_replace("/%s/",$name,$edit.$delete),"attach"=>"style='border-right:0px;'")
                               ));
     }
  
@@ -162,7 +181,23 @@ class servrepository extends plugin
 
   function remove_from_parent()
   {
-    /* This cannot be removed... */
+    plugin::remove_from_parent();    
+    $ldap= $this->config->get_ldap_link();
+    $ldap->cd ($this->config->current['BASE']);
+    
+    $ldap->cat($this->dn);
+    
+    if($ldap->count()){
+      $ldap->cd($this->dn);
+      $ldap->modify($this->attrs);      
+      $this->handle_post_events("modify");
+    }else{
+      $ldap->cd ($this->config->current['BASE']);
+      $ldap->create_missing_trees($this->dn);
+      $ldap->cd($this->dn);
+      $ldap->add($this->attrs);
+      $this->handle_post_events("add");
+    }
   }
 
 
@@ -193,6 +228,11 @@ class servrepository extends plugin
         $str.=$sec.",";
       }
       $str=preg_replace("/,$/","",$str);
+        
+      if($conf['ParentServer']=="none"){
+        $conf['ParentServer'] ="";
+      }    
+    
       $arr[]=$conf['Url']."|".$conf['ParentServer']."|".$conf['Release']."|".$str;
     }
     $this->attrs['FAIrepository'] = $arr;
index 2fa8a7cf6fa8551cb0dc13170e21ddde3a4071cd..3336616a0dbeead0e99491261948a00f9f929c59 100644 (file)
@@ -13,24 +13,21 @@ class servRepositorySetup  extends plugin
   var $objectclasses    = array("whatever");
 
   /* Attributes */
-  var $Release;
-  var $ParentServer;
-  var $Url;
-  var $Sections=array();
-  var $ParentServers;
-
+  var $Release          ="";
+  var $ParentServer     ="";
+  var $Url              ="";   
+  var $Sections         =array();
+  var $ParentServers    ="";
   var $initialy_was=false;
 
   function servRepositorySetup ($config, $dn= NULL,$data = false)
   {
     plugin::plugin ($config, $dn);
     if($data != false){
-      $this->Sections= $data['Sections'];
-      $this->Url= $data['Url'];
-      $this->Release= $data['Release'];
-      $this->ParentServer= $data['ParentServer'];
-      if(isset($data['initialy_was'])){
-        $this->initialy_was= $data['initialy_was'];
+      foreach(array("Sections","Release","Url","ParentServer","initialy_was") as $atr){
+        if(isset($data[$atr])){
+          $this->$atr = $data[$atr];
+        }
       }
     }
   }
@@ -111,10 +108,14 @@ class servRepositorySetup  extends plugin
   {
     $message= array();
 
-    if(!isset($this->Release)){
+    if(empty($this->Release)){
       $message[]=_("Please enter a value for 'release'.");
     }
 
+    if(empty($this->Url)){
+      $message[] = _("Please specify a valid value for 'url'.");
+    }
+
     return ($message);
   }
 
@@ -132,13 +133,9 @@ class servRepositorySetup  extends plugin
 
   function getParentServers()
   {
-
     $ret = array();
-    
     $ldap = $this->config->get_ldap_link();
-        
     $ldap->cd($this->config->current['BASE']);
-    
     $ldap->search("(objectClass=FAIrepositoryServer)",array("*"));
     while($attr = $ldap->fetch()){
       $ret[$attr['cn'][0]]= $attr['cn'][0];