Index: trunk/core/kernel/event_manager.php
===================================================================
diff -u -N -r4689 -r4758
--- trunk/core/kernel/event_manager.php (.../event_manager.php) (revision 4689)
+++ trunk/core/kernel/event_manager.php (.../event_manager.php) (revision 4758)
@@ -70,9 +70,9 @@
*/
var $afterHooks = Array();
-
+
var $recursionStack = Array();
-
+
function kEventManager()
{
parent::kBase();
@@ -107,7 +107,8 @@
unset($this->queryMaps[$prefix]);
}
- $this->Application->SetVar('passed', implode(',', array_keys($this->queryMaps)) );
+// 'passed' is set later in ProcessRequest - do we really need it here? (it breakes HTTPQuery initialization...)
+// $this->Application->SetVar('passed', implode(',', array_keys($this->queryMaps)) );
return $query_map;
}
@@ -165,18 +166,18 @@
$event_key = $event->getPrefixSpecial().':'.$event->Name;
return in_array($event_key, $this->recursionStack) ? true : false;
}
-
+
function pushEvent(&$event)
{
$event_key = $event->getPrefixSpecial().':'.$event->Name;
array_push($this->recursionStack, $event_key);
}
-
+
function popEvent()
{
array_pop($this->recursionStack);
}
-
+
/**
* Allows to process any type of event
*
@@ -188,11 +189,17 @@
if ($this->isRecursion($event)) {
return true;
}
-
+
$this->pushEvent($event);
-
+
if( !$this->Application->prefixRegistred($event->Prefix) )
{
+ $unit_config_reader =& $this->Application->recallObject('kUnitConfigReader');
+ $unit_config_reader->loadConfig($event->Prefix);
+ }
+
+ if( !$this->Application->prefixRegistred($event->Prefix) )
+ {
trigger_error('Prefix '.$event->Prefix.' not registred (requested event '.$event->Name.')', E_USER_NOTICE);
return false;
}
@@ -211,14 +218,14 @@
}
$this->popEvent();
-
+
return true;
}
function ProcessRequest()
{
$this->processOpener();
-
+
// 1. get events from $_POST
$events = $this->Application->GetVar('events');
if ($events === false) $events = Array();
@@ -263,22 +270,22 @@
$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)) {
$this->HandleEvent($event);
}
-
+
if ($event->status == erPERM_FAIL) {
$event->redirect = $this->Application->IsAdmin() ? 'no_permission' : $this->Application->ConfigValue('NoPermissionTemplate');
-
+
// restore stuff, that processOpener() changed
$this->Application->RestoreVar('opener_stack');
// 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);
}
-
+
// should do redirect but to no_permissions template
if ( ($event->status == erSUCCESS || $event->status == erPERM_FAIL) && ($event->redirect === true || strlen($event->redirect) > 0)) {
$this->Application->Redirect($event->redirect, $event->redirect_params, null, $event->redirect_script);
@@ -319,7 +326,7 @@
default: // "s/0," stay on same deep level
break;
}
-
+
if (!$this->Application->GetVar('skip_last_template')) {
$this->Application->SetVar('m_opener', 's');
}
@@ -397,7 +404,7 @@
// use same special as master event
$hook['DoSpecial'] = $event->Special;
}
-
+
$prefix_special = rtrim($hook['DoPrefix'].'_'.$hook['DoSpecial'], '_');
if ( $hook['Conditional'] && !$this->Application->GetVar($prefix_special) ) {
continue;
@@ -463,7 +470,7 @@
$sql = 'REPLACE INTO '.TABLE_PREFIX.'Cache (VarName,Data,Cached) VALUES (%s,%s,%s)';
$this->Conn->Query( sprintf($sql, $this->Conn->qstr('RegularEventRuns'), $this->Conn->qstr(serialize($event_last_runs)), adodb_mktime() ) );
}
-
+
/**
* Allows to determine, that required event is beeing processed right now
*