I want to be able to delete a User, but a User has a Manager:
var $belongsTo = array(
'Manager' => array(
'className' => 'User',
'foreignKey' => 'manager_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
);
And whenever a User is deleted, all of it’s “children” are deleted too.
For example, say I delete User A. User A is the manager of users B, C, and D. When A is deleted, so are B, C, and D, because they have A as their manager_id.
So my question is – is this supposed to be happening? And is there a way I can prevent this from happening?
Thanks!
It was an ACL issue – totally unexpected. Since our users operate in a tree structure with the Manager, the User has a
lftandrghtfield that is only updated in theafterSave. The easy solution is to dissociate the user by setting theirlftandrghtto0, but after deeper thought, I am setting theirmanager_idtoNULLand saving it so that the tree reorganizes itself (via theafterSave).Wow. That was quite the problem.