Exemplo n.º 1
0
 public function Edit()
 {
     if (!isset($_REQUEST['txt_nombres'])) {
         redirect("/0/");
         return;
     }
     $nombre = $_REQUEST['txt_nombres'];
     $apellido = $_REQUEST['txt_apellidos'];
     $correo = $_REQUEST['txt_email'];
     $pass = isset($_REQUEST['txt_pass']) ? $_REQUEST['txt_pass'] : NULL;
     $status = isset($_REQUEST['txt_baja']) ? $_REQUEST['txt_baja'] : NULL;
     $id = $_REQUEST['id_user'];
     $data_login = array();
     $data_user = array("nombres" => $nombre, "apellidos" => $apellido, "email" => $correo);
     if ($status != NULL) {
         $data_login["status"] = $status;
     }
     if ($pass != NULL) {
         $this->load->helper("string");
         $this->load->library("encryption");
         $this->load->helper("setup");
         $random = random_string();
         $this->encryption->initialize(array('cipher' => 'aes-256', 'mode' => 'cbc', 'key' => get_key()));
         $data_login['password'] = $this->encryption->encrypt($random);
         $data_login['password_state'] = 0;
         $this->load->library("email");
         if (email_config() != NULL) {
             $this->email->initialize(email_config());
         }
         $from_ = email_from();
         $this->email->from($from_['from'], $from_['name']);
         $this->email->to($correo);
         $this->email->subject('Contraseña Unitee | Inventario');
         $message_ = 'Tu nueva contraseña es : ' . $random;
         $this->email->message($message_);
         $this->email->send();
     }
     $this->load->model("user/user_edit");
     if (count($data_login) >= 1) {
         $r = $this->user_edit->updateUsers("login", $data_login, "id_login={$id}");
         if (!$r) {
             redirect("/0/user=user_edit?e=3&id=" . $id);
             return;
         }
     }
     $e = $this->user_edit->updateUsers("user", $data_user, "id_login={$id}");
     if ($e) {
         redirect("/0/user=user_edit?e=0&id=" . $id);
         return;
     } else {
         redirect("/0/user=user_edit?e=3&id=" . $id);
         return;
     }
 }
Exemplo n.º 2
0
 public function emailFrom($email = NULL, $name = NULL)
 {
     $this->from_ = $email != NULL ? array("from" => $email, "name" => $name != NULL ? $name : $email) : email_from();
     return $this;
 }