I am in need of doing this exact thing myself. Here are some
suggestions after taking a quick look at the Model/Controller/Dispatch
classes... I am in no way an expert in CakePHP internals, but being
pretty comfortable with OO design I would suggest the following:
Add a public variable to AppModel (app_model.php) which would hold a
reference to your rdAuth object (or controller object, or whatever),
and override the afterSave() method with the code to update your
database fields with the user info.
app_model.php:
class AppModel extends Model {
var $rdAuthRef = false;
function afterSave()
{
// We have just performed a successful update or create.
if ($this->rdAuthRef)
{
//... Determine if this was a create or update ??howto?? ...//
//... Record in DB that this user created something ...//
}
return true;
}
}
Then in your AppController class (app_controller.php), you could
override the beforeFilter() method and add your controller/rdAuth
reference to all of the models in use by the controller.
app_controller.php:
class AppController extends Controller {
// $rdAuth will be initialized by my children controllers...
var $rdAuth = false;
function beforeFilter ()
{
//... Loop thru my bound models,
// add the rdAuth reference to each ...//
foreach ($this->modelNames as $modelClass)
{
if (property_exists($this, $modelClass))
{
$this->{$modelClass}->rdAuthRef = $this->rdAuth;
}
}
}
}
If the models were created with references back to its parent
controller, you wouldn't really need to do this...but it doesn't appear
to be the case (looking thru controller.php:constructClasses()). We are
forced to add the references to the models ourselves. Even though this
is a pain, I almost prefer doing this over saving the rdAuth object to
the session. :P
I don't have the cycles to try this out, nor to test these theories,
but hopefully it may create some additional ideas, comments. I'd be
interested to learn about your final solution. If I'm wrong about any
of this stuff, please correct me. Cheers! :)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---