Index: trunk/core/kernel/event_manager.php =================================================================== diff -u -N -r6428 -r7391 --- trunk/core/kernel/event_manager.php (.../event_manager.php) (revision 6428) +++ trunk/core/kernel/event_manager.php (.../event_manager.php) (revision 7391) @@ -248,7 +248,14 @@ } } + // 3. store all prefixes passed before event processing, because they are used by GetTopmostPrefix $passed = explode(',', $this->Application->GetVar('passed')); + foreach ($events as $prefix_special => $event_name) { + if (!$event_name) continue; + $prefix_special = explode('.',$prefix_special); + array_push($passed, $prefix_special[0]); + } + $this->Application->SetVar('passed', implode(',', $passed)); foreach ($events as $prefix_special => $event_name) { if (!$event_name) continue; @@ -264,15 +271,15 @@ $prefix_special = explode('.',$prefix_special); $event->Prefix = $prefix_special[0]; - array_push($passed, $prefix_special[0]); +// array_push($passed, $prefix_special[0]); $event->Special = isset($prefix_special[1]) ? $prefix_special[1] : ''; $event->redirect_params = Array('opener' => 's', 'pass' => 'all'); $event->redirect = true; $event_handler =& $this->Application->recallObject($event->Prefix.'_EventHandler'); - $event->setEventParam('top_prefix', $this->Application->GetTopmostPrefix($event->Prefix)); - if (($this->Application->GetVar('u_id') == -1) || $event_handler->CheckPermission($event)) { + $event->setEventParam('top_prefix', $this->Application->GetTopmostPrefix($event->Prefix, true)); + if (($this->Application->RecallVar('user_id') == -1) || $event_handler->CheckPermission($event)) { $this->HandleEvent($event); } @@ -282,7 +289,8 @@ $event->redirect_params['m_cat_id'] = 0; // restore stuff, that processOpener() changed - $this->Application->RestoreVar('opener_stack'); + $wid = $this->Application->GetVar('m_wid'); + $this->Application->RestoreVar(rtrim('opener_stack_'.$wid, '_')); // don't save last_template, because no_permission template does js history.back and could cause invalid opener_stack content $this->Application->SetVar('skip_last_template', 1); } @@ -294,19 +302,29 @@ if ($event->redirect === true && !isset($event->redirect_params['pass_category']) && $this->Application->GetVar('m_cat_id')) { $event->redirect_params['pass_category'] = 1; } + + $wid = $this->Application->GetVar('m_wid'); + if ($wid && $event->redirect_params['opener'] == 'u') { + $event->redirect_params['opener'] = 's'; // because Application->HREF will react differently when 'opener' = 'u' + $event->redirect = 'incs/close_popup'; + } + $this->Application->Redirect($event->redirect, $event->redirect_params, null, $event->redirect_script); } } $this->Application->SetVar('events', $events); - $this->Application->SetVar('passed', implode(',', $passed)); +// $this->Application->SetVar('passed', implode(',', $passed)); } function processOpener() { - $opener_action = $this->Application->GetVar('m_opener'); - $opener_stack = $this->Application->RecallVar('opener_stack'); + $wid = $this->Application->GetVar('m_wid'); + + $opener_stack = $this->Application->RecallVar(rtrim('opener_stack_'.$wid, '_')); $opener_stack = $opener_stack ? unserialize($opener_stack) : Array(); + + $opener_action = $this->Application->GetVar('m_opener'); switch ($opener_action) { case 'r': // "reset" opener stack $opener_stack = Array(); @@ -326,30 +344,55 @@ array_pop($opener_stack); break; - case 'p': //pop-up - do not store last template - $this->Application->SetVar('skip_last_template', 1); + case 'p': // pop-up - generate new wid + $parent_wid = $this->Application->GetVar('m_wid'); // window_id of popup's parent window + $popup_wid = (int)$this->Application->RecallVar('last_wid') + 1; + $this->Application->StoreVar('last_wid', $popup_wid); + $this->Application->SetVar('m_wid', $popup_wid); + + if ($this->Application->GetVar('front')) { + $front_session =& $this->Application->recallObject('Session.front'); + + $last_template = $front_session->RecallVar(rtrim('last_template_popup_'.$parent_wid, '_')); + $last_template = '../'.$last_template; + } + else { + $last_template = $this->Application->RecallVar(rtrim('last_template_popup_'.$parent_wid, '_')); + } + + $opener_stack = Array ( $last_template ); + $this->Application->SetVar('m_opener', 's'); + $wid = $popup_wid; break; default: // "s/0," stay on same deep level break; } - if (!$this->Application->GetVar('skip_last_template')) { - $this->Application->SetVar('m_opener', 's'); - } - $this->Application->StoreVar('opener_stack', serialize($opener_stack)); + + $this->Application->SetVar('m_opener', 's'); + $this->Application->StoreVar(rtrim('opener_stack_'.$wid, '_'), serialize($opener_stack)); } - + /** + * Used from relationship event handler + * + * @param string $t + * @param Array $params + * @param string $pass + */ function openerStackPush($t, $params, $pass = 'all') { - $opener_stack = $this->Application->RecallVar('opener_stack'); + $wid = $this->Application->GetVar('m_wid'); + $stack_name = rtrim('opener_stack_'.$wid, '_'); + + $opener_stack = $this->Application->RecallVar($stack_name); $opener_stack = $opener_stack ? unserialize($opener_stack) : Array(); $redirect_params = array_merge_recursive2(Array('m_opener' => 'u', '__URLENCODE__' => 1), $params); $new_level = $this->Application->BuildEnv($t, $redirect_params, $pass, true); array_push($opener_stack, 'index.php|'.ltrim($new_level, ENV_VAR_NAME.'=') ); - $this->Application->StoreVar('opener_stack', serialize($opener_stack)); + $this->Application->StoreVar($stack_name, serialize($opener_stack)); } function registerHook($hookto_prefix, $hookto_special, $hookto_event, $mode, $do_prefix, $do_special, $do_event, $conditional)