/** * Add method * * @return void Redirects on successful add, renders view otherwise. */ public function add() { $projeto = $this->Projeto->newEntity(); if ($this->request->is('post')) { $projeto = $this->Projeto->patchEntity($projeto, $this->request->data); $projeto->grupo = 'grupo-' . str_replace(' ', '-', strtolower($projeto->nomeProjeto)); $projeto->user = str_replace(' ', '.', strtolower($projeto->nomeProjeto)); if ($this->Projeto->save($projeto)) { $ldap = new LDAP(3); $obj = $ldap->monta_projeto($projeto); $ldap->addUser($projeto->user, $obj); $grupo = $ldap->monta_grupo_projeto($projeto); $ldap->addGroup($projeto->grupo, $grupo); $this->Flash->success(__('Projeto Incluído.')); return $this->redirect(['action' => 'index']); } else { $this->Flash->error(__('Problema ao incluir projeto.')); } } $usuario = $this->Projeto->usuario->find('list', ['limit' => 200])->where(['usuario.historico' => 0]); $this->set(compact('projeto', 'usuario', 'obj', 'grupo')); $this->set('_serialize', ['projeto']); }