Index: branches/5.1.x/core/units/helpers/permissions_helper.php =================================================================== diff -u -r12657 -r13086 --- branches/5.1.x/core/units/helpers/permissions_helper.php (.../permissions_helper.php) (revision 12657) +++ branches/5.1.x/core/units/helpers/permissions_helper.php (.../permissions_helper.php) (revision 13086) @@ -1,6 +1,6 @@ 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'); + $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']; + + if ($items_info) { + $category_id = $items_info[$id]['CategoryId']; + $owner_id = $items_info[$id]['CreatedById']; + } + else { + // item wasn't found in database + $category_id = $this->Application->GetVar('m_cat_id'); + } } // specific permission check for pending & owner permissions: begin @@ -212,7 +219,7 @@ $new_item = false; } else { - $new_item = $this->Application->IsAdmin() && $event_handler->isNewItemCreate($event) ? true : false; + $new_item = $this->Application->isAdminUser && $event_handler->isNewItemCreate($event) ? true : false; $check_status = $this->checkCombinedPermissions($event, $owner_id, (int)$category_id, $new_item); } @@ -257,12 +264,19 @@ function finalizePermissionCheck(&$event, $perm_status) { if (!$perm_status) { + if (MOD_REWRITE) { +// $event->SetRedirectParam('m_cat_id', 0); // category means nothing on admin login screen + $event->SetRedirectParam('next_template', urlencode('external:' . $_SERVER['REQUEST_URI'])); + } + else { + $event->SetRedirectParam('next_template', $this->Application->GetVar('t')); + } + if ($this->Application->isDebugMode()) { // for debugging purposes $event->SetRedirectParam('section', $event->getSection()); $event->SetRedirectParam('main_prefix', $event->getEventParam('top_prefix')); $event->SetRedirectParam('event_name', $event->Name); - $event->SetRedirectParam('next_template', $this->Application->GetVar('t')); } $event->status = erPERM_FAIL; @@ -329,7 +343,7 @@ */ function CheckEventCategoryPermission(&$event, $event_perm_mapping) { - if (!$this->Application->IsAdmin()) { + if (!$this->Application->isAdmin) { // check front-end permission by old scheme return $this->_frontCheckEventCategoryPermission($event, $event_perm_mapping); } @@ -348,7 +362,7 @@ } // 1. most of events does require admin login only - $perm_status = $this->Application->LoggedIn() && $this->Application->IsAdmin(); + $perm_status = $this->Application->isAdminUser; // 2. in case, when event require more, then "view" right, then restrict it to temporary tables only if (!in_array('view', $check_perms)) { @@ -448,33 +462,48 @@ $redirect_params['pass_category'] = $params['pass_cateogry']; } + if (MOD_REWRITE) { + // TODO: $next_t variable is ignored !!! (is anyone using m_RequireLogin tag with "next_template" parameter?) + $redirect_params = Array ( + 'm_cat_id' => 0, // category means nothing on admin login screen + 'next_template' => urlencode('external:' . $_SERVER['REQUEST_URI']), + ); + } + else { + $redirect_params['next_template'] = $t; + } + + if ($this->Application->isAdmin) { + $redirect_params['m_wid'] = ''; // remove wid, otherwise parent window may add wid to its name breaking all the frameset (for targets) + $redirect_params['pass'] = 'm'; // don't pass any other (except "m") prefixes to admin login template + } + if (!$this->Application->LoggedIn()) { $redirect_template = array_key_exists('login_template', $params) ? $params['login_template'] : ''; - if (!$redirect_template && $this->Application->IsAdmin()) { + + if (!$redirect_template && $this->Application->isAdmin) { $redirect_template = 'login'; } - $redirect_params['next_template'] = $t; } else { - if (isset($params['no_permissions_template'])) { + if (array_key_exists('no_permissions_template', $params)) { $redirect_template = $params['no_permissions_template']; } else { - $redirect_template = $this->Application->IsAdmin() ? 'no_permission' : $this->Application->ConfigValue('NoPermissionTemplate'); + $redirect_template = $this->Application->isAdmin ? 'no_permission' : $this->Application->ConfigValue('NoPermissionTemplate'); } if ($this->Application->isDebugMode()) { $redirect_params['from_template'] = 1; $redirect_params['perms'] = $params[ isset($params['permissions']) ? 'permissions' : 'perm_event' ]; - $redirect_params['next_template'] = $t; } } if (isset($params['index_file']) && $params['index_file']) { $redirect_params['index_file'] = $params['index_file']; } - return Array($redirect_template, $redirect_params); + return Array ($redirect_template, $redirect_params); } /**