X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=DataObjects%2FCore_enum.php;h=3140cf7a4ea22a47c6e2d3ae1c567becbeac7952;hb=39538dd1c71297fb385a26c1aead204229558d44;hp=473a57ad9ada0489a60fbb0069dcc0952bb5604a;hpb=8091d6f17cad4796042f88efdbd814ee022f7af2;p=Pman.Core diff --git a/DataObjects/Core_enum.php b/DataObjects/Core_enum.php index 473a57ad..3140cf7a 100644 --- a/DataObjects/Core_enum.php +++ b/DataObjects/Core_enum.php @@ -2,8 +2,8 @@ /** * Table Definition for core enum - it's used in pulldowns or simple option lists. */ -//class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php'; -require_once '../../PDO_DataObject/PDO/DataObject.php'; +class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php'; + class Pman_Core_DataObjects_Core_enum extends DB_DataObject { ###START_AUTOCODE @@ -27,6 +27,7 @@ class Pman_Core_DataObjects_Core_enum extends DB_DataObject if (!empty($q['query']['empty_etype'])) { $this->whereAdd("core_enum.etype = ''"); } + // this should be handled by roo... using '!name[0]' .... if(!empty($q['!name'])){ @@ -136,8 +137,22 @@ class Pman_Core_DataObjects_Core_enum extends DB_DataObject function beforeUpdate($old, $request,$roo) { + + /* multiple id merge */ if(!empty($request['_merge_id'])){ - $this->merge($request['_merge_id'], $roo); + if(!empty($request['_ids'])){ + //DB_DataObject::DebugLevel(1); + $ce = DB_DataObject::factory('core_enum'); + $ce->whereAddIn("id", explode(",", $request['_ids']), "int"); + + foreach($ce->fetchAll() as $mergeItem){ + + $mergeItem->merge($request['_merge_id'], $roo); + } + } else { + $this->merge($request['_merge_id'], $roo); + } + $roo->jok('Merged'); } $tn = $this->tableName(); @@ -344,6 +359,7 @@ class Pman_Core_DataObjects_Core_enum extends DB_DataObject $seq_id = $t->seqid+1; } } + foreach($data as $row) { $t = DB_DAtaObject::Factory('core_enum'); @@ -352,7 +368,7 @@ class Pman_Core_DataObjects_Core_enum extends DB_DataObject $t->name = isset($row['name']) ? $row['name'] : ''; - if (empty($t->name)) { + if (empty($t->name) && $t->name != 0) { print_R($data); die("ERROR: invalid name used for core_enum\n\n"); } @@ -395,8 +411,9 @@ class Pman_Core_DataObjects_Core_enum extends DB_DataObject function merge($merge_to, $roo) { $affects = array(); - - $all_links = $GLOBALS['_DB_DATAOBJECT']['LINKS'][$this->_database]; + $tn = $this->tableName(); + $x = $this->factory($tn); + $all_links = $x->databaseLinks(); foreach($all_links as $tbl => $links) { foreach($links as $col => $totbl_col) { @@ -429,7 +446,7 @@ class Pman_Core_DataObjects_Core_enum extends DB_DataObject $this->delete(); - $roo->jok('Merged'); + }