fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [16621] property: more on substitute


From: sigurdne
Subject: [Fmsystem-commits] [16621] property: more on substitute
Date: Tue, 25 Apr 2017 08:06:59 -0400 (EDT)

Revision: 16621
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=16621
Author:   sigurdne
Date:     2017-04-25 08:06:58 -0400 (Tue, 25 Apr 2017)
Log Message:
-----------
property: more on substitute

Modified Paths:
--------------
    trunk/property/inc/class.sosubstitute.inc.php
    trunk/property/setup/phpgw_no.lang

Modified: trunk/property/inc/class.sosubstitute.inc.php
===================================================================
--- trunk/property/inc/class.sosubstitute.inc.php       2017-04-25 10:51:35 UTC 
(rev 16620)
+++ trunk/property/inc/class.sosubstitute.inc.php       2017-04-25 12:06:58 UTC 
(rev 16621)
@@ -98,13 +98,27 @@
                 */
                public function update_substitute( $user_id, 
$substitute_user_id = 0 )
                {
+                       $error = false;
                        $this->db->transaction_begin();
                        $this->db->query('DELETE FROM 
fm_ecodimb_role_user_substitute WHERE user_id = ' . (int)$user_id, __LINE__, 
__FILE__);
                        if($substitute_user_id)
                        {
-                               $this->db->query('INSERT INTO 
fm_ecodimb_role_user_substitute (user_id, substitute_user_id ) VALUES (' . 
(int)$user_id . ',' . (int) $substitute_user_id . ')', __LINE__, __FILE__);
+                               /*
+                                * Check for circle reference
+                                */
+                               $sql = 'SELECT id FROM 
fm_ecodimb_role_user_substitute WHERE substitute_user_id =' . (int) $user_id . 
' AND user_id = ' . (int) $substitute_user_id;
+                               $this->db->query($sql, __LINE__, __FILE__);
+                               if($this->db->next_record())
+                               {
+                                       
phpgwapi_cache::message_set(lang('substitute') . ' ' .lang('circle reference'), 
'error');
+                                       $error = true;
+                               }
+                               else
+                               {
+                                       $this->db->query('INSERT INTO 
fm_ecodimb_role_user_substitute (user_id, substitute_user_id ) VALUES (' . 
(int)$user_id . ',' . (int) $substitute_user_id . ')', __LINE__, __FILE__);
+                               }
                        }
-                       if($this->db->transaction_commit())
+                       if($this->db->transaction_commit() && !$error)
                        {
                                if($substitute_user_id)
                                {

Modified: trunk/property/setup/phpgw_no.lang
===================================================================
--- trunk/property/setup/phpgw_no.lang  2017-04-25 10:51:35 UTC (rev 16620)
+++ trunk/property/setup/phpgw_no.lang  2017-04-25 12:06:58 UTC (rev 16621)
@@ -2106,4 +2106,5 @@
 report property        no      Rapport
 canceled       property        no      Kansellert
 substitute     property        no      Vikar
-set substitute property        no      Sett vikar
\ No newline at end of file
+set substitute property        no      Sett vikar
+circle reference       property        no      Sirkelreferanse
\ No newline at end of file




reply via email to

[Prev in Thread] Current Thread [Next in Thread]