Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1092939
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Aug 11, 7:41 AM
Size
15 KB
Mime Type
text/x-diff
Expires
Wed, Aug 13, 7:41 AM (6 h, 3 m)
Engine
blob
Format
Raw Data
Handle
707889
Attached To
rINP In-Portal
in-portal
View Options
Index: branches/unlabeled/unlabeled-1.14.2/kernel/include/custommetadata.php
===================================================================
--- branches/unlabeled/unlabeled-1.14.2/kernel/include/custommetadata.php (revision 8304)
+++ branches/unlabeled/unlabeled-1.14.2/kernel/include/custommetadata.php (revision 8305)
@@ -1,185 +1,188 @@
<?php
class clsCustomMetaData extends clsItem
{
// var $m_CustomDataId;
// var $m_ResourceId;
// var $m_CustomFieldId;
// var $m_Value;
var $FieldName;
function clsCustomMetaData($CustomDataId=-1,$table="CustomMetaData")
{
parent::clsItem();
$this->tablename=GetTablePrefix()."CustomMetaData";
$this->type=12;
$this->BasePermission="";
$this->id_field = "CustomDataId";
$this->NoResourceId=1; //set this to avoid using a resource ID
}
}
class clsCustomDataList extends clsItemCollection
{
function clsCustomDataList()
{
parent::clsItemCollection();
$this->classname = 'clsCustomMetaData';
}
function LoadResource($ResourceId)
{
// TO REMOVE
}
function DeleteResource($ResourceId, $main_prefix)
{
if (!$ResourceId) return false;
-
+
+ $this->Application->getUnitOption($main_prefix, 'TableName');
$custom_table = $this->Application->getUnitOption($main_prefix.'-cdata', 'TableName');
$sql = 'DELETE FROM '.$custom_table.'
WHERE ResourceId = '.$ResourceId;
$this->adodbConnection->Execute($sql);
}
function CopyResource($OldId,$NewId, $main_prefix)
{
+ $this->Application->getUnitOption($main_prefix, 'TableName');
$custom_data =& $this->Application->recallObject($main_prefix.'-cdata.-item', null, Array('skip_autoload' => true));
$custom_data->Load($OldId, 'ResourceId');
if ($custom_data->isLoaded()) {
$custom_data->SetDBField('ResourceId', $NewId);
$custom_data->Create();
}
}
function &SetFieldValue($FieldId,$ResourceId,$Value)
{
// 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);
if(!strlen($Value))
{
for($x=0;$x<count($this->Items);$x++)
{
if($this->Items[$x]->Get("CustomFieldId") == $FieldId && $this->Items[$x]->Get("ResourceId") == $ResourceId)
{
$this->Items[$x]->Set("CustomFieldId",0);
break;
}
}
$d->Delete(true);
}
}
else
{
$d = new clsCustomMetaData();
$d->Set("CustomFieldId",$FieldId);
$d->Set("ResourceId",$ResourceId);
$d->Set("Value",$Value);
array_push($this->Items,$d);
}
return $d;
}
function &GetDataItem($id, $return_index = false)
{
// $id - custom field id to find
// $return_index - return index to items, not her.
$found = false;
$index = false;
for($i = 0; $i < $this->NumItems(); $i++)
{
$d =& $this->GetItemRefByIndex($i);
if($d->Get("CustomFieldId")==$id)
{
$found = true;
break;
}
}
return $found ? ($return_index ? $i : $d) : $found;
}
function SaveData($main_prefix, $resource_id)
{
// to call OnAfterConfigRead event
$item_table = $this->Application->getUnitOption($main_prefix, 'TableName');
$ml_formatter =& $this->Application->recallObject('kMultiLanguage');
$custom_data =& $this->Application->recallObject($main_prefix.'-cdata', null, Array('skip_autoload' => true));
$custom_data->Load($resource_id, 'ResourceId');
foreach($this->Items as $f) {
$custom_id = $f->Get('CustomFieldId');
$value = isset($GLOBALS['_CopyFromEditTable']) ? $f->Get('Value') : stripslashes($f->Get('Value'));
$custom_name = $ml_formatter->LangFieldName('cust_'.$custom_id);
$custom_data->SetDBField($custom_name, $value);
}
$custom_data->SetDBField('ResourceId', $resource_id);
return $custom_data->isLoaded() ? $custom_data->Update() : $custom_data->Create();
}
function &getTempHandler($prefix)
{
if (strlen($prefix) > 2 || strlen($prefix) == 0) {
// not e.g. bb, c, u, but CustomFieldId :) or empty at all
$this->Application->reportError(get_class($this), 'CopyToEditTable');
}
-
+
+ $this->Application->getUnitOption($prefix, 'TableName');
$temp_handler =& $this->Application->recallObject($prefix.'-cdata_TempHandler', 'kTempTablesHandler');
return $temp_handler;
}
function CopyToEditTable($main_prefix, $idlist)
{
$temp_handler =& $this->getTempHandler($main_prefix);
$tables = $temp_handler->Tables;
$parent_prefix = $this->Application->getUnitOption($main_prefix.'-cdata', 'ParentPrefix');
if ($parent_prefix) {
$tables['ForeignKey'] = $this->Application->getUnitOption($main_prefix.'-cdata', 'ForeignKey');
$tables['ParentPrefix'] = $parent_prefix;
$tables['ParentTableKey'] = $this->Application->getUnitOption($main_prefix.'-cdata', 'ParentTableKey');
}
$temp_handler->Tables = $tables;
$temp_handler->DoCopyLiveToTemp($temp_handler->Tables, $idlist);
}
function CopyFromEditTable($main_prefix)
{
$temp_handler =& $this->getTempHandler($main_prefix);
$temp_handler->DoCopyTempToOriginal($temp_handler->Tables);
}
function PurgeEditTable($main_prefix)
{
$temp_handler =& $this->getTempHandler($main_prefix);
$temp_handler->CancelEdit();
}
function CreateEmptyEditTable($main_prefix)
{
$temp_handler =& $this->getTempHandler($main_prefix);
$temp_handler->DoCopyLiveToTemp($temp_handler->Tables, Array(0));
}
}
?>
Property changes on: branches/unlabeled/unlabeled-1.14.2/kernel/include/custommetadata.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.14
\ No newline at end of property
+1.14.2.1
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.16.2/kernel/include/customfield.php
===================================================================
--- branches/unlabeled/unlabeled-1.16.2/kernel/include/customfield.php (revision 8304)
+++ branches/unlabeled/unlabeled-1.16.2/kernel/include/customfield.php (revision 8305)
@@ -1,289 +1,290 @@
<?php
class clsCustomField extends clsItem
{
function clsCustomField($CustomFieldId=-1)
{
$this->clsItem();
$this->tablename=GetTablePrefix()."CustomField";
$this->type=10;
$this->BasePermission="";
$this->id_field = "CustomFieldId";
$this->NoResourceId=1; //set this to avoid using a resource ID
$this->debuglevel=0;
if($CustomFieldId>-1)
$this->LoadFromDatabase($CustomFieldId);
}
function GetAdminUI()
{
$a = new clsConfigAdminItem();
$a->name = "_".$this->Get("FieldName");
$a->heading = $this->Get("Heading");
$a->prompt = $this->Get("Prompt");
$a->ElementType = $this->Get("ElementType");
$a->ValidationRules="";
$a->default_value = "";
$a->ValueList=$this->Get("ValueList");
if(!strlen($a->ElementType))
$a->ElementType="text";
if(!strlen($a->prompt))
$a->prompt = "lu_fieldcustom__".strtolower($this->Get("FieldName"));
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");
default:
return "Undefined:$tagname";
break;
}
}
}
class clsCustomFieldList extends clsItemCollection
{
var $Type;
function clsCustomFieldList($type = -1, $table = 'CustomField')
{
$this->clsItemCollection();
$this->Type = $type;
$this->classname = 'clsCustomField';
if ($table == 'CustomField') {
$table = GetTablePrefix().$table;
}
$this->SourceTable = $table;
if ($this->Type > 0) {
$this->LoadFields();
}
}
function LoadFields()
{
$this->Clear();
$sql = 'SELECT *
FROM '.$this->SourceTable.'
WHERE Type = '.$this->Type.' AND (IsSystem = 0 OR OnGeneralTab = 1)
ORDER BY DisplayOrder DESC, CustomFieldId ASC';
if($this->debuglevel > 1)
echo $sql."<br>\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();
-
+
+ $this->Application->getUnitOption($main_prefix, 'TableName');
$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);
$custom_info['Value'] = $custom_data[$custom_name];
$custom_info['CustomDataId'] = 0;
$this->AddItemFromArray($custom_info);
}
}
function GetFieldUIList($GeneralTab=FALSE)
{
$ret = new clsConfigAdmin();
if ($this->NumItems() > 0) {
foreach ($this->Items as $field) {
if ($GeneralTab == true && $field->Get('OnGeneralTab') == 1 || !$GeneralTab) {
$ui = $field->GetAdminUI();
array_push($ret->Items,$ui);
}
}
}
return $ret;
}
function GetFieldNames()
{
$res = array();
foreach($this->Items as $f)
$res[] = $f->Get("FieldName");
return $res;
}
function SaveFields()
{
foreach($this->Items as $i)
{
if($i->Get("CustomFieldId"))
{
$i->Update();
}
else
$i->Create();
}
}
function Query_CustomField($where=NULL,$orderby=NULL,$limit=NULL)
{
$this->Clear();
$sql = "SELECT * FROM ".$this->SourceTable;
if(isset($where))
$sql = sprintf('%s WHERE %s',$sql,$where);
if(isset($orderby) && strlen(trim($orderby))>0)
$sql = sprintf('%s ORDER BY %s',$sql,$orderby);
if(isset($limit) && strlen(trim($limit)))
$sql .= " ".$limit;
// $sql."<br>";
$this->Query_Item($sql);
return $this->Items;
}
function AddField($Type,$FieldName,$FieldLabel,$ShowGeneral=0,$Heading="", $Prompt="",
$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",
"ElementType","ValueList"),
array($Type,$FieldName,$FieldLabel,$ShowGeneral,$Heading,$Prompt,
$ElementType,$ValueList));
$f->Create();
$Item = $objItemTypes->GetItem($Type);
if(is_object($Item))
{
//$Table = $Item->Get("SourceTable");
$Table = 'CustomField';
$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') );
$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;
$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;
}
function DeleteField($FieldId)
{
global $objItemTypes, $objSearchConfig;
//echo "<pre>"; print_r($objSearchConfig); echo "</pre>";
$f = $this->GetItem($FieldId);
$Type = $f->Get("Type");
$Item = $objItemTypes->GetItem($Type);
$Module = $Item->Get("Module");
if(is_object($Item))
{
//$table = $Item->Get("TableName");
$table = GetTablePrefix()."CustomField";
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*/
?>
Property changes on: branches/unlabeled/unlabeled-1.16.2/kernel/include/customfield.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.16
\ No newline at end of property
+1.16.2.1
\ No newline at end of property
Event Timeline
Log In to Comment