/** * modify * * @access public * @return void */ function modify() { Configure::write('debug', '0'); $this->layout = 'ajax'; if ($this->Acl->check($this->ZTAuth->user('username'), "Users::edit", '*')) { if ($this->User->save($this->data['User'])) { $aro = new Aro(); $arodata = $aro->findByForeign_Key($this->data['User']['id']); // try to find group ARO $newgroup = $aro->find('model LIKE "Group" AND foreign_key =' . $this->data['User']['group_id']); if (empty($newgroup)) { $this->set('result', '{success:false, msg:"Group ARO not found"}'); return; } // update ARO fields $arodata['Aro']['model'] = 'User'; $arodata['Aro']['alias'] = $this->data['User']['username']; $arodata['Aro']['foreign_key'] = $this->data['User']['id']; $arodata['Aro']['parent_id'] = $newgroup['Aro']['id']; // create new ARO for user if it's not already exists if (empty($arodata['Aro']['id'])) { $aro->create(); } $aro->save($arodata); $this->set('result', '{success:true}'); } else { $this->set('result', '{success:false}'); } } else { $this->set('result', '{success:false, msg:"You can not do that"}'); } }