X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-plugins%2Fgoto%2Fadmin%2Fmimetypes%2Fclass_mimetypeManagement.inc;h=54a04b55b66633741da4bdc457ae13abe3f4b46d;hb=eecd84a0e6cd439d6c5d1b0c4b80cf343cbcea2b;hp=7b66b9a662325c67d95bf3f42974053af3fae12d;hpb=3dea505b63ac7a75ae4c405c759b5ae271237a53;p=gosa.git
diff --git a/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc b/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc
index 7b66b9a66..54a04b55b 100644
--- a/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc
+++ b/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc
@@ -27,11 +27,25 @@ class mimetypeManagement extends plugin
/* Dialog attributes */
var $ui = NULL;
var $DivListMimeTypes = NULL;
- var $enableReleaseManagement = false;
var $mimetabs = NULL;
var $snapDialog = NULL;
var $CopyPasteHandler = NULL;
- var $start_pasting_copied_objects = FALSE;
+ var $start_pasting_copied_objects = FALSE;
+ var $enableReleaseManagement = false;
+
+ var $mime_base = "";
+ var $mime_release = "";
+
+
+ function IsReleaseManagementActivated()
+ {
+ /* Check if we should enable the release selection */
+ $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs'));
+ if(!empty($tmp)){
+ return(true);
+ }
+ return(false);
+ }
function mimetypeManagement (&$config, &$ui)
@@ -57,22 +71,38 @@ class mimetypeManagement extends plugin
$this->DivListMimeTypes->DisableCheckBox("SubSearch");
}
+ /* Set default release */
+ if(!$this->IsReleaseManagementActivated()){
+ $this->mime_base = get_ou("mimetypeou").$this->config->current['BASE'];
+ if(!session::is_set("mime_filter")){
+ session::set("mime_filter",array("mime_base" => $this->mime_base));
+ }
+ $mime_filter = session::get("mime_filter");
+ $this->mime_base = $mime_filter['mime_base'];
+ }else{
+ $this->mime_base = get_ou("mimetypeou").$this->config->current['BASE'];
+ if(!session::is_set("mime_filter")){
+ session::set("mime_filter",array("mime_base" => $this->mime_base,"mime_release" => $this->mime_base));
+ }
+ $mime_filter = session::get("mime_filter");
+ $this->mime_base = $mime_filter['mime_base'];
+ $this->mime_release = $mime_filter['mime_release'];
+ }
}
/* Get all releases */
- function getReleases($base)
+ function getReleases()
{
$ldap = $this->config->get_ldap_link();
- $dn = get_ou('mimetypeou').$base;
$ret = array();
- $ret [get_ou('mimetypeou').$base] = "/";
+ $ret [$this->mime_base] = "/";
- $ldap->cd($dn);
- $ldap->search("objectClass=organizationalUnit",array("ou"));
+ $ldap->cd($this->mime_base);
+ $ldap->search("(&(objectClass=FAIbranch)(objectClass=organizationalUnit))",array("ou"));
while($attrs = $ldap->fetch()){
- $str = str_replace($dn,"",$attrs['dn']);
+ $str = str_replace($this->mime_base,"",$attrs['dn']);
$tmp = array_reverse( split("ou=",$str));
$str = "";
foreach($tmp as $val){
@@ -88,6 +118,7 @@ class mimetypeManagement extends plugin
return($ret);
}
+
function execute()
{
/* Call parent execute */
@@ -100,7 +131,8 @@ class mimetypeManagement extends plugin
/* These vars will be stored if you try to open a locked mime,
to be able to perform your last requests after showing a warning message */
- session::set('LOCK_VARS_TO_USE',array("/^act$/","/^id$/","/^mime_edit_/","/^mime_del_/","/^item_selected/","/^remove_multiple_mimetypes/"));
+ session::set('LOCK_VARS_TO_USE',array("/^act$/","/^id$/","/^mime_edit_/","/^mime_del_/",
+ "/^item_selected/","/^remove_multiple_mimetypes/"));
$smarty = get_smarty(); // Smarty instance
$s_action = ""; // Contains the action to proceed
@@ -145,8 +177,6 @@ class mimetypeManagement extends plugin
$s_entry = preg_replace("/_.$/","",$s_entry);
-
-
/* handle C&P from layers menu */
if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
$s_action = "copy_multiple";
@@ -168,6 +198,7 @@ class mimetypeManagement extends plugin
$s_action = "del_multiple";
}
+
/****************
Copy & Paste handling
****************/
@@ -185,7 +216,7 @@ class mimetypeManagement extends plugin
/* New mime type? */
$ui = get_userinfo();
- $acl = $ui->get_permissions($this->DivListMimeTypes->selectedBase,"mimetypes/mimetype");
+ $acl = $ui->get_permissions($this->mime_base,"mimetypes/mimetype");
if (($s_action=="new") && preg_match("/c/",$acl)){
/* By default we set 'dn' to 'new', all relevant plugins will
@@ -194,7 +225,8 @@ class mimetypeManagement extends plugin
/* Create new usertab object */
$this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes");
- $this->mimetabs->set_acl_base($this->DivListMimeTypes->selectedBase);
+ $this->mimetabs->parent = &$this;
+ $this->mimetabs->set_acl_base($this->mime_base);
}
@@ -227,7 +259,6 @@ class mimetypeManagement extends plugin
if (count($message) == 0){
/* Save data data to ldap */
- $this->mimetabs->set_release($this->DivListMimeTypes->selectedRelease);
$this->mimetabs->save();
if (!isset($_POST['edit_apply'])){
@@ -242,7 +273,7 @@ class mimetypeManagement extends plugin
} else {
/* Ok. There seem to be errors regarding to the tab data,
show message and continue as usual. */
- msgDialog::displayChecks($message);
+ msg_dialog::displayChecks($message);
}
}
@@ -267,9 +298,9 @@ class mimetypeManagement extends plugin
above dialog */
add_lock ($this->dn, $this->ui->dn);
-
/* Register mimetabs to trigger edit dialog */
$this->mimetabs= new mimetabs($this->config,$this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes");
+ $this->mimetabs->parent = &$this;
$this->mimetabs->set_acl_base($this->dn);
session::set('objectinfo',$this->dn);
}
@@ -293,27 +324,20 @@ class mimetypeManagement extends plugin
$this->dns[$id] = $dn;
}
- $dns_names = "
"; + $dns_names = array(); foreach($this->dns as $dn){ add_lock ($dn, $this->ui->dn); - $dns_names .= $dn."\n"; + $dns_names[] = @LDAP::fix($dn); } - $dns_names .=""; /* Lock the current entry, so nobody will edit it during deletion */ - if (count($this->dns) == 1){ - $smarty->assign("intro", sprintf(_("You're about to delete the following entry %s"), @LDAP::fix($dns_names))); - } else { - $smarty->assign("intro", sprintf(_("You're about to delete the following entries %s"), @LDAP::fix($dns_names))); - } + $smarty->assign("info", msgPool::deleteInfo($dns_names,_("Mime type"))); $smarty->assign("multiple", true); return($smarty->fetch(get_template_path('remove.tpl', TRUE))); } } - - /******************** Delete MULTIPLE entries confirmed ********************/ @@ -331,6 +355,7 @@ class mimetypeManagement extends plugin /* Delete request is permitted, perform LDAP action */ $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $dn,"mimetypes"); + $this->mimetabs->parent = &$this; $this->mimetabs->set_acl_base($dn); $this->mimetabs->delete (); unset ($this->mimetabs); @@ -339,7 +364,7 @@ class mimetypeManagement extends plugin } else { /* Normally this shouldn't be reached, send some extra logs to notify the administrator */ - print_red (_("You are not allowed to delete this mime type!")); + msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG); new log("security","mimetypes/".get_class($this),$dn,array(),"Tried to trick deletion."); } /* Remove lock file after successfull deletion */ @@ -387,14 +412,14 @@ class mimetypeManagement extends plugin /* Lock the current entry, so nobody will edit it during deletion */ add_lock ($this->dn, $this->ui->dn); $smarty= get_smarty(); - $smarty->assign("intro", sprintf(_("You're about to delete the mime type '%s'."), @LDAP::fix($this->dn))); + $smarty->assign("info", msgPool::deleteInfo(@LDAP::fix($this->dn),_("Mime type"))); $smarty->assign("multiple", false); return($smarty->fetch (get_template_path('remove.tpl', TRUE))); } else { /* Obviously the user isn't allowed to delete. Show message and clean session. */ - print_red (_("You are not allowed to delete this mime type!")); + msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG); } } @@ -414,6 +439,7 @@ class mimetypeManagement extends plugin /* Delete request is permitted, perform LDAP action */ $this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes"); + $this->mimetabs->parent = &$this; $this->mimetabs->set_acl_base($this->dn); $this->mimetabs->delete (); unset ($this->mimetabs); @@ -423,7 +449,7 @@ class mimetypeManagement extends plugin /* Normally this shouldn't be reached, send some extra logs to notify the administrator */ - print_red (_("You are not allowed to delete this mime type!")); + msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG); new log("security","mimetypes/".get_class($this),$dn,array(),"Tried to trick deletion."); } @@ -449,13 +475,13 @@ class mimetypeManagement extends plugin /* Don't show buttons if tab dialog requests this */ if (!$this->mimetabs->by_object[$this->mimetabs->current]->dialog){ $display.= "
\n"; - $display.= "\n"; + $display.= "\n"; $display.= " \n"; if ($this->dn != "new"){ - $display.= "\n"; + $display.= "\n"; $display.= " \n"; } - $display.= "\n"; + $display.= "\n"; $display.= "
"; } return ($display); @@ -466,8 +492,12 @@ class mimetypeManagement extends plugin Dialog display ****************/ - /* Check if there is a snapshot dialog open */ - $base = $this->DivListMimeTypes->selectedBase; + /* Check if there is a snapshot dialog open */ + if($this->IsReleaseManagementActivated()){ + $base = $this->mime_release; + }else{ + $base = $this->mime_base; + } if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){ return($str); } @@ -475,7 +505,9 @@ class mimetypeManagement extends plugin /* Display dialog with system list */ $this->DivListMimeTypes->parent = $this; $this->DivListMimeTypes->execute(); - $this->DivListMimeTypes->AddDepartments($this->DivListMimeTypes->selectedBase,3,1); + if(!$this->IsReleaseManagementActivated()){ + $this->DivListMimeTypes->AddDepartments($this->DivListMimeTypes->selectedBase,3,1); + } $this->reload(); $this->DivListMimeTypes->setEntries($this->mimetypes); return($this->DivListMimeTypes->Draw()); @@ -485,48 +517,43 @@ class mimetypeManagement extends plugin /* Return departments, that will be included within snapshot detection */ function get_used_snapshot_bases() { - return(array($this->DivListMimeTypes->selectedRelease)); + if($this->IsReleaseManagementActivated()){ + return(array($this->mime_release)); + }else{ + return(array($this->mime_base)); + } } - function reload() { $this->mimetypes= array(); /* Set base for all searches */ - $base = $this->DivListMimeTypes->selectedBase; - $release = $this->DivListMimeTypes->selectedRelease; + $base = $this->mime_base; $Regex = $this->DivListMimeTypes->Regex; $SubSearch = $this->DivListMimeTypes->SubSearch; $Flags = GL_NONE | GL_SIZELIMIT; $Filter = "(&(|(cn=".$Regex.")(description=".$Regex."))(objectClass=gotoMimeType))"; $tmp = array(); - $Releases = $this->getReleases($base); - - /* If release management is enabled, use release as base. */ - if(!$this->enableReleaseManagement){ - $use_base = $base; - }else{ - if(isset($Releases[$release])){ - $use_base = $release; - }else{ - $use_base = $base; + if(!$this->IsReleaseManagementActivated()){ + $use_base = $this->mime_base; + if($SubSearch){ + $use_base = preg_replace("/^".normalizePreg(get_ou("mimeou"))."/","",$use_base); } + }else{ + $use_base = $this->mime_release; + $SubSearch= FALSE; } - /* In case of subsearch, add the subsearch flag */ if($SubSearch){ - $Flags |= GL_SUBSEARCH; + $res= get_sub_list($Filter, "mimetypes",get_ou("mimeou"), $use_base, array("cn","description","dn","objectClass"), $Flags); }else{ - if(!$this->enableReleaseManagement){ - $use_base = get_ou('mimetypeou').$use_base; - } + $res= get_list($Filter, "mimetypes",$use_base, array("cn","description","dn","objectClass"), $Flags); } - - /* Get results and create index */ - $res= get_sub_list($Filter, "mimetypes",get_ou('mimetypeou'), $use_base, array("cn","description","dn","objectClass"), $Flags); + + $tmp2 = array(); foreach ($res as $val){ $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; @@ -542,6 +569,7 @@ class mimetypeManagement extends plugin reset ($this->mimetypes); } + function remove_from_parent() { /* Optionally execute a command after we're done */ @@ -561,17 +589,16 @@ class mimetypeManagement extends plugin /* Cleanup object queue */ $this->CopyPasteHandler->cleanup_queue(); - $this->start_pasting_copied_objects = FALSE; $dn = $this->mimetypes[$s_entry]['dn']; $this->CopyPasteHandler->add_to_queue($dn,$s_action,"mimetabs","MIMETABS","mimetypes"); } + /* Add entries to queue */ if($s_action == "copy_multiple" || $s_action == "cut_multiple"){ /* Cleanup object queue */ $this->CopyPasteHandler->cleanup_queue(); - $this->start_pasting_copied_objects = FALSE; /* Add new entries to CP queue */ foreach($this->list_get_selected_items() as $id){ @@ -595,8 +622,9 @@ class mimetypeManagement extends plugin if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){ /* Get dialog */ + $this->CopyPasteHandler->SetVar("base",preg_replace("/^".normalizePreg(get_ou("mimetypeou"))."/","",$this->mime_base)); + $this->CopyPasteHandler->SetVar("parent",&$this); $data = $this->CopyPasteHandler->execute(); - $this->CopyPasteHandler->SetVar("base",$this->DivListMimeTypes->selectedBase); /* Return dialog data */ if(!empty($data)){ @@ -605,22 +633,10 @@ class mimetypeManagement extends plugin } /* Automatically disable status for pasting */ - #if(!$this->CopyPasteHandler->entries_queued()){ - # $this->start_pasting_copied_objects = FALSE; - #} - return(""); - } - - - /* Check if the release management is activated. */ - function IsReleaseManagementActivated() - { - /* Check if we should enable the release selection */ - $tmp = $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp)){ - return(true); + if(!$this->CopyPasteHandler->entries_queued()){ + $this->start_pasting_copied_objects = FALSE; } - return(false); + return(""); } @@ -651,12 +667,33 @@ class mimetypeManagement extends plugin } } - function save_object() { + function save_object() + { $this->DivListMimeTypes->save_object(); + if(is_object($this->CopyPasteHandler)){ + $this->CopyPasteHandler->save_object(); + } + + if($this->IsReleaseManagementActivated() && isset($_POST['mime_release'])){ + $sel_rel = get_post('mime_release'); + $releases = array_flip($this->getReleases()); + if(isset($releases[$sel_rel])){ + $this->mime_release = $releases[$sel_rel]; + } + $mime_filter = session::get("mime_filter"); + $mime_filter['mime_release'] = $this->mime_release; + session::set("mime_filter",$mime_filter); + }elseif(!$this->IsReleaseManagementActivated()){ + $this->mime_base = get_ou("mimetypeou").$this->DivListMimeTypes->selectedBase; + $mime_filter = session::get("mime_filter"); + $mime_filter['mime_base'] = $this->mime_base; + session::set("mime_filter",$mime_filter); + } } + function check() {} - function adapt_from_template($dn) {} + function adapt_from_template($dn, $skip= array()) {} function password_change_needed() {} } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: