This my attempt to solve the problem (logfile is a table for auditing): function beforeSave() { $this->currentAction = $this->id ? 'Update' : 'Insert'; return true; }
function afterSave() { // hope that this is not necessary // because cake has filled in the id after save if(!$this->id) { $id = $this->getLastInsertId(); } else { $id = $this->id ; } /* ** Save Log ** */ loadModel("Logfile"); $Logfile = new Logfile; $data['Logfile']['created'] = date("Y-m-d H:i:s"); $data['Logfile']['tablename'] = $this->name; $data['Logfile']['tableid'] = $this->getLastUsedId(); $data['Logfile']['username'] = @$_SESSION['cakeAuth']['login']; $data['Logfile']['action'] = $this->currentAction; $data['Logfile']['ipaddress'] = @$_SERVER['REMOTE_ADDR']; $Logfile->save($data); $Logfile = null; $this->currentAction = ''; return true; } function afterDelete() { /* ** save Log */ loadModel("Logfile"); $Logfile = new Logfile; $data['Logfile']['created'] = date("Y-m-d H:i:s"); $data['Logfile']['tablename'] = $this->name; $data['Logfile']['tableid'] = $this->getLastUsedId(); $data['Logfile']['username'] = @$_SESSION['cakeAuth']['login']; $data['Logfile']['action'] = 'Delete'; $data['Logfile']['ipaddress'] = @$_SERVER['REMOTE_ADDR']; $Logfile->save($data); $Logfile = null; return true; } > -----Messaggio originale----- > Da: cake-php@googlegroups.com > [mailto:[EMAIL PROTECTED] Per conto di zipman > Inviato: lunedì 20 agosto 2007 12.42 > A: Cake PHP > Oggetto: Auditing > > > Hello, > > I have finished a project and now I want to add auditing > support, as to know when an update or delete occured and with > what parameters. > I guess the solution to my problem is the afterSave callback > which I'll have to put in the app_model.php. The problem is I > don't know how to access the parameters used for save (the > model on which the save function was called and with what > parameters). How can I do this? > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---