Index: trunk/kernel/include/item.php =================================================================== diff -u -N -r3576 -r4077 --- trunk/kernel/include/item.php (.../item.php) (revision 3576) +++ trunk/kernel/include/item.php (.../item.php) (revision 4077) @@ -124,13 +124,12 @@ /* item custom fields */ - function LoadCustomFields($force = null) + function LoadCustomFields($force = null, $temp_table = false) { - if((!is_null($force) || !$this->CustomLoaded) && $this->Get("ResourceId")>0) - { + if ((!is_null($force) || !$this->CustomLoaded) && $this->Get('ResourceId')>0) { $this->FieldClass = new clsCustomFieldList(); $this->FieldClass->Type = $this->type; - $this->FieldClass->LoadFieldsAndValues($this->Get("ResourceId")); + $this->FieldClass->LoadFieldsAndValues($this->Get("ResourceId"), $this->Prefix, $temp_table); foreach($this->FieldClass->Items as $f) { if (strlen($f->Get("ValueList") && (($f->Get("ElementType") == "select") || ($f->Get("ElementType") == "radio")))) @@ -191,13 +190,12 @@ return TRUE; $data = new clsCustomDataList(); - $data->LoadResource($this->Get("ResourceId")); foreach($this->FieldClass->Items as $f) { $value = $this->CustomFields[$f->Get("FieldName")]; $data->SetFieldValue($f->Get("CustomFieldId"),$this->Get("ResourceId"),$value); } - $data->SaveData(); + $data->SaveData($this->Prefix, $this->Get('ResourceId')); unset($data); } @@ -226,19 +224,18 @@ } */ - function GetCustomFieldValue($fieldname, $default="", $ListValue = 0) + function GetCustomFieldValue($fieldname, $default = '', $ListValue = 0, $temp_table = false) { - if(!$this->CustomLoaded) - $this->LoadCustomFields(null); - elseif (is_array($this->CustomFields) && empty($this->CustomFields)) - $this->LoadCustomFields(1); - - $fieldname = strtolower($fieldname); + if (!$this->CustomLoaded) { + $this->LoadCustomFields(null, $temp_table); + } + elseif (is_array($this->CustomFields) && empty($this->CustomFields)) { + $this->LoadCustomFields(1, $temp_table); + } - foreach($this->CustomFields as $k => $v) - { - if(strtolower($k) == $fieldname) - { + $fieldname = strtolower($fieldname); + foreach($this->CustomFields as $k => $v) { + if (strtolower($k) == $fieldname) { return $ListValue? $v['lang_value'] : $v['value']; } } @@ -249,7 +246,7 @@ function DeleteCustomData() { $cdata = new clsCustomDataList(); - $cdata->DeleteResource($this->Get("ResourceId")); + $cdata->DeleteResource($this->Get('ResourceId'), $this->Prefix); } function Delete($RecordOnly=FALSE) @@ -978,26 +975,25 @@ if(!is_numeric($this->Get("OrgId"))) $this->UnsetField("OrgId"); $this->UnsetField("ResourceId"); - if(is_numeric($TargetCat) && strlen($NameField)) - { + if (is_numeric($TargetCat) && strlen($NameField)) { $OldName = $this->Get($NameField); - if(substr($OldName,0,5)=="Copy ") - { + if (substr($OldName,0,5)=="Copy ") { $parts = explode(" ",$OldName,4); - if($parts[2]=="of" && is_numeric($parts[1])) - { + if ($parts[2]=="of" && is_numeric($parts[1])) { $Name = $parts[3]; } - else - if($parts[1]=="of") - { - $Name = $parts[2]." ".$parts[3]; + else { + if ($parts[1]=="of") { + $Name = $parts[2]." ".$parts[3]; + } + else { + $Name = $OldName; + } } - else + } + else { $Name = $OldName; } - else - $Name = $OldName; $Names = CategoryItemNameCount($TargetCat,$this->tablename,$NameField,$Name); if(count($Names)>0) { @@ -1044,12 +1040,12 @@ // copy custom fields $cdata = new clsCustomDataList(); - $cdata->CopyResource($OldId,$NewId); + $cdata->CopyResource($OldId,$NewId,$this->Prefix); unset($cdata); // copy images if(is_object($this->Images)) - $this->Images->CopyResource($OldId,$NewId); + $this->Images->CopyResource($OldId,$NewId,$this->Prefix); $this->AddToCategory($TargetCat, '', 0); // insert (but with duplicate records check) //echo "ok";