X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=RooPostTrait.php;h=33890369308b019da6693c434d8138db0737297f;hb=refs%2Fheads%2Fmaster;hp=e8a692ed12bc08b148b5281a672d07095bdc94b6;hpb=f08f9a62e102bf101d7b6f3a919c8b45a416e371;p=Pman.Core diff --git a/RooPostTrait.php b/RooPostTrait.php index e8a692ed..33890369 100644 --- a/RooPostTrait.php +++ b/RooPostTrait.php @@ -2,6 +2,8 @@ trait Pman_Core_RooPostTrait { + var $old; + /** * POST method Roo/TABLENAME * -- creates, updates, or deletes data. @@ -66,7 +68,7 @@ trait Pman_Core_RooPostTrait { * * CALLS BEFORE change occurs: * - * beforeDelete($dependants_array, $roo) + * beforeDelete($dependants_array, $roo, $request) * Argument is an array of un-find/fetched dependant items. * - jerr() will stop insert.. (Prefered) * - return false for fail and set DO->err; @@ -170,7 +172,8 @@ trait Pman_Core_RooPostTrait { $affects = array(); - $all_links = $GLOBALS['_DB_DATAOBJECT']['LINKS'][$x->_database]; + $all_links = $x->databaseLinks(); + foreach($all_links as $tbl => $links) { foreach($links as $col => $totbl_col) { $to = explode(':', $totbl_col); @@ -186,8 +189,13 @@ trait Pman_Core_RooPostTrait { // echo '
';print_r($affects);exit; // DB_Dataobject::debugLevel(1); - - $clean = create_function('$v', 'return (int)$v;'); + if (function_exists('create_function')) { + $clean = create_function('$v', 'return (int)$v;'); + } else { + $clean = function($v) { + return (int)$v; + }; + } $bits = array_map($clean, explode(',', $req['_delete'])); @@ -241,7 +249,7 @@ trait Pman_Core_RooPostTrait { $match_total = 0; if ( $has_beforeDelete ) { - if ($xx->beforeDelete($match_ar, $this) === false) { + if ($xx->beforeDelete($match_ar, $this, $req) === false) { $errs[] = "Delete failed ({$xx->id})\n". (isset($xx->err) ? $xx->err : ''); continue; @@ -282,9 +290,7 @@ trait Pman_Core_RooPostTrait { } - DB_DataObject::Factory('Events')->logDeletedRecord($x); - - $this->addEvent("DELETE", $x); + $this->logDeleteEvent($x); $xx->delete(); @@ -301,6 +307,17 @@ trait Pman_Core_RooPostTrait { } + function logDeleteEvent($object) + { + + DB_DataObject::Factory('Events')->logDeletedRecord($object); + + $this->addEvent("DELETE", $object); + + + } + + function update($x, $req, $with_perm_check = true) { if ( $with_perm_check && !$this->checkPerm($x,'E', $req) ) { @@ -386,7 +403,7 @@ trait Pman_Core_RooPostTrait { { $this->permitError = true; // allow it to fail without dieing - $lock = DB_DataObjecT::factory('Core_locking'); + $lock = DB_DataObjecT::factory('core_locking'); $this->permitError = false; if (is_a($lock,'DB_DataObject') && $this->authUser) { @@ -425,7 +442,7 @@ trait Pman_Core_RooPostTrait { // edit it anyways... // can we find the user's lock. - $lock = DB_DataObjecT::factory('Core_locking'); + $lock = DB_DataObjecT::factory('core_locking'); $lock->on_id = $x->{$this->key}; $lock->on_table= strtolower($x->tableName()); $lock->person_id = $this->authUser->id; @@ -440,22 +457,19 @@ trait Pman_Core_RooPostTrait { $x->modified_by != $this->authUser->id ) { - $p = DB_DataObject::factory('Person'); + $p = DB_DataObject::factory('core_person'); $p->get($x->modified_by); - $this->jerr($p->name . " saved the record since you started editing,\nDo you really want to update it?", array('needs_confirm' => true)); + $this->jerr($p->name . " saved the record since you started editing,\nDo you really want to update it?", array('needs_confirm' => true)); } - - - } + return $lock; } function insert($x, $req, $with_perm_check = true) - { - + { if (method_exists($x, 'setFromRoo')) { $res = $x->setFromRoo($req, $this); if (is_string($res)) { @@ -505,7 +519,6 @@ trait Pman_Core_RooPostTrait { $x->beforeInsert($_REQUEST, $this); } - $res = $x->insert(); if ($res === false) { $this->jerr($x->_lastError->toString());