/** * Throws an exception if information in the bean has been changed * by another process or bean. * @param string $event * @param RedBean_OODBBean $item */ public function onEvent($event, $item) { $id = $item->id; if (!(int) $id) { $event = "open"; } $type = $item->getMeta("type"); if ($event == "open") { if (isset($this->stash[$id])) { $insertid = $this->stash[$id]; unset($this->stash[$id]); return $insertid; } $insertid = $this->writer->insertRecord("__log", array("action", "tbl", "itemid"), array(array(1, $type, $id))); $item->setMeta("opened", $insertid); //echo "<br>opened: ".print_r($item, 1); } if ($event == "update" || $event == "delete") { if ($item->getMeta("opened")) { $oldid = $item->getMeta("opened"); } else { $oldid = 0; } $newid = $this->writer->checkChanges($type, $id, $oldid); $item->setMeta("opened", $newid); } }