Created
August 12, 2009 17:06
-
-
Save pvalencia/166613 to your computer and use it in GitHub Desktop.
saving users with ACL in cakephp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Cambia el parent_id del aro asociado al correspondiente al nuevo grupo | |
*/ | |
function afterSave($created) { | |
if(!$created && $this->id && isset($this->data['Usuario']['grupo_id'])) { | |
$aro = $this->Aro->find('first', | |
array( | |
'conditions' => array( | |
'model' => 'Usuario', | |
'foreign_key' => $this->id | |
) | |
) | |
); | |
$aro_parent = $this->Aro->find('first', | |
array( | |
'conditions' => array( | |
'model' => 'Grupo', | |
'foreign_key' => $this->data['Usuario']['grupo_id'] | |
), | |
'fields' => array('Aro.id') | |
) | |
); | |
$aro['Aro']['parent_id'] = $aro_parent['Aro']['id']; | |
$this->Aro->save($aro); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment