Code

Updated snapshot stuff, check acls here too.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 29 May 2008 09:36:20 +0000 (09:36 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 29 May 2008 09:36:20 +0000 (09:36 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11100 594d385d-05f5-0310-b6e9-bd551577e9d8

15 files changed:
gosa-core/include/class_SnapShotDialog.inc
gosa-core/plugins/admin/acl/class_aclManagement.inc
gosa-core/plugins/admin/departments/class_departmentManagement.inc
gosa-core/plugins/admin/groups/class_groupManagement.inc
gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc
gosa-core/plugins/admin/users/class_userManagement.inc
gosa-plugins/fai/admin/fai/class_faiManagement.inc
gosa-plugins/gofax/gofax/blocklists/class_blocklistManagement.inc
gosa-plugins/gofon/gofon/conference/class_phoneConferenceManagment.inc
gosa-plugins/gofon/gofon/macro/class_gofonMacroManagement.inc
gosa-plugins/goto/admin/applications/class_applicationManagement.inc
gosa-plugins/goto/admin/devices/class_deviceManagement.inc
gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc
gosa-plugins/sudo/admin/sudo/class_sudoManagement.inc
gosa-plugins/systems/admin/systems/class_systemManagement.inc

index 4941c34ec3086a1011e7d8a85245a260a84e9e8b..fb7cb1f79c172d42183ee7a3e67e7b4e28cac252 100644 (file)
@@ -61,38 +61,53 @@ class SnapShotDialog extends plugin
                plugin::execute();
                $smarty = get_smarty();
 
+    if(!isset($this->parent->acl_module) || !count($this->parent->acl_module)){
+      trigger_error("Could not detect acl_module in parent object (".get_class($this->parent).").");
+      return("");
+    }
+
+    $ui = get_userinfo();
+
                $once = true;
                foreach($_POST as $name => $value){
                        if((preg_match("/^RemoveSnapShot_/",$name)) && ($once)){
                                $once = false;
        
-                               $entry = preg_replace("/^RemoveSnapShot_/","",$name);
-                               $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
-
-        $found = false;
-        foreach($this->last_list as $t_stamp => $obj){
-          if($obj['dn'] == $entry){
-            $found = true;
-            break;
+        $entry = preg_replace("/^RemoveSnapShot_/","",$name);
+        $entry = base64_decode(preg_replace("/_[xy]$/","",$entry));
+
+        /* Check if we are allowed to handle snapshots 
+         */
+        if($ui->allow_snapshot_restore($entry,$this->parent->acl_module)){
+
+          $found = false;
+          foreach($this->last_list as $t_stamp => $obj){
+            if($obj['dn'] == $entry){
+              $found = true;
+              break;
+            }
           }
-        }
 
-        if($found){
-          $this->del_dn        = $entry;
-          $smarty= get_smarty();
-          $smarty->assign("intro", sprintf(_("You're about to delete the snapshot '%s'."), @LDAP::fix($this->del_dn)));
-          return($smarty->fetch (get_template_path('remove.tpl')));
+          if($found){
+            $this->del_dn      = $entry;
+            $smarty= get_smarty();
+            $smarty->assign("intro", sprintf(_("You're about to delete the snapshot '%s'."), @LDAP::fix($this->del_dn)));
+            return($smarty->fetch (get_template_path('remove.tpl')));
+          }
         }
       }
     }
 
     /* Remove snapshot */
     if(isset($_POST['delete_confirm']) && !empty($this->del_dn)){
-      $this->remove_snapshot($this->del_dn);
+      if($ui->allow_snapshot_restore($this->del_dn,$this->parent->acl_module)){
+        $this->remove_snapshot($this->del_dn);
+      }
       $this->del_dn = "";
                }
 
                /* We must restore a snapshot */
+
                if($this->display_restore_dialog){
 
                        /* Should we only display all snapshots of already deleted objects 
@@ -118,8 +133,12 @@ class SnapShotDialog extends plugin
                        
                        /* Walk through all entries and setup the display text */
                        foreach($tmp as $key => $entry){
-                               $TimeStamp = $entry['gosaSnapshotTimestamp'][0];
-                               $list_of_elements[$TimeStamp] = $entry;
+    
+        /* Check permissions */
+        if($ui->allow_snapshot_restore($entry['dn'],$this->parent->acl_module)){
+          $TimeStamp = $entry['gosaSnapshotTimestamp'][0];
+          $list_of_elements[$TimeStamp] = $entry;
+        }
                        }
 
                        /* Sort generated list */
@@ -129,10 +148,10 @@ class SnapShotDialog extends plugin
       $this->last_list = $list_of_elements;
                        foreach($list_of_elements as $entry){
 
-                               $actions= "<input type='image' src='images/lists/restore.png' name='RestoreSnapShot_%KEY' 
-                                                               class='center' title='"._("Restore snapshot")."'>&nbsp;";
-                               $actions.= "<input type='image' src='images/lists/trash.png' name='RemoveSnapShot_%KEY' 
-                                                               class='center' title='"._("Remove snapshot")."'>&nbsp;";
+        $actions= "<input type='image' src='images/lists/restore.png' name='RestoreSnapShot_%KEY' 
+          class='center' title='"._("Restore snapshot")."'>&nbsp;";
+        $actions.= "<input type='image' src='images/lists/trash.png' name='RemoveSnapShot_%KEY' 
+          class='center' title='"._("Remove snapshot")."'>&nbsp;";
 
                                $time_stamp     = date(_("Y-m-d, H:i:s"),preg_replace("/\-.*$/","",$entry['gosaSnapshotTimestamp'][0]));
                                $display_data   = $entry['description'][0];
index 7bf405a5027284716c1a25c3488182b3ecc57fd5..8aed5f6b0bbb56b8013b13f14b9d8e49316dca74 100644 (file)
@@ -36,6 +36,8 @@ class aclManagement extends plugin
   var $start_pasting_copied_objects = FALSE;
   var $dns = array();
 
+  var $acl_module = array("acl","aclroles");
+
   function aclManagement(&$config, &$ui)
   {
     /* Save configuration for internal use */
@@ -471,7 +473,7 @@ class aclManagement extends plugin
     
     /* Check if there is a snapshot dialog open */
     $base = $this->DivListACL->selectedBase;
-    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
       return($str);
     }
   
index 131a3b3e6778b0327fac82ad2db51221caf0f693..bd6d36e1b58752a0fdb715b9f9751eafefe60e40 100644 (file)
@@ -40,6 +40,8 @@ class departmentManagement extends plugin
   var $ObjectInSaveMode         = false;    // Is true, if current object wasn't saved right now
   var $dns = array();
 
+  var $acl_module = array("department");
+
   function departmentManagement (&$config, &$ui)
   {
     $this->ui= &$ui;
index 70ae8ef626f943ee314eca70e62e7159ed06b05d..4137ca8f9b8f0497f242e07b0b40df385ff5d3d1 100644 (file)
@@ -34,7 +34,7 @@ class groupManagement extends plugin
   var $DivListGroup       = NULL;
   var $ShowPrimaryCheckBox= false; 
   var $start_pasting_copied_objects = FALSE;
-
+  var $acl_module         = "groups";
   var $dns = array();
 
   function groupManagement (&$config, &$ui)
@@ -555,7 +555,7 @@ class groupManagement extends plugin
 
     /* Check if there is a snapshot dialog open */
     $base = $this->DivListGroup->selectedBase;
-    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
       return($str);
     }
    
index 6fe2d6ea249ea72cbc2b706994a5e80d81c429b4..9d5cdf1074e4e70d667a5ca6bc89231e1af9114e 100644 (file)
@@ -37,6 +37,7 @@ class ogroupManagement extends plugin
   var $start_pasting_copied_objects = FALSE;
 
   var $dns = array();
+  var $acl_module   = array("ogroups");  
 
   function ogroupManagement (&$config, $dn= NULL)
   {
@@ -491,7 +492,7 @@ class ogroupManagement extends plugin
 
     /* Check if there is a snapshot dialog open */
     $base = $this->DivListOGroup->selectedBase;
-    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
       return($str);
     }
 
index 2b84bfc2b87b33e3c58703e40aecf1d274e27ce8..6cd576433c9674146a6ed491ed0a6b6bc79d20fc 100644 (file)
@@ -39,8 +39,8 @@ class userManagement extends plugin
 
   var $start_pasting_copied_objects = FALSE;
   var $msg_dialog= NULL;
-  
-  var $dns =array();
+  var $acl_module = array("users");  
+  var $dns    = array();
 
   function userManagement(&$config, $ui)
   {
@@ -971,7 +971,7 @@ class userManagement extends plugin
     
     /* Check if there is a snapshot dialog open */
     $base = $this->DivListUsers->selectedBase;
-    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
       return($str);
     }
   
index b5b335cab57fce6b48fc2a8553a90dbb74d60865..e739f52200e954712ec440fdb9d702547609a5f9 100644 (file)
@@ -53,6 +53,8 @@ class faiManagement extends plugin
   var $fai_base     ="";
   var $fai_release  ="";
 
+  var $acl_module = array("fai");
+
        /* construction/reconstruction 
         */
        function faiManagement (&$config, $ui)
@@ -948,7 +950,7 @@ class faiManagement extends plugin
 
     /* Check if there is a snapshot dialog open */
     $base = $this->fai_base;
-    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
       return($str);
     }
 
index 93987e40466af3fb81808bb79ae24d65dc65a7e4..649ae89f923b6c81f2ca41634e46aaefff1a443e 100644 (file)
@@ -10,6 +10,8 @@ class blocklist extends plugin
   var $CopyPasteHandler = NULL;
   var $dns              = array();
   var $start_pasting_copied_objects = FALSE;
+
+  var $acl_module = array("gofaxlist");
   
   function blocklist (&$config, $ui)
   {
@@ -331,7 +333,7 @@ class blocklist extends plugin
 
     /* Check if there is a snapshot dialog open */
     $base = $this->DivListBlocklist->selectedBase;
-    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
       return($str);
     }
 
index 3cf6ec65d7e1100d0ab7609c098166b75596d350..f41ea11ad8db91a30bece3cff8bff8ac8af3b81c 100644 (file)
@@ -37,6 +37,8 @@ class phoneConferenceManagment extends plugin
   var $start_pasting_copied_objects = FALSE;
   var $dns                = array();
 
+  var $acl_module = array("gofonconference");
+
   /* Initialise Class */
   function phoneConferenceManagment (&$config, $ui)
   {
@@ -398,7 +400,7 @@ class phoneConferenceManagment extends plugin
 
     /* Check if there is a snapshot dialog open */
     $base = $this->DivListConference->selectedBase;
-    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
       return($str);
     }
 
index 46f9d5144383a4a71ee9324eaf612829e98d7fbc..e5e7f3934a0a8b213c355257ae91f9a0d5067db4 100644 (file)
@@ -35,6 +35,8 @@ class goFonMacro extends plugin
 
   var $dns              = array();
 
+  var $acl_module = array("gofonmacro");
+
   function gofonMacro(&$config, $ui)
   {
     /* Save configuration for internal use */
@@ -429,7 +431,7 @@ class goFonMacro extends plugin
 
     /* Check if there is a snapshot dialog open */
     $base = $this->DivListMacro->selectedBase;
-    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
       return($str);
     }
 
index b00a8d29c7f1906c59989e4860bc8bdbce83f826..b4f83907f3eb9bf15762786d0735aa31ed574b83 100644 (file)
@@ -35,6 +35,7 @@ class applicationManagement extends plugin
 
   var $app_base     ="";
   var $app_release  ="";
+  var $acl_module   = array("application");  
 
   var $dns = array();
 
@@ -514,7 +515,7 @@ class applicationManagement extends plugin
     }else{
       $base = $this->app_base;  
     }
-    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
       return($str);
     }
 
index 5cb193a085d0cdf8fbc562d734f8c33a7b6dd102..7b3f750f66d8280fd19d17f332e75cfd202efd1d 100644 (file)
@@ -18,6 +18,8 @@ class deviceManagement extends plugin
   var $dn ="";
   var $dns = array();
 
+  var $acl_module = array("devices");
+
   function deviceManagement(&$config, $dn= NULL)
   {
     plugin::plugin ($config, $dn);
@@ -421,7 +423,7 @@ class deviceManagement extends plugin
 
         /* Check if there is a snapshot dialog open */
     $base = $this->DivListDevices->selectedBase;
-    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
       return($str);
     }
 
index d911448dc5319b10503c1d5cafc44dc23377ae4f..c8f4adb73824e11f7eda5ecbe73880d2e7909857 100644 (file)
@@ -36,6 +36,7 @@ class mimetypeManagement extends plugin
   var $mime_base    = "";
   var $mime_release = "";
 
+  var $acl_module = array("mimetypes");
 
   function IsReleaseManagementActivated()
   {
@@ -518,7 +519,7 @@ class mimetypeManagement extends plugin
     }else{
       $base = $this->mime_base;
     }
-    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
       return($str);
     }
 
index 8ce2d16a508ad572febb853944bd98c46d06e4f0..624a6029c4fcac68f4bd126f79dda6da6bbe3473 100644 (file)
@@ -36,6 +36,8 @@ class sudoManagement extends plugin
   private $base           = "";
 
   private $start_pasting_copied_objects = FALSE;
+
+  public $acl_module = array("sudo");
  
   /*! \brief */ 
   public function __construct(&$config, &$ui)
@@ -347,7 +349,7 @@ class sudoManagement extends plugin
     }
 
     /* Check if there is a snapshot dialog open */
-    if($str = $this->showSnapshotDialog(sudo::get_sudoers_ou($this->config),$this->get_used_snapshot_bases())){
+    if($str = $this->showSnapshotDialog(sudo::get_sudoers_ou($this->config),$this->get_used_snapshot_bases(),$this)){
       return($str);
     }
 
index 1f115d806b3c6cf60b50d70b6f477f6a00078615..7377c5f0a4b5b43ae6b9cce8aa32c001fcdcaeac 100644 (file)
@@ -44,6 +44,8 @@ class systems extends plugin
   var $system_activation_object = ""; // The object to activate (NewDevice)
   var $fai_activated  = FALSE;
 
+  var $acl_module = array("incoming","terminal","workstation","server","printer","phone","winworkstation","component");
+
   function systems (&$config, $ui)
   {
     /* Save configuration for internal use */
@@ -1167,7 +1169,7 @@ class systems extends plugin
 
     /* Check if there is a snapshot dialog open */
     $base = $this->DivListSystem->selectedBase;
-    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
+    if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases(),$this)){
       return($str);
     }