From 22750d9f66f263cbdcdc85f48b6d24b4f37e2623 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 15 May 2008 07:43:27 +0000 Subject: [PATCH] Updated locking for devices. -Fixed undefined index intro in remove.tpl -Fixed locking. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10902 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../mimetypes/class_mimetypeManagement.inc | 46 +++++++------ gosa-plugins/goto/admin/mimetypes/main.inc | 64 +++++++++---------- gosa-plugins/goto/admin/mimetypes/remove.tpl | 2 +- 3 files changed, 59 insertions(+), 53 deletions(-) diff --git a/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc b/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc index 037b24343..debe254dd 100644 --- a/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc +++ b/gosa-plugins/goto/admin/mimetypes/class_mimetypeManagement.inc @@ -132,7 +132,7 @@ 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/")); + "/^item_selected/","/^remove_multiple_mimetypes/","/^menu_action/")); $smarty = get_smarty(); // Smarty instance $s_action = ""; // Contains the action to proceed @@ -236,8 +236,7 @@ class mimetypeManagement extends plugin /* Cancel dialogs */ if (isset($_POST['edit_cancel'])){ - del_lock ($this->mimetabs->dn); - unset ($this->mimetabs); + $this->remove_lock(); $this->mimetabs= NULL; session::un_set('objectinfo'); } @@ -264,7 +263,7 @@ class mimetypeManagement extends plugin if (!isset($_POST['edit_apply'])){ /* Mime type has been saved successfully, remove lock from LDAP. */ if ($this->dn != "new"){ - del_lock ($this->dn); + $this->remove_lock(); } unset ($this->mimetabs); $this->mimetabs= NULL; @@ -323,21 +322,23 @@ class mimetypeManagement extends plugin if(count($ids)){ foreach($ids as $id){ - $dn = $this->mimetypes[$id]['dn']; - if (($user= get_lock($dn)) != ""){ - return(gen_locked_message ($user, $dn)); - } - $this->dns[$id] = $dn; + $this->dns[$id] = $this->mimetypes[$id]['dn']; + } + + /* Check locks */ + if ($user= get_multiple_locks($this->dns)){ + return(gen_locked_message($user,$this->dns)); } $dns_names = array(); foreach($this->dns as $dn){ - add_lock ($dn, $this->ui->dn); $dns_names[] = @LDAP::fix($dn); } + add_lock ($this->dns, $this->ui->dn); + /* Lock the current entry, so nobody will edit it during deletion */ - $smarty->assign("intro", msgPool::deleteInfo($dns_names,_("Mime type"))); + $smarty->assign("info", msgPool::deleteInfo($dns_names,_("Mime type"))); $smarty->assign("multiple", true); return($smarty->fetch(get_template_path('remove.tpl', TRUE))); } @@ -373,10 +374,11 @@ class mimetypeManagement extends plugin 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 */ - del_lock ($dn); - unset($this->dns[$key]); } + + /* Remove lock file after successfull deletion */ + $this->remove_lock(); + $this->dns = array(); } @@ -386,10 +388,8 @@ class mimetypeManagement extends plugin /* Remove lock */ if(isset($_POST['delete_multiple_mimetype_cancel'])){ - foreach($this->dns as $key => $dn){ - del_lock ($dn); - unset($this->dns[$key]); - } + $this->remove_lock(); + $this->dns = array(); } @@ -460,7 +460,7 @@ class mimetypeManagement extends plugin } /* Remove lock file after successfull deletion */ - del_lock ($this->dn); + $this->remove_lock(); } @@ -470,7 +470,7 @@ class mimetypeManagement extends plugin /* Delete mime type canceled? */ if (isset($_POST['delete_cancel'])){ - del_lock ($this->dn); + $this->remove_lock(); session::un_set('objectinfo'); } @@ -671,6 +671,12 @@ class mimetypeManagement extends plugin if (isset($this->mimetabs->dn)){ del_lock ($this->mimetabs->dn); } + if(isset($this->dn) && !empty($this->dn) && $this->dn != "new"){ + del_lock($this->dn); + } + if(isset($this->dns) && is_array($this->dns) && count($this->dns)){ + del_lock($this->dns); + } } function save_object() diff --git a/gosa-plugins/goto/admin/mimetypes/main.inc b/gosa-plugins/goto/admin/mimetypes/main.inc index 29870f130..a9a7b0b05 100644 --- a/gosa-plugins/goto/admin/mimetypes/main.inc +++ b/gosa-plugins/goto/admin/mimetypes/main.inc @@ -19,39 +19,39 @@ */ if ($remove_lock){ - if(session::is_set('MimeTypeManagement')){ - $MimeTypeManagement = session::get('MimeTypeManagement'); - $MimeTypeManagement->remove_lock(); - del_lock ($ui->dn); - session::un_set ('MimeTypeManagement'); - } + if(session::is_set('MimeTypeManagement')){ + $MimeTypeManagement = session::get('MimeTypeManagement'); + $MimeTypeManagement->remove_lock(); + session::un_set ('MimeTypeManagement'); + } } else { - /* Create MimeTypeManagement object on demand */ - if (!session::is_set('MimeTypeManagement') || (isset($_GET['reset']) && $_GET['reset'] == 1)){ - session::set('MimeTypeManagement',new mimetypeManagement ($config, $ui)); - } - - /* Get object */ - $MimeTypeManagement = session::get('MimeTypeManagement'); - $MimeTypeManagement->save_object(); - $output= $MimeTypeManagement->execute(); - - /* Page header*/ - if (session::is_set('objectinfo')){ - $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management"), "\"\" ".@LDAP::fix(session::get('objectinfo'))); - } else { - $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management")); - } - - /* Reset requested? */ - if (isset($_GET['reset']) && $_GET['reset'] == 1){ - del_lock ($ui->dn); - session::un_set ('MimeTypeManagement'); - } - - /* Show and save dialog */ - $display.= $output; - session::set('MimeTypeManagement',$MimeTypeManagement); + /* Create MimeTypeManagement object on demand */ + if (!session::is_set('MimeTypeManagement') || (isset($_GET['reset']) && $_GET['reset'] == 1)){ + session::set('MimeTypeManagement',new mimetypeManagement ($config, $ui)); + } + + /* Get object */ + $MimeTypeManagement = session::get('MimeTypeManagement'); + $MimeTypeManagement->save_object(); + $output= $MimeTypeManagement->execute(); + + /* Page header*/ + if (session::is_set('objectinfo')){ + $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management"), "\"\" ".@LDAP::fix(session::get('objectinfo'))); + } else { + $display= print_header(get_template_path('images/mimetypes.png'), _("Mimetype management")); + } + + /* Reset requested? */ + if (isset($_GET['reset']) && $_GET['reset'] == 1){ + del_lock ($ui->dn); + session::un_set ('MimeTypeManagement'); + } + + /* Show and save dialog */ + $display.= $output; + session::set('MimeTypeManagement',$MimeTypeManagement); } +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/gosa-plugins/goto/admin/mimetypes/remove.tpl b/gosa-plugins/goto/admin/mimetypes/remove.tpl index 68e79ad52..440fc2447 100644 --- a/gosa-plugins/goto/admin/mimetypes/remove.tpl +++ b/gosa-plugins/goto/admin/mimetypes/remove.tpl @@ -2,7 +2,7 @@  {t}Warning{/t}

- {$intro} + {$info} {t}This may be used by several groups. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}

-- 2.30.2