diff --git a/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc b/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc
index 7b66b9a662325c67d95bf3f42974053af3fae12d..54a04b55b66633741da4bdc457ae13abe3f4b46d 100644 (file)
/* Dialog attributes */
var $ui = NULL;
var $DivListMimeTypes = NULL;
/* Dialog attributes */
var $ui = NULL;
var $DivListMimeTypes = NULL;
- var $enableReleaseManagement = false;
var $mimetabs = NULL;
var $snapDialog = NULL;
var $CopyPasteHandler = NULL;
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)
function mimetypeManagement (&$config, &$ui)
$this->DivListMimeTypes->DisableCheckBox("SubSearch");
}
$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 */
}
/* Get all releases */
- function getReleases($base)
+ function getReleases()
{
$ldap = $this->config->get_ldap_link();
{
$ldap = $this->config->get_ldap_link();
- $dn = get_ou('mimetypeou').$base;
$ret = array();
$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()){
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){
$tmp = array_reverse( split("ou=",$str));
$str = "";
foreach($tmp as $val){
return($ret);
}
return($ret);
}
+
function execute()
{
/* Call parent execute */
function execute()
{
/* Call parent execute */
/* 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 */
/* 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
$smarty = get_smarty(); // Smarty instance
$s_action = ""; // Contains the action to proceed
$s_entry = preg_replace("/_.$/","",$s_entry);
$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";
/* handle C&P from layers menu */
if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
$s_action = "copy_multiple";
$s_action = "del_multiple";
}
$s_action = "del_multiple";
}
+
/****************
Copy & Paste handling
****************/
/****************
Copy & Paste handling
****************/
/* New mime type? */
$ui = get_userinfo();
/* 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
if (($s_action=="new") && preg_match("/c/",$acl)){
/* By default we set 'dn' to 'new', all relevant plugins will
/* Create new usertab object */
$this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes");
/* 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);
}
}
if (count($message) == 0){
/* Save data data to ldap */
if (count($message) == 0){
/* Save data data to ldap */
- $this->mimetabs->set_release($this->DivListMimeTypes->selectedRelease);
$this->mimetabs->save();
if (!isset($_POST['edit_apply'])){
$this->mimetabs->save();
if (!isset($_POST['edit_apply'])){
} else {
/* Ok. There seem to be errors regarding to the tab data,
show message and continue as usual. */
} 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);
}
}
}
}
above dialog */
add_lock ($this->dn, $this->ui->dn);
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");
/* 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);
}
$this->mimetabs->set_acl_base($this->dn);
session::set('objectinfo',$this->dn);
}
$this->dns[$id] = $dn;
}
$this->dns[$id] = $dn;
}
- $dns_names = "<br><pre>";
+ $dns_names = array();
foreach($this->dns as $dn){
add_lock ($dn, $this->ui->dn);
foreach($this->dns as $dn){
add_lock ($dn, $this->ui->dn);
- $dns_names .= $dn."\n";
+ $dns_names[] = @LDAP::fix($dn);
}
}
- $dns_names .="</pre>";
/* Lock the current entry, so nobody will edit it during deletion */
/* 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)));
}
}
$smarty->assign("multiple", true);
return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
}
}
-
-
/********************
Delete MULTIPLE entries confirmed
********************/
/********************
Delete MULTIPLE entries confirmed
********************/
/* Delete request is permitted, perform LDAP action */
$this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $dn,"mimetypes");
/* 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);
$this->mimetabs->set_acl_base($dn);
$this->mimetabs->delete ();
unset ($this->mimetabs);
} else {
/* Normally this shouldn't be reached, send some extra
logs to notify the administrator */
} 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 */
new log("security","mimetypes/".get_class($this),$dn,array(),"Tried to trick deletion.");
}
/* Remove lock file after successfull deletion */
/* Lock the current entry, so nobody will edit it during deletion */
add_lock ($this->dn, $this->ui->dn);
$smarty= get_smarty();
/* 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. */
$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);
}
}
}
}
/* Delete request is permitted, perform LDAP action */
$this->mimetabs= new mimetabs($this->config, $this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes");
/* 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);
$this->mimetabs->set_acl_base($this->dn);
$this->mimetabs->delete ();
unset ($this->mimetabs);
/* Normally this shouldn't be reached, send some extra
logs to notify the administrator */
/* 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.");
}
new log("security","mimetypes/".get_class($this),$dn,array(),"Tried to trick deletion.");
}
/* Don't show buttons if tab dialog requests this */
if (!$this->mimetabs->by_object[$this->mimetabs->current]->dialog){
$display.= "<p style=\"text-align:right\">\n";
/* Don't show buttons if tab dialog requests this */
if (!$this->mimetabs->by_object[$this->mimetabs->current]->dialog){
$display.= "<p style=\"text-align:right\">\n";
- $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\n";
+ $display.= "<input type=\"submit\" name=\"edit_finish\" style=\"width:80px\" value=\"".msgPool::okButton()."\">\n";
$display.= " \n";
if ($this->dn != "new"){
$display.= " \n";
if ($this->dn != "new"){
- $display.= "<input type=submit name=\"edit_apply\" value=\""._("Apply")."\">\n";
+ $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
$display.= " \n";
}
$display.= " \n";
}
- $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+ $display.= "<input type=\"submit\" name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
$display.= "</p>";
}
return ($display);
$display.= "</p>";
}
return ($display);
Dialog display
****************/
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);
}
if($str = $this->showSnapshotDialog($base,$this->get_used_snapshot_bases())){
return($str);
}
/* Display dialog with system list */
$this->DivListMimeTypes->parent = $this;
$this->DivListMimeTypes->execute();
/* 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());
$this->reload();
$this->DivListMimeTypes->setEntries($this->mimetypes);
return($this->DivListMimeTypes->Draw());
/* Return departments, that will be included within snapshot detection */
function get_used_snapshot_bases()
{
/* 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 */
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();
$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){
if($SubSearch){
- $Flags |= GL_SUBSEARCH;
+ $res= get_sub_list($Filter, "mimetypes",get_ou("mimeou"), $use_base, array("cn","description","dn","objectClass"), $Flags);
}else{
}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;
$tmp2 = array();
foreach ($res as $val){
$tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val;
reset ($this->mimetypes);
}
reset ($this->mimetypes);
}
+
function remove_from_parent()
{
/* Optionally execute a command after we're done */
function remove_from_parent()
{
/* Optionally execute a command after we're done */
/* Cleanup object queue */
$this->CopyPasteHandler->cleanup_queue();
/* 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");
}
$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();
/* 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){
/* Add new entries to CP queue */
foreach($this->list_get_selected_items() as $id){
if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
/* Get dialog */
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();
$data = $this->CopyPasteHandler->execute();
- $this->CopyPasteHandler->SetVar("base",$this->DivListMimeTypes->selectedBase);
/* Return dialog data */
if(!empty($data)){
/* Return dialog data */
if(!empty($data)){
}
/* Automatically disable status for pasting */
}
/* 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("");
}
}
}
}
}
}
- function save_object() {
+ function save_object()
+ {
$this->DivListMimeTypes->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 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:
function password_change_needed() {}
}
// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: