Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1167284
in-portal
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
Tue, Sep 23, 9:10 AM
Size
23 KB
Mime Type
text/x-diff
Expires
Thu, Sep 25, 9:10 AM (23 h, 7 m)
Engine
blob
Format
Raw Data
Handle
756077
Attached To
rINP In-Portal
in-portal
View Options
Index: branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php (revision 5517)
@@ -0,0 +1,322 @@
+<?php
+
+class CategoriesEventHandler extends InpDBEventHandler {
+
+ /**
+ * Allows to override standart permission mapping
+ *
+ */
+ function mapPermissions()
+ {
+ parent::mapPermissions();
+ $permissions = Array(
+ 'OnRebuildCache' => Array('self' => 'add|edit'),
+ );
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Apply system filter to categories list
+ *
+ * @param kEvent $event
+ */
+ function SetCustomQuery(&$event)
+ {
+ parent::SetCustomQuery($event);
+
+ $types=$event->getEventParam('types');
+ $except_types=$event->getEventParam('except');
+ $object =& $event->getObject();
+ $type_clauses = Array();
+
+ $object =& $event->getObject();
+
+ if ( $event->getEventParam('parent_cat_id') ) {
+ $parent_cat_id = $event->getEventParam('parent_cat_id');
+
+ if ($parent_cat_id == 'Root') {
+ $module_name = $event->getEventParam('module') ? $event->getEventParam('module') : 'In-Commerce';
+ $module =& $this->Application->recallObject('mod.'.$module_name);
+ $parent_cat_id = $module->GetDBField('RootCat');
+ }
+
+ }
+ else {
+ $parent_cat_id = $this->Application->GetVar('c_id');
+ if (!$parent_cat_id) {
+ $parent_cat_id = $this->Application->GetVar('m_cat_id');
+ }
+ if (!$parent_cat_id) {
+ $parent_cat_id = 0;
+ }
+ }
+
+ if ($parent_cat_id != 'any') {
+ if ($event->getEventParam('recursive')) {
+ $current_path = $this->Conn->GetOne('SELECT ParentPath FROM '.TABLE_PREFIX.'Category WHERE CategoryId='.$parent_cat_id);
+ $subcats = $this->Conn->GetCol('SELECT CategoryId FROM '.TABLE_PREFIX.'Category WHERE ParentPath LIKE "'.$current_path.'%" ');
+ $object->addFilter('parent_filter', 'ParentId IN ('.implode(', ', $subcats).')');
+ }
+ else {
+ $object->addFilter('parent_filter', 'ParentId = '.$parent_cat_id);
+ }
+ }
+
+ $object->addFilter('parent_filter', 'ParentId = '.$parent_cat_id);
+
+ $object->addFilter('perm_filter', 'PermId = 1'); // check for CATEGORY.VIEW permission
+ if ($this->Application->GetVar('u_id') > 0) {
+ // apply permission filters to all users except "root"
+ $groups = explode(',',$this->Application->RecallVar('UserGroups'));
+ foreach ($groups as $group) {
+ $view_filters[] = 'FIND_IN_SET('.$group.', acl)';
+ }
+ $view_filter = implode(' OR ', $view_filters);
+ $object->addFilter('perm_filter2', $view_filter);
+ }
+
+ if (!$this->Application->IsAdmin()) {
+ // apply status filter only on front
+ $object->addFilter('status_filter', $object->TableName.'.Status = 1');
+ }
+
+ if(strpos($types, 'category_related') !== false)
+ {
+ $object->removeFilter('parent_filter');
+ $resource_id = $this->Conn->GetOne('
+ SELECT ResourceId FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
+ WHERE CategoryId = '.$parent_cat_id
+ );
+
+ $sql = 'SELECT DISTINCT(TargetId) FROM '.TABLE_PREFIX.'Relationship
+ WHERE SourceId = '.$resource_id.' AND SourceType = 1';
+ $related_cats = $this->Conn->GetCol($sql);
+ $related_cats = is_array($related_cats) ? $related_cats : Array();
+ $sql = 'SELECT DISTINCT(SourceId) FROM '.TABLE_PREFIX.'Relationship
+ WHERE TargetId = '.$resource_id.' AND TargetType = 1 AND Type = 1';
+ $related_cats2 = $this->Conn->GetCol($sql);
+ $related_cats2 = is_array($related_cats2) ? $related_cats2 : Array();
+ $related_cats = array_unique( array_merge( $related_cats2, $related_cats ) );
+
+ if($related_cats)
+ {
+ $type_clauses['category_related']['include'] = '%1$s.ResourceId IN ('.implode(',', $related_cats).')';
+ $type_clauses['category_related']['except'] = '%1$s.ResourceId NOT IN ('.implode(',', $related_cats).')';
+ }
+ else
+ {
+ $type_clauses['category_related']['include'] = '0';
+ $type_clauses['category_related']['except'] = '1';
+ }
+ $type_clauses['category_related']['having_filter'] = false;
+ }
+
+ if(strpos($types, 'product_related') !== false)
+ {
+ $object->removeFilter('parent_filter');
+
+ $product_id = $event->getEventParam('product_id') ? $event->getEventParam('product_id') : $this->Application->GetVar('p_id');
+ $resource_id = $this->Conn->GetOne('
+ SELECT ResourceId FROM '.$this->Application->getUnitOption('p', 'TableName').'
+ WHERE ProductId = '.$product_id
+ );
+
+ $sql = 'SELECT DISTINCT(TargetId) FROM '.TABLE_PREFIX.'Relationship
+ WHERE SourceId = '.$resource_id.' AND TargetType = 1';
+ $related_cats = $this->Conn->GetCol($sql);
+ $related_cats = is_array($related_cats) ? $related_cats : Array();
+ $sql = 'SELECT DISTINCT(SourceId) FROM '.TABLE_PREFIX.'Relationship
+ WHERE TargetId = '.$resource_id.' AND SourceType = 1 AND Type = 1';
+ $related_cats2 = $this->Conn->GetCol($sql);
+ $related_cats2 = is_array($related_cats2) ? $related_cats2 : Array();
+ $related_cats = array_unique( array_merge( $related_cats2, $related_cats ) );
+
+ if($related_cats)
+ {
+ $type_clauses['product_related']['include'] = '%1$s.ResourceId IN ('.implode(',', $related_cats).')';
+ $type_clauses['product_related']['except'] = '%1$s.ResourceId NOT IN ('.implode(',', $related_cats).')';
+ }
+ else
+ {
+ $type_clauses['product_related']['include'] = '0';
+ $type_clauses['product_related']['except'] = '1';
+ }
+ $type_clauses['product_related']['having_filter'] = false;
+ }
+
+ /********************************************/
+
+ $includes_or_filter =& $this->Application->makeClass('kMultipleFilter');
+ $includes_or_filter->setType(FLT_TYPE_OR);
+
+ $excepts_and_filter =& $this->Application->makeClass('kMultipleFilter');
+ $excepts_and_filter->setType(FLT_TYPE_AND);
+
+ $includes_or_filter_h =& $this->Application->makeClass('kMultipleFilter');
+ $includes_or_filter_h->setType(FLT_TYPE_OR);
+
+ $excepts_and_filter_h =& $this->Application->makeClass('kMultipleFilter');
+ $excepts_and_filter_h->setType(FLT_TYPE_AND);
+
+ $except_types_array=explode(',', $types);
+
+ if ($types){
+ $types_array=explode(',', $types);
+ for ($i=0; $i<sizeof($types_array); $i++){
+ $type=trim($types_array[$i]);
+ if (isset($type_clauses[$type])){
+ if ($type_clauses[$type]['having_filter']){
+ $includes_or_filter_h->removeFilter('filter_'.$type);
+ $includes_or_filter_h->addFilter('filter_'.$type, $type_clauses[$type]['include']);
+ }else{
+ $includes_or_filter->removeFilter('filter_'.$type);
+ $includes_or_filter->addFilter('filter_'.$type, $type_clauses[$type]['include']);
+ }
+ }
+ }
+ }
+
+ if ($except_types){
+ $except_types_array=explode(',', $except_types);
+ for ($i=0; $i<sizeof($except_types_array); $i++){
+ $type=trim($except_types_array[$i]);
+ if (isset($type_clauses[$type])){
+ if ($type_clauses[$type]['having_filter']){
+ $excepts_and_filter_h->removeFilter('filter_'.$type);
+ $excepts_and_filter_h->addFilter('filter_'.$type, $type_clauses[$type]['except']);
+ }else{
+ $excepts_and_filter->removeFilter('filter_'.$type);
+ $excepts_and_filter->addFilter('filter_'.$type, $type_clauses[$type]['except']);
+ }
+ }
+ }
+ }
+
+ $object->addFilter('includes_filter', $includes_or_filter);
+ $object->addFilter('excepts_filter', $excepts_and_filter);
+
+ $object->addFilter('includes_filter_h', $includes_or_filter_h, HAVING_FILTER);
+ $object->addFilter('excepts_filter_h', $excepts_and_filter_h, HAVING_FILTER);
+ }
+
+ function GetPassedId(&$event)
+ {
+ if ( $this->Application->IsAdmin() ) return parent::getPassedID($event);
+
+ $ret = $this->Application->GetVar('m_cat_id');
+ if($ret) return $ret;
+
+ return parent::getPassedID($event);
+ }
+
+ /**
+ * Adds calculates fields for item statuses
+ *
+ * @param kCatDBItem $object
+ * @param kEvent $event
+ */
+ function prepareObject(&$object, &$event)
+ {
+ $object =& $event->getObject( Array('skip_autoload' => true) );
+
+ $object->addCalculatedField('IsNew', ' IF(%1$s.NewItem = 2,
+ IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - '.
+ $this->Application->ConfigValue('Category_DaysNew').
+ '*3600*24), 1, 0),
+ %1$s.NewItem
+ )');
+ }
+
+ /**
+ * Set correct parent path for newly created categories
+ *
+ * @param kEvent $event
+ */
+ function OnAfterCopyToLive(&$event)
+ {
+ if ($event->getEventParam('temp_id') == 0) {
+ $object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('skip_autoload' => true, 'live_table' => true));
+ $object->Load($event->getEventParam('id'));
+
+ $fields_hash = Array('ParentPath' => $object->buildParentPath());
+ $this->Conn->doUpdate($fields_hash, $object->TableName, 'CategoryId = '.$object->GetID());
+ }
+ }
+
+ /**
+ * Set cache modification mark if needed
+ *
+ * @param kEvent $event
+ */
+ function OnBeforeDeleteFromLive(&$event)
+ {
+ $id = $event->getEventParam('id');
+ if ($id == 0) {
+ // new category -> update chache
+ $this->Application->StoreVar('PermCache_UpdateRequired', 1);
+ return ;
+ }
+
+ // existing category was edited, check if in-cache fields are modified
+ $temp_object =& $event->getObject( Array('skip_autoload' => true) );
+ $temp_object->Load($id);
+
+ $live_object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('live_table' => true));
+ $live_object->Load($id);
+
+ $cached_fields = Array('Name', 'Filename', 'CategoryTemplate', 'ItemTemplate');
+
+ foreach ($cached_fields as $cached_field) {
+ if ($live_object->GetDBField($cached_field) != $temp_object->GetDBField($cached_field)) {
+ // use session instead of REQUEST because of permission editing in category can contain
+ // multiple submits, that changes data before OnSave event occurs
+ $this->Application->StoreVar('PermCache_UpdateRequired', 1);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Checks cache update mark and redirect to cache if needed
+ *
+ * @param kEvent $event
+ */
+ function OnSave(&$event)
+ {
+ parent::OnSave($event);
+ if ($event->status == erSUCCESS && $this->Application->RecallVar('PermCache_UpdateRequired')) {
+ // "catalog" should be in opener stack by now
+ $opener_stack = unserialize($this->Application->RecallVar('opener_stack'));
+ $opener_stack[0] = str_replace('catalog', 'categories/cache_updater', $opener_stack[0]);
+ $this->Application->StoreVar('opener_stack', serialize($opener_stack));
+ $this->Application->RemoveVar('PermCache_UpdateRequired');
+ }
+ }
+
+ /**
+ * Deletes all selected items.
+ * Automatically recurse into sub-items using temp handler, and deletes sub-items
+ * by calling its Delete method if sub-item has AutoDelete set to true in its config file
+ *
+ * @param kEvent $event
+ */
+ function OnMassDelete(&$event)
+ {
+ if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
+ return;
+ }
+
+// $event->status = erSUCCESS;
+
+ $ids = $this->StoreSelectedIDs($event);
+ if ($ids) {
+ $recursive_helper =& $this->Application->recallObject('RecursiveHelper');
+ foreach ($ids as $id) {
+ $recursive_helper->DeleteCategory($id);
+ }
+ }
+ $this->clearSelectedIDs($event);
+ }
+}
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.22
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.22.2/core/units/categories/categories_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.22.2/core/units/categories/categories_event_handler.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.22.2/core/units/categories/categories_event_handler.php (revision 5517)
@@ -0,0 +1,322 @@
+<?php
+
+class CategoriesEventHandler extends InpDBEventHandler {
+
+ /**
+ * Allows to override standart permission mapping
+ *
+ */
+ function mapPermissions()
+ {
+ parent::mapPermissions();
+ $permissions = Array(
+ 'OnRebuildCache' => Array('self' => 'add|edit'),
+ );
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Apply system filter to categories list
+ *
+ * @param kEvent $event
+ */
+ function SetCustomQuery(&$event)
+ {
+ parent::SetCustomQuery($event);
+
+ $types=$event->getEventParam('types');
+ $except_types=$event->getEventParam('except');
+ $object =& $event->getObject();
+ $type_clauses = Array();
+
+ $object =& $event->getObject();
+
+ if ( $event->getEventParam('parent_cat_id') ) {
+ $parent_cat_id = $event->getEventParam('parent_cat_id');
+
+ if ($parent_cat_id == 'Root') {
+ $module_name = $event->getEventParam('module') ? $event->getEventParam('module') : 'In-Commerce';
+ $module =& $this->Application->recallObject('mod.'.$module_name);
+ $parent_cat_id = $module->GetDBField('RootCat');
+ }
+
+ }
+ else {
+ $parent_cat_id = $this->Application->GetVar('c_id');
+ if (!$parent_cat_id) {
+ $parent_cat_id = $this->Application->GetVar('m_cat_id');
+ }
+ if (!$parent_cat_id) {
+ $parent_cat_id = 0;
+ }
+ }
+
+ if ($parent_cat_id != 'any') {
+ if ($event->getEventParam('recursive')) {
+ $current_path = $this->Conn->GetOne('SELECT ParentPath FROM '.TABLE_PREFIX.'Category WHERE CategoryId='.$parent_cat_id);
+ $subcats = $this->Conn->GetCol('SELECT CategoryId FROM '.TABLE_PREFIX.'Category WHERE ParentPath LIKE "'.$current_path.'%" ');
+ $object->addFilter('parent_filter', 'ParentId IN ('.implode(', ', $subcats).')');
+ }
+ else {
+ $object->addFilter('parent_filter', 'ParentId = '.$parent_cat_id);
+ }
+ }
+
+ $object->addFilter('parent_filter', 'ParentId = '.$parent_cat_id);
+
+ $object->addFilter('perm_filter', 'PermId = 1'); // check for CATEGORY.VIEW permission
+ if ($this->Application->GetVar('u_id') > 0) {
+ // apply permission filters to all users except "root"
+ $groups = explode(',',$this->Application->RecallVar('UserGroups'));
+ foreach ($groups as $group) {
+ $view_filters[] = 'FIND_IN_SET('.$group.', acl)';
+ }
+ $view_filter = implode(' OR ', $view_filters);
+ $object->addFilter('perm_filter2', $view_filter);
+ }
+
+ if (!$this->Application->IsAdmin()) {
+ // apply status filter only on front
+ $object->addFilter('status_filter', $object->TableName.'.Status = 1');
+ }
+
+ if(strpos($types, 'category_related') !== false)
+ {
+ $object->removeFilter('parent_filter');
+ $resource_id = $this->Conn->GetOne('
+ SELECT ResourceId FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
+ WHERE CategoryId = '.$parent_cat_id
+ );
+
+ $sql = 'SELECT DISTINCT(TargetId) FROM '.TABLE_PREFIX.'Relationship
+ WHERE SourceId = '.$resource_id.' AND SourceType = 1';
+ $related_cats = $this->Conn->GetCol($sql);
+ $related_cats = is_array($related_cats) ? $related_cats : Array();
+ $sql = 'SELECT DISTINCT(SourceId) FROM '.TABLE_PREFIX.'Relationship
+ WHERE TargetId = '.$resource_id.' AND TargetType = 1 AND Type = 1';
+ $related_cats2 = $this->Conn->GetCol($sql);
+ $related_cats2 = is_array($related_cats2) ? $related_cats2 : Array();
+ $related_cats = array_unique( array_merge( $related_cats2, $related_cats ) );
+
+ if($related_cats)
+ {
+ $type_clauses['category_related']['include'] = '%1$s.ResourceId IN ('.implode(',', $related_cats).')';
+ $type_clauses['category_related']['except'] = '%1$s.ResourceId NOT IN ('.implode(',', $related_cats).')';
+ }
+ else
+ {
+ $type_clauses['category_related']['include'] = '0';
+ $type_clauses['category_related']['except'] = '1';
+ }
+ $type_clauses['category_related']['having_filter'] = false;
+ }
+
+ if(strpos($types, 'product_related') !== false)
+ {
+ $object->removeFilter('parent_filter');
+
+ $product_id = $event->getEventParam('product_id') ? $event->getEventParam('product_id') : $this->Application->GetVar('p_id');
+ $resource_id = $this->Conn->GetOne('
+ SELECT ResourceId FROM '.$this->Application->getUnitOption('p', 'TableName').'
+ WHERE ProductId = '.$product_id
+ );
+
+ $sql = 'SELECT DISTINCT(TargetId) FROM '.TABLE_PREFIX.'Relationship
+ WHERE SourceId = '.$resource_id.' AND TargetType = 1';
+ $related_cats = $this->Conn->GetCol($sql);
+ $related_cats = is_array($related_cats) ? $related_cats : Array();
+ $sql = 'SELECT DISTINCT(SourceId) FROM '.TABLE_PREFIX.'Relationship
+ WHERE TargetId = '.$resource_id.' AND SourceType = 1 AND Type = 1';
+ $related_cats2 = $this->Conn->GetCol($sql);
+ $related_cats2 = is_array($related_cats2) ? $related_cats2 : Array();
+ $related_cats = array_unique( array_merge( $related_cats2, $related_cats ) );
+
+ if($related_cats)
+ {
+ $type_clauses['product_related']['include'] = '%1$s.ResourceId IN ('.implode(',', $related_cats).')';
+ $type_clauses['product_related']['except'] = '%1$s.ResourceId NOT IN ('.implode(',', $related_cats).')';
+ }
+ else
+ {
+ $type_clauses['product_related']['include'] = '0';
+ $type_clauses['product_related']['except'] = '1';
+ }
+ $type_clauses['product_related']['having_filter'] = false;
+ }
+
+ /********************************************/
+
+ $includes_or_filter =& $this->Application->makeClass('kMultipleFilter');
+ $includes_or_filter->setType(FLT_TYPE_OR);
+
+ $excepts_and_filter =& $this->Application->makeClass('kMultipleFilter');
+ $excepts_and_filter->setType(FLT_TYPE_AND);
+
+ $includes_or_filter_h =& $this->Application->makeClass('kMultipleFilter');
+ $includes_or_filter_h->setType(FLT_TYPE_OR);
+
+ $excepts_and_filter_h =& $this->Application->makeClass('kMultipleFilter');
+ $excepts_and_filter_h->setType(FLT_TYPE_AND);
+
+ $except_types_array=explode(',', $types);
+
+ if ($types){
+ $types_array=explode(',', $types);
+ for ($i=0; $i<sizeof($types_array); $i++){
+ $type=trim($types_array[$i]);
+ if (isset($type_clauses[$type])){
+ if ($type_clauses[$type]['having_filter']){
+ $includes_or_filter_h->removeFilter('filter_'.$type);
+ $includes_or_filter_h->addFilter('filter_'.$type, $type_clauses[$type]['include']);
+ }else{
+ $includes_or_filter->removeFilter('filter_'.$type);
+ $includes_or_filter->addFilter('filter_'.$type, $type_clauses[$type]['include']);
+ }
+ }
+ }
+ }
+
+ if ($except_types){
+ $except_types_array=explode(',', $except_types);
+ for ($i=0; $i<sizeof($except_types_array); $i++){
+ $type=trim($except_types_array[$i]);
+ if (isset($type_clauses[$type])){
+ if ($type_clauses[$type]['having_filter']){
+ $excepts_and_filter_h->removeFilter('filter_'.$type);
+ $excepts_and_filter_h->addFilter('filter_'.$type, $type_clauses[$type]['except']);
+ }else{
+ $excepts_and_filter->removeFilter('filter_'.$type);
+ $excepts_and_filter->addFilter('filter_'.$type, $type_clauses[$type]['except']);
+ }
+ }
+ }
+ }
+
+ $object->addFilter('includes_filter', $includes_or_filter);
+ $object->addFilter('excepts_filter', $excepts_and_filter);
+
+ $object->addFilter('includes_filter_h', $includes_or_filter_h, HAVING_FILTER);
+ $object->addFilter('excepts_filter_h', $excepts_and_filter_h, HAVING_FILTER);
+ }
+
+ function GetPassedId(&$event)
+ {
+ if ( $this->Application->IsAdmin() ) return parent::getPassedID($event);
+
+ $ret = $this->Application->GetVar('m_cat_id');
+ if($ret) return $ret;
+
+ return parent::getPassedID($event);
+ }
+
+ /**
+ * Adds calculates fields for item statuses
+ *
+ * @param kCatDBItem $object
+ * @param kEvent $event
+ */
+ function prepareObject(&$object, &$event)
+ {
+ $object =& $event->getObject( Array('skip_autoload' => true) );
+
+ $object->addCalculatedField('IsNew', ' IF(%1$s.NewItem = 2,
+ IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - '.
+ $this->Application->ConfigValue('Category_DaysNew').
+ '*3600*24), 1, 0),
+ %1$s.NewItem
+ )');
+ }
+
+ /**
+ * Set correct parent path for newly created categories
+ *
+ * @param kEvent $event
+ */
+ function OnAfterCopyToLive(&$event)
+ {
+ if ($event->getEventParam('temp_id') == 0) {
+ $object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('skip_autoload' => true, 'live_table' => true));
+ $object->Load($event->getEventParam('id'));
+
+ $fields_hash = Array('ParentPath' => $object->buildParentPath());
+ $this->Conn->doUpdate($fields_hash, $object->TableName, 'CategoryId = '.$object->GetID());
+ }
+ }
+
+ /**
+ * Set cache modification mark if needed
+ *
+ * @param kEvent $event
+ */
+ function OnBeforeDeleteFromLive(&$event)
+ {
+ $id = $event->getEventParam('id');
+ if ($id == 0) {
+ // new category -> update chache
+ $this->Application->StoreVar('PermCache_UpdateRequired', 1);
+ return ;
+ }
+
+ // existing category was edited, check if in-cache fields are modified
+ $temp_object =& $event->getObject( Array('skip_autoload' => true) );
+ $temp_object->Load($id);
+
+ $live_object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('live_table' => true));
+ $live_object->Load($id);
+
+ $cached_fields = Array('Name', 'Filename', 'CategoryTemplate', 'ItemTemplate');
+
+ foreach ($cached_fields as $cached_field) {
+ if ($live_object->GetDBField($cached_field) != $temp_object->GetDBField($cached_field)) {
+ // use session instead of REQUEST because of permission editing in category can contain
+ // multiple submits, that changes data before OnSave event occurs
+ $this->Application->StoreVar('PermCache_UpdateRequired', 1);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Checks cache update mark and redirect to cache if needed
+ *
+ * @param kEvent $event
+ */
+ function OnSave(&$event)
+ {
+ parent::OnSave($event);
+ if ($event->status == erSUCCESS && $this->Application->RecallVar('PermCache_UpdateRequired')) {
+ // "catalog" should be in opener stack by now
+ $opener_stack = unserialize($this->Application->RecallVar('opener_stack'));
+ $opener_stack[0] = str_replace('catalog', 'categories/cache_updater', $opener_stack[0]);
+ $this->Application->StoreVar('opener_stack', serialize($opener_stack));
+ $this->Application->RemoveVar('PermCache_UpdateRequired');
+ }
+ }
+
+ /**
+ * Deletes all selected items.
+ * Automatically recurse into sub-items using temp handler, and deletes sub-items
+ * by calling its Delete method if sub-item has AutoDelete set to true in its config file
+ *
+ * @param kEvent $event
+ */
+ function OnMassDelete(&$event)
+ {
+ if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
+ return;
+ }
+
+// $event->status = erSUCCESS;
+
+ $ids = $this->StoreSelectedIDs($event);
+ if ($ids) {
+ $recursive_helper =& $this->Application->recallObject('RecursiveHelper');
+ foreach ($ids as $id) {
+ $recursive_helper->DeleteCategory($id);
+ }
+ }
+ $this->clearSelectedIDs($event);
+ }
+}
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.22.2/core/units/categories/categories_event_handler.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.22
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Event Timeline
Log In to Comment