Index: trunk/kernel/include/customfield.php =================================================================== diff -u -N -r7391 -r7635 --- trunk/kernel/include/customfield.php (.../customfield.php) (revision 7391) +++ trunk/kernel/include/customfield.php (.../customfield.php) (revision 7635) @@ -2,11 +2,11 @@ class clsCustomField extends clsItem { - + function clsCustomField($CustomFieldId=-1) { $this->clsItem(); - $this->tablename=GetTablePrefix()."CustomField"; + $this->tablename=GetTablePrefix()."CustomField"; $this->type=10; $this->BasePermission=""; $this->id_field = "CustomFieldId"; @@ -31,27 +31,27 @@ $a->ElementType="text"; if(!strlen($a->prompt)) $a->prompt = "lu_fieldcustom__".strtolower($this->Get("FieldName")); - return $a; - } - + return $a; + } + function parsetag($tag) - { + { if(is_object($tag)) - { + { $tagname = $tag->name; } else $tagname = $tag; switch($tagname) - { + { case "fieldlabel": return $this->Get("FieldLabel"); break; - + case "fieldname": return $this->Get("FieldName"); break; - + case "customfieldid": return $this->Get("CustomFieldId"); @@ -75,7 +75,7 @@ if ($table == 'CustomField') { $table = GetTablePrefix().$table; } - + $this->SourceTable = $table; if ($this->Type > 0) { $this->LoadFields(); @@ -87,39 +87,39 @@ $this->Clear(); $sql = 'SELECT * FROM '.$this->SourceTable.' - WHERE Type = '.$this->Type.' AND IsSystem = 0 + WHERE Type = '.$this->Type.' AND (IsSystem = 0 OR OnGeneralTab = 1) ORDER BY DisplayOrder DESC, CustomFieldId ASC'; - if($this->debuglevel > 1) + if($this->debuglevel > 1) echo $sql."
\n"; $rs = $this->adodbConnection->Execute($sql); - + while($rs && !$rs->EOF) { $data = $rs->fields; $this->AddItemFromArray($data); $rs->MoveNext(); - } + } } function LoadFieldsAndValues($ResourceId, $main_prefix, $temp_table = false) { $this->Clear(); - + $table = $this->Application->getUnitOption($main_prefix.'-cdata', 'TableName'); if ($temp_table) { $table = $this->Application->GetTempName($table, 'prefix:'.$main_prefix); } - + $sql = 'SELECT * FROM '.$table.' WHERE ResourceId = '.$ResourceId; $custom_data = $this->adodbConnection->GetRow($sql); - + $sql = 'SELECT * FROM '.TABLE_PREFIX.'CustomField WHERE Type = '.$this->Application->getUnitOption($main_prefix, 'ItemType'); $custom_fields = $this->Conn->Query($sql, 'CustomFieldId'); - + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); foreach ($custom_fields as $custom_id => $custom_info) { $custom_name = $ml_formatter->LangFieldName('cust_'.$custom_id); @@ -128,7 +128,7 @@ $this->AddItemFromArray($custom_info); } } - + function GetFieldUIList($GeneralTab=FALSE) { $ret = new clsConfigAdmin(); @@ -185,9 +185,9 @@ $ElementType="",$ValueList="") { global $objItemTypes,$objSearchConfig,$objLanguages; - + //if(!is_numeric($Type)) - // { + // { $f = new clsCustomField(); $f->tablename = $this->SourceTable; $f->Set(array("Type","FieldName","FieldLabel","OnGeneralTab","Heading","Prompt", @@ -203,56 +203,56 @@ $Header = "la_text_".strtolower($Item->Get("ItemName")); $Module = $Item->Get("Module"); // $Desc = $FieldLabel; - + if(!is_object($objSearchConfig)) { $objSearchConfig = new clsSearchConfigList(); } - + $NextOrder = $objSearchConfig->GetNextDisplayOrder($Module); $desc = "lu_fieldcustom__".strtolower($FieldName); if(!strlen($FieldLabel)) { $FieldLabel = $FieldName; } - + $l = $objLanguages->GetPrimary(); $phrases = new clsPhraseList(); - $phrases->AddPhrase($desc,$l,$FieldLabel,2, $Item->Get('Module') ); - + $phrases->AddPhrase($desc,$l,$FieldLabel,2, $Item->Get('Module') ); + $dtable = GetTablePrefix()."CustomMetaData"; $Join = "($dtable.ResourceId={Table}.ResourceId)"; $objSearchConfig->AddSearchField($Table,$FieldName,$Module,$Type == 6 ? -1 : 0,0, $FieldLabel,$desc,$Header,$NextOrder,0, $ElementType, NULL, NULL, NULL, NULL, NULL, $f->Get("CustomFieldId"), NULL); - } + } return $f; //} //else // return FALSE; } - + function EditField($FieldId,$Type,$FieldName,$FieldLabel,$ShowGeneral=0,$Heading="", $Prompt="",$ElementType="",$ValueList="") { global $objSearchConfig; - + $f = $this->GetItem($FieldId); $f->Set(array("Type","FieldName","FieldLabel","OnGeneralTab","Heading","Prompt","ElementType","ValueList"), array($Type,$FieldName,$FieldLabel,$ShowGeneral,$Heading,$Prompt,$ElementType,$ValueList)); $f->Update(); - + $db =& $this->adodbConnection; - - if (!$FieldLabel) $FieldLabel = $FieldName; + + if (!$FieldLabel) $FieldLabel = $FieldName; $sql = 'UPDATE '.GetTablePrefix().'SearchConfig SET FieldType = '.$db->qstr($ElementType).', DisplayName = '.$db->qstr('lu_fieldcustom__'.strtolower($FieldName)).', FieldName = '.$db->qstr($FieldName).', Description = '.$db->qstr($FieldLabel).' WHERE CustomFieldId = '.$FieldId; $this->adodbConnection->Execute($sql); - + return $f; } @@ -271,17 +271,17 @@ if(!is_object($objSearchConfig)) { $objSearchConfig = new clsSearchConfigList($Module); - } - + } + $sql = 'DELETE FROM '.$objSearchConfig->SourceTable.' WHERE CustomFieldId = '.$FieldId; $this->adodbConnection->Execute($sql); - + $phrase_name = 'lu_fieldcustom__'.strtolower($f->Get('FieldName')); $sql = 'DELETE FROM '.GetTablePrefix().'Phrase WHERE Phrase = '.$this->adodbConnection->qstr($phrase_name); $this->adodbConnection->Execute($sql); } $f->Delete(); - } + } }/*clsCustomFieldList*/