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'] = 'la_Text_CustomFields'; $cf_search['TableName'] = "CustomField"; $cf_search['ModuleName'] = "In-Commerce"; $cf_search['ForeignField'] = "CustomMetaData.Value"; $cf_search['JoinClause'] = "{ForeignTable}.ResourceId={LocalTable}.ResourceId"; 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); } } ?>