fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [8412] api: check for existing value before adding as


From: Sigurd Nes
Subject: [Fmsystem-commits] [8412] api: check for existing value before adding as new
Date: Fri, 23 Dec 2011 07:40:22 +0000

Revision: 8412
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8412
Author:   sigurdne
Date:     2011-12-23 07:40:21 +0000 (Fri, 23 Dec 2011)
Log Message:
-----------
api: check for existing value before adding as new

Modified Paths:
--------------
    trunk/admin/inc/class.soconfig.inc.php

Modified: trunk/admin/inc/class.soconfig.inc.php
===================================================================
--- trunk/admin/inc/class.soconfig.inc.php      2011-12-22 15:17:59 UTC (rev 
8411)
+++ trunk/admin/inc/class.soconfig.inc.php      2011-12-23 07:40:21 UTC (rev 
8412)
@@ -146,6 +146,17 @@
 
                        $values['name'] = 
$this->db->db_addslashes($values['name']);
                        $values['descr'] = 
$this->db->db_addslashes($values['descr']);
+
+                       $sql = "SELECT id FROM phpgw_config2_section WHERE 
location_id = {$this->location_id} AND descr = '{$values['descr']}'";
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       if ($this->db->next_record())
+                       {
+                               $receipt['section_id']=  $this->db->f('id');
+                               $receipt['message'][]=array('msg'=>lang('config 
section has not been saved'));
+                               return $receipt;
+                       }
+
                        $values['section_id'] = 
$this->db->next_id('phpgw_config2_section');
 
                        $insert_values = array
@@ -325,6 +336,18 @@
 
                        $values['name'] = 
$this->db->db_addslashes($values['name']);
                        $values['descr'] = 
$this->db->db_addslashes($values['descr']);
+
+                       $sql = "SELECT id FROM phpgw_config2_attrib WHERE 
section_id = '{$values['section_id']}' AND name = '{$values['name']}'";
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+
+                       if ($this->db->next_record())
+                       {
+                               $receipt['attrib_id']   = $this->db->f('id');
+                               $receipt['error'][]=array('msg'=>lang('config 
attrib has been saved'));
+                               return $receipt;
+                       }
+
                        $values['attrib_id'] = 
$this->db->next_id('phpgw_config2_attrib',array('section_id'=>$values['section_id']));
 
                        $insert_values = array




reply via email to

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