From 0b472d97f334babed107e435362211b92f0da6b2 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 5 Dec 2007 11:03:30 +0000 Subject: [PATCH] Added CSN check to plugin - Makes more sense git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8010 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_plugin.inc | 36 ++++++++++++++++++++++++++++++++++++ include/class_tabs.inc | 1 - 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/include/class_plugin.inc b/include/class_plugin.inc index b71e576ca..c7b2346e5 100644 --- a/include/class_plugin.inc +++ b/include/class_plugin.inc @@ -118,6 +118,9 @@ class plugin /* This can be set to render the tabulators in another stylesheet */ var $pl_notify= FALSE; + /* Object entry CSN */ + var $entryCSN = ""; + var $CSN_check_active = FALSE; /* This variable indicates that this class can handle multiple dns at once. */ var $multiple_support = FALSE; @@ -151,6 +154,11 @@ class plugin $ldap= $this->config->get_ldap_link(); if ($dn !== NULL){ + /* Get entry CSN */ + if($this->CSN_check_active){ + $this->entryCSN = getEntryCSN($dn); + } + /* Load data to 'attrs' and save 'dn' */ if ($parent !== NULL){ $this->attrs= $parent->attrs; @@ -280,6 +288,11 @@ class plugin /* Save data to object */ function save_object() { + /* Update entry CSN if it is empty. */ + if(empty($this->entryCSN) && $this->CSN_check_active){ + $this->entryCSN = getEntryCSN($this->dn); + } + if($this->multiple_support_active){ foreach($this->attributes as $attr){ if(isset($_POST["use_".$attr])){ @@ -328,6 +341,9 @@ class plugin /* include global link_info */ $ldap= $this->config->get_ldap_link(); + /* Save all plugins */ + $this->entryCSN = ""; + /* Start with empty array */ $this->attrs= array(); @@ -477,6 +493,14 @@ class plugin } + /* Check entryCSN */ + if($this->CSN_check_active){ + $current_csn = getEntryCSN($this->dn); + if($current_csn != $this->entryCSN && !empty($this->entryCSN) && !empty($current_csn)){ + $this->entryCSN = $current_csn; + $message[] = _("The object has changed since opened in GOsa. Please ensure that nobody has done serious changes that may get lost if you save this entry."); + } + } return ($message); } @@ -1657,6 +1681,18 @@ class plugin return($ret); } + + /* This function enables the entry Serial ID check. + * If an entry was edited while we have edited the entry too, + * an error message will be shown. + * To configure this check correctly read the FAQ. + */ + function enable_CSN_check() + { + $this->CSN_check_active =TRUE; + } + + function set_multi_edit_value() { diff --git a/include/class_tabs.inc b/include/class_tabs.inc index c54739fb6..219c9d15c 100644 --- a/include/class_tabs.inc +++ b/include/class_tabs.inc @@ -284,7 +284,6 @@ class tabs $obj->pl_notify= FALSE; } } - $messages = array_unique($messages); return ($messages); } -- 2.30.2