From 75b909ce9348a622ee311a09701db0140a50489c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Aug 2016 16:55:32 +0200 Subject: [PATCH] Fix missing transaction in update_perso function --- htdocs/contact/class/contact.class.php | 25 ++++++++++++++++++++++++- htdocs/contact/perso.php | 17 +++++++++++------ 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index 259918c5aa9..1edb0b1d3c3 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -474,13 +474,16 @@ class Contact extends CommonObject * * @param int $id Id of contact * @param User $user User asking to change alert or birthday + * @param int $notrigger 0=no, 1=yes * @return int <0 if KO, >=0 if OK */ - function update_perso($id, $user=null) + function update_perso($id, $user=null, $notrigger=0) { $error=0; $result=false; + $this->db->begin(); + // Mis a jour contact $sql = "UPDATE ".MAIN_DB_PREFIX."socpeople SET"; $sql.= " birthday=".($this->birthday ? "'".$this->db->idate($this->birthday)."'" : "null"); @@ -531,6 +534,26 @@ class Contact extends CommonObject } } + if (! $error && ! $notrigger) + { + // Call trigger + $result=$this->call_trigger('CONTACT_MODIFY',$user); + if ($result < 0) { $error++; } + // End call triggers + } + + if (! $error) + { + $this->db->commit(); + return 1; + } + else + { + dol_syslog(get_class($this)."::update Error ".$this->error,LOG_ERR); + $this->db->rollback(); + return -$error; + } + return $result; } diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index da70bc3e007..5feafcbb6b3 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -135,11 +135,9 @@ $object->fetch($id, $user); $head = contact_prepare_head($object); -dol_fiche_head($head, 'perso', $title, 0, 'contact'); - if ($action == 'edit') { - /* + /* * Fiche en mode edition */ @@ -148,6 +146,8 @@ if ($action == 'edit') print ''; print ''; + dol_fiche_head($head, 'perso', $title, 0, 'contact'); + print ''; // Ref @@ -213,8 +213,10 @@ if ($action == 'edit') } print ''; - print "

"; + print ""; + dol_fiche_end(); + print '
'; print ''; print '     '; @@ -227,6 +229,8 @@ else { // View mode + dol_fiche_head($head, 'perso', $title, 0, 'contact'); + $linkback = ''.$langs->trans("BackToList").''; dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', ''); @@ -285,16 +289,17 @@ else } else { - print ''.$langs->trans("DateToBirth").''.$langs->trans("Unknown").""; + print ''.$langs->trans("DateToBirth").''; } print ""; print ""; print '
'; + + dol_fiche_end(); } -dol_fiche_end(); if ($action != 'edit') {