[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [8107] Property: more on EAV
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [8107] Property: more on EAV |
Date: |
Mon, 14 Nov 2011 22:39:01 +0000 |
Revision: 8107
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=8107
Author: sigurdne
Date: 2011-11-14 22:39:00 +0000 (Mon, 14 Nov 2011)
Log Message:
-----------
Property: more on EAV
Modified Paths:
--------------
trunk/phpgwapi/inc/class.custom_fields.inc.php
trunk/property/inc/class.soadmin_entity.inc.php
trunk/property/inc/class.soentity.inc.php
trunk/property/inc/class.uiadmin_entity.inc.php
Modified: trunk/phpgwapi/inc/class.custom_fields.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.custom_fields.inc.php 2011-11-14 15:23:37 UTC
(rev 8106)
+++ trunk/phpgwapi/inc/class.custom_fields.inc.php 2011-11-14 22:39:00 UTC
(rev 8107)
@@ -147,7 +147,7 @@
/**
* Add a group for custom fields/attributes
- *
+ *
* @param array $attrib the field data
*
* @return int the the new custom field db pk
@@ -217,7 +217,7 @@
}
/**
* Add a custom field/attribute
- *
+ *
* @param array $attrib the field data
* @param string $attrib_table where to append the attrib
* @param bool $doubled sometimes the attribute fits into a
history-table as a double
@@ -477,7 +477,7 @@
/**
* Delete a custom field/attribute group
- *
+ *
* @param string $location within an application
* @param string $appname where to delete the attrib
* @param integer $group_id id of attrib to delete
@@ -518,7 +518,7 @@
}
/**
* Delete a custom field/attribute
- *
+ *
* @param string $location within an application
* @param string $appname where to delete the attrib
* @param integer $attrib_id id of attrib to delete
@@ -553,7 +553,7 @@
if(!$doubled) // else: wait for it - another one is
coming
{
- $sql = "SELECT group_id FROM
phpgw_cust_attribute "
+ $sql = "SELECT group_id FROM
phpgw_cust_attribute "
. " WHERE location_id = {$loc_id} AND
id = {$attrib_id}";
$this->_db->query($sql, __LINE__, __FILE__);
$this->_db->next_record();
@@ -592,7 +592,7 @@
/**
* Edit a group for custom fields
- *
+ *
* @param array $group the field data
*
* @return integer the database id of the group
@@ -625,7 +625,7 @@
}
/**
* Edit a custom field
- *
+ *
* @param array $attrib the field data
* @param string $attrib_table which table the attribute is
part of
* @param bool $doubled sometimes the attribute fits into a
history-table as a double
@@ -683,7 +683,7 @@
default: // all is good
}
- $sql = "SELECT column_name, datatype, precision_,
group_id FROM phpgw_cust_attribute "
+ $sql = "SELECT column_name, datatype, precision_,
group_id FROM phpgw_cust_attribute "
. " WHERE location_id = {$location_id} AND id
= {$attrib_id}";
$this->_db->query($sql, __LINE__, __FILE__);
if ( !$this->_db->next_record() )
@@ -721,7 +721,7 @@
if($OldGroup != $attrib['group_id'])
{
- $sql = "SELECT MAX(attrib_sort) AS
max_sort FROM phpgw_cust_attribute "
+ $sql = "SELECT MAX(attrib_sort) AS
max_sort FROM phpgw_cust_attribute "
. " WHERE location_id =
{$location_id} AND group_id = {$attrib['group_id']}";
$this->_db->query($sql,__LINE__,__FILE__);
$this->_db->next_record();
@@ -756,19 +756,13 @@
}
- if(!$attrib_table) // Assume EAV-model
+ if($attrib_table)
{
- if ( $this->_db->transaction_commit() )
- {
- return true;
- }
+ $table_def =
$this->get_table_def($attrib_table);
+ $this->_oProc->m_aTables = $table_def;
- return false;
}
- $table_def = $this->get_table_def($attrib_table);
- $this->_oProc->m_aTables = $table_def;
-
if($OldColumnName !=$attrib['column_name'])
{
$value_set=array('column_name' =>
$attrib['column_name']);
@@ -779,7 +773,10 @@
$this->_db->query("UPDATE
phpgw_cust_attribute set $value_set WHERE location_id = {$location_id} AND id="
. $attrib_id,__LINE__,__FILE__);
}
- $this->_oProc->RenameColumn($attrib_table,
$OldColumnName, $attrib['column_name']);
+ if($attrib_table)
+ {
+
$this->_oProc->RenameColumn($attrib_table, $OldColumnName,
$attrib['column_name']);
+ }
}
if (($OldDataType != $attrib['column_info']['type'])
@@ -836,7 +833,10 @@
}
$attrib['column_info']['type'] =
$this->_translate_datatype_insert($attrib['column_info']['type']);
-
$this->_oProc->AlterColumn($attrib_table,$attrib['column_name'],$attrib['column_info']);
+ if($attrib_table)
+ {
+
$this->_oProc->AlterColumn($attrib_table,$attrib['column_name'],$attrib['column_info']);
+ }
}
if(isset($attrib['new_choice']) &&
$attrib['new_choice'] && !$doubled )
@@ -911,20 +911,20 @@
/**
* Get a list of attributes
- *
+ *
* @param string $appname the name of the application
* @param string $location the name of the location
* @param integer $start
- * @param string query
- * @param string $sort
- * @param string $order
- * @param bool $allrows
- * @param bool $inc_choices
+ * @param string query
+ * @param string $sort
+ * @param string $order
+ * @param bool $allrows
+ * @param bool $inc_choices
* @param array $filtermethod
*
* @return array attributes at location
*/
- public function find($appname, $location, $start = 0, $query =
'', $sort = 'ASC',
+ public function find($appname, $location, $start = 0, $query =
'', $sort = 'ASC',
$order = 'attrib_sort', $allrows = false,
$inc_choices = false, $filter = array())
{
$location_id =
$GLOBALS['phpgw']->locations->get_id($appname, $location);
@@ -1056,7 +1056,7 @@
}
/**
* Get a list of groups availlable for attributes within a
location
- *
+ *
* @param string $appname the name of the application
* @param string $location the name of the location
* @param ?????? $start ask sigurd
@@ -1067,7 +1067,7 @@
*
* @return ???? something
*/
- public function find_group($appname, $location, $start = 0,
$query = '', $sort = 'ASC',
+ public function find_group($appname, $location, $start = 0,
$query = '', $sort = 'ASC',
$order = 'group_sort', $allrows = false)
{
$location_id =
$GLOBALS['phpgw']->locations->get_id($appname, $location);
@@ -1181,7 +1181,7 @@
$location_id =
$GLOBALS['phpgw']->locations->get_id($appname, $location);
$id = (int) $id;
- $sql = "SELECT phpgw_cust_attribute.* FROM
phpgw_cust_attribute "
+ $sql = "SELECT phpgw_cust_attribute.* FROM
phpgw_cust_attribute "
. " WHERE location_id = {$location_id}"
. " AND phpgw_cust_attribute.id=$id";
$this->_db->query($sql, __LINE__, __FILE__);
@@ -1291,7 +1291,7 @@
*/
public function get_table_def($table = '', $table_def = array())
{
- if( !$GLOBALS['phpgw_setup']->oProc
+ if( !$GLOBALS['phpgw_setup']->oProc
|| !is_object($GLOBALS['phpgw_setup']->oProc) )
{
$GLOBALS['phpgw_setup']->oProc =& $this->_oProc;
@@ -1380,7 +1380,7 @@
/**
* Resort an attribute's position in relation to other
attributes
- *
+ *
* @param int $id the attribute db pk
* @param string $resort the direction to move the field
[up|down]
*/
@@ -1401,13 +1401,13 @@
$this->_db->transaction_begin();
- $sql = "SELECT group_sort FROM
phpgw_cust_attribute_group "
+ $sql = "SELECT group_sort FROM
phpgw_cust_attribute_group "
. " WHERE location_id = {$location_id} AND id =
{$id}";
$this->_db->query($sql, __LINE__, __FILE__);
$this->_db->next_record();
$attrib_sort = $this->_db->f('group_sort');
- $sql = "SELECT MAX(group_sort) AS max_sort FROM
phpgw_cust_attribute_group "
+ $sql = "SELECT MAX(group_sort) AS max_sort FROM
phpgw_cust_attribute_group "
. " WHERE location_id = {$location_id}";
$this->_db->query($sql,__LINE__,__FILE__);
$this->_db->next_record();
@@ -1453,7 +1453,7 @@
/**
* Resort an attribute's position in relation to other
attributes
- *
+ *
* @param int $id the attribute db pk
* @param string $resort the direction to move the field
[up|down]
*/
@@ -1474,19 +1474,19 @@
$this->_db->transaction_begin();
- $sql = "SELECT group_id FROM phpgw_cust_attribute "
+ $sql = "SELECT group_id FROM phpgw_cust_attribute "
. " WHERE location_id = {$location_id} AND id =
{$id}";
$this->_db->query($sql, __LINE__, __FILE__);
$this->_db->next_record();
$group_id = (int) $this->_db->f('group_id');
- $sql = "SELECT attrib_sort FROM phpgw_cust_attribute "
+ $sql = "SELECT attrib_sort FROM phpgw_cust_attribute "
. " WHERE location_id = {$location_id} AND id =
{$id} AND group_id = {$group_id}";
$this->_db->query($sql, __LINE__, __FILE__);
$this->_db->next_record();
$attrib_sort = $this->_db->f('attrib_sort');
- $sql = "SELECT MAX(attrib_sort) AS max_sort FROM
phpgw_cust_attribute "
+ $sql = "SELECT MAX(attrib_sort) AS max_sort FROM
phpgw_cust_attribute "
. " WHERE location_id = {$location_id} AND
group_id = {$group_id}";
$this->_db->query($sql,__LINE__,__FILE__);
$this->_db->next_record();
@@ -1557,7 +1557,7 @@
$location_id = (int) $location_id;
$attrib_id = (int) $attrib_id;
- $sql = "SELECT * FROM phpgw_cust_choice "
+ $sql = "SELECT * FROM phpgw_cust_choice "
. " WHERE location_id = {$location_id}"
. " AND attrib_id = {$attrib_id}"
. " ORDER BY choice_sort ASC, value";
@@ -1580,7 +1580,7 @@
/**
* Finds the next ID for a record at a table
- *
+ *
* @param string $table tablename in question
* @param array $key conditions for finding the next id
*
Modified: trunk/property/inc/class.soadmin_entity.inc.php
===================================================================
--- trunk/property/inc/class.soadmin_entity.inc.php 2011-11-14 15:23:37 UTC
(rev 8106)
+++ trunk/property/inc/class.soadmin_entity.inc.php 2011-11-14 22:39:00 UTC
(rev 8107)
@@ -134,7 +134,7 @@
$sort =
isset($data['sort'])?$data['sort']:'DESC';
$order =
isset($data['order'])?$data['order']:'';
$allrows =
isset($data['allrows'])?$data['allrows']:'';
- $entity_id =
isset($data['entity_id'])?$data['entity_id']:'';
+ $entity_id = isset($data['entity_id'])?
(int)$data['entity_id']:0;
$type = isset($data['type']) &&
$data['type'] ? $data['type'] : $this->type;
$required =
isset($data['required'])?$data['required']:'';
}
@@ -177,6 +177,7 @@
$id = $this->db2->f('id');
$category = array
(
+ 'entity_id' => $entity_id,
'id' => $id,
'name' =>
$this->db2->f('name'),
'prefix' =>
$this->db2->f('prefix'),
@@ -950,10 +951,18 @@
}
}
-
$this->oProc->DropTable("fm_{$this->type}_{$entity_id}_{$id}");
-
$location_id = $GLOBALS['phpgw']->locations->get_id(
$this->type_app[$this->type], ".{$this->type}.{$entity_id}.{$id}");
+ $category = $this->read_single_category($entity_id,
$id);
+ if($category['is_eav'])
+ {
+ $this->db->query("DELETE FROM fm_bim_type WHERE
location_id= {$location_id}",__LINE__,__FILE__);
+ }
+ else
+ {
+
$this->oProc->DropTable("fm_{$this->type}_{$entity_id}_{$id}");
+ }
+
$this->db->query("DELETE FROM fm_{$this->type}_category
WHERE entity_id= {$entity_id} AND id= {$id}",__LINE__,__FILE__);
$this->db->query("DELETE FROM phpgw_cust_attribute
WHERE location_id = {$location_id}",__LINE__,__FILE__);
$this->db->query("DELETE FROM phpgw_locations WHERE
location_id = {$location_id}",__LINE__,__FILE__);
Modified: trunk/property/inc/class.soentity.inc.php
===================================================================
--- trunk/property/inc/class.soentity.inc.php 2011-11-14 15:23:37 UTC (rev
8106)
+++ trunk/property/inc/class.soentity.inc.php 2011-11-14 22:39:00 UTC (rev
8107)
@@ -915,8 +915,15 @@
if($category['is_eav'])
{
+ if(isset($values_insert['p_num']) &&
$values_insert['p_num'])
+ {
+ $p_category =
$admin_entity->read_single_category($values_insert['p_entity_id'],
$values_insert['p_cat_id']);
+ $values_insert['p_id']
= (int) ltrim($values_insert['p_num'], $p_category['prefix']);
+ $values_insert['p_location_id'] =
$GLOBALS['phpgw']->locations->get_id('property',
".{$this->type}.{$values_insert['p_entity_id']}.{$values_insert['p_cat_id']}");
+ }
+
$location_id =
$GLOBALS['phpgw']->locations->get_id('property',
".{$this->type}.{$entity_id}.{$cat_id}");
- $this->_save_eav($values_insert, $location_id);
+ $values['id'] =
$this->_save_eav($values_insert, $location_id);
}
else
{
@@ -983,7 +990,7 @@
$doc->formatOutput = true;
$xml = $doc->saveXML();
- _debug_array($xml);
+ // _debug_array($xml);
if (function_exists('com_create_guid') === true)
{
@@ -997,11 +1004,11 @@
$values_insert = array
(
'type' =>
$type,
- 'guid' =>
$guid,// character varying(24) NOT NULL,
+ 'guid' =>
$guid,
'xml_representation' =>
$this->db->db_addslashes($xml),
- 'model' =>
0,//integer
- 'p_location_id' => '',//integer
- 'p_id' =>
'',//integer
+ 'model' => 0,
+ 'p_location_id' =>
isset($data['p_location_id']) && $data['p_location_id'] ?
$data['p_location_id'] : '',
+ 'p_id' =>
isset($data['p_id']) && $data['p_id'] ? $data['p_id'] : '',
'location_code' =>
$data['location_code'],//character varying(20),
'address' =>
$data['address'],//character varying(150),
'entry_date' => time(),
@@ -1010,8 +1017,8 @@
$this->db->query("INSERT INTO fm_bim_item (" .
implode(',',array_keys($values_insert)) . ') VALUES ('
.
$this->db->validate_insert(array_values($values_insert)) .
')',__LINE__,__FILE__);
- $this->db->transaction_commit();
- die();
+
+ return
$this->db->get_last_insert_id('fm_bim_item','id');
}
function edit($values,$values_attribute,$entity_id,$cat_id)
Modified: trunk/property/inc/class.uiadmin_entity.inc.php
===================================================================
--- trunk/property/inc/class.uiadmin_entity.inc.php 2011-11-14 15:23:37 UTC
(rev 8106)
+++ trunk/property/inc/class.uiadmin_entity.inc.php 2011-11-14 22:39:00 UTC
(rev 8107)
@@ -533,7 +533,6 @@
{
$entry['location_id'] =
$GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type],
".{$this->type}.{$entity_id}.{$entry['id']}");
}
-
$uicols['name'][0] = 'location_id';
$uicols['descr'][0] = 'location_id';
$uicols['name'][1] = 'id';
@@ -546,8 +545,8 @@
$uicols['descr'][4] = lang('Prefix');
$uicols['name'][5] = 'entity_id';
$uicols['descr'][5] = lang('id');
- $uicols['name'][5] = 'is_eav';
- $uicols['descr'][5] = lang('is_eav');
+ $uicols['name'][6] = 'is_eav';
+ $uicols['descr'][6] = lang('is_eav');
$j = 0;
$count_uicols_name = count($uicols['name']);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [8107] Property: more on EAV,
Sigurd Nes <=