Skip to content

Instantly share code, notes, and snippets.

@pvalencia
Created August 12, 2009 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pvalencia/166613 to your computer and use it in GitHub Desktop.
Save pvalencia/166613 to your computer and use it in GitHub Desktop.
saving users with ACL in cakephp
<?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