X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-core%2Finclude%2Fclass_management.inc;h=2e42c572eca2fd1fd97b342d2064e1a900a9775a;hb=226580d683c1bebd09e732b0ce8af02935fd7e31;hp=2769a57458d14dfc453cd63976f743640248fab0;hpb=c949624ae7233c3d1f39f0d4b8d1fc85105e7c86;p=gosa.git diff --git a/gosa-core/include/class_management.inc b/gosa-core/include/class_management.inc index 2769a5745..2e42c572e 100644 --- a/gosa-core/include/class_management.inc +++ b/gosa-core/include/class_management.inc @@ -118,7 +118,15 @@ class management $this->registerAction("restore", "restoreSnapshotDialog"); $this->registerAction("saveSnapshot","saveSnapshot"); $this->registerAction("restoreSnapshot","restoreSnapshot"); + $this->registerAction("removeSnapshotConfirmed","removeSnapshotConfirmed"); $this->registerAction("cancelSnapshot","closeDialogs"); + + $this->registerAction("config-filter","editFilter"); + $this->registerAction("saveFilter","saveFilter"); + $this->registerAction("cancelFilter","cancelFilter"); + + // To temporay disable the filter caching UNcomment this line. + #session::global_un_set(get_class($this)."_filter"); } /*! \brief Execute this plugin @@ -130,6 +138,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){ @@ -141,9 +151,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) @@ -180,11 +187,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(); @@ -236,21 +248,22 @@ class management // 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){ - $str.= "
- + $str.= " +
+
"; return($str); }else{ // 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); @@ -266,14 +279,21 @@ class management */ protected function removeEntryRequested($action="",$target=array(),$all=array()) { + // Close dialogs and remove locks for currently handled dns + $this->cancelEdit(); + $disallowed = array(); $this->dns = array(); @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$target,"Entry removel requested!"); // Check permissons for each target + $h = $this->getHeadpage(); + $oTypes = array_reverse($h->objectTypes); foreach($target as $dn){ - $acl = $this->ui->get_permissions($dn, $this->aclCategory."/".$this->aclPlugin); + $entry = $h->getEntry($dn); + $obj = $h->getObjectType($oTypes, $entry['objectClass']); + $acl = $this->ui->get_permissions($dn, $obj['category']."/".$obj['class']); if(preg_match("/d/",$acl)){ $this->dns[] = $dn; }else{ @@ -294,16 +314,28 @@ class management // Add locks $dns_names = array(); + $types = array(); + + // Build list of object -labels + foreach($h->objectTypes as $type){ + $map[$type['objectClass']]= $type['label']; + } + foreach($this->dns as $dn){ - $dns_names[] =LDAP::fix($dn); + $tmp = $h->getType($dn); + if(isset($map[$tmp])){ + $dns_names[LDAP::fix($dn)] = _($map[$tmp]); + }else{ + $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("info", msgPool::deleteInfo($dns_names)); $smarty->assign("multiple", true); - return($smarty->fetch(get_template_path('remove.tpl', TRUE))); + return($smarty->fetch(get_template_path('removeEntries.tpl'))); } } @@ -315,26 +347,34 @@ class management * @param Array 'all' A combination of both 'action' and 'target'. */ function removeEntryConfirmed($action="",$target=array(),$all=array(), - $altTabClass="",$altTabType="",$altAclCategory="") + $altTabClass="",$altTabType="", $altAclCategory="",$altAclPlugin="") { $tabType = $this->tabType; $tabClass = $this->tabClass; $aclCategory = $this->aclCategory; + $aclPlugin = $this->aclPlugin; if(!empty($altTabClass)) $tabClass = $altTabClass; if(!empty($altTabType)) $tabType = $altTabType; if(!empty($altAclCategory)) $aclCategory = $altAclCategory; + if(!empty($altAclPlugin)) $aclPlugin = $altAclPlugin; @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$target,"Entry removel confirmed!"); + // Check permissons for each target + $h = $this->getHeadpage(); + $oTypes = array_reverse($h->objectTypes); foreach($this->dns as $key => $dn){ + $entry = $h->getEntry($dn); + $obj = $h->getObjectType($oTypes, $entry['objectClass']); + $acl = $this->ui->get_permissions($dn, $obj['category']."/".$obj['class']); // Check permissions, are we allowed to remove this object? - $acl = $this->ui->get_permissions($dn, $this->aclCategory."/".$this->aclPlugin); if(preg_match("/d/",$acl)){ // Delete the object $this->dn = $dn; - $this->tabObject= new $tabClass($this->config,$this->config->data['TABS'][$tabType], $this->dn, $aclCategory, true, true); + $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 (); @@ -367,7 +407,10 @@ class management 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_snapshot_confirm'])) $action['action'] = "removeSnapshotConfirmed"; if(isset($_POST['delete_cancel'])) $action['action'] = "cancelDelete"; + if(isset($_POST['saveFilter'])) $action['action'] = "saveFilter"; + if(isset($_POST['cancelFilter'])) $action['action'] = "cancelFilter"; // Detect Snapshot actions if(isset($_POST['CreateSnapshot'])) $action['action'] = "saveSnapshot"; @@ -376,7 +419,7 @@ class management $once =TRUE; if(preg_match("/^RestoreSnapShot_/",$name) && $once){ $once = FALSE; - $entry = base64_decode(preg_replace("/^RestoreSnapShot_([^_]*)_[xy]$/i","\\1",$name)); + $entry = base64_decode(preg_replace("/^RestoreSnapShot_(.*)$/i","\\1",$name)); $action['action'] = "restoreSnapshot"; $action['targets'] = array($entry); } @@ -416,7 +459,7 @@ class management $this->dialogObject->parent = &$this; }else{ - msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to create a snapshot for %s."),$entry), + msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to create a snapshot for %s!"), bold($entry)), ERROR_DIALOG); } } @@ -463,7 +506,22 @@ class management @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), + msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to restore a snapshot for %s!"), bold($entry)), + ERROR_DIALOG); + } + } + + + /*! \brief Removes a snapshot object. + */ + function removeSnapshotConfirmed($action="",$target=array(),$all=array()) + { + $entry = $this->dialogObject->del_dn; + if(!empty($entry) && $this->ui->allow_snapshot_create($entry,$this->aclCategory)){ + $this->snapHandler->remove_snapshot($entry); + @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__,$entry,"Snaptshot removed!"); + }else{ + msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to remove a snapshot for %s!"), bold($entry)), ERROR_DIALOG); } } @@ -500,7 +558,7 @@ class management $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), + msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to restore a snapshot for %s!"), bold($entry)), ERROR_DIALOG); } }else{ @@ -514,7 +572,7 @@ class management $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), + msg_dialog::display(_("Permission"),sprintf(_("You are not allowed to restore a snapshot for %s!"), bold($entry)), ERROR_DIALOG); } } @@ -573,7 +631,7 @@ class management $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); + msg_dialog::display(_("Error"), sprintf(_("No tab definition for %s found in configuration file: cannot create plugin instance!"), bold($tabType)), ERROR_DIALOG); } } } @@ -632,7 +690,7 @@ class management set_object_info($this->dn); $user = get_lock($this->dn); if ($user != ""){ - return(gen_locked_message ($user, $this->dn,TRUE)); + return(gen_locked_message ($user, array($this->dn),TRUE)); } add_lock ($this->dn, $this->ui->dn); @@ -679,6 +737,39 @@ class management } + /*! \brief Close filter dialog + */ + protected function cancelFilter() + { + if($this->dialogObject instanceOf userFilter){ + $this->remove_lock(); + $this->closeDialogs(); + } + } + + + /*! \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). @@ -914,6 +1005,31 @@ class management { 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].", bold($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; + } + } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: