Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1175182
e_product_eh.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
Fri, Oct 3, 6:25 PM
Size
4 KB
Mime Type
text/x-php
Expires
Sun, Oct 5, 6:25 PM (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
762079
Attached To
rMCUS Modules.Custom
e_product_eh.php
View Options
<?php
defined
(
'FULL_PATH'
)
or
die
(
'restricted access!'
);
/**
* Extends/overrides methods of default ProductsEventHandler class
*
*/
class
EProductEventHandler
extends
ProductsEventHandler
{
/**
* Allows to override standard permission mapping
*
*/
function
mapPermissions
()
{
parent
::
mapPermissions
();
$permissions
=
Array
(
# admin
'OnCustomEvent1'
=>
Array
(
'self'
=>
true
),
# front
'OnCustomEvent2'
=>
Array
(
'self'
=>
true
),
);
$this
->
permMapping
=
array_merge
(
$this
->
permMapping
,
$permissions
);
}
/**
* Checks user permission to execute given $event
*
* @param kEvent $event
* @return bool
* @access public
*/
public
function
CheckPermission
(&
$event
)
{
$skip_permissions_check_events
=
Array
(
'OnAnotherCustomEvent'
,
);
if
(
in_array
(
$event
->
Name
,
$skip_permissions_check_events
)
)
{
return
true
;
}
return
parent
::
CheckPermission
(
$event
);
}
/**
* Updates structure config
*
* @param kEvent $event
*/
function
OnAfterConfigRead
(&
$event
)
{
parent
::
OnAfterConfigRead
(
$event
);
# 1. Regular Fields from /in-commerce/units/products/products_config.php
$fields
=
$this
->
Application
->
getUnitOption
(
$event
->
Prefix
,
'Fields'
);
#get regular fields
// $fields['Status']['default'] = STATUS_ACTIVE; #add/edit field configuration (make default = STATUS_ACTIVE)
$this
->
Application
->
setUnitOption
(
$event
->
Prefix
,
'Fields'
,
$fields
);
#save regular fields
# 2. Virtual Fields from /in-commerce/units/products/products_config.php
$virtual_fields
=
$this
->
Application
->
getUnitOption
(
$event
->
Prefix
,
'VirtualFields'
);
#get virtual fields
// $virtual_fields['Qty']['default'] = 1; #add/edit field configuration
$this
->
Application
->
setUnitOption
(
$event
->
Prefix
,
'VirtualFields'
,
$virtual_fields
);
# save virtual fields
}
/**
* Apply any custom changes to list's sql query
*
* @param kEvent $event
* @return void
* @access protected
* @see kDBEventHandler::OnListBuild()
*/
protected
function
SetCustomQuery
(&
$event
)
{
parent
::
SetCustomQuery
(
$event
);
$object
=&
$event
->
getObject
();
/* @var $object kDBList */
# identifying event based on special and setting filter
if
(
$event
->
Special
==
'custom-special'
)
{
// $object->addFilter('primary_filter', '%1$s.Status = '.STATUS_DISABLED);
}
# identifying event based not admin condition and setting filter
if
(!
$this
->
Application
->
isAdminUser
)
{
// $object->addFilter('status_filter', '%1$s.Status = '.STATUS_ACTIVE);
}
}
/**
* Sets default processing data for subscriptions
*
* @param kEvent $event
* @return void
* @access protected
*/
protected
function
OnBeforeItemCreate
(&
$event
)
{
parent
::
OnBeforeItemCreate
(
$event
);
}
/**
* Moves item to preferred category, updates item hits
*
* @param kEvent $event
* @return void
* @access protected
*/
protected
function
OnBeforeItemUpdate
(&
$event
)
{
parent
::
OnBeforeItemUpdate
(
$event
);
}
/**
* Before item deleted
*
* @param kEvent $event
*/
function
OnBeforeItemDelete
(&
$event
)
{
parent
::
OnBeforeItemDelete
(
$event
);
}
/**
* After item loaded
*
* @param kEvent $event
*/
function
OnBeforeItemLoad
(&
$event
)
{
parent
::
OnBeforeItemLoad
(
$event
);
}
/**
* Set new price to ProductsPricing
*
* @param kEvent $event
* @return void
* @access protected
*/
protected
function
OnAfterItemCreate
(&
$event
)
{
parent
::
OnAfterItemCreate
(
$event
);
}
/**
* After existing item updated
*
* @param kEvent $event
*/
function
OnAfterItemUpdate
(&
$event
)
{
parent
::
OnAfterItemUpdate
(
$event
);
}
/**
* After item deleted
*
* @param kEvent $event
*/
function
OnAfterItemDelete
(&
$event
)
{
parent
::
OnAfterItemDelete
(
$event
);
}
/**
* Occurs after loading item, 'id' parameter
* allows to get id of item that was loaded
*
* @param kEvent $event
* @return void
* @access protected
*/
protected
function
OnAfterItemLoad
(&
$event
)
{
parent
::
OnAfterItemLoad
(
$event
);
}
}
Event Timeline
Log In to Comment