Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1172586
affiliate_plans_items_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, Sep 29, 9:55 PM
Size
3 KB
Mime Type
text/x-php
Expires
Wed, Oct 1, 9:55 PM (1 d, 17 h)
Engine
blob
Format
Raw Data
Handle
759936
Attached To
rMINC Modules.In-Commerce
affiliate_plans_items_event_handler.php
View Options
<?php
/**
* @version $Id: affiliate_plans_items_event_handler.php 15149 2012-03-04 09:05:03Z alex $
* @package In-Commerce
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license Commercial License
* This software is protected by copyright law and international treaties.
* Unauthorized reproduction or unlicensed usage of the code of this program,
* or any portion of it may result in severe civil and criminal penalties,
* and will be prosecuted to the maximum extent possible under the law
* See http://www.in-portal.org/commercial-license for copyright notices and details.
*/
defined
(
'FULL_PATH'
)
or
die
(
'restricted access!'
);
// NOT IN USE RIGHT NOW (by Alex)
class
AffiliatePlansItemsEventHandler
extends
kDBEventHandler
{
/**
* Adds selected items to affiliate products
*
* @param kEvent $event
*/
function
OnProcessSelected
(
$event
)
{
// uses another handler event, because does the same stuff but on different table
$di_handler
=
$this
->
Application
->
recallObject
(
'di_EventHandler'
);
$di_handler
->
OnProcessSelected
(
$event
);
}
/**
* Allows to set discount on entire order
*
* @param kEvent $event
* @todo get parent item id through $object->getLinkedInfo()['ParentId']
* @access public
*/
function
OnEntireOrder
(
$event
)
{
$object
=
$event
->
getObject
();
$sql
=
'DELETE FROM '
.
$object
->
TableName
.
' WHERE AffiliatePlanId='
.
$this
->
Application
->
GetVar
(
'ap_id'
);
$this
->
Conn
->
Query
(
$sql
);
$object
->
SetDBField
(
'AffiliatePlanId'
,
$this
->
Application
->
GetVar
(
'ap_id'
));
$object
->
SetDBField
(
'ItemResourceId'
,
-
1
);
$object
->
SetDBField
(
'ItemType'
,
0
);
if
(
$object
->
Create
()
)
{
$this
->
customProcessing
(
$event
,
'after'
);
$event
->
status
=
kEvent
::
erSUCCESS
;
$event
->
SetRedirectParam
(
'opener'
,
's'
);
//stay!
}
else
{
$event
->
status
=
kEvent
::
erFAIL
;
$this
->
Application
->
SetVar
(
$event
->
getPrefixSpecial
().
'_SaveEvent'
,
'OnCreate'
);
$object
->
setID
(
0
);
}
}
/**
* Deletes discount items where hooked item (product) is used
*
* @param kEvent $event
*/
function
OnDeleteDiscountedItem
(
$event
)
{
$main_object
=
$event
->
MasterEvent
->
getObject
();
$resource_id
=
$main_object
->
GetDBField
(
'ResourceId'
);
$table
=
$this
->
Application
->
getUnitOption
(
$event
->
Prefix
,
'TableName'
);
$sql
=
'DELETE FROM '
.
$table
.
' WHERE ItemResourceId = '
.
$resource_id
;
$this
->
Conn
->
Query
(
$sql
);
}
/**
* Makes ItemName calculated field from primary language
*
* @param kEvent $event
* @return void
* @access protected
*/
protected
function
OnAfterConfigRead
(
kEvent
$event
)
{
parent
::
OnAfterConfigRead
(
$event
);
$calculated_fields
=
$this
->
Application
->
getUnitOption
(
$event
->
Prefix
,
'CalculatedFields'
);
$language_id
=
$this
->
Application
->
GetVar
(
'm_lang'
);
$primary_language_id
=
$this
->
Application
->
GetDefaultLanguageId
();
$calculated_fields
[
''
][
'ItemName'
]
=
'COALESCE(p.l'
.
$language_id
.
'_Name, p.l'
.
$primary_language_id
.
'_Name)'
;
$this
->
Application
->
setUnitOption
(
$event
->
Prefix
,
'CalculatedFields'
,
$calculated_fields
);
}
}
Event Timeline
Log In to Comment