Code

Removed double | entry
[gosa.git] / gosa-plugins / fai / admin / fai / class_divListFai.inc
index f23f8a7d4b2135e764c01b44f3edc355e0906fb2..5505fe28f2595834687c7a981dc93b0f461c6afe 100644 (file)
@@ -2,12 +2,6 @@
 
 class divListFai extends MultiSelectWindow
 {
-  /* Current base */
-  var $selectedBase       = "";
-  var $selectedBranch     = "main";
-  var $AvailableBranches  = array();
-  var $departments        = array();
-
   /* Regex */
   var $Regex              = "*";
   var $ShowProfiles;
@@ -24,8 +18,6 @@ class divListFai extends MultiSelectWindow
   var $parent             ;
   var $ui                 ;
 
-  var $SaveAdditionalVars = array("selectedBranch");
-
   function divListFai (&$config,$parent)
   {
     MultiSelectWindow::MultiSelectWindow($config, "Fai", "fai");
@@ -33,15 +25,9 @@ class divListFai extends MultiSelectWindow
     $this->parent       = $parent;
     $this->ui           = get_userinfo();
 
-    /* Set default base */
-    if(!session::is_set('CurrentMainBase')){
-      session::set('CurrentMainBase',$this->config->current['BASE']);
-    }
-    $this->selectedBase  = session::get('CurrentMainBase');
-
     /* Set list strings */
-    $this->SetTitle(_("List of FAI classes"));
-    $this->SetSummary(_("This table displays all FAI classes in the selected tree."));
+    $this->SetTitle(  _("List of classes"));
+    $this->SetSummary(_("List of deployment classes and packages"));
 
     /* Result page will look like a headpage */
     $this->SetHeadpageMode();
@@ -54,9 +40,6 @@ class divListFai extends MultiSelectWindow
 
     /* Dynamic action col, depending on snapshot icons */
     $action_col_size = 120;
-#   if($this->parent->snapshotEnabled()){
-#     $action_col_size += 32;
-#   }
 
     /* Toggle all selected / deselected */
     $chk = "<input type='checkbox' id='select_all' name='select_all'
@@ -65,7 +48,7 @@ class divListFai extends MultiSelectWindow
     /* set Page header */
     $this->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
     $this->AddHeader(array("string" => "&nbsp;",                "attach" => "style='text-align:center;width:20px;'"));
-    $this->AddHeader(array("string" => _("Name of FAI class"),  "attach" => "style=''"));
+    $this->AddHeader(array("string" => _("Class name"),  "attach" => "style=''"));
     $this->AddHeader(array("string" => _("Class type"),         "attach" => "style='width:200px;'"));
     $this->AddHeader(array("string" => _("Actions"),            "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
 
@@ -97,11 +80,14 @@ class divListFai extends MultiSelectWindow
       $c = $this->config->search("faiManagement", "POSTCREATE",array('menu','tabs'));
 
       $smarty = get_smarty();
+      $releases = $this->parent->getBranches();
+      
       $smarty->assign("allow_create", $c);
       $smarty->assign("allow_remove", $r);
-      $smarty->assign("selectedBranch",$this->selectedBranch);
+      $smarty->assign("fai_release" , $releases[$this->parent->fai_release]);
+      $smarty->assign("fai_base"    , $releases[$this->parent->fai_base]);
       $smarty->assign("branchimage","images/branch.png");
-      $smarty->assign("branches",$this->AvailableBranches);
+      $smarty->assign("fai_releases", $releases);
       $plug_id = 0;       
       if(isset($_GET['plug'])){
         $plug_id = $_GET['plug'];
@@ -114,128 +100,78 @@ class divListFai extends MultiSelectWindow
 
   function GenHeader()
   {
-    /* Prepare departments,
-       which are shown in the listbox on top of the listbox
-     */
-    $options= "";
-
     /* Get all departments within this subtree */
     $ui= get_userinfo();
     $first = "";
     $found = FALSE;
     $base = $this->config->current['BASE'];
 
-    /* Add base */
-    $tmp = array();
-    $tmp[] = array("dn"=>$this->config->current['BASE']);
-    $tmp=  array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
-                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
-
-    $deps = array();
-    foreach($tmp as $tm){
-      $deps[$tm['dn']] = $tm['dn'];
-    }
-
-    /* Load possible departments */
-    $ui= get_userinfo();
-    $tdeps= $ui->get_module_departments("fai");
-    $ids = $this->config->idepartments;
-    $first = "";
-    $found = FALSE;
-    foreach($ids as $dep => $name){
-      if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){
-
-        /* Keep first base dn in mind, we could need this
-         *  info if no valid base was found
-         */
-        if(empty($first)) {
-          $first = $dep['dn'];
-        }
-
-        $value = $ids[$dep];
-        if ($this->selectedBase == $dep){
-          $found = TRUE;
-          $options.= "<option selected='selected' value='".$dep."'>$value</option>";
-        } else {
-          $options.= "<option value='".$dep."'>$value</option>";
-        }
-      }
-    }
-
-    /* The currently used base is not visible with your acl setup.
-     * Set base to first useable base.
-     */
-    if(!$found){
-      $this->selectedBase = $first;
-    }
-
     /* Add seperator */
     $add_sep = false;
 
     /* Get complete fai acls, to be able to check if we must show or hide the snapshot abilities */ 
-    $acl_all = $ui->has_complete_category_acls($this->selectedBase,$this->module);
+    $acl_all = $ui->has_complete_category_acls($this->parent->fai_base,$this->module);
 
     /* Add default header */
-    $listhead = MultiSelectWindow::get_default_header();
+    $listhead = MultiSelectWindow::get_default_header(false);
 
     /* Add additional seperator */
     if($add_sep){
-      $listhead .=" <img class='center' src='images/list_seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
+      $listhead .=" <img class='center' src='images/lists/seperator.png' align='middle' alt='' height='16' width='1'>&nbsp;";
     }
 
-    $listhead .=  _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
-      " <input class='center' type='image' src='images/list_submit.png' align='middle'
-      title='"._("Submit department")."' name='submit_department' alt='".  _("Submit")."'>&nbsp;";
-
-
     $s  = ".|"._("Actions")."|\n";
-    $s .= "..|<img src='images/list_new.png' alt='' border='0' class='center'>".
+    $s .= "..|<img src='images/lists/new.png' alt='' border='0' class='center'>".
       "&nbsp;"._("Create")."|\n";
 
-    $acl = $ui->get_permissions($this->selectedBase,"fai/faiProfile");
-    if(preg_match("/c/",$acl)){
-      $s.= "...|<input class='center' type='image' src='images/fai_new_profile.png' alt=''>".
-        "&nbsp;"._("Profile")."|Create_profile|\n";
-    }
+    $acl = $ui->get_permissions($this->parent->fai_base,"fai/faiProfile");
+    if($this->parent->lock_type == "freeze" && !$this->parent->allow_freeze_object_attach){
+      $s.= "...|<input class='center' type='image' src='images/freeze.png' alt=''>".
+        "&nbsp;"._("Freezed")."|\n";
+    }else{
+      if(preg_match("/c/",$acl)){
+        $s.= "...|<input class='center' type='image' src='images/fai_new_profile.png' alt=''>".
+          "&nbsp;"._("Profile")."|Create_profile|\n";
+      }
 
-    /* Append create icons for each fai component */
-    $arr = array(
-        array("images/fai_new_partitionTable.png" , _("Partition table")  ,"Create_partition" , _("PT") , "faiPartitionTable"),
-        array("images/fai_new_script.png"         , _("Scripts")          ,"Create_script"    , _("S")  , "faiScript"),
-        array("images/fai_new_hook.png"           , _("Hooks")            ,"Create_hook"      , _("H")  , "faiHook"),
-        array("images/fai_new_variable.png"       , _("Variables")        ,"Create_variable"  , _("V")  , "faiVariable"),
+      /* Append create icons for each fai component */
+      $arr = array(
+          array("images/fai_new_partitionTable.png" , _("Partition table")  ,"Create_partition" , _("PT") , "faiPartitionTable"),
+          array("images/fai_new_script.png"         , _("Scripts")          ,"Create_script"    , _("S")  , "faiScript"),
+          array("images/fai_new_hook.png"           , _("Hooks")            ,"Create_hook"      , _("H")  , "faiHook"),
+          array("images/fai_new_variable.png"       , _("Variables")        ,"Create_variable"  , _("V")  , "faiVariable"),
         array("images/fai_new_template.png"       , _("Templates ")       ,"Create_template"  , _("I")  , "faiTemplate"),
         array("images/fai_new_packages.png"       , _("Package list")     ,"Create_package"   , _("PK") , "faiPackage"));
 
-    foreach($arr as $ar){
-      $acl = $ui->get_permissions($this->selectedBase,"fai/".$ar[4]);
-      if(preg_match("/c/",$acl)){
-        $s.= "...|<input class='center' type='image' src='".$ar[0]."' alt=''>".
-          "&nbsp;".$ar[1]."|".$ar[2]."|\n";
+      foreach($arr as $ar){
+        $acl = $ui->get_permissions($this->parent->fai_base,"fai/".$ar[4]);
+        if(preg_match("/c/",$acl)){
+          $s.= "...|<input class='center' type='image' src='".$ar[0]."' alt=''>".
+            "&nbsp;".$ar[1]."|".$ar[2]."|\n";
+        }
       }
     }
 
     /* Multiple options */
-    $s.= "..|<img src='images/edittrash.png' alt='' border='0' class='center'>".
+    $s.= "..|<img src='images/lists/trash.png' alt='' border='0' class='center'>".
       "&nbsp;"._("Remove")."|"."remove_multiple|\n";
 
     /* Add multiple copy & cut icons */
     if(is_object($this->parent->CopyPasteHandler)){
       $s.= "..|---|\n";
-      $s.= "..|<img src='images/editcopy.png' alt='' border='0' class='center'>".
+      $s.= "..|<img src='images/lists/copy.png' alt='' border='0' class='center'>".
         "&nbsp;"._("Copy")."|"."multiple_copy_systems|\n";
-      $s.= "..|<img src='images/editcut.png' alt='' border='0' class='center'>".
-        "&nbsp;"._("Cut")."|"."multiple_cut_systems|\n";
     }
 
     /* Add copy & paste icons, currently disabled, this ability is not implemeneted yet */
-    if(preg_match("/(c.*w|w.*c)/",$acl_all) &&  isset($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler){
+    if(!($this->parent->lock_type == "freeze" && !$this->parent->allow_freeze_object_attach) && 
+      preg_match("/(c.*w|w.*c)/",$acl_all) &&  isset($this->parent->CopyPasteHandler) && $this->parent->CopyPasteHandler){
       $s .= "..|---|\n";
       if($this->parent->CopyPasteHandler->entries_queued()){
-        $img = "<img border='0' class='center' src='images/editpaste.png' alt=''>";
+        $img = "<img border='0' class='center' src='images/lists/paste.png' alt=''>";
         $s.="..|".$img."&nbsp;"._("Paste")."|editPaste|\n";
       }else{
-        $img = "<img border='0' class='center' src='images/cant_editpaste.png' alt=''>";
+        $img = "<img border='0' class='center' src='images/lists/paste.png' alt=''>";
         $s.="..|".$img."&nbsp;"._("Paste")."\n";
       }
     }
@@ -275,7 +211,6 @@ class divListFai extends MultiSelectWindow
            "FAIprofile"         => array("IMG"=> "images/fai_profile.png",        "NAME"=>_("Profile") ,       "KZL"=> "P",  "VAR"=>"ShowProfiles"),
            "FAItemplate"        => array("IMG"=> "images/fai_template.png",       "NAME"=>_("Templates") ,     "KZL"=> "T",  "VAR"=>"ShowTemplates"));
 
-    $editlink ="<a href='?plug=".$_GET['plug']."&amp;edit_entry=%KEY%' title='%TITLE%'>%NAME%</a>";
 
     /* Dynamic action col, depending on snapshot icons */
     $action_col_size = 120;
@@ -319,23 +254,23 @@ class divListFai extends MultiSelectWindow
        /* Add copy & cut icons */
        $ui = get_userinfo();
        $action ="";
-       $acl_all = $ui->has_complete_category_acls($this->selectedBase,$this->module);
+       $acl_all = $ui->has_complete_category_acls($this->parent->fai_base,$this->module);
        if(preg_match("/(c.*w|w.*c)/",$acl_all) && $this->parent->CopyPasteHandler){
          $action .= "<input class='center' type='image'
-           src='images/editcut.png' alt='"._("cut")."' name='cut_%KEY%' title='"._("Cut this entry")."'>&nbsp;";
-         $action.= "<input class='center' type='image'
-           src='images/editcopy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
+           src='images/lists/copy.png' alt='"._("copy")."' name='copy_%KEY%' title='"._("Copy this entry")."'>&nbsp;";
        }
 
-       if($value['FAIstate'] == "freeze"){
-         $action.=  "<input class='center' type='image' src='images/edit.png'  alt='"._("edit")."'
-                      name='entry_edit_%KEY%' title='"._("Edit class")."'>";
-         $action.=  "<img src='images/closedlock.png' alt='F' class='center'>";
+       if(preg_match("/^freeze/", $value['FAIstate'])){
+         $editlink ="<a href='?plug=".$_GET['plug']."&amp;edit_freeze_entry=%KEY%' title='%TITLE%'>%NAME%</a>";
+         $action.=  "<input class='center' type='image' src='images/lists/edit.png'  alt='"._("edit")."'
+           name='entry_freeze_edit_%KEY%' title='"._("Edit class")."'>";
+         $action.=  "<img src='images/lists/locked.png' alt='F' class='center'>";
        }else{
-         $action.= "<input class='center' type='image' src='images/edit.png'  alt='"._("edit")."'
+         $editlink ="<a href='?plug=".$_GET['plug']."&amp;edit_entry=%KEY%' title='%TITLE%'>%NAME%</a>";
+         $action.= "<input class='center' type='image' src='images/lists/edit.png'  alt='"._("edit")."'
            name='entry_edit_%KEY%' title='"._("Edit class")."'>";
          if(preg_match("/d/",$value['acl'])){
-           $action.= "<input class='center' type='image' src='images/edittrash.png' alt='"._("delete")."'
+           $action.= "<input class='center' type='image' src='images/lists/trash.png' alt='"._("delete")."'
              name='entry_delete_%KEY%' title='"._("Delete class")."'>";
          }
        }
@@ -392,7 +327,7 @@ class divListFai extends MultiSelectWindow
        title='".$template_str."' alt='".$template_str."'>&nbsp;".$cnts['FAItemplate']."&nbsp;&nbsp;&nbsp;&nbsp;";
      $str.= "<img class='center' src='".$objects['FAIpackageList']['IMG']."'
        title='".$package_str."' alt='".$package_str."'>&nbsp;".$cnts['FAIpackageList']."&nbsp;&nbsp;&nbsp;&nbsp;";
-     $str.= "<img class='center' src='images/folder.png'
+     $str.= "<img class='center' src='images/lists/folder.png'
        title='".$dep_str."' alt='".$dep_str."'>&nbsp;".$num_deps."&nbsp;&nbsp;&nbsp;&nbsp;";
      $this->set_List_Bottom_Info($str);
   }
@@ -406,9 +341,6 @@ class divListFai extends MultiSelectWindow
   {
     /* Save automatic created POSTs like regex, checkboxes */
     MultiSelectWindow::save_object(); 
-    $faifilter = session::get('faifilter');
-    $faifilter['branch'] = $this->selectedBranch; 
-    session::set('faifilter',$faifilter);
   }
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: