public function lastid($id) { $this->load->view("read", $this->title, array("user" => Authentication::user_info(), "dados" => $this->model->Read($id)), null, $this->module); }
public function index() { $this->title = $this->title ? $this->title : ucfirst(get_class($this)) . ".Index"; $this->load->view('index', $this->title, array("user" => Authentication::user_info(), "dados" => $this->model ? $this->model->Read(null, null, "id desc") : null), null, $this->module); }
public function delete($ids) { $redirect = null; if (!is_numeric($ids)) { $redirect = ($this->module ? $this->module . "-" : null) . substr($ids, strpos($ids, '_') + 1, strpos($ids, ',') - 3); $ids = $this->model->Read_Where(preg_replace('/\\,/', '=', $ids), "id"); if (empty($ids)) { header("location:" . $redirect); exit; } } else { $ids = array("id" => $ids); } if (!is_multidimensional($ids)) { $ids = array($ids); } foreach ($ids as $id) { if (get_class($this) == "pessoas") { $user_id = Authentication::user_info(); if ($id['id'] == $user_id['_pessoas__id']) { $_SESSION['flash'] = "1#Ops! Parece que você está tentando deletar seus próprios dados!<br><small>Essa é uma operação impossível. Caso queira continuar, chame o administrador do Sistema.</small>"; $redirect = $redirect == null ? ($this->module ? $this->module . "/" : null) . get_class($this) : $redirect; header("location:" . $redirect); exit; } } $v = $this->model->Read($id['id']); $ks = array_keys($v); foreach ($ks as $k) { if ($k == "path") { if (dir_exists("assets/" . $this->uploadpath . "/" . $this->controller . "/" . $v['path'])) { $this->erase_dir("assets/" . $this->uploadpath . "/" . $this->controller . "/" . $v['path']); } } elseif (preg_match('/\\_upload/', $k)) { if (file_exists($v[$k])) { unlink($v[$k]); } } } } $this->model->Delete($id['id']); $_SESSION['flash'] = "3#Dados deletados com sucesso!"; $redirect = $redirect == null ? ($this->module ? $this->module . "/" : null) . get_class($this) : $redirect; header("location:" . get_base() . "/{$redirect}"); }
public function create_usuarios_fast() { $this->load->view("create", $this->title, array("user" => Authentication::user_info(), "form" => $this->form_create("_usuarios", array("_pessoas.nome", "_pessoas.imagem_upload", "_usuarios.usuario", "_usuarios.senha", "_usuarios.level")))); }