[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [6739] convert data for datatype CH: from serialized
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [6739] convert data for datatype CH: from serialized array to comma separated list |
Date: |
Sun, 09 Jan 2011 20:24:11 +0000 |
Revision: 6739
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6739
Author: sigurdne
Date: 2011-01-09 20:24:11 +0000 (Sun, 09 Jan 2011)
Log Message:
-----------
convert data for datatype CH: from serialized array to comma separated list
Modified Paths:
--------------
trunk/phpgwapi/inc/class.custom_fields.inc.php
trunk/property/inc/class.bocommon.inc.php
trunk/property/inc/class.boentity.inc.php
trunk/property/inc/class.boifc.inc.php
trunk/property/inc/class.custom_fields.inc.php
trunk/property/inc/class.soadmin_location.inc.php
trunk/property/inc/class.soagreement.inc.php
trunk/property/inc/class.sos_agreement.inc.php
trunk/property/inc/class.uientity.inc.php
trunk/property/setup/setup.inc.php
trunk/property/setup/tables_update.inc.php
Modified: trunk/phpgwapi/inc/class.custom_fields.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.custom_fields.inc.php 2011-01-08 20:44:08 UTC
(rev 6738)
+++ trunk/phpgwapi/inc/class.custom_fields.inc.php 2011-01-09 20:24:11 UTC
(rev 6739)
@@ -419,7 +419,7 @@
switch ( $attrib['datatype'] )
{
case 'CH':
- $attrib['value'] =
serialize($attrib['value']);
+ $attrib['value'] = ',' .
implode(',', $attrib['value']) . ',';
break;
case 'R':
Modified: trunk/property/inc/class.bocommon.inc.php
===================================================================
--- trunk/property/inc/class.bocommon.inc.php 2011-01-08 20:44:08 UTC (rev
6738)
+++ trunk/property/inc/class.bocommon.inc.php 2011-01-09 20:24:11 UTC (rev
6739)
@@ -1089,7 +1089,8 @@
{
if($values_attribute[$i]['datatype']=='CH' &&
$values_attribute[$i]['value'])
{
- $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
+// $values_attribute[$i]['value'] =
serialize($values_attribute[$i]['value']);
+ $values_attribute[$i]['value'] = ',' .
implode(',', $values_attribute[$i]['value']) . ',';
}
if($values_attribute[$i]['datatype']=='R' &&
$values_attribute[$i]['value'])
{
Modified: trunk/property/inc/class.boentity.inc.php
===================================================================
--- trunk/property/inc/class.boentity.inc.php 2011-01-08 20:44:08 UTC (rev
6738)
+++ trunk/property/inc/class.boentity.inc.php 2011-01-09 20:24:11 UTC (rev
6739)
@@ -269,13 +269,20 @@
{
foreach ( $attrib_data as $attrib )
{
- if($attrib['datatype'] == 'LB')
+ if($attrib['datatype'] == 'LB' ||
$attrib['datatype'] == 'R')
{
if($_attrib_filter_value =
phpgw::get_var($attrib['column_name'], 'int'))
{
$attrib_filter[] =
"fm_{$this->type}_{$this->entity_id}_{$this->cat_id}.{$attrib['column_name']} =
'{$_attrib_filter_value}'";
}
}
+ else if($attrib['datatype'] == 'CH')
+ {
+ if($_attrib_filter_value =
phpgw::get_var($attrib['column_name'], 'int'))
+ {
+ $attrib_filter[] =
"fm_{$this->type}_{$this->entity_id}_{$this->cat_id}.{$attrib['column_name']}
{$GLOBALS['phpgw']->db->like} '%,{$_attrib_filter_value},%'";
+ }
+ }
}
}
Modified: trunk/property/inc/class.boifc.inc.php
===================================================================
--- trunk/property/inc/class.boifc.inc.php 2011-01-08 20:44:08 UTC (rev
6738)
+++ trunk/property/inc/class.boifc.inc.php 2011-01-09 20:24:11 UTC (rev
6739)
@@ -237,7 +237,8 @@
{
if($values_attribute[$i]['datatype']=='CH' && $values_attribute[$i]['value'])
{
- $values_attribute[$i]['value']
= serialize($values_attribute[$i]['value']);
+ // $values_attribute[$i]['value']
= serialize($values_attribute[$i]['value']);
+ $values_attribute[$i]['value']
= ',' . implode(',', $values_attribute[$i]['value']) . ',';
}
if($values_attribute[$i]['datatype']=='R' && $values_attribute[$i]['value'])
{
Modified: trunk/property/inc/class.custom_fields.inc.php
===================================================================
--- trunk/property/inc/class.custom_fields.inc.php 2011-01-08 20:44:08 UTC
(rev 6738)
+++ trunk/property/inc/class.custom_fields.inc.php 2011-01-09 20:24:11 UTC
(rev 6739)
@@ -208,7 +208,8 @@
if($attributes['datatype'] == 'CH')
{
- $attributes['value'] =
unserialize($attributes['value']);
+// $attributes['value'] =
unserialize($attributes['value']);
+ $attributes['value'] =
explode(',', trim($attributes['value'], ','));
if
(isset($attributes['choice']) AND is_array($attributes['choice']))
{
@@ -437,7 +438,8 @@
}
else if($data['datatype']=='CH' &&
$data['value'])
{
- $ch=
unserialize($data['value']);
+ // $ch=
unserialize($data['value']);
+ $ch = explode(',',
trim($data['value'], ','));
if (isset($ch) AND
is_array($ch))
{
for
($k=0;$k<count($ch);$k++)
Modified: trunk/property/inc/class.soadmin_location.inc.php
===================================================================
--- trunk/property/inc/class.soadmin_location.inc.php 2011-01-08 20:44:08 UTC
(rev 6738)
+++ trunk/property/inc/class.soadmin_location.inc.php 2011-01-09 20:24:11 UTC
(rev 6739)
@@ -660,6 +660,7 @@
{
$this->db->query("SELECT * FROM fm_location_type ORDER
BY id ");
+ $location_type = array();
while ($this->db->next_record())
{
$location_type[] = array(
Modified: trunk/property/inc/class.soagreement.inc.php
===================================================================
--- trunk/property/inc/class.soagreement.inc.php 2011-01-08 20:44:08 UTC
(rev 6738)
+++ trunk/property/inc/class.soagreement.inc.php 2011-01-09 20:24:11 UTC
(rev 6739)
@@ -336,8 +336,8 @@
}
else
if($cols_return_extra[$i]['datatype']=='CH' && $value)
{
- $ch=
unserialize($value);
-
+// $ch=
unserialize($value);
+ $ch = explode(',',
trim($data['value'], ','));
if (isset($ch) AND
is_array($ch))
{
for
($k=0;$k<count($ch);$k++)
Modified: trunk/property/inc/class.sos_agreement.inc.php
===================================================================
--- trunk/property/inc/class.sos_agreement.inc.php 2011-01-08 20:44:08 UTC
(rev 6738)
+++ trunk/property/inc/class.sos_agreement.inc.php 2011-01-09 20:24:11 UTC
(rev 6739)
@@ -427,8 +427,8 @@
}
else
if($return_extra['datatype']=='CH' && $value)
{
- $ch=
unserialize($value);
-
+// $ch=
unserialize($value);
+ $ch = explode(',',
trim($data['value'], ','));
if (isset($ch) AND
is_array($ch))
{
for
($k=0;$k<count($ch);$k++)
Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php 2011-01-08 20:44:08 UTC (rev
6738)
+++ trunk/property/inc/class.uientity.inc.php 2011-01-09 20:24:11 UTC (rev
6739)
@@ -616,7 +616,7 @@
$i = 4;
foreach ( $attrib_data as $attrib )
{
- if($attrib['datatype'] == 'LB')
+ if($attrib['datatype'] == 'LB'
|| $attrib['datatype'] == 'CH' || $attrib['datatype'] == 'R')
{
$datatable['actions']['form'][0]['fields']['field'][] = array
(
Modified: trunk/property/setup/setup.inc.php
===================================================================
--- trunk/property/setup/setup.inc.php 2011-01-08 20:44:08 UTC (rev 6738)
+++ trunk/property/setup/setup.inc.php 2011-01-09 20:24:11 UTC (rev 6739)
@@ -12,7 +12,7 @@
*/
$setup_info['property']['name'] = 'property';
- $setup_info['property']['version'] = '0.9.17.603';
+ $setup_info['property']['version'] = '0.9.17.604';
$setup_info['property']['app_order'] = 8;
$setup_info['property']['enable'] = 1;
$setup_info['property']['app_group'] = 'office';
Modified: trunk/property/setup/tables_update.inc.php
===================================================================
--- trunk/property/setup/tables_update.inc.php 2011-01-08 20:44:08 UTC (rev
6738)
+++ trunk/property/setup/tables_update.inc.php 2011-01-09 20:24:11 UTC (rev
6739)
@@ -4837,4 +4837,88 @@
return $GLOBALS['setup_info']['property']['currentver'];
}
}
+ /**
+ * Update property version from 0.9.17.602 to 0.9.17.603
+ * convert data for datatype CH: from serialized array to comma
separated list
+ *
+ */
+ $test[] = '0.9.17.603';
+ function property_upgrade0_9_17_603()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+ $GLOBALS['phpgw_setup']->oProc->query('SELECT count(*) as cnt
FROM fm_location_type');
+ $GLOBALS['phpgw_setup']->oProc->next_record();
+ $levels = $GLOBALS['phpgw_setup']->oProc->f('cnt');
+
+ for ($i=1; $i<($levels +1); $i++)
+ {
+ $sql = "UPDATE phpgw_locations SET c_attrib_table =
'fm_location{$i}' WHERE name = '.location.{$i}' AND c_attrib_table IS NULL";
+ $GLOBALS['phpgw_setup']->oProc->query($sql);
+ }
+
+
+ $sql = "SELECT c_attrib_table, column_name FROM
phpgw_cust_attribute JOIN phpgw_locations ON phpgw_cust_attribute.location_id =
phpgw_locations.location_id WHERE datatype = 'CH' GROUP BY c_attrib_table,
column_name";
+
+ $GLOBALS['phpgw_setup']->oProc->query($sql);
+
+ $attribs = array();
+
+ while ($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+
$attribs[$GLOBALS['phpgw_setup']->oProc->f('c_attrib_table')][] =
$GLOBALS['phpgw_setup']->oProc->f('column_name');
+ }
+
+ $value_set = array();
+ foreach($attribs as $table => $columns)
+ {
+ $id_name = 'id';
+ if(preg_match('/(^fm_location)/', $table))
+ {
+ $id_name = 'location_code';
+ }
+
+ foreach($columns as $column)
+ {
+ $sql = "SELECT {$id_name}, {$column} FROM
{$table} WHERE {$column} IS NOT NULL";
+ $GLOBALS['phpgw_setup']->oProc->query($sql);
+ while
($GLOBALS['phpgw_setup']->oProc->next_record())
+ {
+ if($value =
$GLOBALS['phpgw_setup']->oProc->f($column))
+ {
+ if(@unserialize($value))
+ {
+ $value = ',' .
implode(',', unserialize($value)) . ',';
+ }
+ else
+ {
+ $value = ",{$value}";
+ }
+
+ $value_set[] = array
+ (
+ 'table' =>
$table,
+ 'id_name' =>
$id_name,
+ 'id_value' =>
$GLOBALS['phpgw_setup']->oProc->f($id_name),
+ 'column' =>
$column,
+ 'value' =>
$value
+ );
+ }
+ }
+ }
+ }
+
+ foreach($value_set as $update)
+ {
+ $sql = "UPDATE {$update['table']} SET
{$update['column']} = '{$update['value']}' WHERE {$update['id_name']} =
'{$update['id_value']}'";
+ $GLOBALS['phpgw_setup']->oProc->query($sql);
+ }
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['property']['currentver'] =
'0.9.17.604';
+ return $GLOBALS['setup_info']['property']['currentver'];
+ }
+ }
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [6739] convert data for datatype CH: from serialized array to comma separated list,
Sigurd Nes <=