X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_management.inc;h=98f02cee2fa00e1f020fc4958dc88d4833b15697;hb=53553834328f43ffd06c805c940b18738349ab94;hp=8cdeb12ec9b4b9ea11ceeaec605ce7d84f82536a;hpb=ee0b4a12b15acd5a7c9ea4013b597765f9dc675e;p=gosa.git diff --git a/gosa-core/include/class_management.inc b/gosa-core/include/class_management.inc index 8cdeb12ec..98f02cee2 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 @@ -58,7 +58,13 @@ class management protected $last_dialogObject = null; // Whether to display the apply button or not - protected $displayApplyBtn = ""; + protected $displayApplyBtn = FALSE; + + // Whether to display a header or not. + protected $skipHeader = false; + + // Whether to display a footer or not. + protected $skipFooter = false; // Copy&Paste handler protected $cpHandler = null; @@ -70,13 +76,16 @@ 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) + // Attributes managed by this plugin, can be used in post events; + protected $attributes = array(); + + function __construct(&$config,$ui,$plugname, $headpage) { $this->plugname = $plugname; $this->headpage = $headpage; @@ -96,6 +105,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"); @@ -163,21 +173,41 @@ 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. */ protected function getHeader() { + if($this->skipHeader) return(""); + if (get_object_info() != ""){ $display= print_header(get_template_path($this->plIcon),_($this->plDescription), "\"\"". @@ -202,11 +232,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){ @@ -308,8 +341,9 @@ class management // Delete the object $this->dn = $dn; - $this->tabObject= new $tabClass($this->config,$this->config->data['TABS'][$tabType], $this->dn, $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->parent = &$this; $this->tabObject->delete (); // Remove the lock for the current object. @@ -331,11 +365,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"; @@ -381,6 +420,7 @@ class management 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), @@ -452,6 +492,9 @@ 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(); @@ -461,6 +504,7 @@ class management $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); @@ -474,6 +518,7 @@ class management $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); @@ -530,6 +575,7 @@ 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!"); } } @@ -561,7 +607,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; @@ -593,6 +646,7 @@ class management $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{ @@ -617,8 +671,8 @@ class management @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()); } @@ -647,6 +701,18 @@ class management $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(); + } } } @@ -685,6 +751,7 @@ class management $this->dns = array(); $this->tabObject = null; $this->dialogObject = null; + $this->skipFooter = FALSE; set_object_info(); } @@ -756,11 +823,11 @@ 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!"); } } @@ -792,6 +859,59 @@ class management $this->filter = $str; } + + function postcreate() { + $this->_handlePostEvent('POSTCREATE'); + } + function postmodify(){ + $this->_handlePostEvent('POSTMODIFY'); + } + function postremove(){ + $this->_handlePostEvent('POSTREMOVE'); + } + + function _handlePostEvent($type) + { + + /* Find postcreate entries for this class */ + $command= $this->config->search(get_class($this), $type,array('menu', 'tabs')); + if ($command != ""){ + + /* Walk through attribute list */ + foreach ($this->attributes as $attr){ + if (!is_array($this->$attr)){ + $add_attrs[$attr] = $this->$attr; + } + } + $add_attrs['dn']=$this->dn; + + $tmp = array(); + foreach($add_attrs as $name => $value){ + $tmp[$name] = strlen($name); + } + arsort($tmp); + + /* Additional attributes */ + foreach ($tmp as $name => $len){ + $value = $add_attrs[$name]; + $command= str_replace("%$name", "$value", $command); + } + + if (check_command($command)){ + @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, + $command, "Execute"); + exec($command,$arr); + foreach($arr as $str){ + @DEBUG (DEBUG_SHELL, __LINE__, __FUNCTION__, __FILE__, + $command, "Result: ".$str); + } + } else { + $message= msgPool::cmdnotfound($type, get_class($this)); + msg_dialog::display(_("Error"), $message, ERROR_DIALOG); + } + } + + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: