protected function private_core() { $this->agente = new agente(); $fslog = new fs_log(); $this->historial = $fslog->all_by('login'); if (isset($_POST['nnick'])) { $nu = $this->user->get($_POST['nnick']); if ($nu) { $this->new_error_msg('El usuario <a href="' . $nu->url() . '">ya existe</a>.'); } else { if (isset($_POST['nadmin']) and !$this->user->admin) { $this->new_error_msg('Solamente un administrador puede crear otro administrador.'); } else { $nu = new fs_user(); $nu->nick = $_POST['nnick']; if ($nu->set_password($_POST['npassword'])) { $nu->admin = isset($_POST['nadmin']); if (isset($_POST['ncodagente'])) { if ($_POST['ncodagente'] != '') { $nu->codagente = $_POST['ncodagente']; } } if ($nu->save()) { Header('location: index.php?page=admin_user&snick=' . $nu->nick); } else { $this->new_error_msg("¡Imposible guardar el usuario!"); } } } } } else { if (isset($_GET['delete'])) { $nu = $this->user->get($_GET['delete']); if ($nu) { if (FS_DEMO) { $this->new_error_msg('En el modo <b>demo</b> no se pueden eliminar usuarios. Esto es así para evitar malas prácticas entre usuarios que prueban la demo.'); } else { if ($nu->admin and !$this->user->admin) { $this->new_error_msg("No tienes permiso para eliminar a un administrador."); } else { if (!$this->user->allow_delete_on(__CLASS__)) { $this->new_error_msg("No tienes permiso para eliminar usuarios."); } else { if ($nu->delete()) { $this->new_message("Usuario " . $nu->nick . " eliminado correctamente."); } else { $this->new_error_msg("¡Imposible eliminar al usuario!"); } } } } } else { $this->new_error_msg("¡Usuario no encontrado!"); } } } }
protected function process() { $this->show_fs_toolbar = FALSE; $this->agente = new agente(); $fslog = new fs_log(); $this->historial = $fslog->all_by('login'); if (isset($_POST['nnick'])) { $nu = $this->user->get($_POST['nnick']); if ($nu) { Header('location: ' . $nu->url()); } else { $nu = new fs_user(); $nu->nick = $_POST['nnick']; if ($nu->set_password($_POST['npassword'])) { $nu->admin = isset($_POST['nadmin']); if (isset($_POST['ncodagente'])) { if ($_POST['ncodagente'] != '') { $nu->codagente = $_POST['ncodagente']; } } if ($nu->save()) { Header('location: index.php?page=admin_user&snick=' . $nu->nick); } else { $this->new_error_msg("¡Imposible guardar el usuario!"); } } } } else { if (isset($_GET['delete'])) { $nu = $this->user->get($_GET['delete']); if ($nu) { if (FS_DEMO) { $this->new_error_msg('En el modo <b>demo</b> no se pueden eliminar usuarios. Esto es así para evitar malas prácticas entre usuarios que prueban la demo.'); } else { if ($nu->delete()) { $this->new_message("Usuario " . $nu->nick . " eliminado correctamente."); } else { $this->new_error_msg("¡Imposible eliminar al usuario!"); } } } else { $this->new_error_msg("¡Usuario no encontrado!"); } } } }