Code

Reenabled system deletion
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 8 Jan 2010 16:55:51 +0000 (16:55 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 8 Jan 2010 16:55:51 +0000 (16:55 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15130 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/systems/admin/systems/class_systemManagement.inc
gosa-plugins/systems/admin/systems/remove.tpl

index b92bfd9156e31914d8acfbf0fdd9119c300d02dd..1859951cf1bfd276d6ed46be135c95ae00af43f3 100644 (file)
@@ -76,6 +76,10 @@ class systemManagement extends management
   parent::__construct($config, $ui, "systems", $headpage);
   }
 
+
+  /*! \brief    Update filter part for INCOMING.
+   *            Allows us to search for "systemIncomingRDN".
+   */
   static function incomingFilterConverter($filter)
   {
     $rdn = preg_replace("/^[^=]*=/", "", get_ou('systemIncomingRDN'));
@@ -83,6 +87,114 @@ class systemManagement extends management
     return(preg_replace("/%systemIncomingRDN/", $rdn,$filter));
   }
 
+  /*! \brief    Queue selected objects to be removed. 
+   *            Checks ACLs, Locks and ask for confirmation.
+   */
+  protected function removeEntryRequested($action="",$target=array(),$all=array())
+  {
+    $disallowed = array();
+    $this->dns = array();
+
+    @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$target,"Entry removel requested!");
+
+    // Check permissons for each target
+    $tInfo = $this->getObjectDefinitions();
+    $headpage = $this->getHeadpage();
+    foreach($target as $dn){
+      $type = $headpage->getType($dn);
+      if(!isset($tInfo[$type])){
+        trigger_error("Unknown object type received '".$type."' please update systemManagement::getObjectDefinitions()!");
+      }else{
+        $info = $tInfo[$type];
+        $acl = $this->ui->get_permissions($dn, $info['aclCategory']."/".$info['aclClass']);
+        if(preg_match("/d/",$acl)){
+          $this->dns[] = $dn;
+        }else{
+          $disallowed[] = $dn;
+        }
+      }
+    }
+    if(count($disallowed)){
+      msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
+    }
+
+    // We've at least one entry to delete.
+    if(count($this->dns)){
+
+      // check locks
+      if ($user= get_multiple_locks($this->dns)){
+        return(gen_locked_message($user,$this->dns));
+      }
+
+      // Add locks
+      $dns_names = array();
+      foreach($this->dns as $dn){
+        $dns_names[] =LDAP::fix($dn);
+      }
+      add_lock ($this->dns, $this->ui->dn);
+
+      // Display confirmation dialog.
+      $smarty = get_smarty();
+      $smarty->assign("info", msgPool::deleteInfo($dns_names,_($this->objectName)));
+      $smarty->assign("multiple", true);
+      return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+    }
+  }
+
+
+  /*! \brief  Object removal was confirmed, now remove the requested entries.
+   *
+   *  @param  String  'action'  The name of the action which was the used as trigger.
+   *  @param  Array   'target'  A list of object dns, which should be affected by this method.
+   *  @param  Array   'all'     A combination of both 'action' and 'target'.
+   */
+  function removeEntryConfirmed($action="",$target=array(),$all=array(),
+      $altTabClass="",$altTabType="",$altAclCategory="")
+  {
+    @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$target,"Entry removel confirmed!");
+
+    // Check permissons for each target
+    $tInfo = $this->getObjectDefinitions();
+    $headpage = $this->getHeadpage();
+    $disallowed = array();
+    foreach($this->dns as $key => $dn){
+      $type = $headpage->getType($dn);
+      if(!isset($tInfo[$type])){
+        trigger_error("Unknown object type received '".$type."' please update systemManagement::getObjectDefinitions()!");
+      }else{
+
+        $info = $tInfo[$type];
+        $acl = $this->ui->get_permissions($dn, $info['aclCategory']."/".$info['aclClass']);
+        if(preg_match("/d/",$acl)){
+
+          // Delete the object
+          $this->dn = $dn;
+          $this->tabObject= new $info['tabClass']($this->config,$this->config->data['TABS'][$info['tabDesc']], 
+              $this->dn, $info['aclCategory'], true, true);
+          $this->tabObject->set_acl_base($this->dn);
+          $this->tabObject->parent = &$this;
+          $this->tabObject->delete ();
+
+          // Remove the lock for the current object.
+          del_lock($this->dn);
+
+        }else{
+          $disallowed[] = $dn;
+          new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion.");
+        }
+      }
+    }
+    if(count($disallowed)){
+      msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
+    }
+
+    // Cleanup
+    $this->remove_lock();
+    $this->closeDialogs();
+  }
+
+
   function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
   {
     if(count($target) == 1){
@@ -203,7 +315,7 @@ class systemManagement extends management
     $tabs['gotoTerminal__IS_LOCKED'] = &$tabs['gotoTerminal'];
     $tabs['goServer__IS_BUSY'] = &$tabs['goServer'];
     $tabs['goServer__IS_ERROR'] = &$tabs['goServer'];
-    $tabs['goServer__ISLOCKED'] = &$tabs['goServer'];
+    $tabs['goServer__IS_LOCKED'] = &$tabs['goServer'];
 
     $tabs['FAKE_OC_NewUnknownDevice'] = &$tabs['FAKE_OC_NewDevice'];
 
index 7db0f84ca0f4da540853f49e3a28dd9c41b765a4..f60f42d2599ceb8022bb7afa36d693eabe23924d 100644 (file)
@@ -1,23 +1,18 @@
 <div style="font-size:18px;">
-<img alt="" src="images/warning.png" align=top>&nbsp;{t}Warning{/t}
+ <img alt="" src="images/warning.png" align=top>&nbsp;{t}Warning{/t}
 </div>
 <p>
{$warning}
{t}This includes all system and setup informations. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
 {$info}
 {t}This includes all account data, system access rules, imap settings, etc. for this user. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
 </p>
 
 <p>
- {t}Best thing to do before performing this action would be to save the current contents of your LDAP tree in a file. So - if you've done so - press 'Delete' to continue or 'Cancel' to abort.{/t}
+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t}
 </p>
 
 <p class="plugbottom">
-       {if $multiple}
-               <input type=submit name="delete_multiple_system_confirm" value="{msgPool type=delButton}">
-               &nbsp;
-               <input type=submit name="delete_multiple_system_cancel" value="{msgPool type=cancelButton}">
-       {else}
-               <input type=submit name="delete_terminal_confirm" value="{msgPool type=delButton}">
-               &nbsp;
-               <input type=submit name="delete_cancel" value="{msgPool type=cancelButton}">
-       {/if}
+  <input type=submit name="delete_confirmed" value="{msgPool type=delButton}">
+  <input type=submit name="delete_cancel" value="{msgPool type=cancelButton}">
+  &nbsp;
 </p>
+