From d075a8c302c3b5b967bc70d7943e87f0f9c019a4 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 17 Jul 2008 13:43:32 +0000 Subject: [PATCH] Mimetypes -Added freeze handling git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11707 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../mimetypes/class_divListMimeTypes.inc | 22 ++- .../admin/mimetypes/class_mimetypeGeneric.inc | 140 +++++++++--------- .../mimetypes/class_mimetypeManagement.inc | 28 +++- .../goto/admin/mimetypes/tabs_mimetypes.inc | 11 +- 4 files changed, 123 insertions(+), 78 deletions(-) diff --git a/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc b/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc index 23c76196c..7c80b55ed 100644 --- a/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc +++ b/gosa-plugins/goto/admin/mimetypes/class_divListMimeTypes.inc @@ -164,6 +164,10 @@ class divListMimeTypes extends MultiSelectWindow foreach($list as $key => $val){ + /* Check FAI state + */ + $FAIstate = $val['FAIstate'][0]; + $ui = get_userinfo(); $acl = $ui->get_permissions($val['dn'],"mimetypes/mimetype"); $acl_all = $ui->has_complete_category_acls($val['dn'],"mimetypes") ; @@ -171,16 +175,28 @@ class divListMimeTypes extends MultiSelectWindow $action = ""; /* Add copy & cut functionality */ - $action.= $this->parent->get_copypaste_action($val['dn'],"mimetypes","mimetype"); + if(!preg_match("/freeze/i",$FAIstate)){ + $action.= $this->parent->get_copypaste_action($val['dn'],"mimetypes","mimetype"); + }else{ + $action.= " "; + $action.= " "; + } $action.= ""; /* Add snapshot icon */ - $action.= $this->parent->get_snapshot_action($val['dn'],$this->module); + if(!preg_match("/freeze/i",$FAIstate)){ + $action.= $this->parent->get_snapshot_action($val['dn'],$this->module); + }else{ + $action.= " "; + $action.= " "; + } /* Add delete button */ - if(preg_match("/d/",$acl)){ + if(preg_match("/freeze/i",$FAIstate)){ + $action .= "!"; + }elseif(preg_match("/d/",$acl)){ $action.= ""; }else{ diff --git a/gosa-plugins/goto/admin/mimetypes/class_mimetypeGeneric.inc b/gosa-plugins/goto/admin/mimetypes/class_mimetypeGeneric.inc index f5cb4d0aa..0e51158e6 100644 --- a/gosa-plugins/goto/admin/mimetypes/class_mimetypeGeneric.inc +++ b/gosa-plugins/goto/admin/mimetypes/class_mimetypeGeneric.inc @@ -37,6 +37,8 @@ class mimetype extends plugin var $DivApps = NULL; var $DivEApps = NULL; + var $FAIstate =""; + /* These vars will be copied too, if you use copy&paste mode */ var $CopyPasteVars = array("use_gotoMimeFilePattern","use_gotoMimeApplication","use_gotoMimeEmbeddedApplication","iconData", "gotoMimeLeftClickAction_I","gotoMimeLeftClickAction_E","gotoMimeLeftClickAction_Q","use_gotoMimeIcon"); @@ -127,7 +129,7 @@ class mimetype extends plugin $this->base= dn2base($ui->dn); } } else { - $this->base= preg_replace ("/^[^,]+,[^,]+,/", "", $this->dn); + $this->base= preg_replace ("/^.*,".normalizePreg(get_ou("mimetypeou"))."/", "", $this->dn); } /* Get icon data */ @@ -156,13 +158,13 @@ class mimetype extends plugin $tmp = $this->plInfo(); foreach($tmp['plProvidedAcls'] as $name => $translation){ - $smarty->assign($name."ACL",$this->getacl($name)); + $smarty->assign($name."ACL",$this->getacl($name,preg_match("/freeze/i",$this->FAIstate))); } /* Base select dialog */ $once = true; foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once){ + if(preg_match("/^chooseBase/",$name) && $once && !preg_match("/freeze/i",$this->FAIstate)){ $once = false; $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); $this->dialog->setCurrentBase($this->base); @@ -205,81 +207,83 @@ class mimetype extends plugin $once = true; /* Walk through posts and try to find some commands for us. */ - foreach($_POST as $name => $value){ + if(!preg_match("/freeze/i",$this->FAIstate)){ + foreach($_POST as $name => $value){ - /* Walk through possible commands */ - foreach($posts as $regex => $action){ + /* Walk through possible commands */ + foreach($posts as $regex => $action){ - /* Check if there is a command posted */ - if(preg_match($regex,$name) && $once){ - $once = false; + /* Check if there is a command posted */ + if(preg_match($regex,$name) && $once){ + $once = false; - /* Get action vars */ - $func = $action['Func']; // Get function name - $attr = $action['Attr']; // Get attribute name + /* Get action vars */ + $func = $action['Func']; // Get function name + $attr = $action['Attr']; // Get attribute name - /* Get entry id */ - $s_entry = preg_replace($regex,"",$name); - $s_entry = preg_replace("/_[xy]$/","",$s_entry); + /* Get entry id */ + $s_entry = preg_replace($regex,"",$name); + $s_entry = preg_replace("/_[xy]$/","",$s_entry); - /* Execute a command with the given attribute and entry - e.g. $this->gotoMimeFilePattern = $this->ArrayUp(3,$this->gotoMimeFilePattern) */ - if($this->acl_is_writeable($attr)){ - $this->$attr= $this->$func($s_entry,$this->$attr,true); + /* Execute a command with the given attribute and entry + e.g. $this->gotoMimeFilePattern = $this->ArrayUp(3,$this->gotoMimeFilePattern) */ + if($this->acl_is_writeable($attr)){ + $this->$attr= $this->$func($s_entry,$this->$attr,true); + } } } } - } - /* Set a new icon was requested */ - if(isset($_POST['update_icon']) && (isset($_FILES['picture_file']['name']))){ - $this->set_new_picture($_FILES['picture_file']['tmp_name']); - } - - /* Add gotoMimeFilePattern */ - if(isset($_POST['AddNewFilePattern']) && isset($_POST['NewFilePattern'])){ - if($this->acl_is_writeable("gotoMimeFilePattern")){ - $str = $_POST['NewFilePattern']; - if(!empty($str)){ - $this->use_gotoMimeFilePattern[] = $str; - } - } - } - - /* Add gotoMimeFilePattern */ - if(isset($_POST['AddNewApplication']) && - (isset($_POST['NewApplication']) || isset($_POST['NewApplicationSelect']))){ - if($this->acl_is_writeable("gotoMimeApplication")){ - $str = ""; - if(isset($_POST['NewApplicationSelect']) && !empty($_POST['NewApplicationSelect'])){ - $str = get_post("NewApplicationSelect"); - } - if(isset($_POST['NewApplication']) && !empty($_POST['NewApplication'])){ - $str = get_post("NewApplication"); - } - if(!empty($str) && !in_array($str,$this->use_gotoMimeApplication)){ - $this->use_gotoMimeApplication[] = $str; - } + /* Set a new icon was requested */ + if(isset($_POST['update_icon']) && (isset($_FILES['picture_file']['name']))){ + $this->set_new_picture($_FILES['picture_file']['tmp_name']); } - } - /* Add embedded application - * - From input or from select box - */ - if(isset($_POST['AddNewEmbeddedApplication']) && - (isset($_POST['NewEmbeddedApplication']) || isset($_POST['NewEmbeddedApplicationSelect']))){ - if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){ - $str = ""; - if(isset($_POST['NewEmbeddedApplicationSelect']) && !empty($_POST['NewEmbeddedApplicationSelect'])){ - $str = get_post('NewEmbeddedApplicationSelect'); + /* Add gotoMimeFilePattern */ + if(isset($_POST['AddNewFilePattern']) && isset($_POST['NewFilePattern'])){ + if($this->acl_is_writeable("gotoMimeFilePattern")){ + $str = $_POST['NewFilePattern']; + if(!empty($str)){ + $this->use_gotoMimeFilePattern[] = $str; + } } - if(isset($_POST['NewEmbeddedApplication']) && !empty($_POST['NewEmbeddedApplication'])){ - $str = get_post('NewEmbeddedApplication'); + } + + /* Add gotoMimeFilePattern */ + if(isset($_POST['AddNewApplication']) && + (isset($_POST['NewApplication']) || isset($_POST['NewApplicationSelect']))){ + if($this->acl_is_writeable("gotoMimeApplication")){ + $str = ""; + if(isset($_POST['NewApplicationSelect']) && !empty($_POST['NewApplicationSelect'])){ + $str = get_post("NewApplicationSelect"); + } + if(isset($_POST['NewApplication']) && !empty($_POST['NewApplication'])){ + $str = get_post("NewApplication"); + } + if(!empty($str) && !in_array($str,$this->use_gotoMimeApplication)){ + $this->use_gotoMimeApplication[] = $str; + } } - if(!empty($str) && !in_array($str,$this->use_gotoMimeEmbeddedApplication)){ - $this->use_gotoMimeEmbeddedApplication[] = $str; + } + + /* Add embedded application + * - From input or from select box + */ + if(isset($_POST['AddNewEmbeddedApplication']) && + (isset($_POST['NewEmbeddedApplication']) || isset($_POST['NewEmbeddedApplicationSelect']))){ + if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){ + $str = ""; + if(isset($_POST['NewEmbeddedApplicationSelect']) && !empty($_POST['NewEmbeddedApplicationSelect'])){ + $str = get_post('NewEmbeddedApplicationSelect'); + } + if(isset($_POST['NewEmbeddedApplication']) && !empty($_POST['NewEmbeddedApplication'])){ + $str = get_post('NewEmbeddedApplication'); + } + if(!empty($str) && !in_array($str,$this->use_gotoMimeEmbeddedApplication)){ + $this->use_gotoMimeEmbeddedApplication[] = $str; + } } - } + } } /* Create divlists */ @@ -291,7 +295,7 @@ class mimetype extends plugin $DivEApps -> SetHeight(100); - if($this->acl_is_writeable("gotoMimeFilePattern")){ + if($this->acl_is_writeable("gotoMimeFilePattern") && !preg_match("/freeze/i",$this->FAIstate)){ $Pattern_Actions= "     "; @@ -299,7 +303,7 @@ class mimetype extends plugin $Pattern_Actions= ""; } - if($this->acl_is_writeable("gotoMimeApplication")){ + if($this->acl_is_writeable("gotoMimeApplication") && !preg_match("/freeze/i",$this->FAIstate)){ $Apps_Actions = "     "; @@ -307,7 +311,7 @@ class mimetype extends plugin $Apps_Actions= ""; } - if($this->acl_is_writeable("gotoMimeEmbeddedApplication")){ + if($this->acl_is_writeable("gotoMimeEmbeddedApplication") && !preg_match("/freeze/i",$this->FAIstate)){ $EApps_Actions = "     "; @@ -369,7 +373,7 @@ class mimetype extends plugin function save_object() { - if(isset($_POST['MimeGeneric'])){ + if(isset($_POST['MimeGeneric']) && !preg_match("/freeze/i",$this->FAIstate)){ /* Create a base backup and reset the base directly after calling plugin::save_object(); diff --git a/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc b/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc index c8f4adb73..080c596a2 100644 --- a/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc +++ b/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc @@ -306,6 +306,9 @@ class mimetypeManagement extends plugin /* Register mimetabs to trigger edit dialog */ $this->mimetabs= new mimetabs($this->config,$this->config->data['TABS']['MIMETABS'], $this->dn,"mimetypes"); + if($this->IsReleaseManagementActivated()){ + $this->mimetabs->set_FAIstate($this->mimetypes[$s_entry]['FAIstate'][0]); + } $this->mimetabs->parent = &$this; $this->mimetabs->set_acl_base($this->dn); session::set('objectinfo',$this->dn); @@ -496,12 +499,16 @@ 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"; - if ($this->dn != "new"){ - $display.= "\n"; + + if(isset($this->mimetabs->FAIstate) && !preg_match("/freeze/i",$this->mimetabs->FAIstate)){ + $display.= "\n"; $display.= " \n"; + if ($this->dn != "new"){ + $display.= "\n"; + $display.= " \n"; + } } + $display.= "\n"; $display.= "

"; } @@ -568,15 +575,24 @@ class mimetypeManagement extends plugin $SubSearch= FALSE; } + /* Add FAIstate to the search attributes */ + $search_attrs = array("cn","description","dn","objectClass"); + if($this->IsReleaseManagementActivated()) { + $search_attrs[] = "FAIstate"; + } + if($SubSearch){ - $res= get_sub_list($Filter, "mimetypes",get_ou("mimeou"), $use_base, array("cn","description","dn","objectClass"), $Flags); + $res= get_sub_list($Filter, "mimetypes",get_ou("mimeou"), $use_base, $search_attrs, $Flags); }else{ - $res= get_list($Filter, "mimetypes",$use_base, array("cn","description","dn","objectClass"), $Flags); + $res= get_list($Filter, "mimetypes",$use_base, $search_attrs, $Flags); } $tmp2 = array(); foreach ($res as $val){ + if(!isset($val['FAIstate'])){ + $val['FAIstate'][0] = ""; + } $tmp[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']]=$val; $tmp2[strtolower($val['cn'][0]).$val['cn'][0].$val['dn']] = strtolower($val['cn'][0]).$val['cn'][0].$val['dn']; } diff --git a/gosa-plugins/goto/admin/mimetypes/tabs_mimetypes.inc b/gosa-plugins/goto/admin/mimetypes/tabs_mimetypes.inc index a2fc2bb40..45a8f99dd 100644 --- a/gosa-plugins/goto/admin/mimetypes/tabs_mimetypes.inc +++ b/gosa-plugins/goto/admin/mimetypes/tabs_mimetypes.inc @@ -2,7 +2,8 @@ class mimetabs extends tabs { - var $parent = FALSE; + var $parent = FALSE; + var $FAIstate = ""; function mimetabs($config, $data, $dn,$category) { @@ -12,6 +13,14 @@ class mimetabs extends tabs $this->addSpecialTabs(); } + function set_FAIstate($state) + { + $this->FAIstate = $state; + foreach($this->by_name as $name => $desc){ + $this->by_object[$name]->FAIstate = $state; + } + } + function save($ignore_account= FALSE) { $baseobject= $this->by_object['mimetype']; -- 2.30.2