} else { throw new OOB_Exception_400("La variable [txt_nombre] no esta definida"); } //descripcion if (isset($_POST['txt_descripcion'])) { $grupo->set('description', $_POST['txt_descripcion']); } else { throw new OOB_Exception_400("La variable [txt_descripcion] no esta definida"); } //estado $grupo->set('status', 1); if (!isset($_POST['usuarios'])) { throw new OOB_Exception_400("La variable [usuarios] no esta definida"); } // tratamos de grabar if ($grupo->store()) { $resultado["success"] = true; //usuarios $miebros = split(",", $_POST['usuarios']); $real_members = array(); if ($usuarios = seguridad_group::listUsersFor($grupo)) { foreach ($usuarios as $u) { $real_members[] = $u->get('user'); } } for ($i = 0; $i < count($real_members); $i++) { if (!in_array($real_members[$i], $miebros)) { $tmpUser = new oob_user($real_members[$i]); $grupo->removeUser($tmpUser); } }
//DESCRIPCION if (isset($_POST['txt_descripcion'])) { $group->set('description', $_POST['txt_descripcion']); } else { throw new OOB_Exception_400("La variable [txt_descripcion] no esta definida"); } //NOMBRE if (isset($_POST['txt_nombre'])) { $group->set('name', $_POST['txt_nombre']); } else { throw new OOB_Exception_400("La variable [txt_nombre] no esta definida"); } //ESTADO $group->set('status', 1); //TRATAMOS DE GRABAR if ($group->store()) { $resultado["success"] = true; $resultado["id"] = $group->id(); } if ($errores = $ari->error->getErrorsfor("seguridad_group")) { $error_codes = array(); $error_codes['INVALID_NAME'] = array("id" => "txt_nombre", "msg" => "El Nombre del Grupo no es válido."); $error_codes['DUPLICATE_GROUP'] = array("id" => "txt_nombre", "msg" => "El Grupo con ese nombre ya existe"); $error_codes['INVALID_DESCRIPTION'] = array("id" => "txt_descripcion", "msg" => "La descripción es invalida"); foreach ($errores as $error) { $resultado["errors"][] = $error_codes[$error]; } } //RESULTADO $obj_comunication = new OOB_ext_comunication(); $obj_comunication->set_data($resultado);