Code

Enabled multiple remove
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 6 Jan 2010 11:39:41 +0000 (11:39 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 6 Jan 2010 11:39:41 +0000 (11:39 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15082 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/fai/class_faiManagement.inc
gosa-plugins/fai/admin/fai/class_filterFAI.inc
gosa-plugins/fai/admin/fai/fai-list.xml

index 03ba0cd838a1db619407ce2d9bbcbd46c5acf3fd..08e50cf9bd502a648507637de909c7f6e82b6caa 100644 (file)
@@ -76,45 +76,47 @@ class faiManagement extends management
 #    if (session::global_is_set(get_class($this)."_filter")){
 #      $filter= session::global_get(get_class($this)."_filter");
 #    } else {
-      $filter = new filter(get_template_path("fai-filter.xml", true));
-      $filter->setObjectStorage($this->storagePoints);
+  $filter = new filter(get_template_path("fai-filter.xml", true));
+  $filter->setObjectStorage($this->storagePoints);
 #    }
-    $this->setFilter($filter);
+  $this->setFilter($filter);
 
-    // Build headpage
-    $headpage = new listing(get_template_path("fai-list.xml", true));
-    $headpage->setFilter($filter);
-    $headpage->setBase($this->fai_release);
-    $headpage->registerElementFilter("filterProperties", "faiManagement::filterProperties");
+  // Build headpage
+  $headpage = new listing(get_template_path("fai-list.xml", true));
+  $headpage->setFilter($filter);
+  $headpage->setBase($this->fai_release);
+  $headpage->registerElementFilter("filterProperties", "faiManagement::filterProperties");
 
-    // Add copy&paste and snapshot handler.
-    if ($this->config->boolValueIsTrue("main", "copyPaste")){
-      $this->cpHandler = new CopyPasteHandler($this->config);
-    }
-    if($this->config->get_cfg_value("enableSnapshots") == "true"){
-      $this->snapHandler = new SnapshotHandler($this->config);
-    }
+  // Add copy&paste and snapshot handler.
+  if ($this->config->boolValueIsTrue("main", "copyPaste")){
+    $this->cpHandler = new CopyPasteHandler($this->config);
+  }
+  if($this->config->get_cfg_value("enableSnapshots") == "true"){
+    $this->snapHandler = new SnapshotHandler($this->config);
+  }
 
-    $this->registerAction("new_profile","newEntry");
-    $this->registerAction("new_template","newEntry");
-    $this->registerAction("new_script","newEntry");
-    $this->registerAction("new_hook","newEntry");
-    $this->registerAction("new_variable","newEntry");
-    $this->registerAction("new_package","newEntry");
-    $this->registerAction("new_partition","newEntry");
+  $this->registerAction("remove_multiple","removeEntryRequested");
 
-    $this->registerAction("newClassNameSelected","newClassNameSelected");
+  $this->registerAction("new_profile","newEntry");
+  $this->registerAction("new_template","newEntry");
+  $this->registerAction("new_script","newEntry");
+  $this->registerAction("new_hook","newEntry");
+  $this->registerAction("new_variable","newEntry");
+  $this->registerAction("new_package","newEntry");
+  $this->registerAction("new_partition","newEntry");
 
-    $this->registerAction("saveOpsiProperties","saveOpsiProperties");
+  $this->registerAction("newClassNameSelected","newClassNameSelected");
 
-    $this->registerAction("editByGroup","editByGroup");
-    $this->registerAction("createBranch","createBranch");
-    $this->registerAction("createFreeze","createFreeze");
-    $this->registerAction("removeBranch","removeBranch");
-    $this->registerAction("removeBranchConfirmed","removeBranchConfirmed");
-    $this->registerAction("saveBranch","saveBranch");
-    $this->registerAction("PerformBranch","PerformBranch");
-    parent::__construct($config, $ui, "roles", $headpage);
+  $this->registerAction("saveOpsiProperties","saveOpsiProperties");
+
+  $this->registerAction("editByGroup","editByGroup");
+  $this->registerAction("createBranch","createBranch");
+  $this->registerAction("createFreeze","createFreeze");
+  $this->registerAction("removeBranch","removeBranch");
+  $this->registerAction("removeBranchConfirmed","removeBranchConfirmed");
+  $this->registerAction("saveBranch","saveBranch");
+  $this->registerAction("PerformBranch","PerformBranch");
+  parent::__construct($config, $ui, "roles", $headpage);
   }
 
 
@@ -257,11 +259,66 @@ class faiManagement extends management
 
   function removeEntryRequested($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
   {
-    $headpage = $this->getHeadpage();
-    if(count($target) == 1){
-      $entry = $headpage->getEntry($target[0]);
-      if($entry){
-        $this->dialogObject = new faiGroupHandle($entry['GROUPS'],"remove");
+
+    $this->closeDialogs();
+    if($action == "remove_multiple"){
+
+      /* Collect objects to delete and check if objects are freezed
+       */
+      $errors = "";
+      $headpage = $this->getHeadpage();
+      $to_delete = array();
+      foreach($target as $id){
+        $object = $headpage->getEntry($id);
+        if(in_array("FAKE_OC_FAI", $object['objectClass'])){
+          foreach($object['GROUPS']  as $entry){
+
+            // Only allow to remove FAI classes  
+            array_push($to_delete, $entry);
+          }
+        }
+      }
+
+      foreach($to_delete as $obj){
+        if(isset($obj['FAIstate']) && preg_match('/^freeze/', $obj['FAIstate'])){
+          $errors .= $obj['cn'].", ";
+        }else{
+          $this->dns[] = $obj['dn'];
+        }
+      }
+
+      if($errors != ""){
+        msg_dialog::display(_("Branch locked"),sprintf(_("The following entries are locked, you can't remove them %s."),
+              "<br><br>".trim($errors,", ")),INFO_DIALOG);
+      }
+      /* Check locking
+       */
+      if(count($this->dns)){
+        if ($user= get_multiple_locks($this->dns)){
+          return(gen_locked_message($user,$this->dns));
+        }
+        if(count($this->dns)){
+          $smarty = get_smarty();
+          $dns_names = array();
+          foreach($this->dns as $dn){
+            add_lock ($dn, $this->ui->dn);
+            $dns_names[] = LDAP::fix($dn);
+          }
+          $smarty->assign("info",msgPool::deleteInfo($dns_names,_("FAI object")));
+          $smarty->assign("multiple", true);
+          return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+        }
+      }
+
+    }else{
+
+      // Try to remove a single object, only FAI objects can be removed!
+      $headpage = $this->getHeadpage();
+      if(count($target) == 1){
+        $entry = $headpage->getEntry($target[0]);
+        if($entry && !in_array("FAKE_OC_OPSI",$entry['objectClass'])){
+          $this->dialogObject = new faiGroupHandle($entry['GROUPS'],"remove");
+        }
       }
     }
   }
@@ -276,7 +333,8 @@ class faiManagement extends management
       $altTabClass="",$altTabType="",$altAclCategory="")
   {
     $ldap = $this->config->get_ldap_link();
-    $ldap->cd($this->config->current['BASE']);  
+    $ldap->cd($this->config->current['BASE']); 
+
     foreach($this->dns as $key => $dn){
       $ldap->cat($dn);
       if($ldap->count()){
@@ -404,6 +462,7 @@ class faiManagement extends management
   function detectPostActions()
   {
     $action = management::detectPostActions();
+    if(isset($_POST['remove_multiple'])) $action['action'] = "remove";
     if(isset($_POST['new_profile'])) $action['action'] = "new_profile";
     if(isset($_POST['new_template'])) $action['action'] = "new_template";
     if(isset($_POST['new_script'])) $action['action'] = "new_script";
index e270058dd170ee13d87261a0a9f075d4d5c6524d..5524e0c1f9df1819a90424ddf407314b12323a44 100644 (file)
@@ -49,12 +49,13 @@ class filterFAI extends filterLDAP{
           /* Clean up object informations */
           $obj                  = array();
           $obj['cn']            = $object['cn'][0];
-          $obj['dn']            = $object['cn'][0];
+          $obj['dn']            = $object['cn'][0].",".get_ou("faiBaseRDN").$config->current['BASE'];
           $obj['acl']           = $acl;
           $obj['class']         = $rest ['ACL'];
           $obj['FAIstate']      = $entry['FAIstate'];
           $obj['description']   = $object['description'][0];
           $obj['objectClass']   = $object['objectClass'];
+          $obj['objectClass'][] = 'FAKE_OC_FAI';
 
           if(!preg_match("/freeze/i", $entry['FAIstate'])){
             $obj['objectClass'][] = "FAKE_OC_IsBranch";
@@ -139,8 +140,7 @@ class filterFAI extends filterLDAP{
         }
         $item =array();
 
-        // FAKE_OC_IsBranch allows us to delete this entry (indicates NOT freezed state)
-        $item['objectClass']  = array('count' => 2, $data['type'], "FAKE_OC_IsBranch"); 
+        $item['objectClass']  = array('count' => 2, $data['type'],"FAKE_OC_OPSI");
         $item[] = 'objectClass';
         $item['cn']  = $data['cn'];
         $item[] = 'cn';
index d7b7503208c5915b8137ff7d1228c78b0f3b1514..703cae6d23c7ddb624ccf321698a295f247772c1 100644 (file)
@@ -9,7 +9,7 @@
     <template>fai-list.tpl</template>
     <module>fai</module>
     <label>List of deployment classes and products</label>
-    <defaultSortColumn>1</defaultSortColumn>
+    <defaultSortColumn>0</defaultSortColumn>
 
     <objectType>
       <label>FAI</label>
 
     </action>
 
+    <action>
+      <type>separator</type>
+    </action>
+
+    <action>
+      <name>remove_multiple</name>
+      <type>entry</type>
+      <image>images/lists/trash.png</image>
+      <label>Remove</label>
+    </action>
+
     <action>
       <type>exporter</type>
     </action>
 
   </actionmenu>
 
-  <actiontriggers snapshot="true" copypaste="true">
+  <actiontriggers snapshot="false" copypaste="true">
 
     <action>
       <name>cp</name>
+      <cut>false</cut>
+      <objectclass>FAKE_OC_FAI</objectclass>
       <type>copypaste</type>
     </action>
 
       <label>Edit</label>
     </action>
 
-    <action>
-      <name>snapshot</name>
-      <type>snapshot</type>
-    </action>
-
     <action>
       <name>remove</name>
       <type>entry</type>