1 <?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80:
2 -------------------------------------------------------------------------------
3 Ministerio de EconomÃa
5 -------------------------------------------------------------------------------
6 This file is part of meconlib.
8 meconlib is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2 of the License, or (at your option)
13 meconlib is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License; if not,
18 write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 Boston, MA 02111-1307 USA
20 -------------------------------------------------------------------------------
21 Creado: Thu Aug 11 15:17:11 2003
22 Autor: Manuel Nazar <manazar@mecon.gov.ar>
23 -------------------------------------------------------------------------------
24 $Id: Usuario.php 242 2003-08-11 18:02:16Z manazar $
25 -----------------------------------------------------------------------------*/
27 require_once 'DB.php';
29 // +X2C Class 131 :MECON_Usuario
56 var $dsn = 'mysql://intranet:intranet@bal747f.mecon.ar/usuario';
68 function ArmarconDNI($dni) // ~X2C
70 $db = DB::connect($this->dsn);
73 die ($db->getMessage("No pudo conectarse a la base"));
77 $sql = "SELECT login,nombre
80 $result = $db->query($sql);
82 if ($result->NumRows()>0){
83 $row = $result->fetchRow();
87 $this->nombre=$nombre;
90 die ('El dni '.$dni.' no existe, debe loguearse al
91 menos una vez a la intranet.');
101 * @param string $login
106 function ArmarconLOGIN($login) // ~X2C
108 $db = DB::connect($this->dsn);
109 if (DB::isError($db))
111 die ($db->getMessage("No pudo conectarse a la base"));
116 //$login = ereg_replace ("@", "\\\@", $login);
117 $sql = "SELECT dni,nombre
119 where login = '$login'";
121 $result = $db->query($sql);
123 if ($result->NumRows()>0){
124 $row = $result->fetchRow();
128 $this->nombre=$nombre;
132 die ('El usuario '.$login.' no existe, debe loguearse al
133 menos una vez a la intranet.');
139 // +X2C Operation 135
146 function MECON_Usuario($dni = NULL, $login = NULL) // ~X2C
150 $this->ArmarconDNI($dni);
151 $this->buscarUsuarioDNI($dni);
153 if(! is_null($login))
155 $this->ArmarconLOGIN($login);
156 $this->buscarUsuarioDNI($this->getDni());
162 // +X2C Operation 136
169 function Insertar_Usuario($dni = NULL, $login = NULL, $nombre = NULL) // ~X2C
171 if((! is_null($dni)) && (! is_null($login)) && (! is_null($nombre)))
173 $db = DB::connect($this->dsn);
174 if (DB::isError($db))
176 die ($db->getMessage("No pudo conectarse a la base"));
180 $sql = "REPLACE INTO Usuario (login,dni,nombre)
181 values ('$login',$dni,'$nombre')";
182 $result = $db->query($sql);
188 // +X2C Operation 136
193 function getDni() // ~X2C
199 // +X2C Operation 137
204 function getLogin() // ~X2C
210 // +X2C Operation 138
215 function getNombre() // ~X2C
217 return $this->nombre;
222 // +X2C Operation 154
229 function buscarUsuarioDNI($dni) // ~X2C
232 $dsn = 'mysql://intranet:intranet@intranet-db/novedades';
233 $db = DB::connect($dsn);
234 if (DB::isError($db)) die ($db->getMessage("No pudo conectarse a la base"));
235 $sql = "SELECT nombre
237 WHERE nrodoc = $dni";
238 $result = $db->query($sql);
239 if(DB::isError($result)) {
240 die($result->getMessage("query mal hecho"));
242 if($result->numRows() > 0)
244 $row = $result->fetchRow();
246 $this->nombre = $nombre;
250 $dsn = 'mysql://intranet:intranet@intranet-db/Contratados';
251 $db = DB::connect($dsn);
252 if (DB::isError($db)) die ($db->getMessage("No pudo conectarse a la base"));
253 $sql = "SELECT nombre
255 WHERE nrodoc = $dni";
256 $result = $db->query($sql);
257 if(DB::isError($result))
258 die($result->getMessage("query mal hecho"));
259 if($result->numRows() > 0)
261 $row = $result->fetchRow();
263 $this->nombre = $nombre;
272 } // -X2C Class :MECON_Usuario