Index: branches/RC/core/units/general/cat_event_handler.php =================================================================== diff -u -N -r11649 -r11693 --- branches/RC/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 11649) +++ branches/RC/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 11693) @@ -13,9 +13,8 @@ { parent::mapPermissions(); $permissions = Array( - 'OnExport' => Array('self' => 'view|advanced:export'), - 'OnExportBegin' => Array('self' => 'view|advanced:export'), 'OnSaveSettings' => Array('self' => 'add|edit|advanced:import'), + 'OnResetSettings' => Array('self' => 'add|edit|advanced:import'), 'OnBeforeDeleteOriginal' => Array('self' => 'edit|advanced:approve'), 'OnDownloadFile' => Array('self' => 'view'), @@ -69,12 +68,6 @@ $this->Application->LinkVar('m_cat_id'); } - if ($event->Name == 'OnNew' && preg_match('/(.*)\/import$/', $this->Application->GetVar('t'), $rets)) { - // redirect to item import template, where permission (import) category will be chosen) - $root_category = $this->Application->findModule('Path', $rets[1].'/', 'RootCat'); - $this->Application->StoreVar('m_cat_id', $root_category); - } - $check_events = Array ('OnEdit', 'OnSave', 'OnMassDelete'); if (in_array($event->Name, $check_events)) { // check each id from selected individually and only if all are allowed proceed next @@ -114,6 +107,19 @@ return $perm_value; } + $export_events = Array ('OnSaveSettings', 'OnResetSettings', 'OnExportBegin'); + if (in_array($event->Name, $export_events)) { + // when import settings before selecting target import category + return $this->Application->CheckPermission('in-portal:main_import.view'); + } + + if ($event->Name == 'OnProcessSelected') { + if ($this->Application->RecallVar('dst_field') == 'ImportCategory') { + // when selecting target import category + return $this->Application->CheckPermission('in-portal:main_import.view'); + } + } + return parent::CheckPermission($event); } @@ -1727,12 +1733,21 @@ if ($field_values['start_from'] == $field_values['total_records']) { if ($event->Special == 'import') { $this->Application->StoreVar('PermCache_UpdateRequired', 1); - $this->Application->Redirect('categories/cache_updater', Array('m_opener' => 'r', 'pass' => 'm', 'continue' => 1, 'no_amp' => 1)); + $url_params = Array( + 't' => 'catalog/catalog', + 'm_cat_id' => $this->Application->RecallVar('ImportCategory'), + 'anchor' => 'tab-' . $event->Prefix, + ); + $this->Application->EventManager->openerStackChange($url_params); + + $event->SetRedirectParam('opener', 'u'); } elseif ($event->Special == 'export') { - $template = $this->Application->getUnitOption($event->Prefix, 'ModuleFolder').'/'.$event->Special.'_finish'; - $this->Application->Redirect($template, Array('pass' => 'all')); + $event->redirect = $this->Application->getUnitOption($event->Prefix, 'ModuleFolder') . '/' . $event->Special . '_finish'; + $event->SetRedirectParam('pass', 'all'); } + + return ; } $export_options = $export_object->loadOptions($event); @@ -1834,7 +1849,6 @@ if ($event->Special == 'import' || $event->Special == 'export') { $export_helper =& $this->Application->recallObject('CatItemExportHelper'); $export_helper->setRequiredFields($event); - $this->Application->StoreVar('ImportCategory', 0); } } @@ -1863,15 +1877,16 @@ $this->Application->StoreVar('ImportCategory', $selected_ids['c']); // $this->Application->StoreVar($event->getPrefixSpecial().'_ForceNotValid', 1); // not to loose import/export values on form refresh - $this->Application->SetVar($event->getPrefixSpecial().'_id', 0); - $this->Application->SetVar($event->getPrefixSpecial().'_event', 'OnExportBegin'); + $url_params = Array ( + $event->getPrefixSpecial() . '_id' => 0, + $event->getPrefixSpecial() . '_event' => 'OnExportBegin', +// 'm_opener' => 's', + ); - $passed = $this->Application->GetVar('passed'); - $this->Application->SetVar('passed', $passed.','.$event->getPrefixSpecial()); - $event->setEventParam('pass_events', true); + $this->Application->EventManager->openerStackChange($url_params); } - $this->finalizePopup($event); + $event->SetRedirectParam('opener', 'u'); } /** @@ -1897,6 +1912,16 @@ } } + /** + * Saves Import/Export settings to session + * + * @param kEvent $event + */ + function OnResetSettings(&$event) + { + $this->Application->StoreVar('ImportCategory', $this->Application->findModule('Name', 'Core', 'RootCat')); + } + function OnCancelAction(&$event) { $event->redirect_params = Array('pass' => 'all,'.$event->GetPrefixSpecial());