Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Feb 2, 9:08 PM

in-portal

Index: trunk/kernel/units/configuration/configuration_event_handler.php
===================================================================
--- trunk/kernel/units/configuration/configuration_event_handler.php (revision 1874)
+++ trunk/kernel/units/configuration/configuration_event_handler.php (revision 1875)
@@ -1,165 +1,170 @@
<?php
class ConfigurationEventHandler 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('conf_module'));
$this->Application->SetVar("module", $module_owner);
}
$section=$this->Application->GetVar('section');
if ($section===false){
$section=$this->myUrlDecode($this->Application->GetVar('conf_section'));
$this->Application->SetVar("section", $section);
}
$object->addFilter('module_filter', '%1$s.ModuleOwner = "'.$module_owner.'"');
$object->addFilter('section_filter', '%1$s.Section = "'.$section.'"');
$object->AddOrderField('DisplayOrder', 'ASC');
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnBeforeItemUpdate(&$event)
{
$object =& $event->getObject();
if($object->GetDBField('element_type') == 'password')
{
if (trim($object->GetDBField('VariableValue'))=='') {
$field_options=$object->GetFieldOptions('VariableValue');
$field_options['skip_empty']=1;
$object->SetFieldOptions('VariableValue', $field_options);
}else{
$object->SetDBField('VariableValue', md5($object->GetDBField('VariableValue')));
}
}
- $this->country_state_pairs = Array('Comm_Country' => 'Comm_State', 'Comm_Shipping_Country' => 'Comm_Shipping_State');
+ $submitted_vars = $this->Application->GetVar('conf');
- if ( isset($this->country_state_pairs[$object->GetDBField('VariableName')]) ){
- $this->state_country_codes[$this->country_state_pairs[$object->GetDBField('VariableName')]]=$object->GetDBField('VariableValue');
- }
+ //$this->country_state_pairs = Array('Comm_Country' => 'Comm_State', 'Comm_Shipping_Country' => 'Comm_Shipping_State');
+ $this->state_country_pairs = Array('Comm_State' => 'Comm_Country', 'Comm_Shipping_State' => 'Comm_Shipping_Country');
- if( isset($this->state_country_codes[$object->GetDBField('VariableName')]) )
- {
+ if ( isset($this->state_country_pairs[$object->GetDBField('VariableName')]) ){
+ //$this->state_country_codes[$this->country_state_pairs[$object->GetDBField('VariableName')]]=$object->GetDBField('VariableValue');
+ $check_state = $object->GetDBField('VariableValue');
+ $check_country = $submitted_vars[$this->state_country_pairs[$object->GetDBField('VariableName')]]['VariableValue'];
+ //}
+
+ //if( isset($this->state_country_codes[$object->GetDBField('VariableName')]) )
+ //{
$cs_helper = &$this->Application->recallObject('CountryStatesHelper');
- $state_valid_code = $cs_helper->CheckState( $object->GetDBField('VariableValue'), $this->state_country_codes[$object->GetDBField('VariableName')] );
+ $state_valid_code = $cs_helper->CheckState( $check_state, $check_country );
if ($state_valid_code !== false)
{
$object->SetDBField('VariableValue', $state_valid_code);
}
else
{
$errormsgs = $this->Application->GetVar('errormsgs');
$errors = !$errormsgs || !isset($errormsgs[$event->Prefix_Special]) ? Array() : $errormsgs[$event->Prefix_Special];
$errors[ $object->GetDBField('VariableName') ] = 'la_InvalidState';
$errormsgs[$event->Prefix_Special] = $errors;
$this->Application->SetVar('errormsgs', $errormsgs);
$event->redirect = false;
$event->status = erFAIL;
}
}
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnAfterItemUpdate(&$event)
{
$object =& $event->getObject();
if($object->GetDBField('element_type') == 'password')
{
if (trim($object->GetDBField('VariableValue'))=='') {
$field_options=$object->GetFieldOptions('VariableValue');
unset($field_options['skip_empty']);
$object->SetFieldOptions('VariableValue', $field_options);
}
}
}
function OnUpdate(&$event)
{
if (!$this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 0)) {
parent::OnUpdate($event);
}
$module_owner=$this->Application->GetVar('module');
$section=$this->Application->GetVar('section');
$event->redirect_params = Array('opener' => 's','conf_section'=>$this->myUrlEncode($section), 'conf_module'=>$this->myUrlEncode($module_owner),'pass'=>'all,conf'); //stay!
if ($this->Application->GetVar('errormsgs')){
$event->redirect = false;
}
}
function OnCancel(&$event)
{
parent::OnCancel($event);
$module_owner=$this->Application->GetVar('module');
$section=$this->Application->GetVar('section');
$event->redirect_params = Array('opener' => 's','conf_section'=>$this->myUrlEncode($section), 'conf_module'=>$this->myUrlEncode($module_owner),'pass'=>'all,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 OnChangeCountry(&$event)
{
$event->setPseudoClass('_List');
$object = &$event->getObject( Array('per_page'=>-1) );
$object->Query();
//$object->SetDBField('');
$array_records = &$object->Records;
foreach($array_records as $i=>$record){
if ($record['VariableName']=='Comm_Country'){
$values = $this->Application->GetVar('conf');
$array_records[$i]['VariableValue'] = $values['Comm_Country']['VariableValue'];
}
}
$event->redirect_params = Array('opener' => 's', 'pass'=>'all,conf'); //stay!
$event->redirect = false;
}
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/configuration/configuration_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.7
\ No newline at end of property
+1.8
\ No newline at end of property
Index: trunk/core/units/configuration/configuration_event_handler.php
===================================================================
--- trunk/core/units/configuration/configuration_event_handler.php (revision 1874)
+++ trunk/core/units/configuration/configuration_event_handler.php (revision 1875)
@@ -1,165 +1,170 @@
<?php
class ConfigurationEventHandler 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('conf_module'));
$this->Application->SetVar("module", $module_owner);
}
$section=$this->Application->GetVar('section');
if ($section===false){
$section=$this->myUrlDecode($this->Application->GetVar('conf_section'));
$this->Application->SetVar("section", $section);
}
$object->addFilter('module_filter', '%1$s.ModuleOwner = "'.$module_owner.'"');
$object->addFilter('section_filter', '%1$s.Section = "'.$section.'"');
$object->AddOrderField('DisplayOrder', 'ASC');
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnBeforeItemUpdate(&$event)
{
$object =& $event->getObject();
if($object->GetDBField('element_type') == 'password')
{
if (trim($object->GetDBField('VariableValue'))=='') {
$field_options=$object->GetFieldOptions('VariableValue');
$field_options['skip_empty']=1;
$object->SetFieldOptions('VariableValue', $field_options);
}else{
$object->SetDBField('VariableValue', md5($object->GetDBField('VariableValue')));
}
}
- $this->country_state_pairs = Array('Comm_Country' => 'Comm_State', 'Comm_Shipping_Country' => 'Comm_Shipping_State');
+ $submitted_vars = $this->Application->GetVar('conf');
- if ( isset($this->country_state_pairs[$object->GetDBField('VariableName')]) ){
- $this->state_country_codes[$this->country_state_pairs[$object->GetDBField('VariableName')]]=$object->GetDBField('VariableValue');
- }
+ //$this->country_state_pairs = Array('Comm_Country' => 'Comm_State', 'Comm_Shipping_Country' => 'Comm_Shipping_State');
+ $this->state_country_pairs = Array('Comm_State' => 'Comm_Country', 'Comm_Shipping_State' => 'Comm_Shipping_Country');
- if( isset($this->state_country_codes[$object->GetDBField('VariableName')]) )
- {
+ if ( isset($this->state_country_pairs[$object->GetDBField('VariableName')]) ){
+ //$this->state_country_codes[$this->country_state_pairs[$object->GetDBField('VariableName')]]=$object->GetDBField('VariableValue');
+ $check_state = $object->GetDBField('VariableValue');
+ $check_country = $submitted_vars[$this->state_country_pairs[$object->GetDBField('VariableName')]]['VariableValue'];
+ //}
+
+ //if( isset($this->state_country_codes[$object->GetDBField('VariableName')]) )
+ //{
$cs_helper = &$this->Application->recallObject('CountryStatesHelper');
- $state_valid_code = $cs_helper->CheckState( $object->GetDBField('VariableValue'), $this->state_country_codes[$object->GetDBField('VariableName')] );
+ $state_valid_code = $cs_helper->CheckState( $check_state, $check_country );
if ($state_valid_code !== false)
{
$object->SetDBField('VariableValue', $state_valid_code);
}
else
{
$errormsgs = $this->Application->GetVar('errormsgs');
$errors = !$errormsgs || !isset($errormsgs[$event->Prefix_Special]) ? Array() : $errormsgs[$event->Prefix_Special];
$errors[ $object->GetDBField('VariableName') ] = 'la_InvalidState';
$errormsgs[$event->Prefix_Special] = $errors;
$this->Application->SetVar('errormsgs', $errormsgs);
$event->redirect = false;
$event->status = erFAIL;
}
}
}
/**
* Enter description here...
*
* @param kEvent $event
*/
function OnAfterItemUpdate(&$event)
{
$object =& $event->getObject();
if($object->GetDBField('element_type') == 'password')
{
if (trim($object->GetDBField('VariableValue'))=='') {
$field_options=$object->GetFieldOptions('VariableValue');
unset($field_options['skip_empty']);
$object->SetFieldOptions('VariableValue', $field_options);
}
}
}
function OnUpdate(&$event)
{
if (!$this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 0)) {
parent::OnUpdate($event);
}
$module_owner=$this->Application->GetVar('module');
$section=$this->Application->GetVar('section');
$event->redirect_params = Array('opener' => 's','conf_section'=>$this->myUrlEncode($section), 'conf_module'=>$this->myUrlEncode($module_owner),'pass'=>'all,conf'); //stay!
if ($this->Application->GetVar('errormsgs')){
$event->redirect = false;
}
}
function OnCancel(&$event)
{
parent::OnCancel($event);
$module_owner=$this->Application->GetVar('module');
$section=$this->Application->GetVar('section');
$event->redirect_params = Array('opener' => 's','conf_section'=>$this->myUrlEncode($section), 'conf_module'=>$this->myUrlEncode($module_owner),'pass'=>'all,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 OnChangeCountry(&$event)
{
$event->setPseudoClass('_List');
$object = &$event->getObject( Array('per_page'=>-1) );
$object->Query();
//$object->SetDBField('');
$array_records = &$object->Records;
foreach($array_records as $i=>$record){
if ($record['VariableName']=='Comm_Country'){
$values = $this->Application->GetVar('conf');
$array_records[$i]['VariableValue'] = $values['Comm_Country']['VariableValue'];
}
}
$event->redirect_params = Array('opener' => 's', 'pass'=>'all,conf'); //stay!
$event->redirect = false;
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/units/configuration/configuration_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.7
\ No newline at end of property
+1.8
\ No newline at end of property

Event Timeline