public function guardar() { $arrayprivilegios = $this->input->post('privilegios'); $usuario = new Usuario($this->input->post('idusuario')); $password = $this->input->post('password'); if ($usuario->exists()) { if (!empty($password)) { $usuario->password = crypt($password, 'mr%fsdfOk5ad'); } } else { $usuario->password = crypt($password, 'mr%fsdfOk5ad'); } $usuario->usuario = $this->input->post('usuario'); $usuario->email = $this->input->post('email'); $usuario->save(); //guardamos los privilegios... $privilegios = new Privilegio(); $privilegios->get(); $usuario->delete($privilegios->all); //borramos todos... foreach ($arrayprivilegios as $idprivilegio) { $privilegio = new Privilegio($idprivilegio); $usuario->save($privilegio); } redirect('admin/usuarios/listado'); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Propietario(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Propietario'])) { $model->attributes = $_POST['Propietario']; $usuario = new Usuario(); $model->rut = Tools::removeDots($model->rut); $usuario->user = $model->rut; $arr = explode("-", $model->rut); $usuario->clave = CPasswordHelper::hashPassword($arr[0]); $usuario->rol = "propietario"; $usuario->nombre = $_POST['Propietario']['nombre']; $usuario->email = $_POST['Propietario']['email']; $usuario->apellido = $_POST['Propietario']['apellido']; $model->usuario_id = 1; if ($model->validate()) { if ($usuario->validate()) { if ($usuario->save()) { $model->usuario_id = $usuario->id; if ($model->save()) { $auth = Yii::app()->authManager; Authassignment::model()->deleteAllByAttributes(array('userid' => $usuario->id)); $auth->revoke($usuario->rol, $model->usuario_id); $auth->assign($usuario->rol, $model->usuario_id); $this->redirect(array('view', 'id' => $model->id)); } } } } } $this->render('create', array('model' => $model)); }
public function postCreate() { $rules = array('txtRol' => 'required|numeric|min:1', 'txtEmail' => 'required|email|min:8|max:100', 'txtPassword' => 'required|min:6|max:100', "txtNombres" => "required|min:2|max:100", "txtApellidos" => "required|min:2|max:100", "username" => "required|min:3|max:20|unique:users", "txtEstado" => "required|numeric|min:0|max:1"); $messages = array('required' => 'El campo :attribute es obligatorio.', 'min' => 'El campo :attribute no puede tener menos de :min carácteres.', 'email' => 'El campo :attribute debe ser un email válido.', 'max' => 'El campo :attribute no puede tener más de :min carácteres.', 'unique' => 'El :attribute ingresado ya existe en la base de datos', "numeric" => "El campo :attribute debe ser un numero"); $friendly_names = array('username' => 'Nombre de Usuario', 'txtPassword' => 'Contraseña', "txtNombres" => "Nombres", "txtApellidos" => "Apellidos", "txtEstado" => "Estado", "txtEmail" => "Email", "txtRol" => "Rol"); $validation = Validator::make(Input::all(), $rules, $messages); $validation->setAttributeNames($friendly_names); if ($validation->fails()) { return Redirect::to('usuarios/ausuario')->withErrors($validation)->withInput(); } else { DB::transaction(function () { $usuario = new Usuario(); $usuario->roles_id = Input::get("txtRol"); $usuario->nombres = Input::get("txtNombres"); $usuario->apellidos = Input::get("txtApellidos"); $usuario->email = Input::get("txtEmail"); $usuario->password = Hash::make(Input::get("txtPassword")); $usuario->contrasenia = Crypt::encrypt(Input::get("txtPassword")); $usuario->username = Input::get("username"); $usuario->fechaCreacion = new DateTime(); $usuario->estado = Input::get("txtEstado"); $usuario->save(); }); return Redirect::to("admin")->with("insertar", true); } }
function nuevo() { $objeto = new Usuario(); $this->usuarios = array(); $usuario = new Usuario(Input::post("usuario")); $usuarioencontrado = $objeto->find("conditions: cedula='{$usuario->cedula}'"); $this->usuarios = $objeto->find(); $this->usuario_id = "0"; if (Input::hasPost("tipousuario")) { //Campos if (!$usuarioencontrado) { $tipousuario = Input::post("tipousuario"); $usuario->tipousuario_id = $tipousuario["tipousuario_id"]; if ($usuario->save()) { $this->usuario_id = $usuario->id; Flash::info("Datos grabados correctamente"); Router::redirect("usuario/index"); } else { Flash::error("Ups!! hay un error, intente nuevamente"); } } else { Flash::error("El usuario registrado con esa cedula ya existe"); } } }
public function postNuevo() { if (Request::ajax()) { $reglas = array('dni' => 'required|min:8|unique:activistas', 'email' => 'required|email', 'passwordn' => 'min:6'); $mensaje = array('required' => ':attribute Es requerido', 'regex' => ':attribute Solo debe ser Texto', 'numeric' => ':attribute seleccione una opcion', 'email' => ':attribute No es un email válido ejemplo@ejemplo.ejemplo', 'unique' => ':attribute Ya existente', 'min' => ':attribute No cumple con el minimo de :min caracteres'); $validator = Validator::make(Input::all(), $reglas, $mensaje); if ($validator->fails()) { return Response::json(array('rst' => 2, 'msj' => $validator->messages())); } $activista = new Usuario(); $activista->paterno = Input::get('paterno'); $activista->materno = Input::get('materno'); $activista->nombres = Input::get('nombre'); $activista->email = Input::get('email'); $activista->dni = Input::get('dni'); $activista->fecha_ingreso = date("Y-m-d"); $activista->password = Hash::make(Input::get('passwordn')); $activista->nivel_id = Input::get('rdb_check'); $activista->save(); $activistaCargo = new ActivistaCargo(); $activistaCargo->activista_id = $activista->id; $activistaCargo->cargo_id = Input::get('rdb_check'); $activistaCargo->usuario_created_at = $activista->id; $activistaCargo->save(); $parametros = array('email' => Input::get('email'), 'persona' => $activista->paterno . " " . $activista->materno . ", " . $activista->nombres); try { Mail::send('emails', $parametros, function ($message) { $message->to(Input::get('email'))->subject('.::Bienvenido PPKausa::.'); }); } catch (Exception $e) { //echo $qem[$k]->email."<br>"; } return Response::json(array('rst' => '1', 'msj' => '')); } }
public function sala() { // http://gravatar.com/avatar/ $this->title = 'Sala de Asistencia'; if (Input::post("nombre") and Input::post("email") and Input::post("ayuda")) { $usuario = new Usuario(); $usuario->nombre = Input::post("nombre"); $usuario->email = Input::post("email"); $usuario->online = 1; if ($usuario->save()) { $id = $usuario->find('columns: id', 'limit: 1', 'order: id desc'); $canal = new Canal(); $this->imagen = $this->get_gravatar($usuario->email); $imagen = "<img style='float:left;padding:4px;' src='" . $this->imagen . "' width=\"50\" alt=\"Tu Imagen\">"; $canal->mensaje = "<span style='float:left;padding-top:10px;'>" . $imagen . "<b>" . $usuario->nombre . "(" . $usuario->email . ")</b>: <br>" . Input::post("ayuda") . "</span> <div class='clearfix'></div>"; $canal->identificador_canal = md5(Input::post("email") . date("Y-m-d") . $id[0]->id); $canal->usuario_id = $id[0]->id; if ($canal->save()) { $this->nombre = Input::post("nombre"); $this->email = Input::post("email"); $this->identificador_canal = $canal->identificador_canal; $this->usuario_id = $canal->usuario_id; } else { Flash::error("No se pudo abrir un canal de asistencia, Vuelva a intentarlo por favor!"); Router::redirect("index/chat"); } } else { Flash::error("No pudo ingresar a una sala de asistencia, por favor intentelo de nuevo"); } } else { Flash::error("El nombre, email y la consulta de como podemos ayudarte, son obligatorios"); Router::redirect("index/chat"); } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Usuario(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Usuario'])) { $model->attributes = $_POST['Usuario']; $model->clave = crypt($model->clave, 'salt'); $allowed_chars = 'ABCD1234567890'; $allowed_count = strlen($allowed_chars); $password = null; $exist = null; $band = true; $password_length = 6; while ($password === null || $band) { $password = ''; for ($i = 0; $i < $password_length; ++$i) { $password .= $allowed_chars[mt_rand(0, $allowed_count - 1)]; } $exist = Usuario::model()->find('pin=:pin', array(':pin' => $password)); if ($exist) { $band = true; } else { $band = false; } } $model->pin = $password; if ($model->save()) { $this->redirect(array('view', 'id' => $model->cedula)); } } $this->render('create', array('model' => $model)); }
public function postRegistro() { include_once public_path() . '/securimage/securimage.php'; $securimage = new Securimage(); $captcha_sesion = strtoupper($securimage->getCode()); include app_path() . "/include/cifrado.php"; $usuario = new Usuario(); $data = Input::all(); $data['captcha_sesion'] = $captcha_sesion; $data['captcha_code'] = strtoupper($data['captcha_code']); $data['fecha_nacimiento'] = $data['anyo'] . "-" . $data['mes'] . "-" . $data['dia']; foreach ($data as $key => $value) { if ($key != 'password' && $key != 'email') { $data[$key] = mb_strtoupper($value, 'UTF-8'); } } $data['password'] = encriptar($data['password']); $data['cod_verif'] = rand(111111, 999999); if (!$usuario->isValid($data)) { return Redirect::action('Usuario_UsuarioController@getRegistro')->withInput(Input::except('password'))->withErrors($usuario->errors)->with('id_municipio', $data['municipio']); } $usuario->fill($data); $usuario->save(); return Redirect::action('Usuario_UsuarioController@getVerificar', array($usuario->id))->with('message_ok', 'Registro Completado. Por favor, inserte el código de verificación que le hemos enviado a su correo electrónico. Gracias'); }
/** * Show the form for creating a new resource. * * @return Response */ public function crearUsuario() { $user = new Usuario(); // Obtenemos la data enviada por el usuario $data = Input::all(); //$user->roles->attach(2); // Revisamos si la data es válido if ($user->isValid($data)) { // Si la data es valida se la asignamos al usuario $user->fill($data); // Guardamos el usuario $user->save(); return Redirect::to('registro'); } else { // En caso de error regresa a la acción create con los datos y los errores encontrados return Redirect::back()->with('error_message', 'el usuario ya existe ')->withInput(); } /* $respuesta = Usuario::agregarUsuario(Input::all()); if ($respuesta['error'] == true){ return Redirect::to('registro')->withErrors($respuesta['mensaje'] )->withInput(); }else{ return Redirect::to('registro')->with('mensaje', $respuesta['mensaje']); } */ }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { if (!Yii::app()->user->isAdmin()) { $this->redirect(array('index')); } $model = new Usuario(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); try { if (isset($_POST['Usuario'])) { $model->attributes = $_POST['Usuario']; $model->id_usuario = Yii::app()->user->id; $model->senha = md5($_POST['Usuario']['senha']); $model->isAdmin = $_POST['Usuario']['isAdmin']; $model->telefone = $_POST['Usuario']['telefone']; if ($_POST['Usuario']['senha'] != $_POST['Usuario']['senha2']) { throw new Exception("As senha digitadas não são iguais"); } if (!$this->checarEmail($model->email)) { throw new Exception("Este email já está cadastrado. Por favor informe um email diferente"); } if ($model->save()) { $this->setFlashMessage('success', "Usuário cadastrado com uscesso"); $this->redirect(array('view', 'id' => $model->idUsuario)); } } } catch (Exception $e) { $this->setFlashMessage("error", $e->getMessage()); $this->redirect(array('create')); } $this->render('create', array('model' => $model)); }
public function store() { $post = Input::all(); if (Usuario::find($post['ni'])) { $model = Usuario::find($post['ni']); } else { $model = new Usuario(); } if (isset($post['senha']) && $post['senha'] !== '') { $senha = md5($post['senha']); } else { $senha = md5(123); } $validator = $model->validate(Input::all()); if (!$validator) { return Redirect::to('usuario/create')->withInput($post)->withErrors($model->errors); } else { $model->ni = $post['ni']; $model->nome = $post['nome']; $model->senha = $senha; $model->acesso = $post['acesso']; $id = $model->ni; if ($model->save()) { Session::flash('success', 'Usuário cadastrado com sucesso!'); return Redirect::to('/usuario/' . $id); } } }
public function postAlta() { $input = Input::All(); $validacion = Validator::make(Input::All(), array('codigo' => 'required|unique:agente,codigo', 'razon-social' => 'required', 'nombre-fantasia' => 'required', 'domicilio' => 'required', 'password' => 'required', 'repassword' => 'required')); if (!$validacion->fails()) { $agente = new Agente(); $agente->estado_logico = $input['estado']; $agente->codigo = $input['codigo']; $agente->razon_social = $input['razon-social']; $agente->nombre_fantasia = $input['nombre-fantasia']; $agente->domicilio = $input['domicilio']; $agente->id_localidad = $input['localidad']; $agente->codigo_postal = '1678'; $agente->save(); $usuario = new Usuario(); $usuario->id_usuario = $agente->id; $usuario->email = $input['email']; $usuario->password = $input['password']; $usuario->id_tipo = 1; $usuario->save(); return Redirect::to('panel_administrador/abm_agente'); } else { return Redirect::back()->withErrors($validacion); } }
public function actionProfesores() { if ($_SESSION['perfil'] == 1) { $params['active'] = 2; $params['vista'] = '_profesores'; $params['modelProfesor'] = new Profesor(); if (isset($_POST['Profesor'])) { try { $usuario = new Usuario(); $usuario->perfil = 2; $usuario->nombreUsuario = $_POST['Profesor']['identificacion']; $usuario->password = md5($_POST['Profesor']['identificacion']); if ($usuario->save()) { $profesor = new Profesor(); $profesor->attributes = $_POST['Profesor']; $profesor->idUsuario = $usuario->idUsuario; if (!$profesor->save()) { Yii::app()->user->setFlash('alert alert-danger', "Profesor no fue creado"); } else { Yii::app()->user->setFlash('alert alert-success', "Profesor fue creado con éxito"); } } else { Yii::app()->user->setFlash('alert alert-danger', "Usuario no fue creado"); } } catch (Exception $e) { Yii::app()->user->setFlash('alert alert-danger', "Usuario no fue creado"); } } $params['profesores'] = Profesor::model()->findAll(); } else { $params['active'] = 0; $params['vista'] = "_sinPermisos"; } $this->render('panel', array('params' => $params)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { if (isset($_POST['nombre'])) { echo $_POST['nombre']; echo '<br>'; echo $_POST['apellidos']; echo '<br>'; echo $_POST['cedula']; echo '<br>'; echo $_POST['correo']; echo '<br>'; echo $_POST['telefono']; echo '<br>'; echo $_POST['usuario']; echo '<br>'; echo $_POST['contrasenna']; echo '<br>'; $usuario = new Usuario(); $usuario->nombre = $_POST['nombre']; $usuario->apellidos = $_POST['apellidos']; $usuario->cedula = $_POST['cedula']; $usuario->correo_electronico = $_POST['correo']; $usuario->telefono = $_POST['telefono']; $usuario->login = $_POST['usuario']; $usuario->password = $_POST['contrasenna']; $usuario->foto = "uno.png"; $usuario->estado_cuenta = 1; $usuario->save(); // $this->render('admin'); } else { $this->render('create'); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $todo = Input::all(); $reglas = array('nick' => 'required|unique:usuarios,nick|alpha_num', 'password' => 'required|alpha_num', 'repassword' => 'required|same:password', 'cargo' => 'required|alpha', 'nombre' => 'required|alpha', 'apellidoPaterno' => 'required|alpha', 'apellidoMaterno' => 'required|alpha', 'ci' => 'required|numeric|digits_between:7,8', 'telefono' => 'required|numeric', 'direccion' => 'required'); $validator = Validator::make($todo, $reglas); if ($validator->fails()) { return Redirect::back()->withErrors($validator); } else { $usuario = new Usuario(); $usuario->nick = Input::get('nick'); $usuario->password = Hash::make(Input::get('password')); $usuario->cargo = Input::get('cargo'); $usuario->save(); $persona = new Persona(); $persona->nombre = Input::get('nombre'); $persona->apellidoPaterno = Input::get('apellidoPaterno'); $persona->apellidoMaterno = Input::get('apellidoMaterno'); $persona->ci = Input::get('ci'); $persona->telefono = Input::get('telefono'); $persona->direccion = Input::get('direccion'); $persona->usuario_id = $usuario->id; $persona->save(); if ($usuario->cargo == "administrador") { $admin = new Administradore(); $admin->usuario_id = $usuario->id; $admin->save(); } return Redirect::route('usuario.show', array($usuario->id)); } }
public function actionRegistro() { $modelAlumnos = new Alumno(); if (isset($_POST['Alumno'])) { try { $usuario = new Usuario(); $usuario->perfil = 3; $usuario->nombreUsuario = $_POST['Alumno']['identificacion']; $usuario->password = md5($_POST['Alumno']['identificacion']); if ($usuario->save()) { $alumno = new Alumno(); $alumno->attributes = $_POST['Alumno']; $alumno->idUsuario = $usuario->idUsuario; if (!$alumno->save()) { Yii::app()->user->setFlash('alert alert-danger', "Alumno no fue creado"); } else { Yii::app()->user->setFlash('alert alert-success', "Alumno fue creado con éxito"); $this->redirect(CController::createUrl('/sitio/index')); } } else { Yii::app()->user->setFlash('alert alert-danger', "Alumno no fue creado"); } } catch (Exception $e) { Yii::app()->user->setFlash('alert alert-danger', "Alumno no fue creado"); } } $this->render('registroEstudiantes', array('modelAlumnos' => $modelAlumnos)); }
public function registrar_nuevo($login, $password) { $password = $this->encriptar_password($password); $u = new Usuario(); $u->login = $login; $u->password = $password; return $u->save(); }
public function saveUsuario($data) { $usuario = new Usuario(); foreach ($data as $key => $field) { $usuario->{$key} = $field; } $usuario->save(); return $usuario->id; }
public function saveUser() { $input = Input::all(); $input["senha"] = Hash::make($input["senha"]); $user = new Usuario(); $user->fill($input); $user->save(); return $user; }
public function actionCrearUsuario() { $contenidoFlujo = file_get_contents("php://input"); $objetoUsuario = CJSON::decode($contenidoFlujo, false); $model = new Usuario; $model->nombre = $objetoUsuario->nombre; $model->save(); echo CJSON::encode($model); exit(); }
public function testCreate() { $user = new Usuario(); $comment->setAttributes(array('id' => '50', 'cedula' => 'A', 'nombre' => 'José', 'sexo_id' => 1, 'profesion_id' => 1, 'f_creacion' => '2012-05-08 19:37:02', 'f_cambios' => '2012-05-08 19:37:02'), false); $this->assertTrue($user->save(false)); // verify $user = Usuario::model()->findByPk($user->id); $this->assertTrue($user instanceof Usuario); $this->assertEquals(1, $user->profesion_id); }
public function testEmailDeveSerUnico() { Usuario::model()->deleteAllByAttributes(['email' => '*****@*****.**']); $usuario1 = new Usuario(); $usuario1->setAttributes(['pnome' => 'Fulano', 'snome' => 'de Tal', 'email' => '*****@*****.**', 'senha' => '123456', 'situacao' => Usuario::SIT_ATIVO, 'dt_criacao' => date('Y-m-d H:i:s')], false); $this->assertTrue($usuario1->save(false)); $usuario2 = new Usuario(); $usuario2->setAttributes(['pnome' => 'Ciclano', 'snome' => 'de Tal', 'email' => '*****@*****.**', 'senha' => '123456', 'senha_confirma' => '123456', 'situacao' => Usuario::SIT_ATIVO, 'dt_criacao' => date('Y-m-d H:i:s')], false); $this->assertFalse($usuario2->save()); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Usuario(); if (isset($_POST['Usuario'])) { $model->attributes = $_POST['Usuario']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model, 'oAclTiposUsuarios' => AclTipoUsuario::model()->naoExcluido()->findAll())); }
public function postCreate() { $mensajeError = ''; $validator = Validator::make(['rfc' => Input::get('rfc'), 'nombre' => Input::get('name'), 'paterno' => Input::get('last_name'), 'usuario' => Input::get('username'), 'email' => Input::get('email'), 'password' => Input::get('password')], ['rfc' => 'required|min:13|max:13', 'nombre' => 'required|min:3|max:30', 'paterno' => 'required|min:3', 'usuario' => 'required|unique:usuario', 'email' => 'required|unique:usuario|email', 'password' => 'required|min:6']); if ($validator->fails()) { //verificamos que los campos requeridos no esten vacios, en caso de q si manda el msj de error if ($validator->messages() != '') { $mensajeError .= 'Completa correctamente los campos que se te piden. <br/>'; } //Verificamos que el username sea unico if ($validator->messages()->first('usuario')) { $mensajeError .= 'El nombre de usuario ya existe, elige otro. <br/>'; } //Verificamos que el email sea unico if ($validator->messages()->first('email')) { $mensajeError .= 'El email ya existe, elige otro. <br/>'; } } //Validamos que las contraseñas sean identicas if (Input::get('password') != Input::get('rpassword')) { $mensajeError .= 'Las contraseñas no coinciden'; } //Si la variable mensaje es diferente a vacio mandamos los msjs if ($mensajeError != '') { Session::flash('messageDanger', $mensajeError); return Redirect::to('/'); } //si todo es correcto guardamos //insertamos los datos a la tabla users si todo esta correcto $user = new Usuario(); $user->id = Input::get('id'); $user->rol_id = Input::get('level'); $user->usuario = Input::get('username'); $password = Input::get('password'); $user->password = Hash::make($password); $user->email = Input::get('email'); $user->save(); //insertamos en la tabla clientes $cliente = new Cliente(); $cliente->usuario()->associate($cliente); $cliente->rfc = Input::get('rfc'); $cliente->usuario_id = $user['id']; $cliente->nivel_descuento_id = "1"; $cliente->nombre_cliente = Input::get('name'); $cliente->paterno = Input::get('last_name'); $cliente->materno = Input::get('materno'); $cliente->nombre_comercial = Input::get('comercial'); $cliente->razon_social = Input::get('social'); $cliente->numero_cliente = date('Y') . date('m') . date("d") . date('G') . date('i') . date('s') . $user->id; $cliente->save(); Session::flash('messageOK', ' Usuario creado exitosamente '); //redirigimos a usurios return Redirect::to('/'); }
public function save() { try { $model = new Usuario($this->data->id); $model->setData($this->data); $model->save(); $go = '>auth/usuario/formObject/' . $model->getId(); $this->renderPrompt('information', 'OK', $go); } catch (EControllerException $e) { $this->renderPrompt('error', $e->getMessage()); } }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aUsuario !== null) { if ($this->aUsuario->isModified() || $this->aUsuario->isNew()) { $affectedRows += $this->aUsuario->save($con); } $this->setUsuario($this->aUsuario); } if ($this->aProveedor !== null) { if ($this->aProveedor->isModified() || $this->aProveedor->isNew()) { $affectedRows += $this->aProveedor->save($con); } $this->setProveedor($this->aProveedor); } if ($this->isNew() || $this->isModified()) { // persist changes if ($this->isNew()) { $this->doInsert($con); } else { $this->doUpdate($con); } $affectedRows += 1; $this->resetModified(); } if ($this->detallePedidoProveedorsScheduledForDeletion !== null) { if (!$this->detallePedidoProveedorsScheduledForDeletion->isEmpty()) { foreach ($this->detallePedidoProveedorsScheduledForDeletion as $detallePedidoProveedor) { // need to save related object because we set the relation to null $detallePedidoProveedor->save($con); } $this->detallePedidoProveedorsScheduledForDeletion = null; } } if ($this->collDetallePedidoProveedors !== null) { foreach ($this->collDetallePedidoProveedors as $referrerFK) { if (!$referrerFK->isDeleted()) { $affectedRows += $referrerFK->save($con); } } } $this->alreadyInSave = false; } return $affectedRows; }
/** * Performs the work of inserting or updating the row in the database. * * If the object is new, it inserts it; otherwise an update is performed. * All related objects are also updated in this method. * * @param PropelPDO $con * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. * @throws PropelException * @see save() */ protected function doSave(PropelPDO $con) { $affectedRows = 0; // initialize var to track total num of affected rows if (!$this->alreadyInSave) { $this->alreadyInSave = true; // We call the save method on the following object(s) if they // were passed to this object by their coresponding set // method. This object relates to these object(s) by a // foreign key reference. if ($this->aEmpresa !== null) { if ($this->aEmpresa->isModified() || $this->aEmpresa->isNew()) { $affectedRows += $this->aEmpresa->save($con); } $this->setEmpresa($this->aEmpresa); } if ($this->aTabla !== null) { if ($this->aTabla->isModified() || $this->aTabla->isNew()) { $affectedRows += $this->aTabla->save($con); } $this->setTabla($this->aTabla); } if ($this->aUsuario !== null) { if ($this->aUsuario->isModified() || $this->aUsuario->isNew()) { $affectedRows += $this->aUsuario->save($con); } $this->setUsuario($this->aUsuario); } if ($this->isNew()) { $this->modifiedColumns[] = AlcancePeer::ID_ALCANCE; } // If this object has been modified, then save it to the database. if ($this->isModified()) { if ($this->isNew()) { $pk = AlcancePeer::doInsert($this, $con); $affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which // should always be true here (even though technically // BasePeer::doInsert() can insert multiple rows). $this->setIdAlcance($pk); //[IMV] update autoincrement primary key $this->setNew(false); } else { $affectedRows += AlcancePeer::doUpdate($this, $con); } $this->resetModified(); // [HL] After being saved an object is no longer 'modified' } $this->alreadyInSave = false; } return $affectedRows; }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Usuario(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Usuario'])) { $model->attributes = $_POST['Usuario']; if ($model->save()) { $this->redirect(Yii::app()->request->baseUrl . '/site/login'); } } $this->render('create', array('model' => $model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Usuario(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Usuario'])) { $model->attributes = $_POST['Usuario']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function crear() { if (isset($_POST["nombre"])) { //Creamos un usuario $usuario = new Usuario(); $usuario->setNombre($_POST["nombre"]); $usuario->setApellido($_POST["apellido"]); $usuario->setEmail($_POST["email"]); $usuario->setPassword(sha1($_POST["password"])); $save = $usuario->save(); } $this->redirect("Usuarios", "index"); }