fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [15828] api: generic core


From: sigurdne
Subject: [Fmsystem-commits] [15828] api: generic core
Date: Fri, 14 Oct 2016 17:42:22 +0000 (UTC)

Revision: 15828
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=15828
Author:   sigurdne
Date:     2016-10-14 17:42:22 +0000 (Fri, 14 Oct 2016)
Log Message:
-----------
api: generic core

Modified Paths:
--------------
    trunk/phpgwapi/inc/class.db_pdo.inc.php
    trunk/phpgwapi/inc/class.socommon.inc.php
    trunk/phpgwapi/inc/model/class.model.inc.php
    trunk/property/inc/class.sogeneric_.inc.php

Modified: trunk/phpgwapi/inc/class.db_pdo.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.db_pdo.inc.php     2016-10-14 17:41:44 UTC (rev 
15827)
+++ trunk/phpgwapi/inc/class.db_pdo.inc.php     2016-10-14 17:42:22 UTC (rev 
15828)
@@ -831,7 +831,7 @@
                                {
                                        if ($strip_slashes || 
($this->auto_stripslashes && ! $strip_slashes))
                                        {
-                                               return 
htmlspecialchars_decode(stripslashes(str_replace(array('&#40&#59;', 
'&#41&#59;'), array('(', ')'), $this->Record[$name])),ENT_QUOTES);
+                                               return 
htmlspecialchars_decode(stripslashes(str_replace(array('&amp&#59;#40&#59;', 
'&amp&#59;#41&#59;'), array('(', ')'), $this->Record[$name])),ENT_QUOTES);
 //                                             return 
htmlspecialchars_decode(stripslashes($this->Record[$name]));
                                        }
                                        else

Modified: trunk/phpgwapi/inc/class.socommon.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.socommon.inc.php   2016-10-14 17:41:44 UTC (rev 
15827)
+++ trunk/phpgwapi/inc/class.socommon.inc.php   2016-10-14 17:42:22 UTC (rev 
15828)
@@ -408,7 +408,7 @@
                                        }
                                        else
                                        {
-                                               $row[$field] = 
$this->unmarshal($this->db->f($field, false), $params['type']);
+                                               $row[$field] = 
$this->unmarshal($this->db->f($field, true), $params['type']);
                                        }
                                }
                        }
@@ -645,6 +645,7 @@
 
                        foreach ($this->fields as $field => $params)
                        {
+                               $value = $object->get_field($field);
                                if (!empty($params['manytomany']) && 
!empty($params['manytomany']['input_field']) && 
$object->get_field($params['manytomany']['input_field']))
                                {
                                        $table = $params['manytomany']['table'];
@@ -696,6 +697,66 @@
                                                return 
$this->db->query($update_query,__LINE__,__FILE__);
                                        }
                                }
+                               else if(!empty($params['manytomany']) && 
is_array($value))
+                               {
+                                       $update_queries = array();
+                                       $table = $params['manytomany']['table'];
+                                       $key = $params['manytomany']['key'];
+                                       $update_queries[] = "DELETE FROM $table 
WHERE $key=$id";
+
+                                       if 
(is_array($params['manytomany']['column']))
+                                       {
+                                               $colnames = array();
+                                               foreach 
($params['manytomany']['column'] as $intOrCol => $paramsOrCol)
+                                               {
+                                                       
$colnames[(is_array($paramsOrCol) ? $intOrCol : $paramsOrCol)] = true;
+                                               }
+                                               unset($colnames['id']);
+
+                                               $colnames = join(',', 
array_keys($colnames));
+
+                                               foreach ($value as $v)
+                                               {
+                                                       $data = array();
+                                                       foreach 
($params['manytomany']['column'] as $intOrCol => $paramsOrCol)
+                                                       {
+                                                               if 
(is_array($paramsOrCol))
+                                                               {
+                                                                       $col = 
$intOrCol;
+                                                                       $type = 
isset($paramsOrCol['type']) ? $paramsOrCol['type'] : $params['type'];
+                                                               }
+                                                               else
+                                                               {
+                                                                       $col = 
$paramsOrCol;
+                                                                       $type = 
$params['type'];
+                                                               }
+
+                                                               if ($col == 
'id')
+                                                               {
+                                                                       
continue;
+                                                               }
+
+                                                               $data[] = 
$this->marshal($v, $type);
+                                                       }
+                                                       $v = join(',', $data);
+                                                       $update_queries[] = 
"INSERT INTO $table ($key, $colnames) VALUES($id, $v)";
+                                               }
+                                       }
+                                       else
+                                       {
+                                               $colname = 
$params['manytomany']['column'];
+                                               foreach ($value as $v)
+                                               {
+                                                       $v = $this->marshal($v, 
$params['type']);
+                                                       $update_queries[] = 
"INSERT INTO $table ($key, $colname) VALUES($id, $v)";
+                                               }
+                                       }
+                                       foreach ($update_queries as 
$update_query)
+                                       {
+                                               $this->db->query($update_query, 
__LINE__, __FILE__);
+                                       }
+
+                               }
                        }
                        return true;
                }

Modified: trunk/phpgwapi/inc/model/class.model.inc.php
===================================================================
--- trunk/phpgwapi/inc/model/class.model.inc.php        2016-10-14 17:41:44 UTC 
(rev 15827)
+++ trunk/phpgwapi/inc/model/class.model.inc.php        2016-10-14 17:42:22 UTC 
(rev 15828)
@@ -64,25 +64,32 @@
                                $datatype = $fields[$name]['type'];
                        }
 
-                       if ( isset($this->$name) )
+                       if ( isset($this->$name))
                        {
-                               switch ($datatype)
+                               if(is_array($this->$name))
                                {
-                                       case 'int':
-                                       case 'integert':
-                                               $value = (int)$this->$name;
-                                               break;
-                                       case 'float':
-                                               $value = (float)$this->$name;
-                                               break;
-                                       case 'bool':
-                                       case 'boolean':
-                                               $value = (bool)$this->$name;
-                                               break;
-                                       default:
-                                               $value = $this->$name;
-                                               break;
+                                       $value = $this->$name;
                                }
+                               else
+                               {
+                                       switch ($datatype)
+                                       {
+                                               case 'int':
+                                               case 'integert':
+                                                       $value = 
(int)$this->$name;
+                                                       break;
+                                               case 'float':
+                                                       $value = 
(float)$this->$name;
+                                                       break;
+                                               case 'bool':
+                                               case 'boolean':
+                                                       $value = 
(bool)$this->$name;
+                                                       break;
+                                               default:
+                                                       $value = $this->$name;
+                                                       break;
+                                       }
+                               }
 
                                return $value;
                        }
@@ -318,7 +325,7 @@
                                                {
                                                        $this->_validate(
 //                                                             
(array)$sub_entity, (array)$params['manytomany']['column'], $errors, 
sprintf('%s%s[%s]', $field_prefix, empty($field_prefix) ? $field : 
"[{$field}]", (is_string($key) ? $key : $sub_entity_count))
-                                                               
(array)$sub_entity, (array)$params['manytomany']['column'], $errors
+                                                               $entity, 
array($field => $params['manytomany']['column']), $errors
                                                        );
                                                        $sub_entity_count++;
                                                }

Modified: trunk/property/inc/class.sogeneric_.inc.php
===================================================================
--- trunk/property/inc/class.sogeneric_.inc.php 2016-10-14 17:41:44 UTC (rev 
15827)
+++ trunk/property/inc/class.sogeneric_.inc.php 2016-10-14 17:42:22 UTC (rev 
15828)
@@ -466,7 +466,7 @@
                        $i = 0;
                        while ($this->_db->next_record())
                        {
-                               $_extra = $this->_db->f($id_in_name);
+                               $_extra = $this->_db->f($id_in_name, true);
                                $id = $this->_db->f('id');
                                if (!$name = $this->_db->f('name', true))
                                {




reply via email to

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