Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1198541
in-commerce
No One
Temporary
Actions
View 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
Thu, Oct 30, 4:11 PM
Size
4 KB
Mime Type
text/x-diff
Expires
Sat, Nov 1, 4:11 PM (18 h, 18 m)
Engine
blob
Format
Raw Data
Handle
781512
Attached To
rMINC Modules.In-Commerce
in-commerce
View Options
Index: branches/5.2.x/units/manufacturers/manufacturers_event_handler.php
===================================================================
--- branches/5.2.x/units/manufacturers/manufacturers_event_handler.php (revision 15070)
+++ branches/5.2.x/units/manufacturers/manufacturers_event_handler.php (revision 15071)
@@ -1,137 +1,137 @@
<?php
/**
* @version $Id$
* @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!');
class ManufacturersEventHandler extends kDBEventHandler {
/**
* Allows to override standard permission mapping
*
* @return void
* @access protected
* @see kEventHandler::$permMapping
*/
protected function mapPermissions()
{
parent::mapPermissions();
$permissions = Array(
'OnItemBuild' => Array('self' => true),
);
$this->permMapping = array_merge($this->permMapping, $permissions);
}
/**
* Apply any custom changes to list's sql query
*
* @param kEvent $event
* @return void
* @access protected
* @see kDBEventHandler::OnListBuild()
*/
protected function SetCustomQuery(kEvent &$event)
{
parent::SetCustomQuery($event);
if ( $this->Application->isAdminUser ) {
return;
}
$category_id = $this->Application->GetVar('m_cat_id');
$parent_category_id = $event->getEventParam('parent_cat_id');
if ( (string)$parent_category_id !== '' ) {
if ( $parent_category_id != 'any' && $parent_category_id > 0 ) {
$category_id = $parent_category_id;
}
}
$sql = 'SELECT m.ManufacturerId, COUNT(p.ProductId)
FROM ' . TABLE_PREFIX . 'Manufacturers m
LEFT JOIN ' . TABLE_PREFIX . 'Products p ON p.ManufacturerId = m.ManufacturerId
LEFT JOIN ' . TABLE_PREFIX . 'CategoryItems ci ON ci.ItemResourceId = p.ResourceId
LEFT JOIN ' . TABLE_PREFIX . 'Categories c ON c.CategoryId = ci.CategoryId
WHERE (ci.PrimaryCat = 1) AND (p.Status = ' . STATUS_ACTIVE . ') AND (c.Status = ' . STATUS_ACTIVE . ') GROUP BY m.ManufacturerId';
// add category filter
$tree_indexes = $this->Application->getTreeIndex($category_id);
// if category_id is 0 returs false
if ( $tree_indexes ) {
$sql .= ' AND c.TreeLeft BETWEEN ' . $tree_indexes['TreeLeft'] . ' AND ' . $tree_indexes['TreeRight'];
}
$manufacturers = $this->Conn->GetCol($sql);
$object =& $event->getObject();
/* @var $object kDBList */
$object->addFilter('category_manufacturer_filter', $manufacturers ? '%1$s.ManufacturerId IN (' . implode(',', $manufacturers) . ')' : 'FALSE');
}
/**
* Pre-fills states dropdown with correct values
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnAfterItemLoad(kEvent &$event)
{
parent::OnAfterItemLoad($event);
$cs_helper =& $this->Application->recallObject('CountryStatesHelper');
/* @var $cs_helper kCountryStatesHelper */
$cs_helper->PopulateStates($event, 'State', 'Country');
}
/**
* Processes states
*
* @param kEvent $event
* @return void
* @access protected
*/
protected function OnBeforeItemUpdate(kEvent &$event)
{
parent::OnBeforeItemUpdate($event);
$cs_helper =& $this->Application->recallObject('CountryStatesHelper');
/* @var $cs_helper kCountryStatesHelper */
$cs_helper->CheckStateField($event, 'State', 'Country');
$cs_helper->PopulateStates($event, 'State', 'Country');
}
/**
* Processes states
*
* @param kEvent $event
* @return void
* @access protected
*/
- protected function OnBeforeItemCreate(&$event)
+ protected function OnBeforeItemCreate(kEvent &$event)
{
parent::OnBeforeItemCreate($event);
$cs_helper =& $this->Application->recallObject('CountryStatesHelper');
/* @var $cs_helper kCountryStatesHelper */
$cs_helper->CheckStateField($event, 'State', 'Country');
$cs_helper->PopulateStates($event, 'State', 'Country');
}
}
\ No newline at end of file
Event Timeline
Log In to Comment