Code

Some changes in package management ...
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 6 Oct 2005 07:55:16 +0000 (07:55 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 6 Oct 2005 07:55:16 +0000 (07:55 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1496 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/fai/class_faiHook.inc
plugins/admin/fai/class_faiHookEntry.inc
plugins/admin/fai/class_faiPackage.inc
plugins/admin/fai/faiPackage.tpl

index 2530af3a03342d33a5e1624cd61ea5e077512058..14183bf191526fc969c2b8f71a4fdcf1a61f1632 100644 (file)
@@ -207,10 +207,6 @@ class faiHook extends plugin
   function check()
   {
     $message= array();
-    $str = utf8_encode("üöä");
-    if((preg_match("/[^a-z0-9".$str."\-.,;:_\? ]/i",$this->description))){
-      $message[]=_("Please enter a valid description.");
-    }
     return ($message);
   }
 
index 01daab114fe033c30567bafa023a7b7f37c66b32..ced60480df9c1fd92bc8f9a09fe144a5792b530d 100644 (file)
@@ -93,12 +93,6 @@ class faiHookEntry extends plugin
       $message[]=_("Please enter a value for script.");
     }
 
-    $str = utf8_encode("üöä");
-
-    if(preg_match("/[^a-z0-9".$str."\.,;:\-_\? ]/i",$this->Object_description)){
-      $message[] = _("Invalid character in description. Please enter a valid description.");
-    }
-
     if(empty($this->Object_cn)){
       $message[] = _("Please enter a name.");
     }
index cd36ab66482c8a362d13e0c6845f5e4be94b9ef9..eb27521f5c591d5c891999b72a8ba5c20b71c9c7 100644 (file)
@@ -11,7 +11,7 @@ class faiPackage extends plugin
   var $ignore_account   = TRUE;
 
   /* Attributes for this Object */
-  var $attributes       = array("cn","description","FAIpackage");
+  var $attributes       = array("cn","description","FAIpackage","section","mirror","release");
 
   /* ObjectClasses for this Object*/
   var $objectclasses    = array("top","FAIclass","FAIpackageList");
@@ -34,6 +34,17 @@ class faiPackage extends plugin
   var $dialog           = NULL;     // a dialog, e.g. new disk dialog
   var $SubObjects       = array();  // All leafobjects of this object
 
+  var $section          = ""; // The selected section
+  var $release          = ""; // selected release
+  var $mirror           = ""; // selected mirror
+
+  var $servers          = array();  // All available servers
+  var $sections         = array();  // All possible sections 
+  var $releases         = array();  // All release types
+
+  var $mirrors          = array();  // The combination of server/section/release
+  var $confDir          = "";
+
   function faiPackage ($config, $dn= NULL)
   {
     /* Load Attributes */
@@ -47,6 +58,7 @@ class faiPackage extends plugin
       $this->dn =$dn;
     }
 
+    $this->confDir = CONFIG_DIR."/fai/";
     $this->FAIpackage = "test";
   }
 
@@ -61,20 +73,92 @@ class faiPackage extends plugin
       $smarty->assign($attrs,$this->$attrs);
     }
 
-    $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE));
-    return($display);
-  }
+    /* Second try */
+    
+    /* Check available server entries in CONFIG_DIR/fai 
+     */
+    $confDir = $this->confDir; 
+    if(!is_readable($confDir)){
+      print_red(sprintf(_("Can't read configuration folder '%s'."),$confDir));
+    }else{
+      
+      /* Try to catch all available mirrors 
+         Possibly check if each server is reachable
+       */
+      $this->mirrors= array();
+      $fd = opendir($confDir);
+      while($mirror = readdir($fd)){
+        if((is_dir($confDir.$mirror."/"))&&(($mirror != "." )&&($mirror!=".."))){
+
+          $mirrorDir = $confDir.$mirror."/";
+
+          $fe = opendir($mirrorDir);
+          while($section = readdir($fe)){
+            if((is_dir($mirrorDir.$section))&&(($section != "." )&&($section!=".."))){
+
+              $sectionDir = $mirrorDir.$section."/";
+
+              $ff = opendir($sectionDir);
+              while($release = readdir($ff)){
+                if((is_file($sectionDir.$release))&&(($release != "." )&&($release!="..")&&(!preg_match("/.*\.in$/",$release)))){
+              
+                  $this->servers[$mirror]=$mirror;
+                  $this->sections[$section]=$section;
+                  $this->releases[$release]=$release;
+
+                  if(empty($this->mirror)){
+                    $this->mirror= $mirror;
+                  }
+                  if(empty($this->section)){
+                    $this->section = $section;
+                  }
+                  if(empty($this->release)){
+                    $this->release = $release;
+                  }                    
+
+                  $arr=array();
+                  $arr['mirror'] = $mirror;
+                  $arr['section']= $section; 
+                  $arr['release']= $release;
+                  $this->mirrors[] = $arr ;
+                }
+              }
+              fclose($ff);
+            }
+          }
+          fclose($fe);
+        }
+      }
+      fclose($fd);
+    }
 
-  /* Generate listbox friendly SubObject list
-  */
-  function getList(){
-    $a_return=array();
-    foreach($this->SubObjects as $obj){
-      if($obj['status'] != "delete"){
-        $a_return[$obj['cn']]= $obj['cn']." [".$obj['description']."]";
+    $availableServer = array();
+    foreach($this->mirrors as $mir){
+      if(($mir['section'] == $this->section)&&($mir['release']==$this->release)){
+        $availableServer[$mir['mirror']]=$mir['mirror'];
       }
     }
-    return($a_return);
+
+    if(isset($_POST['Addpkg'])){
+      $this->dialog = new faiPackageEntry($this->config, $this->dn,$this->confDir.$this->mirror."/".$this->section."/".$this->release);
+      $this->is_dialog =true;
+    }
+    
+    if($this->is_dialog){
+      return $this->dialog->execute();
+    }
+    
+
+    $smarty->assign("mirrors" ,$availableServer);
+    $smarty->assign("mirror"  ,$this->mirror);
+    $smarty->assign("sections",$this->sections);
+    $smarty->assign("section" ,$this->section);
+    $smarty->assign("releases",$this->releases);
+    $smarty->assign("release" ,$this->release);
+    $smarty->assign("usedPackages",$this->usedPackages);
+    $display.= $smarty->fetch(get_template_path('faiPackage.tpl', TRUE));
+    return($display);
   }
 
   /* Delete me, and all my subtrees
index 7b8f9a774337cdb286b1aa1b9bbe67974b6ea3bb..885690152e7cf59c622e0c5e64dbe00b9ceb9ea3 100644 (file)
                                        </tr>
                                </table>
                </td>
+               <td width="50%" valign="top">
+                       <h2><img alt="" src="images/house.png" align="middle" title="{t}Repository{/t}">&nbsp;{t}Repository{/t}</h2>
+                               <table summary="" cellspacing="4">
+                                       <tr>
+                                               <td>
+                                                       <LABEL for="section">
+                                                       {t}Section{/t}
+                                                       </LABEL>
+                                               </td>
+                                               <td>
+                                                       <select name="section" title="{t}section{/t}">
+                                                               {html_options options=$sections selected=$section}
+                                                       </select>
+                                                       <input type="submit" value="{t}refresh{/t}" name="refresh1">
+                                               </td>
+                                       </tr>
+                                       <tr>
+                                               <td>
+                                                       <LABEL for="release">
+                                                       {t}Release{/t}
+                                                       </LABEL>
+                                               </td>
+                                               <td>
+                                                       <select name="release" title="{t}release{/t}">
+                                                               {html_options options=$releases selected=$release}
+                                                       </select>
+                                                       <input type="submit" value="{t}refresh{/t}" name="refresh2">
+                                               </td>
+                                       </tr>
+                                       <tr>
+                                               <td>
+                                                       <LABEL for="mirror">
+                                                       {t}Mirror{/t}
+                                                       </LABEL>
+                                               </td>
+                                               <td>
+                                                       <select name="mirror" title="{t}mirror{/t}">
+                                                               {html_options options=$mirrors selected=$mirror}
+                                                       </select>
+                                                       <input type="submit" value="{t}refresh{/t}" name="refresh3">
+                                               </td>
+                                       </tr>
+                               </table>
+               </td>
+       </tr>
+</table>
+<table width="99%">
+       <tr>
+               <td> 
+                       <h2><img alt="" src="images/house.png" align="middle" title="{t}Used packages{/t}">&nbsp;{t}Used packages{/t}</h2>
+                       <br>
+                       <select id="usedPackages" name="usedPackages" title="{t}Choosen packages{/t}" multiple style="width:100%;height:300px;">
+                               {html_options options=$usedPackages}
+               </select>
+                       <br>
+                       <input type="submit" name="Addpkg" value="+">
+                       <input type="submit" name="Delpkg" value="-">
+                       <input type="submit" name="Conpkg" value="Configure">
+               </td>
        </tr>
 </table>
+
+
+
+
+
+