From 5ce8b4ccf7976026a55988109683234f7b74f5c6 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 5 Dec 2007 10:39:16 +0000 Subject: [PATCH] Added entryCSN check to tabs. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8008 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_tabs.inc | 19 ++++++++++++++++++- include/functions.inc | 24 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/include/class_tabs.inc b/include/class_tabs.inc index 7e9c593a1..c54739fb6 100644 --- a/include/class_tabs.inc +++ b/include/class_tabs.inc @@ -33,6 +33,8 @@ class tabs var $by_object= array(); var $SubDialog = false; + var $entryCSN = ""; + function tabs(&$config, $data, $dn, $acl_category= "") { /* Save dn */ @@ -41,6 +43,8 @@ class tabs $baseobject= NULL; + $this->entryCSN = getEntryCSN($dn); + foreach ($data as &$tab){ $this->by_name[$tab['CLASS']]= $tab['NAME']; @@ -127,6 +131,11 @@ class tabs function save_object($save_current= FALSE) { + /* Update entry CSN if it is empty. */ + if(empty($this->entryCSN)){ + $this->entryCSN = getEntryCSN($this->dn); + } + /* Save last tab */ if ($this->last != ""){ @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, @@ -247,6 +256,13 @@ class tabs $current_set = FALSE; + /* Check entryCSN */ + $current_csn = getEntryCSN($this->dn); + if($current_csn != $this->entryCSN && !empty($this->entryCSN) && !empty($current_csn)){ + $this->entryCSN = $current_csn; + $messages[] = _("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."); + } + /* Check all plugins */ foreach ($this->by_object as $key => &$obj){ if ($obj->is_account || $ignore_account || $obj->ignore_account){ @@ -268,12 +284,14 @@ class tabs $obj->pl_notify= FALSE; } } + $messages = array_unique($messages); return ($messages); } function save($ignore_account= FALSE) { /* Save all plugins */ + $this->entryCSN = ""; foreach ($this->by_object as $key => &$obj){ @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, $key, "Saving"); @@ -362,7 +380,6 @@ class tabs } } } - } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/include/functions.inc b/include/functions.inc index 2ed6b9be5..812715bf0 100644 --- a/include/functions.inc +++ b/include/functions.inc @@ -2647,6 +2647,30 @@ function crypt_single($string,$enc_type ) } +function getEntryCSN($dn) +{ + global $config; + if(empty($dn) || !is_object($config)){ + return(""); + } + + /* Get attribute that we should use as serial number */ + if(isset($config->current['UNIQ_IDENTIFIER'])){ + $attr = $config->current['UNIQ_IDENTIFIER']; + }elseif(isset($config->data['MAIN']['UNIQ_IDENTIFIER'])){ + $attr = $config->data['MAIN']['UNIQ_IDENTIFIER']; + } + if(!empty($attr)){ + $ldap = $config->get_ldap_link(); + $ldap->cat($dn,array($attr)); + $csn = $ldap->fetch(); + if(isset($csn[$attr][0])){ + return($csn[$attr][0]); + } + } + return(""); +} + /* This function returns the offset for the default timezone. * $stamp is used to detect summer or winter time. * In case of PHP5, the integrated timezone functions are used. -- 2.30.2