Index: branches/unlabeled/unlabeled-1.79.4/core/kernel/db/db_event_handler.php =================================================================== diff -u -r6873 -r6878 --- branches/unlabeled/unlabeled-1.79.4/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 6873) +++ branches/unlabeled/unlabeled-1.79.4/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 6878) @@ -180,7 +180,7 @@ if($ret) return $ret; // recall selected ids array and use the first one - $ids=$this->Application->GetVar($event->getPrefixSpecial().'_selected_ids'); + $ids = $this->Application->GetVar($event->getPrefixSpecial().'_selected_ids'); if ($ids != '') { $ids=explode(',',$ids); if($ids) $ret=array_shift($ids); @@ -199,10 +199,21 @@ * id passed in get/post as prefix_id * * @param kEvent $event + * @param Array $ids + * * @return Array ids stored */ - function StoreSelectedIDs(&$event) + function StoreSelectedIDs(&$event, $ids = null) { + $wid = $this->Application->GetTopmostWid($event->Prefix); + $session_name = rtrim($event->getPrefixSpecial().'_selected_ids_'.$wid, '_'); + + if (isset($ids)) { + // save ids directly if they given + $this->Application->StoreVar($session_name, implode(',', $ids)); + return $ids; + } + $ret = Array(); // May be we don't need this part: ? @@ -228,8 +239,8 @@ $ret = array_unique(array_merge($ret, $ids)); - $this->Application->SetVar($event->getPrefixSpecial().'_selected_ids',implode(',',$ret)); - $this->Application->LinkVar($event->getPrefixSpecial().'_selected_ids'); + $this->Application->SetVar($event->getPrefixSpecial().'_selected_ids', implode(',',$ret)); + $this->Application->LinkVar($event->getPrefixSpecial().'_selected_ids', $session_name); // This is critical - otherwise getPassedID will return last ID stored in session! (not exactly true) // this smells... needs to be refactored @@ -248,11 +259,21 @@ * Returns stored selected ids as an array * * @param kEvent $event + * @param bool $from_session return ids from session (written, when editing was started) * @return array */ - function getSelectedIDs(&$event) + function getSelectedIDs(&$event, $from_session = false) { - return explode(',', $this->Application->GetVar($event->getPrefixSpecial().'_selected_ids')); + if ($from_session) { + $wid = $this->Application->GetTopmostWid($event->Prefix); + $var_name = rtrim($event->getPrefixSpecial().'_selected_ids_'.$wid, '_'); + $ret = $this->Application->RecallVar($var_name); + } + else { + $ret = $this->Application->GetVar($event->getPrefixSpecial().'_selected_ids'); + } + + return explode(',', $ret); } /** @@ -278,10 +299,14 @@ function clearSelectedIDs(&$event) { $prefix_special = $event->getPrefixSpecial(); - $ids = $this->Application->RecallVar($prefix_special.'_selected_ids'); + + $ids = implode(',', $this->getSelectedIDs($event, true)); $event->setEventParam('ids', $ids); - - $this->Application->RemoveVar($prefix_special.'_selected_ids'); + + $wid = $this->Application->GetTopmostWid($event->Prefix); + $session_name = rtrim($prefix_special.'_selected_ids_'.$wid, '_'); + + $this->Application->RemoveVar($session_name); $this->Application->SetVar($prefix_special.'_selected_ids', ''); $this->Application->SetVar($prefix_special.'_id', ''); // $event->getPrefixSpecial(true).'_id' too may be @@ -1015,9 +1040,9 @@ $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); - $this->StoreSelectedIDs($event); + $ids = $this->StoreSelectedIDs($event); - $event->setEventParam('ids', $this->getSelectedIDs($event) ); + $event->setEventParam('ids', $ids); $this->customProcessing($event, 'before'); $ids = $event->getEventParam('ids'); @@ -1050,8 +1075,8 @@ */ function OnEdit(&$event) { - $this->StoreSelectedIDs($event); $this->setTempWindowID($event); + $this->StoreSelectedIDs($event); $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); /* @var $temp kTempTablesHandler */ @@ -1079,7 +1104,7 @@ if ($live_ids) { // ensure, that newly created item ids are avalable as if they were selected from grid // NOTE: only works if main item has subitems !!! - $this->Application->StoreVar($event->getPrefixSpecial().'_selected_ids', implode(',', $live_ids)); + $this->StoreSelectedIDs($event, $live_ids); } } $this->clearSelectedIDs($event); @@ -1220,8 +1245,8 @@ */ function OnPreCreate(&$event) { - $this->clearSelectedIDs($event); $this->setTempWindowID($event); + $this->clearSelectedIDs($event); $object =& $event->getObject( Array('skip_autoload' => true) );