X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_management.inc;h=89f56c163272f825930a41461e8eee52dc472ca4;hb=6ac95cb185bd87219075cd798784ba7b8d792eac;hp=544051dd06b291e088e3f49a374b0a6346009824;hpb=e28042421add487735e2f8d0e1aa91c236525e8e;p=gosa.git diff --git a/gosa-core/include/class_management.inc b/gosa-core/include/class_management.inc index 544051dd0..89f56c163 100644 --- a/gosa-core/include/class_management.inc +++ b/gosa-core/include/class_management.inc @@ -33,7 +33,7 @@ class management public $plHeadline = "unconfigured"; // The currently used object(s) (e.g. in edit, removal) - protected $dn = ""; + public $dn = ""; // this is public due to some compatibility problems with class plugin.. protected $dns = array(); // The last used object(s). @@ -46,6 +46,7 @@ class management // The tab definitions to use for the current object. protected $tabClass = ""; // e.g. usertabs protected $tabType = ""; // e.g. USERTABS + protected $aclPlugin = ""; // e.g. generic protected $aclCategory = ""; // e.g. users protected $objectName = ""; // e.g. users @@ -60,6 +61,9 @@ class management // Whether to display the apply button or not protected $displayApplyBtn = FALSE; + // Whether to display a header or not. + protected $skipHeader = false; + // Whether to display a footer or not. protected $skipFooter = false; @@ -80,7 +84,7 @@ class management protected $actions = array(); // Attributes managed by this plugin, can be used in post events; - protected $attributes = array(); + public $attributes = array(); function __construct(&$config,$ui,$plugname, $headpage) { @@ -115,6 +119,12 @@ class management $this->registerAction("saveSnapshot","saveSnapshot"); $this->registerAction("restoreSnapshot","restoreSnapshot"); $this->registerAction("cancelSnapshot","closeDialogs"); + + $this->registerAction("config-filter","editFilter"); + $this->registerAction("saveFilter","saveFilter"); + + // To temporay disable the filter caching UNcomment this line. + #session::global_un_set(get_class($this)."_filter"); } /*! \brief Execute this plugin @@ -126,6 +136,8 @@ class management $vars = array('/^act$/','/^listing/','/^PID$/','/^FILTER_PID$/'); session::set('LOCK_VARS_TO_USE',$vars); + pathNavigator::registerPlugin($this); + /* Display the copy & paste dialog, if it is currently open */ $ret = $this->copyPasteHandler("",array()); if($ret){ @@ -137,9 +149,6 @@ class management $this->filter->update(); session::global_set(get_class($this)."_filter", $this->filter); session::set('autocomplete', $this->filter); - if (!$this->filter->isValid()){ - msg_dialog::display(_("Filter error"), _("The filter is incomplete!"), ERROR_DIALOG); - } } // Handle actions (POSTs and GETs) @@ -158,7 +167,7 @@ class management // Display tab object. if($this->tabObject instanceOf tabs || $this->tabObject instanceOf multi_plug){ - $this->tabObject->save_object(); +# $this->tabObject->save_object(); $display = $this->tabObject->execute(); $display.= $this->_getTabFooter(); return($this->getHeader().$display); @@ -176,11 +185,16 @@ class management $this->snapHandler->setSnapshotBases($bases); } - + // Display list return($this->renderList()); } - + + function editFilter() + { + $this->dialogObject = new userFilter($this->config,$this->getHeadpage()); + } + function renderList() { $this->headpage->update(); @@ -203,14 +217,8 @@ class management */ protected function getHeader() { - if (get_object_info() != ""){ - $display= print_header(get_template_path($this->plIcon),_($this->plDescription), - "\"\"". - LDAP::fix(get_object_info())); - } else { - $display= print_header(get_template_path($this->plIcon),_($this->plDescription)); - } - return($display); + // We do not display any headers right now. + if(1 || $this->skipHeader) return(""); } @@ -246,13 +254,13 @@ class management // Display ok, (apply) and cancel buttons $str.= "

\n"; - $str.= "\n"; + $str.= "\n"; $str.= " \n"; if($this->displayApplyBtn){ - $str.= "\n"; + $str.= "\n"; $str.= " \n"; } - $str.= "\n"; + $str.= "\n"; $str.= "

"; } return($str); @@ -370,6 +378,8 @@ class management if(isset($_POST['edit_cancel'])) $action['action'] = "cancel"; if(isset($_POST['delete_confirmed'])) $action['action'] = "removeConfirmed"; if(isset($_POST['delete_cancel'])) $action['action'] = "cancelDelete"; + if(isset($_POST['saveFilter'])) $action['action'] = "saveFilter"; + if(isset($_POST['cancelFilter'])) $action['action'] = "cancel"; // Detect Snapshot actions if(isset($_POST['CreateSnapshot'])) $action['action'] = "saveSnapshot"; @@ -433,7 +443,8 @@ class management * @param Array 'all' A combination of both 'action' and 'target'. */ function saveSnapshot($action="",$target=array(),$all=array()) - { + { + if(!is_object($this->dialogObject)) return; $this->dialogObject->save_object(); $msgs = $this->dialogObject->check(); if(count($msgs)){ @@ -568,10 +579,14 @@ class management if(empty($tabClass) || empty($tabType)){ // No tab type defined }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!"); + if (isset($this->config->data['TABS'][$tabType])) { + $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!"); + } else { + msg_dialog::display(_("Error"), sprintf(_("No tab declaration for '%s' found in your configuration file. Cannot create plugin instance!"), $tabType), ERROR_DIALOG); + } } } @@ -676,6 +691,28 @@ class management } + /*! \brief Save filter modifcations. + */ + protected function saveFilter() + { + if($this->dialogObject instanceOf userFilter){ + $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(); + + // Ask filter to reload information + $this->filter->reloadFilters(); + } + } + } + + /*! \brief Save object modifications and closes dialogs (returns to object listing). * - Calls '::check' to validate the given input. * - Calls '::save' to save back object modifications (e.g. to ldap). @@ -905,7 +942,36 @@ class management msg_dialog::display(_("Error"), $message, ERROR_DIALOG); } } + } + + function is_modal_dialog() + { + return(is_object($this->tabObject) || is_object($this->dialogObject)); + } + + + /*! \brief Forward command execution request + * to the correct method. + */ + function handle_post_events($mode, $addAttrs= array()) + { + if(!in_array($mode, array('add','remove','modify'))){ + trigger_error(sprintf("Invalid post event type given '%s'! Valid types are [add,modify,remove].", $mode)); + return; + } + switch ($mode){ + case "add": + plugin::callHook($this,"POSTCREATE", $addAttrs); + break; + case "modify": + plugin::callHook($this,"POSTMODIFY", $addAttrs); + break; + + case "remove": + plugin::callHook($this,"POSTREMOVE", $addAttrs); + break; + } } }