Code

Updated repository list.
[gosa.git] / plugins / admin / systems / class_servRepository.inc
index 27bb610f73c6c9257e7907199fc1c0a65c59c502..de72d986e397a8165a1782e6eecca2c3a509729e 100644 (file)
@@ -1,7 +1,5 @@
 <?php
 
-require_once("class_goService.inc");
-
 class servrepository extends goService
 {
   /* CLI vars */
@@ -14,12 +12,6 @@ class servrepository extends goService
   var $attributes             = array("FAIrepository");
   var $objectclasses          = array("FAIrepositoryServer");
   
-  /* Search filter */
-  var $regex                  = "*";
-
-  /* Configurationdialog for repositories */
-  var $dialog                 = NULL;
-
   /* Repositories */
   var $repositories          = array();
   var $FAIrepository         = array();
@@ -30,20 +22,22 @@ class servrepository extends goService
   var $view_logged            = FALSE;
   var $fai_activated          = FALSE;
 
-  function servrepository ($config, $dn= NULL, $parent= NULL)
+  var $divlist = NULL;
+
+  function servrepository (&$config, $dn= NULL, $parent= NULL)
   {
     plugin::plugin ($config, $dn, $parent);
 
+    $this->DisplayName = _("Repository service");
+
     /* Skip this if fai is deactivated */
-    $tmp = search_config($this->config->data,"faiManagement","CLASS");
+    $tmp= $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
     if(!empty($tmp)){
       $this->fai_activated = TRUE;    
     }else{
       return;
     }
 
-    $this->DisplayName = _("Repository service");
-
     $this->repositories = array();
     if(isset($this->attrs['FAIrepository'])){
       for($i = 0; $i < $this->attrs['FAIrepository']['count']; $i++){
@@ -84,6 +78,24 @@ class servrepository extends goService
         $this->repositories[$tmp[2]]=$tmp2;      
       }
     }
+
+
+    /* Create divlist */
+    $divlist = new MultiSelectWindow($this->config,"repositories","server/servRepository");
+    $divlist->SetTitle("repositories");
+    $divlist->SetSummary(_("List of configured repositories."));
+    $divlist->SetInformation(_("This menu allows you to create, delete and edit repository settings."));
+    $divlist->EnableCloseButton(FALSE);
+    $divlist->EnableSaveButton(FALSE);
+    $divlist->AddHeader(array("string"=>_("Release"),"attach"=>"style='width:80px;'"));
+    $divlist->AddHeader(array("string"=>_("Sections")));
+    $divlist->AddHeader(array("string"=>_("Options"),"attach"=>"style='border-right:0px;width:55px;'"));
+    $divlist->AddRegex("regex",_("Regular expression for matching object names"),"*",TRUE);
+    $divlist->EnableAplhabet(TRUE);
+    if($this->acl_is_createable()){
+      $divlist->SetListHeader("<input type=\"image\" src=\"images/fai_new_packages.png\" title=\""._("Add repository")."\" name=\"AddRepository\">");
+    }
+    $this->divlist = $divlist;
   }
 
   function execute()
@@ -93,7 +105,7 @@ class servrepository extends goService
 
     if($this->is_account && !$this->view_logged){
       $this->view_logged = TRUE;
-      @log::log("view","server/".get_class($this),$this->dn);
+      new log("view","server/".get_class($this),$this->dn);
     }
 
     if(!$this->fai_activated){
@@ -106,15 +118,6 @@ class servrepository extends goService
     $smarty->assign("is_createable",$this->acl_is_createable());
     $display= "";
 
-    /* Smarty vars*/
-    $smarty->assign("infoimage",    get_template_path('images/info.png'));
-    $smarty->assign("search_image", get_template_path('images/search.png'));
-    $smarty->assign("launchimage",  get_template_path('images/small_filter.png'));
-    $smarty->assign("tree_image",   get_template_path('images/tree.png'));
-    $smarty->assign("alphabet",     generate_alphabet());
-    $smarty->assign("apply",        apply_filter());
-    $smarty->assign("regex",        $this->regex);
-
     /* Show tab dialog headers */
     /*
        ADD / EDIT Repository
@@ -205,14 +208,14 @@ class servrepository extends goService
         }
       }
     }
-    if((isset($_GET['act']))&&($_GET['act']=="open")&&(isset($_GET['id']))){
+    if((isset($_GET['act']))&&($_GET['act']=="open_repository")&&(isset($_GET['id']))){
       $obj = $this->repositories[base64_decode($_GET['id'])];
       $obj['initialy_was'] = $obj['Release'];
       $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj);
       $this->dialog->parent = $this;
     }
 
-    if(isset($_POST['repository_setup_save'])){
+    if(isset($_POST['repository_setup_save']) && is_object($this->dialog)){
       $this->dialog->save_object();
       if(($this->dialog->is_new_name())&&(isset($this->repositories[$this->dialog->GetName()]))){
         print_red(_("This name is already in use."));
@@ -231,17 +234,17 @@ class servrepository extends goService
         }else{ 
           $this->repositories[$obj['Release']]=$obj;        
         }
-        $this->dialog = NULL;
+        $this->dialog = FALSE;
         $this->is_dialog= false;
       }
     }
 
     if(isset($_POST['repository_setup_cancel'])){
-      $this->dialog=NULL;
+      $this->dialog=FALSE;
       $this->is_dialog = false;
     }
    
-    if($this->dialog != NULL){
+    if(is_object($this->dialog)){
       $this->dialog->save_object();
       $this->is_dialog = true;
       return($this->dialog->execute());
@@ -251,16 +254,8 @@ class servrepository extends goService
       Repository setup dialog handling /END
     */
 
-    $divlist = new divList("repositories");
-    $divlist->SetEntriesPerPage(0);
-    $divlist->setHeight(400);
-
-    $divlist->setHeader(array(array("string"=>_("Release"),"attach"=>"style='width:80px;'"),
-                              array("string"=>_("Sections")),
-                              array("string"=>_("Options"),"attach"=>"style='border-right:0px;width:55px;'")
-                       )     );
 
-    $link   = "<a href='?plug=".$_GET['plug']."&amp;act=open&amp;id=%s'>%s</a>";
+    $link   = "<a href='?plug=".$_GET['plug']."&amp;act=open_repository&amp;id=%s'>%s</a>";
     $edit   = "<input type='image' value='%s' name='edit_%s'   src='images/edit.png'>&nbsp;";
    
     /* Hide delete icon, if delete is not allowed */ 
@@ -270,22 +265,23 @@ class servrepository extends goService
       $delete = "<img src='images/empty.png' alt='&nbsp;'>";
     }
   
+    $this->divlist->ClearElementsList(); 
     foreach($this->repositories as $name => $reps){
 
       $str = " ";
-      if(preg_match("/".str_replace("*",".*",$this->regex)."/",$reps['Release'])){
-      foreach($reps['Sections'] as $sec){
-        $str.=$sec." ";  
-      }    
-      $divlist->AddEntry(array(
-          array("string"=>sprintf($link,base64_encode($name),$name),"attach"=>"style='width:80px;'"),
-          array("string"=>sprintf($link,base64_encode($name),_("Sections")." :".$str)),
-          array("string"=>preg_replace("/%s/",base64_encode($name),$edit.$delete),"attach"=>"style='border-right:0px;width:55px;text-align:right;'")
-                              ));
+      if(preg_match("/".str_replace("*",".*",$this->divlist->regex)."/",$reps['Release'])){
+        foreach($reps['Sections'] as $sec){
+          $str.=$sec." ";  
+        }    
+        $this->divlist->AddElement(array(
+              array("string"=>sprintf($link,base64_encode($name),$name),"attach"=>"style='width:80px;'"),
+              array("string"=>sprintf($link,base64_encode($name),_("Sections")." :".$str)),
+              array("string"=>preg_replace("/%s/",base64_encode($name),$edit.$delete),"attach"=>"style='border-right:0px;width:55px;text-align:right;'")
+              ));
       }
     }
  
-    $smarty -> assign("Repositories",$divlist->DrawList());
+    $smarty->assign("Repositories",$this->divlist->Draw());
 
     $display.= $smarty->fetch(get_template_path('servRepository.tpl', TRUE));
     return($display);
@@ -296,8 +292,8 @@ class servrepository extends goService
   function save_object()
   {
     plugin::save_object();
-    if(isset($_POST['regex'])){
-      $this->regex = $_POST['regex'];
+    if(is_object($this->divlist)){
+      $this->divlist->save_object();
     }
   }
 
@@ -354,9 +350,9 @@ class servrepository extends goService
     }
 
     if($this->initially_was_account){
-      @log::log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+      new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
     }else{
-      @log::log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
+      new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
     }
   }
 
@@ -371,7 +367,7 @@ class servrepository extends goService
   }
 
   /* Return plugin informations for acl handling */
-  function plInfo()
+  static function plInfo()
   {
     return (array(
           "plShortName"   => _("Repository"),