You can add to "articles" table "created_by" filed
and virtual association belongsTo
or bind only when you need it:

app_model.php
function bindCreatedBy()
{
        $this->bindModel(array('belongsTo'=>array('CreatedBy' =>
             array( 'className' => 'User', 'foreignKey' =>
'created_by','fields' =>    array
('CreatedBy.id','CreatedBy.username')))));
}


On Mar 9, 9:21 am, Marcus Silva <[email protected]> wrote:
> I am looking for an easy way to manage user added record to the db.  I
> thought that I could use the following idea:
>
>         Create a tabled with the following fields: id,record_id,user_id and
> record_model.
>         Basically the idea is to add/delete a entry into that table like so:
>
>         id = null
>         user_id = User currently logged in
>         record_id = id of linked model record
>         record_model = Article, Album,Photo,Video etc...
>
>         Then whenever the user trie to either edit or delete the record we
> find that record and act on it....
>
>         That way i could just use in the controller or maybe I could write a
> behaviour to handle everything:
>
>         $conditions = array(
>                 'Record.record_id' => $record_id,
>                 'Record.user_id' => $this->getInfo('User','user_id'),
>                 'Record.record_model' => $this->{$this->modelClass}->name,
>         );
>
>         if($record = $this->Record->find('first',array('conditions' =>
> $conditions,'fields' => array()))){
>                 //The user logged in created the record
>                 //The record could be anything really
>         }
>
>         This would only be used to track what records the user can touch in
> terms of deleting/editing etc since only the actual user who added the
> record would be able to access it...
>         Admins would overhide this anyway...
>
>         Have you guys ever used anything like this and is it actually a good
> approach?
>
>         Many thanks in advance for anyones input....
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to