/** * After Save method * * @param boolean $created */ public function afterSave($created, $options = array()) { $this->updateUserRolesViewPrefix(); if (!empty($this->data['UserRole']['duplicate'])) { App::uses('Privilege', 'Privileges.Model'); $Privilege = new Privilege(); $Privilege->duplicatePermissions('UserRole', $this->data['UserRole']['duplicate'], $this->id); } return parent::afterSave($created); }
/** * After save method * * @param bool $created */ public function afterSave($created, $options = array()) { // add the user to a group if the data for the group exists (can't use saveAll() because of extra fields) if (!empty($this->data['UserGroup']['UserGroup']['id'])) { $this->UserGroup->UsersUserGroup->add($this->data); } if ($created) { $this->data = $this->__afterCreation($this->data); $welcomeData = $this->data; // need this for the welcome email (gets rewritten after the second save below) } unset($this->data[$this->alias]['password']); unset($this->data[$this->alias]['current_password']); unset($this->data[$this->alias]['confirm_password']); $this->save($data[$this->alias], array('callbacks' => false)); if ($created) { // Send a Welcome Email (moved to after the second save because the forgot_key is if we don't) if (defined('__APP_REGISTRATION_EMAIL_VERIFICATION')) { $this->welcome($welcomeData[$this->alias]['username']); } // after creation callback (to use, ) $this->_afterCreationCallback(); } if ($this->autoLogin && CakeSession::read('Auth.User.id') == $this->data[$this->alias]['id']) { CakeSession::write('Auth', Set::merge(CakeSession::read('Auth'), $this->data)); } return parent::afterSave($created, $options); }