X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_management.inc;h=81a798b5876e808fb4728848a4f9d7c178c33136;hb=30d939bbc772a9b8cdd9704e8034101e957ab972;hp=6eababcf81ca6ed95ca0ed05d169e90fe236af0e;hpb=d8332a2f8467a9678c48d879d6d89de15e0f2c1c;p=gosa.git diff --git a/gosa-core/include/class_management.inc b/gosa-core/include/class_management.inc index 6eababcf8..81a798b58 100644 --- a/gosa-core/include/class_management.inc +++ b/gosa-core/include/class_management.inc @@ -3,7 +3,7 @@ * This code is part of GOsa (http://www.gosa-project.org) * Copyright (C) 2003-2008 GONICUS GmbH * - * ID: $$Id: class_plugin.inc 14584 2009-10-12 14:04:22Z hickert $$ + * ID: $$Id$$ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -60,6 +60,9 @@ class management // Whether to display the apply button or not protected $displayApplyBtn = ""; + // Whether to display a footer or not. + protected $skipFooter = false; + // Copy&Paste handler protected $cpHandler = null; @@ -70,13 +73,13 @@ class management protected $snapHandler = null; // The listing handlers - protected $headpage = null; - protected $filter = null; + private $headpage = null; + private $filter = null; // A list of configured actions/events protected $actions = array(); - function __construct($config,$ui,$plugname, $headpage) + function __construct(&$config,$ui,$plugname, $headpage) { $this->plugname = $plugname; $this->headpage = $headpage; @@ -96,6 +99,7 @@ class management $this->registerAction("apply", "applyChanges"); $this->registerAction("save", "saveChanges"); $this->registerAction("cancel", "cancelEdit"); + $this->registerAction("cancelDelete", "cancelEdit"); $this->registerAction("remove", "removeEntryRequested"); $this->registerAction("removeConfirmed", "removeEntryConfirmed"); @@ -108,7 +112,6 @@ class management $this->registerAction("saveSnapshot","saveSnapshot"); $this->registerAction("restoreSnapshot","restoreSnapshot"); $this->registerAction("cancelSnapshot","closeDialogs"); - } /*! \brief Execute this plugin @@ -164,15 +167,33 @@ class management foreach($this->storagePoints as $sp){ $bases[] = $sp.$this->headpage->getBase(); } + + // No bases specified? Try base + if(!count($bases)) $bases[] = $this->headpage->getBase(); + $this->snapHandler->setSnapshotBases($bases); } - + + // Display list + return($this->renderList()); + } + + function renderList() + { $this->headpage->update(); $display = $this->headpage->render(); return($this->getHeader().$display); } + function getHeadpage() + { + return($this->headpage); + } + function getFilter() + { + return($this->filter); + } /*! \brief Generates the plugin header which is displayed whenever a tab object is * opened. @@ -203,11 +224,14 @@ class management // Check if there is a dialog opened - We don't need any buttons in this case. if($this->tabObject->by_object[$this->tabObject->current]){ $current = $this->tabObject->by_object[$this->tabObject->current]; - if(is_object($current->dialog)){ + if(isset($current->dialog) && (is_object($current->dialog) || $current->dialog)){ return(""); } } + // Skip footer if requested; + if($this->skipFooter) return(""); + // In case an of locked entry, we may have opened a read-only tab. $str = ""; if(isset($this->tabObject->read_only) && $this->tabObject->read_only == TRUE){ @@ -239,11 +263,13 @@ class management * @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'. */ - protected function removeEntryRequested($action,$target,$all) + 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 foreach($target as $dn){ $acl = $this->ui->get_permissions($dn, $this->aclCategory."/".$this->aclPlugin); @@ -287,8 +313,18 @@ class management * @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()) + function removeEntryConfirmed($action="",$target=array(),$all=array(), + $altTabClass="",$altTabType="",$altAclCategory="") { + $tabType = $this->tabType; + $tabClass = $this->tabClass; + $aclCategory = $this->aclCategory; + if(!empty($altTabClass)) $tabClass = $altTabClass; + if(!empty($altTabType)) $tabType = $altTabType; + if(!empty($altAclCategory)) $aclCategory = $altAclCategory; + + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$target,"Entry removel confirmed!"); + foreach($this->dns as $key => $dn){ // Check permissions, are we allowed to remove this object? @@ -297,10 +333,10 @@ class management // Delete the object $this->dn = $dn; - $tab = $this->tabClass; - $this->tabObject= new $tab($this->config,$this->config->data['TABS'][$this->tabType], $this->dn, $this->aclCategory); + $this->tabObject= new $tabClass($this->config,$this->config->data['TABS'][$tabType], $this->dn, $aclCategory, true, true); $this->tabObject->set_acl_base($this->dn); $this->tabObject->delete (); + $this->tabObject->parent = &$this; // Remove the lock for the current object. del_lock($this->dn); @@ -321,11 +357,16 @@ class management */ function detectPostActions() { + if(!is_object($this->headpage)){ + trigger_error("No valid headpage given....!"); + return(array()); + } $action= $this->headpage->getAction(); if(isset($_POST['edit_apply'])) $action['action'] = "apply"; if(isset($_POST['edit_finish'])) $action['action'] = "save"; if(isset($_POST['edit_cancel'])) $action['action'] = "cancel"; if(isset($_POST['delete_confirmed'])) $action['action'] = "removeConfirmed"; + if(isset($_POST['delete_cancel'])) $action['action'] = "cancelDelete"; // Detect Snapshot actions if(isset($_POST['CreateSnapshot'])) $action['action'] = "saveSnapshot"; @@ -365,10 +406,13 @@ class management */ function createSnapshotDialog($action="",$target=array(),$all=array()) { + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$target,"Snaptshot creation initiated!"); + foreach($target as $entry){ if(!empty($entry) && $this->ui->allow_snapshot_create($entry,$this->aclCategory)){ $this->dialogObject = new SnapShotDialog($this->config,$entry,$this); $this->dialogObject->aclCategories = array($this->aclCategory); + $this->dialogObject->parent = &$this; }else{ msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to create a snapshot for %s."),$entry), @@ -385,7 +429,7 @@ class management * @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 saveSnapsho($action="",$target=array(),$all=array()) + function saveSnapshot($action="",$target=array(),$all=array()) { $this->dialogObject->save_object(); $msgs = $this->dialogObject->check(); @@ -396,6 +440,7 @@ class management }else{ $this->dn = $this->dialogObject->dn; $this->snapHandler->create_snapshot( $this->dn,$this->dialogObject->CurrentDescription); + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dn,"Snaptshot created!"); $this->closeDialogs(); } } @@ -413,6 +458,7 @@ class management $entry = array_pop($target); if(!empty($entry) && $this->ui->allow_snapshot_restore($entry,$this->aclCategory)){ $this->snapHandler->restore_snapshot($entry); + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dn,"Snaptshot restored!"); $this->closeDialogs(); }else{ msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to restore a snapshot for %s."),$entry), @@ -438,14 +484,19 @@ class management } } + // No bases specified? Try base + if(!count($bases)) $bases[] = $this->headpage->getBase(); + // No target, open the restore removed object dialog. if(!count($target)){ $entry = $this->headpage->getBase(); if(!empty($entry) && $this->ui->allow_snapshot_restore($entry,$this->aclCategory)){ + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$entry,"Snaptshot restoring initiated!"); $this->dialogObject = new SnapShotDialog($this->config,$entry,$this); $this->dialogObject->set_snapshot_bases($bases); $this->dialogObject->display_all_removed_objects = true; $this->dialogObject->display_restore_dialog = true; + $this->dialogObject->parent = &$this; }else{ msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to restore a snapshot for %s."),$entry), ERROR_DIALOG); @@ -455,9 +506,11 @@ class management // Display the restore points for a given object. $entry = array_pop($target); if(!empty($entry) && $this->ui->allow_snapshot_restore($entry,$this->aclCategory)){ + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$entry,"Snaptshot restoring initiated!"); $this->dialogObject = new SnapShotDialog($this->config,$entry,$this); $this->dialogObject->set_snapshot_bases($bases); $this->dialogObject->display_restore_dialog = true; + $this->dialogObject->parent = &$this; }else{ msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to restore a snapshot for %s."),$entry), ERROR_DIALOG); @@ -514,6 +567,8 @@ class management }else{ $this->tabObject= new $tabClass($this->config,$this->config->data['TABS'][$tabType], $this->dn, $aclCategory); $this->tabObject->set_acl_base($this->headpage->getBase()); + $this->tabObject->parent = &$this; + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dn,"Create new entry initiated!"); } } @@ -544,7 +599,14 @@ class management * } * } * } - **/ + **/ + + // Do not create a new tabObject while there is already one opened, + // the user may have just pressed F5 to reload the page. + if(is_object($this->tabObject)){ + return; + } + $tabType = $this->tabType; $tabClass = $this->tabClass; $aclCategory = $this->aclCategory; @@ -574,7 +636,9 @@ class management }else{ $tab = $tabClass; $this->tabObject= new $tab($this->config,$this->config->data['TABS'][$tabType], $this->dn,$aclCategory); + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dn,"Edit entry initiated!"); $this->tabObject->set_acl_base($this->dn); + $this->tabObject->parent = &$this; } }else{ @@ -596,9 +660,11 @@ class management return($tmp->display_lock_message()); } + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dns,"Edit entry initiated!"); + // Now lock entries. - $tmp->lock_entries($this->ui->dn); if($tmp->multiple_available()){ + $tmp->lock_entries($this->ui->dn); $this->tabObject = $tmp; set_object_info($this->tabObject->get_object_info()); } @@ -623,6 +689,19 @@ class management return(""); }else{ $this->tabObject->save(); + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dns,"Entry saved!"); + $this->remove_lock(); + $this->closeDialogs(); + } + }elseif($this->dialogObject instanceOf plugin){ + $this->dialogObject->save_object(); + $msgs = $this->dialogObject->check(); + if(count($msgs)){ + msg_dialog::displayChecks($msgs); + return(""); + }else{ + $this->dialogObject->save(); + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dns,"Entry saved!"); $this->remove_lock(); $this->closeDialogs(); } @@ -644,6 +723,7 @@ class management return(""); }else{ $this->tabObject->save(); + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$this->dns,"Modifications applied!"); $this->tabObject->re_init(); } } @@ -734,10 +814,12 @@ class management $this->cpHandler->cleanup_queue(); foreach($target as $dn){ if($action == "copy" && $this->ui->is_copyable($dn,$aclCategory,$aclPlugin)){ - $this->cpHandler->add_to_queue($dn,"copy",$tabClass,$tabType,$aclCategory); + $this->cpHandler->add_to_queue($dn,"copy",$tabClass,$tabType,$aclCategory,$this); + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$dn,"Entry copied!"); } if($action == "cut" && $this->ui->is_cutable($dn,$aclCategory,$aclPlugin)){ - $this->cpHandler->add_to_queue($dn,"cut",$tabClass,$tabType,$aclCategory); + $this->cpHandler->add_to_queue($dn,"cut",$tabClass,$tabType,$aclCategory,$this); + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$dn,"Entry cutted!"); } } }