Actually, this isn't good enough - if, given a Post (which is spam) I
want to disable this Posts's Author which in turns hides all of that
Author's Posts, then I loose the id. For instance :
// In the Post controller
function hide($id = null) {
if ($id) {
$this->id = $id;
}
if ($this->id) {
$this->saveField('hidden', 1);
}
}
function disableAuthor($id = null) {
if ($id) {
$this->id = $id;
}
if ($this->id) {
$this->Author->setId($this->field('author_id'));
$this->Author->disable();
}
}
// In the author controller
function disable($id = null) {
if ($id) {
$this->id = $id;
}
if ($this->id) {
$this->saveField('status', 'disabled');
$posts = $this->Post->findAll(array('Post.author_id' =>
$this->id));
foreach ($posts as $post) {
$this->Post->set($post);
$this->Post->hide();
}
}
}
// Now if this is called :
function hideSpam() {
$posts = $this->Post->findAll(array('Post.title' => 'spam'));
foreach ($posts as $post) {
$this->Post->set($post); // This sets $this->Post->id
$this->Post->disableAuthor();
// XXX here the 'id' of $this->Post->id has changed, so I must use
'set' again if I want to manipulate
// the post further.
}
}
In that case it would have been up to function 'disable' in the
'Author' model to save and restore the 'id' field of the Post model.
Could this be done automatically ?
Anselm
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---