Code

Updated FAI management
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 25 Apr 2008 12:47:52 +0000 (12:47 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 25 Apr 2008 12:47:52 +0000 (12:47 +0000)
-Ensure that only the displayed release is removed

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10694 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/fai/class_faiManagement.inc
gosa-plugins/fai/admin/fai/remove_branch.tpl

index 2b1e2d2570f18fd42de5c0584ef5dfbdcbddf7a3..7fea76a93cb40e335d20310d9d1be8831a9c403d 100644 (file)
@@ -461,7 +461,7 @@ class faiManagement extends plugin
         /* Load permissions for selected 'dn' and check if
            we're allowed to remove this 'dn' */
         if($this->acl_is_removeable()){
-
+          $smarty->assign("release_hidden",base64_encode($this->fai_release));
           $smarty->assign("info", msgPool::deleteInfo(@LDAP::fix($this->fai_release),_("FAI branch/freeze")));
           return($smarty->fetch(get_template_path('remove_branch.tpl',TRUE)));
         } else {
@@ -482,33 +482,35 @@ class faiManagement extends plugin
        */
       if("" != $this->config->search("faiManagement", "POSTREMOVE",array('menu','tabs'))){
 
-        $bb =  $this->fai_release;
-        if(!isset($ldap)){
-          $ldap = $this->config->get_ldap_link();
-        }
+        if(!isset($_POST['release_hidden']) || base64_decode($_POST['release_hidden']) != $this->fai_release){
+          msg_dialog::display(_("Warning"),_("Release remove aborted, release name check failed."));
+        }else{
 
-        $br = $this->getBranches();
+          $bb =  $this->fai_release;
+          if(!isset($ldap)){
+            $ldap = $this->config->get_ldap_link();
+          }
 
-        if(isset($br[$bb]) && $this->acl_is_removeable()){
-          $name = $br[$bb];
+          $br = $this->getBranches();
 
-          echo $bb." <br>";
-          echo $name." <br>";
+          if(isset($br[$bb]) && $this->acl_is_removeable()){
+            $name = $br[$bb];
 
-          $ldap->cd($bb);
-          $ldap->recursive_remove();
-          $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiou')).'/', ','.get_ou('applicationou'), $bb));
-          $ldap->recursive_remove();
-          $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiou')).'/', ','.get_ou('mimetypeou'), $bb));
-          $ldap->recursive_remove();
-          $this->fai_release = $this->fai_base;
+            $ldap->cd($bb);
+            $ldap->recursive_remove();
+            $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiou')).'/', ','.get_ou('applicationou'), $bb));
+            $ldap->recursive_remove();
+            $ldap->cd(preg_replace('/,'.normalizePreg(get_ou('faiou')).'/', ','.get_ou('mimetypeou'), $bb));
+            $ldap->recursive_remove();
+            $this->fai_release = $this->fai_base;
 
-          /* Post remove */
-          $this->lock_name   = $name;
-          $this->lock_dn     = $bb;
-          $this->postremove();
+            /* Post remove */
+            $this->lock_name   = $name;
+            $this->lock_dn     = $bb;
+            $this->postremove();
 
-          new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed");
+            new log("remove","fai/".get_class($this),$br[$bb],array(),"Release removed");
+          }
         }
       }
     }
index 1fb1d9f3dfc042240a58828cbb6c5bc063acf111..23e8b09265835068fdcdc7cb2d7cd062fe90509a 100644 (file)
@@ -9,7 +9,7 @@
 <p>
  {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t}
 </p>
-
+<input type='hidden' name='release_hidden' value='{$release_hidden}'>
 <p class="plugbottom">
   <input type=submit name="delete_branch_confirm" value="{msgPool type=delButton}">
   &nbsp;