Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Mon, Sep 29, 7:25 AM

in-portal

Index: branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_config.php
===================================================================
--- branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_config.php (revision 1372)
+++ branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_config.php (revision 1373)
@@ -1,90 +1,99 @@
<?php
$config = Array(
'Prefix' => 'confs',
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'ConfigSearchEventHandler','file'=>'config_search_event_handler.php','build_event'=>'OnBuild'),
'TagProcessorClass' => Array('class'=>'ConfigSearchTagProcessor','file'=>'config_search_tag_processor.php','build_event'=>'OnBuild'),
'AutoLoad' => true,
'hooks' => Array(),
'QueryString' => Array(
1 => 'id',
2 => 'page',
3 => 'event',
4 => 'module',
5 => 'section',
),
'Hooks' => Array(
Array(
'Mode' => hAFTER,
'Conditional' => false,
'HookToPrefix' => 'cf',
'HookToSpecial' => '',
- //'HookToEvent' => Array( 'OnPreSaveCreated' ),
'HookToEvent' => Array( 'OnSave' ),
'DoPrefix' => 'confs',
'DoSpecial' => '',
'DoEvent' => 'OnCreateCustomField',
),
+ Array(
+ 'Mode' => hAFTER,
+ 'Conditional' => false,
+ 'HookToPrefix' => 'cf',
+ 'HookToSpecial' => '-item',
+ 'HookToEvent' => Array( 'OnAfterItemDelete' ),
+ 'DoPrefix' => 'confs',
+ 'DoSpecial' => '',
+ 'DoEvent' => 'OnDeleteCustomField',
+ ),
),
'IDField' => 'SearchConfigId',
'TitlePresets' => Array(
'config_list' => Array('prefixes' => Array('confs_List'), 'format' => "!la_updating_config!"),
),
'TableName' => TABLE_PREFIX.'SearchConfig',
'ListSQLs' => Array(''=>'SELECT *, IF('.TABLE_PREFIX.'SearchConfig.CustomFieldId=0, 0, 1) AS IsCustom FROM '.TABLE_PREFIX.'SearchConfig'),
'ItemSQLs' => Array(''=>'SELECT * FROM '.TABLE_PREFIX.'SearchConfig'),
'SubTables' => Array(),
'Fields' => Array(
'TableName' => Array('type' => 'string','not_null' => '1','default' => ''),
'FieldName' => Array('type' => 'string','not_null' => '1','default' => ''),
'SimpleSearch' => Array('type' => 'int','not_null' => '1','default' => '0'),
'AdvancedSearch' => Array('type' => 'int','not_null' => '1','default' => '0'),
'Description' => Array('type' => 'string','default' => ''),
'DisplayName' => Array('type' => 'string','default' => ''),
'ModuleName' => Array('type' => 'string','default' => ''),
'ConfigHeader' => Array('type' => 'string','default' => ''),
'DisplayOrder' => Array('type' => 'int','not_null' => '1','default' => '0'),
'SearchConfigId' => Array('type' => 'int','not_null' => '1','default' => ''),
'Priority' => Array('type' => 'int','not_null' => '1','default' => '0'),
'FieldType' => Array('type' => 'string','not_null' => '1','default' => 'text'),
'ForeignField' => Array('type' => 'string','default' => ''),
'JoinClause' => Array('type' => 'string','default' => ''),
'IsWhere' => Array('type' => 'string','default' => ''),
'IsNotWhere' => Array('type' => 'string','default' => ''),
'ContainsWhere' => Array('type' => 'string','default' => ''),
'NotContainsWhere' => Array('type' => 'string','default' => ''),
'CustomFieldId' => Array('type' => 'int','not_null' => '1','default' => '0'),
),
'VirtualFields' => Array(),
'ListSortings' => Array(
'' => Array(
'ForcedSorting' => Array('IsCustom' => 'asc'),
'Sorting' => Array('DisplayOrder' => 'asc'),
)
),
'Grids' => Array(
'Default' => Array(
'Icons' => Array('default'=>'icon16_custom.gif'), // icons for each StatusField values, if no matches or no statusfield selected, then "default" icon is used
'Fields' => Array(
'TableName' => Array( 'title'=>'la_col_TableName', 'data_block' => 'grid_data_td'),
'FieldName' => Array( 'title'=>'la_col_FieldName', 'data_block' => 'grid_data_td' ),
'SimpleSearch' => Array( 'title'=>'la_col_SimpleSearch', 'data_block' => 'grid_data_td'),
),
),
),
);
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_config.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1.2.3
\ No newline at end of property
+1.1.2.4
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_event_handler.php (revision 1372)
+++ branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_event_handler.php (revision 1373)
@@ -1,127 +1,139 @@
<?php
class ConfigSearchEventHandler extends InpDBEventHandler {
/**
* Apply any custom changes to list's sql query
*
* @param kEvent $event
* @access protected
* @see OnListBuild
*/
function SetCustomQuery(&$event)
{
$object =& $event->getObject();
$module_owner=$this->Application->GetVar('module');
if ($module_owner===false) {
$module_owner=$this->myUrlDecode($this->Application->GetVar('confs_module'));
$this->Application->SetVar("module", $module_owner);
}
$section=$this->Application->GetVar('section');
if ($section===false){
$section=$this->myUrlDecode($this->Application->GetVar('confs_section'));
$this->Application->SetVar("section", $section);
}
$object->addFilter('module_filter', '%1$s.ModuleName = "'.$module_owner.'"');
}
function OnUpdate(&$event)
{
parent::OnUpdate($event);
$module_owner=$this->Application->GetVar('module');
$module_section=$this->Application->GetVar('section');
$conf_update = new kEvent( );
$conf_update->Init('conf');
$conf_update->Name = 'OnUpdate';
$conf_update->redirect = false;
$this->Application->HandleEvent($conf_update);
$event->redirect_params = Array('opener' => 's','confs_module'=>$this->myUrlEncode($module_owner),'confs_section'=>$this->myUrlEncode($module_section),'conf_module'=>$this->myUrlEncode($module_owner),'conf_section'=>$this->myUrlEncode($module_section),'pass'=>'all,confs,conf'); //stay!
}
function OnCancel(&$event)
{
parent::OnCancel($event);
$module_owner=$this->Application->GetVar('module');
$module_section=$this->Application->GetVar('section');
$event->redirect_params = Array('opener' => 's','confs_module'=>$this->myUrlEncode($module_owner),'confs_section'=>$this->myUrlEncode($module_section),'conf_module'=>$this->myUrlEncode($module_owner),'conf_section'=>$this->myUrlEncode($module_section),'pass'=>'all,confs,conf'); //stay!
}
function myUrlDecode($str){
$str=str_replace(';',':', $str);
$str=str_replace('!','-', $str);
return $str;
}
function myUrlEncode($str){
$str=str_replace('-', '!', $str);
$str=str_replace(':', ';', $str);
return $str;
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnCreateCustomField(&$event)
{
$cf_object =& $event->MasterEvent->getObject();
$is_new = $event->MasterEvent->getEventParam('IsNew');
$cf_search = array();
$cf_search['DisplayOrder'] = $cf_object->FieldValues['DisplayOrder'];
$cf_search['ElementType'] = $cf_object->FieldValues['ElementType'];
$cf_search['DisplayName'] = $cf_object->FieldValues['FieldLabel'];
$cf_search['FieldName'] = $cf_object->FieldValues['FieldName'];
$cf_search['Description'] = $cf_object->FieldValues['Prompt'];
$cf_search['ConfigHeader'] = $cf_object->FieldValues['Heading'];
$cf_search['TableName'] = "CustomField";
$cf_search['ModuleName'] = "In-Commerce";
$cf_search['ForeignField'] = "CustomMetaData.Value";
$cf_search['JoinClause'] = "{ForeignTable}.CustomFieldId={LocalTable}.CustomFieldId";
if($is_new)
{
$live_id = $this->Conn->GetOne("SELECT CustomFieldId FROM ".TABLE_PREFIX."CustomField WHERE FieldName='".$cf_search['FieldName']."'");
$cf_search['CustomFieldId'] = $live_id;
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$confs_item = $event->getObject();
$confs_item->SetFieldsFromHash($cf_search);
$confs_item->Create();
}else{
$cf_search['CustomFieldId'] = $cf_object->FieldValues['CustomFieldId'];
$search_config_id = $this->Conn->GetOne("SELECT SearchConfigId FROM ".TABLE_PREFIX."SearchConfig WHERE CustomFieldId='".$cf_object->FieldValues['CustomFieldId']."'");
$cf_search['SearchConfigId'] = $search_config_id;
$this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
$confs_item = $event->getObject();
$confs_item->SetFieldsFromHash($cf_search);
$confs_item->Update($search_config_id);
}
}
+
+ /**
+ * Enter description here...
+ *
+ * @param kEvent $event
+ */
+ function OnDeleteCustomField(&$event){
+
+ $custom_field_id =&$event->MasterEvent->getEventParam('id');
+ $this->Conn->Query("DELETE FROM ".TABLE_PREFIX."SearchConfig WHERE CustomFieldId=".$custom_field_id);
+
+ }
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.1.2/core/units/config_search/config_search_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1.2.5
\ No newline at end of property
+1.1.2.6
\ No newline at end of property

Event Timeline