function enable($id = null) { if (empty($this->data)) { $this->data = $this->User->read(null, $id); } else { if ($this->User->save($this->data)) { $user = $this->User->read(null, $this->data['User']['id']); $aro_user = $user['User']['USERNAME']; $aro_group = null; $parent_id = 0; if ($user['User']['TYPE'] === 'MAHASISWA') { $aro_group = 'Mahasiswa'; $parent_id = 1; } else { if ($user['User']['TYPE'] === 'DOSEN') { $aro_group = 'Dosen'; $parent_id = 2; } else { $aro_group = 'Pegawai'; $parent_id = 3; } } $aro = new Aro(); $aro->create(); if (!$aro->node("{$aro_group}/{$aro_user}")) { $aro->save(array('alias' => $aro_user, 'parent_id' => $parent_id, 'model' => 'User', 'foreign_key' => $user['User']['id'])); } $this->Session->setFlash(__('The User has been Actived', true)); $this->redirect(array('action' => 'index')); } } }