Index: trunk/kernel/include/custommetadata.php =================================================================== diff -u -r13 -r104 --- trunk/kernel/include/custommetadata.php (.../custommetadata.php) (revision 13) +++ trunk/kernel/include/custommetadata.php (.../custommetadata.php) (revision 104) @@ -90,7 +90,7 @@ $this->classname = "clsCustomMetaData"; if(!strlen($table)) $table = GetTablePrefix()."CustomMetaData"; - $this->SourceTable = $table; + $this->SetTable('live', $table); } function LoadResource($ResourceId) @@ -108,7 +108,16 @@ function &SetFieldValue($FieldId,$ResourceId,$Value) { - $d =& $this->GetDataItem($FieldId); + // so strange construction used, because in normal + // way it doesn't work at all (gets item copy not + // pointer) + $index = $this->GetDataItem($FieldId, true); + + if($index !== false) + $d =& $this->Items[$index]; + else + $d = null; + if(is_object($d)) { $d->Set("Value",$Value); @@ -137,13 +146,17 @@ array_push($this->Items,$d); } } + $this->ShowItems(); return $d; } - function &GetDataItem($id) + function &GetDataItem($id, $return_index = false) { + // $id - custom field id to find + // $return_index - return index to items, not her. $found = false; - for($i=0;$i<$this->NumItems();$i++) + $index = false; + for($i = 0; $i < $this->NumItems(); $i++) { $d =& $this->GetItemRefByIndex($i); if($d->Get("CustomFieldId")==$id) @@ -152,7 +165,7 @@ break; } } - return ($found) ? $d : false; + return $found ? ($return_index ? $i : $d) : false; } function SaveData()