Code

Added sorting to FAIscripts
[gosa.git] / plugins / admin / fai / class_divListFai.inc
index 95e193f1dcb5805a76cefcb5ec537f56530e2c43..b6fc3e3998109230811f1d9c1d9bab9b5311603f 100644 (file)
@@ -80,16 +80,26 @@ class divListFai extends MultiSelectWindow
 
     /* Add SubSearch checkbox */
     //$this->AddCheckBox(SEPERATOR);
-    //$this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Ignore subtrees"), false);
+    //$this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Search in subtrees"), false);
 
     /*                  Name                 ,Text                              ,Default  , Connect with alphabet  */
     $this->AddRegex   ("Regex",     _("Display users matching"),"*" , true);
   }
 
-  function AddUserBoxToFilter($position){
+  function AddUserBoxToFilter($position)
+  {
     $str = "";
     if($position  == 2){
+
+      /* Check if there are post commands available for fai management.
+       * If not, grey out freeze/branch and release remove buttons.
+       */
+      $r = ("" != search_config($this->config->data,"faiManagement","POSTREMOVE"));
+      $c = ("" != search_config($this->config->data,"faiManagement","POSTCREATE"));
+
       $smarty = get_smarty();
+      $smarty->assign("allow_create", $c);
+      $smarty->assign("allow_remove", $r);
       $smarty->assign("selectedBranch",$this->selectedBranch);
       $smarty->assign("branchimage","images/branch.png");
       $smarty->assign("branches",$this->AvailableBranches);
@@ -110,15 +120,26 @@ class divListFai extends MultiSelectWindow
     $first = "";
     $found = FALSE;
     $base = $this->config->current['BASE'];
-    $deps= get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
-                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH);
+
+    /* 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;
-    foreach($deps as $dep){
-      if(isset($ids[$dep['dn']]) && in_array_ics($dep['dn'], $tdeps)){
+    $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
@@ -126,12 +147,13 @@ class divListFai extends MultiSelectWindow
         if(empty($first)) {
           $first = $dep['dn'];
         }
-  
-        $value = $ids[$dep['dn']];
-        if ($this->selectedBase == $dep['dn']){
-          $options.= "<option selected='selected' value='".$dep['dn']."'>$value</option>";
+
+        $value = $ids[$dep];
+        if ($this->selectedBase == $dep){
+          $found = TRUE;
+          $options.= "<option selected='selected' value='".$dep."'>$value</option>";
         } else {
-          $options.= "<option value='".$dep['dn']."'>$value</option>";
+          $options.= "<option value='".$dep."'>$value</option>";
         }
       }
     }
@@ -199,6 +221,15 @@ class divListFai extends MultiSelectWindow
     $listhead .= "&nbsp;<input class='center' type='image' align='middle' src='images/edittrash.png'
         title='"._("Remove selected fai objects")."' alt='"._("Remove fai objects")."' name='remove_multiple_fai_objects'>&nbsp;";
 
+    /* Add multiple copy & cut icons */
+    if(is_object($this->parent->CopyPasteHandler)){
+      $listhead .= "&nbsp;<input class='center' type='image' align='middle' src='images/editcopy.png'
+        title='"._("Copy selected objects")."' alt='"._("Copy fai objects")."' name='multiple_copy_fai'>&nbsp;";
+      $listhead .= "&nbsp;<input class='center' type='image' align='middle' src='images/editcut.png'
+        title='"._("cut selected objects")."' alt='"._("Cut fai objects")."' name='multiple_cut_fai'>&nbsp;";
+      $listhead .= "</div>";
+    }
+
     $listhead .="</div>";;