Index: branches/RC/core/units/categories/categories_tag_processor.php =================================================================== diff -u -N -r11760 -r11823 --- branches/RC/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 11760) +++ branches/RC/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 11823) @@ -1999,4 +1999,44 @@ return $json_helper->encode($ret); } + + /** + * Checks, that "view in browse mode" functionality available + * + * @param Array $params + * @return bool + */ + function BrowseModeAvailable($params) + { + $valid_special = $params['Special'] != 'user'; + $not_selector = $this->Application->GetVar('type') != 'item_selector'; + + return $valid_special && $not_selector; + } + + /** + * Returns a link for editing product + * + * @param Array $params + * @return string + */ + function ItemEditLink($params) + { + $object =& $this->getObject(); + /* @var $object kDBList */ + + $edit_template = $this->Application->getUnitOption($this->Prefix, 'AdminTemplatePath') . '/' . $this->Application->getUnitOption($this->Prefix, 'AdminTemplatePrefix') . 'edit'; + + $url_params = Array ( + 'm_opener' => 'd', + $this->Prefix.'_mode' => 't', + $this->Prefix.'_event' => 'OnEdit', + $this->Prefix.'_id' => $object->GetID(), + 'm_cat_id' => $object->GetDBField('ParentId'), + 'pass' => 'all,'.$this->Prefix, + 'no_pass_through' => 1, + ); + + return $this->Application->HREF($edit_template,'', $url_params); + } } \ No newline at end of file Index: branches/RC/core/units/general/cat_tag_processor.php =================================================================== diff -u -N -r11711 -r11823 --- branches/RC/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 11711) +++ branches/RC/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 11823) @@ -693,6 +693,46 @@ return $this->Application->ProcessParsedTag('m', 'Link', $params); } + + /** + * Checks, that "view in browse mode" functionality available + * + * @param Array $params + * @return bool + */ + function BrowseModeAvailable($params) + { + $valid_special = $valid_special = $params['Special'] != 'user'; + $not_selector = $this->Application->GetVar('type') != 'item_selector'; + + return $valid_special && $not_selector; + } + + /** + * Returns a link for editing product + * + * @param Array $params + * @return string + */ + function ItemEditLink($params) + { + $object =& $this->getObject(); + /* @var $object kDBList */ + + $edit_template = $this->Application->getUnitOption($this->Prefix, 'AdminTemplatePath') . '/' . $this->Application->getUnitOption($this->Prefix, 'AdminTemplatePrefix') . 'edit'; + + $url_params = Array ( + 'm_opener' => 'd', + $this->Prefix.'_mode' => 't', + $this->Prefix.'_event' => 'OnEdit', + $this->Prefix.'_id' => $object->GetID(), + 'm_cat_id' => $object->GetDBField('CategoryId'), + 'pass' => 'all,'.$this->Prefix, + 'no_pass_through' => 1, + ); + + return $this->Application->HREF($edit_template,'', $url_params); + } } ?> \ No newline at end of file Index: branches/RC/core/admin_templates/img/ic_browse_mode.gif =================================================================== diff -u -N Binary files differ Index: branches/RC/core/kernel/db/db_event_handler.php =================================================================== diff -u -N -r11821 -r11823 --- branches/RC/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 11821) +++ branches/RC/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 11823) @@ -1306,7 +1306,7 @@ $temp->PrepareEdit(); - $event->redirect=false; + $event->redirect = false; } /** Index: branches/RC/core/admin_templates/catalog_tab.tpl =================================================================== diff -u -N -r11750 -r11823 --- branches/RC/core/admin_templates/catalog_tab.tpl (.../catalog_tab.tpl) (revision 11750) +++ branches/RC/core/admin_templates/catalog_tab.tpl (.../catalog_tab.tpl) (revision 11823) @@ -51,35 +51,23 @@ - - - + , '');" title=""> + + ', this.href);"> - -  * - - - + - <inp2:m_Phrase name='la_alt_Browse' html_escape='1'/> + <inp2:m_Phrase name='la_alt_Browse' html_escape='1'/> - + - + +  * + Index: branches/RC/core/admin_templates/categories/ci_blocks.tpl =================================================================== diff -u -N -r11750 -r11823 --- branches/RC/core/admin_templates/categories/ci_blocks.tpl (.../ci_blocks.tpl) (revision 11750) +++ branches/RC/core/admin_templates/categories/ci_blocks.tpl (.../ci_blocks.tpl) (revision 11823) @@ -1,31 +1,29 @@ - + img/ic_.gif" title="" width="11" height="11" align="absmiddle" /> - + + + + ', this.href);"> + + + + + <inp2:m_Phrase name='la_alt_Browse' html_escape='1'/> + + + - - - - <inp2:m_Phrase name='la_alt_Browse' html_escape='1'/> - - - Index: branches/RC/core/units/general/helpers/permissions_helper.php =================================================================== diff -u -N -r11724 -r11823 --- branches/RC/core/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 11724) +++ branches/RC/core/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 11823) @@ -151,88 +151,88 @@ * * @param kEvent $event */ -// function CheckEventCategoryPermission_OLD(&$event, $event_perm_mapping) -// { -// // mapping between specific permissions and common permissions -// static $perm_mapping = Array( -// 'add' => 'ADD', 'add.pending' => 'ADD.PENDING', 'edit' => 'MODIFY', -// 'edit.pending' => 'MODIFY.PENDING', 'delete' => 'DELETE', 'view' => 'VIEW' -// ); -// -// $top_prefix = $event->getEventParam('top_prefix'); -// $event_handler =& $this->Application->recallObject($event->Prefix.'_EventHandler'); -// /* @var $event_handler kCatDBEventHandler */ -// -// $raise_warnings = $event->getEventParam('raise_warnings'); -// $event->setEventParam('raise_warnings', 0); -// if ($event->Prefix != $top_prefix) { -// $top_event = new kEvent($top_prefix.':'.$event->Name); -// $id = $event_handler->getPassedID($top_event); -// } -// else { -// $id = $event_handler->getPassedID($event); -// } -// $event->setEventParam('raise_warnings', $raise_warnings); -// -// $owner_id = -1; // owner is root if not detected -// if (!$id) { -// // item being created -> check by current (before editing started, saved in OnPreCreate event) category permissions -// // note: category in session is placed on catalog data import start -// $category_id = $this->Application->IsAdmin() ? $this->Application->RecallVar('m_cat_id') : $this->Application->GetVar('m_cat_id'); -// } -// elseif ($top_prefix == 'c' || $top_prefix == 'st') { -// $category_id = $id; -// } -// else { -// // item being edited -> check by it's primary category permissions -// $items_info = $this->GetCategoryItemData($top_prefix, $id); -// $category_id = $items_info[$id]['CategoryId']; -// $owner_id = $items_info[$id]['CreatedById']; -// } -// -// // specific permission check for pending & owner permissions: begin -// $uploader_events = Array ('OnUploadFile', 'OnDeleteFile', 'OnViewFile'); -// if (in_array($event->Name, $uploader_events)) { -// // don't recall target object during uploader-related, because OnItemLoad will use incorrect -// // $user_id in Firefox (during Flash problems session will be used from Internet Exploere) -// $new_item = false; -// } -// else { -// $new_item = $this->Application->IsAdmin() && $event_handler->isNewItemCreate($event) ? true : false; -// $check_status = $this->checkCombinedPermissions($event, $owner_id, (int)$category_id, $new_item); -// } -// -// if (isset($check_status)) { -// return $this->finalizePermissionCheck($event, $check_status); -// } -// // specific permission check for pending & owner permissions: end -// -// $perm_status = false; -// $check_perms = $this->getPermissionByEvent($event, $event_perm_mapping); -// -// if ($check_perms === true) { -// // event is defined in mapping but is not checked by permissions -// return true; -// } -// -// $item_prefix = $this->Application->getUnitOption($top_prefix, 'PermItemPrefix'); -// foreach ($check_perms as $perm_name) { -// // check if at least one of required permissions is set -// if (!isset($perm_mapping[$perm_name])) { -// // not mapped permission (e.g. advanced:approve) -> skip -// continue; -// } -// $perm_name = $item_prefix.'.'.$perm_mapping[$perm_name]; -// $perm_status = $this->CheckPermission($perm_name, 0, (int)$category_id); -// -// if ($perm_status) { -// return $perm_status; -// } -// } -// -// return $this->finalizePermissionCheck($event, $perm_status); -// } + function _frontCheckEventCategoryPermission(&$event, $event_perm_mapping) + { + // mapping between specific permissions and common permissions + static $perm_mapping = Array( + 'add' => 'ADD', 'add.pending' => 'ADD.PENDING', 'edit' => 'MODIFY', + 'edit.pending' => 'MODIFY.PENDING', 'delete' => 'DELETE', 'view' => 'VIEW' + ); + $top_prefix = $event->getEventParam('top_prefix'); + $event_handler =& $this->Application->recallObject($event->Prefix.'_EventHandler'); + /* @var $event_handler kCatDBEventHandler */ + + $raise_warnings = $event->getEventParam('raise_warnings'); + $event->setEventParam('raise_warnings', 0); + if ($event->Prefix != $top_prefix) { + $top_event = new kEvent($top_prefix.':'.$event->Name); + $id = $event_handler->getPassedID($top_event); + } + else { + $id = $event_handler->getPassedID($event); + } + $event->setEventParam('raise_warnings', $raise_warnings); + + $owner_id = -1; // owner is root if not detected + if (!$id) { + // item being created -> check by current (before editing started, saved in OnPreCreate event) category permissions + // note: category in session is placed on catalog data import start + $category_id = $this->Application->IsAdmin() ? $this->Application->RecallVar('m_cat_id') : $this->Application->GetVar('m_cat_id'); + } + elseif ($top_prefix == 'c' || $top_prefix == 'st') { + $category_id = $id; + } + else { + // item being edited -> check by it's primary category permissions + $items_info = $this->GetCategoryItemData($top_prefix, $id); + $category_id = $items_info[$id]['CategoryId']; + $owner_id = $items_info[$id]['CreatedById']; + } + + // specific permission check for pending & owner permissions: begin + $uploader_events = Array ('OnUploadFile', 'OnDeleteFile', 'OnViewFile'); + if (in_array($event->Name, $uploader_events)) { + // don't recall target object during uploader-related, because OnItemLoad will use incorrect + // $user_id in Firefox (during Flash problems session will be used from Internet Exploere) + $new_item = false; + } + else { + $new_item = $this->Application->IsAdmin() && $event_handler->isNewItemCreate($event) ? true : false; + $check_status = $this->checkCombinedPermissions($event, $owner_id, (int)$category_id, $new_item); + } + + if (isset($check_status)) { + return $this->finalizePermissionCheck($event, $check_status); + } + // specific permission check for pending & owner permissions: end + + $perm_status = false; + $check_perms = $this->getPermissionByEvent($event, $event_perm_mapping); + + if ($check_perms === true) { + // event is defined in mapping but is not checked by permissions + return true; + } + + $item_prefix = $this->Application->getUnitOption($top_prefix, 'PermItemPrefix'); + foreach ($check_perms as $perm_name) { + // check if at least one of required permissions is set + if (!isset($perm_mapping[$perm_name])) { + // not mapped permission (e.g. advanced:approve) -> skip + continue; + } + $perm_name = $item_prefix.'.'.$perm_mapping[$perm_name]; + $perm_status = $this->CheckPermission($perm_name, 0, (int)$category_id); + + if ($perm_status) { + return $perm_status; + } + } + + return $this->finalizePermissionCheck($event, $perm_status); + } + /** * Finalizes permission checking (with additional debug output, when in debug mode) * @@ -315,6 +315,11 @@ */ function CheckEventCategoryPermission(&$event, $event_perm_mapping) { + if (!$this->Application->IsAdmin()) { + // check front-end permission by old scheme + return $this->_frontCheckEventCategoryPermission($event, $event_perm_mapping); + } + if (substr($event->Name, 0, 9) == 'OnPreSave') { // check separately, because permission mapping is not defined for OnPreSave* events $check_perms = Array ('add', 'edit'); Index: branches/RC/core/admin_templates/reviews/reviews.tpl =================================================================== diff -u -N -r11748 -r11823 --- branches/RC/core/admin_templates/reviews/reviews.tpl (.../reviews.tpl) (revision 11748) +++ branches/RC/core/admin_templates/reviews/reviews.tpl (.../reviews.tpl) (revision 11823) @@ -80,12 +80,16 @@ { $form_name = $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'tab_id') + '_form'; var $kf = document.getElementById($form_name); + var $prev_action = $kf.action; $kf.action = '' . replace('#PREFIX#', $Catalog.ActivePrefix); - std_edit_temp_item($Catalog.ActivePrefix, 'reviews/review_direct_edit'); - - $kf.action = $prev_action; + std_edit_temp_item( + $Catalog.ActivePrefix, 'reviews/review_direct_edit', + function() { + $kf.action = $prev_action; + } + ); } Index: branches/RC/core/admin_templates/categories/categories_tabs.tpl =================================================================== diff -u -N -r11662 -r11823 --- branches/RC/core/admin_templates/categories/categories_tabs.tpl (.../categories_tabs.tpl) (revision 11662) +++ branches/RC/core/admin_templates/categories/categories_tabs.tpl (.../categories_tabs.tpl) (revision 11823) @@ -1,5 +1,5 @@ - style="display: none;"> +
style="display: none;">
Index: branches/RC/core/admin_templates/users/user_edit_items.tpl =================================================================== diff -u -N -r11748 -r11823 --- branches/RC/core/admin_templates/users/user_edit_items.tpl (.../user_edit_items.tpl) (revision 11748) +++ branches/RC/core/admin_templates/users/user_edit_items.tpl (.../user_edit_items.tpl) (revision 11823) @@ -87,13 +87,17 @@ function edit() { $form_name = $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'tab_id') + '_form'; var $kf = document.getElementById($form_name); + var $prev_action = $kf.action; $kf.action = ''; set_hidden_field('remove_specials[' + $Catalog.ActivePrefix + ']', 1); - std_edit_item($Catalog.ActivePrefix, $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'edit_template')); - - $kf.action = $prev_action; + std_edit_item( + $Catalog.ActivePrefix, $Catalog.queryTabRegistry('prefix', $Catalog.ActivePrefix, 'edit_template'), + function() { + $kf.action = $prev_action; + } + ); } a_toolbar.Render();