Array('self' => true), ); $this->permMapping = array_merge($this->permMapping, $permissions); } /** * Enter description here... * * @param kEvent $event */ function SetCustomQuery(&$event) { if( $this->Application->IsAdmin() ) return true; $object =& $event->getObject(); $sql = 'SELECT DISTINCT '.TABLE_PREFIX.'Manufacturers.ManufacturerId FROM '.TABLE_PREFIX.'Manufacturers LEFT JOIN '.TABLE_PREFIX.'Products ON '.TABLE_PREFIX.'Products.ManufacturerId = '.TABLE_PREFIX.'Manufacturers.ManufacturerId LEFT JOIN '.TABLE_PREFIX.'CategoryItems ON '.TABLE_PREFIX.'CategoryItems.ItemResourceId = '.TABLE_PREFIX.'Products.ResourceId LEFT JOIN '.TABLE_PREFIX.'Category ON '.TABLE_PREFIX.'Category.CategoryId = '.TABLE_PREFIX.'CategoryItems.CategoryId WHERE '.TABLE_PREFIX.'CategoryItems.PrimaryCat = 1 '; $parent = $event->getEventParam('parent_cat_id'); if ($parent) { if($parent != 'any' && $parent > 0) { $sql .= ' AND '.TABLE_PREFIX.'Category.ParentPath LIKE "%|'.$parent.'|%"'; } } else { $sql .= ' AND '.TABLE_PREFIX.'Category.ParentPath LIKE "%|'.$this->Application->GetVar('m_cat_id').'|%"'; } $manuf_ids = $this->Conn->GetCol($sql); if ( count($manuf_ids) > 0 ) { $object->addFilter('manuf_by_category', 'ManufacturerId IN ('.implode(',', $manuf_ids).')'); } else { $object->addFilter('manuf_by_category', '0'); //display none } } /** * Prefill states dropdown with correct values * * @param kEvent $event * @access public */ function OnPrepareStates(&$event) { $cs_helper =& $this->Application->recallObject('CountryStatesHelper'); $cs_helper->PopulateStates($event, 'State', 'Country'); $object =& $event->getObject(); if( $object->isRequired('Country') && $cs_helper->CountryHasStates( $object->GetDBField('Country') ) ) $object->setRequired('State', true); } function OnUpdate(&$event) { $cs_helper =& $this->Application->recallObject('CountryStatesHelper'); $cs_helper->CheckStateField($event, 'State', 'Country'); parent::OnUpdate($event); } function OnCreate(&$event) { $cs_helper =& $this->Application->recallObject('CountryStatesHelper'); $cs_helper->CheckStateField($event, 'State', 'Country'); parent::OnCreate($event); } function OnPreSave(&$event) { $cs_helper =& $this->Application->recallObject('CountryStatesHelper'); $cs_helper->CheckStateField($event, 'State', 'Country'); parent::OnPreSave($event); } } ?>