function Novo() { session_start(); $this->pessoa_logada = $_SESSION['id_pessoa']; session_write_close(); $tipoUsuario = new clsPmieducarTipoUsuario($this->cod_tipo_usuario, $this->pessoa_logada, NULL, $this->nm_tipo, $this->descricao, $this->nivel, NULL, NULL, 1); $this->cod_tipo_usuario = $tipoUsuario->cadastra(); if ($this->cod_tipo_usuario) { $this->createMenuTipoUsuario(); } $this->mensagem = 'Cadastro não realizado.<br>'; return FALSE; }
function Novo() { session_start(); $this->pessoa_logada = $_SESSION['id_pessoa']; session_write_close(); $obj = new clsPmieducarTipoUsuario($this->cod_tipo_usuario, $this->pessoa_logada, NULL, $this->nm_tipo, $this->descricao, $this->nivel, NULL, NULL, 1); $cadastrou = $obj->cadastra(); if ($cadastrou) { $this->cod_tipo_usuario = $cadastrou; if ($this->permissoes) { // Apaga todos as permissões (itens de menu) cadastradaos a este usuário. $obj_menu_usuario = new clsPmieducarMenuTipoUsuario($this->cod_tipo_usuario, $key, $valor['cadastra'], $valor['visualiza'], $valor['exclui']); $obj_menu_usuario->excluirTudo(); foreach ($this->permissoes as $key => $valor) { $valor['cadastra'] = $valor['cadastra'] == 'on' ? 1 : 0; $valor['visualiza'] = $valor['visualiza'] == 'on' ? 1 : 0; $valor['exclui'] = $valor['exclui'] == 'on' ? 1 : 0; if ($valor['cadastra'] || $valor['visualiza'] || $valor['exclui']) { // Instancia novo objeto clsPmieducarMenuTipoUsuario. $obj_menu_usuario = new clsPmieducarMenuTipoUsuario($this->cod_tipo_usuario, $key, $valor['cadastra'], $valor['visualiza'], $valor['exclui']); if (!$obj_menu_usuario->cadastra()) { $this->mensagem .= 'Erro ao cadastrar acessos aos menus.<br>'; return FALSE; } } } } $this->mensagem .= 'Cadastro efetuado com sucesso.<br>'; header('Location: educar_tipo_usuario_lst.php'); die; } $this->mensagem = 'Cadastro não realizado.<br>'; return FALSE; }