Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1377033
gw_event_handler.php
No One
Temporary
Actions
Download 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, Feb 2, 12:50 AM
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Feb 4, 12:50 AM (1 h, 43 m)
Engine
blob
Format
Raw Data
Handle
885018
Attached To
rMINC Modules.In-Commerce
gw_event_handler.php
View Options
<?php
class
GatewayEventHandler
extends
kDBEventHandler
{
function
OnSaveValues
(&
$event
)
{
// if there is no id - it means we need to create an item
$item_id
=
$this
->
getPassedID
(
$event
);
$event
->
setPseudoClass
(
'_List'
);
$items_info
=
$this
->
Application
->
GetVar
(
$event
->
getPrefixSpecial
(
true
)
);
$PaymentType_info
=
$this
->
Application
->
GetVar
(
'pt'
);
$GWConfigValue
=&
$this
->
Application
->
recallObject
(
'gwfv'
);
$GWConfigValue
->
SetDBField
(
'PaymentTypeId'
,
$this
->
Application
->
GetVar
(
'pt_id'
));
//deleting old values
$sql
=
'DELETE FROM '
.
$GWConfigValue
->
TableName
.
' WHERE PaymentTypeId = '
.
$this
->
Application
->
GetVar
(
'pt_id'
);
$res
=
$this
->
Conn
->
Query
(
$sql
);
//selecting fields for selected gateway only
$sql
=
'SELECT GWConfigFieldId FROM '
.
TABLE_PREFIX
.
'GatewayConfigFields
WHERE GatewayId = '
.
$PaymentType_info
[
$this
->
Application
->
GetVar
(
'pt_id'
)][
'GatewayId'
];
$res
=
$this
->
Conn
->
GetCol
(
$sql
);
if
(
$items_info
)
{
foreach
(
$res
as
$gw_field_id
)
{
$field_values
=
$items_info
[
$gw_field_id
];
$field_values
[
'GWConfigFieldId'
]
=
$gw_field_id
;
$GWConfigValue
->
SetFieldsFromHash
(
$field_values
);
if
(
$GWConfigValue
->
Create
()
)
{
$event
->
status
=
erSUCCESS
;
}
else
{
$event
->
status
=
erFAIL
;
break
;
}
}
}
}
function
OnCheckGateways
(&
$event
)
{
if
(!
$this
->
Application
->
IsAdmin
())
return
;
$fh
=
opendir
(
GW_CLASS_PATH
);
while
(
$entry
=
readdir
(
$fh
)
)
{
if
(
!
is_file
(
GW_CLASS_PATH
.
'/'
.
$entry
)
)
continue
;
$pathinfo
=
pathinfo
(
$entry
);
if
(
$pathinfo
[
'extension'
]
!=
'php'
)
continue
;
$class_name
=
false
;
include_once
(
GW_CLASS_PATH
.
'/'
.
$entry
);
if
(!
$class_name
)
continue
;
$tmp
=&
new
$class_name
();
$tmp
->
Install
();
}
}
}
?>
Event Timeline
Log In to Comment