<?php setcookie("login", $_COOKIE["login"] , time()+3600, "/", "deim.etse.urv.es", 1 ); ?>
<?php setcookie("sessio", $_COOKIE["sessio"] , time()+3600, "/", "deim.etse.urv.es", 1 ); ?>
<html>
  <head>
    <link rel="stylesheet" href="../estils/hoja.css" type="text/css">
    <title>Modificar usuari</title>
  </head>

  <body leftmargin="0" topmargin="0" bgcolor="#8F0000">
    <table border="0" width="100%" height="100%" cellpadding="0" cellspacing="0">
      <tr>
        <!-- Menú dret -->
        <td align="left" valign="top" width="100" bgcolor="#4F0000">
          <?php include("../menu.inc") ?>
        </td>

        <!-- Capçalera -->
        <td align="left" valign="top" width="100%" class="centered">
        <h2>Departament d'Enginyeria Informàtica i Matemàtiques</h2>
        <img src="images/separador.gif">
        <br><br>
        <div align="left"><blockquote>

        <!-- Començament del cos -->
        <?php 
              require("../private/connect.inc");
              require("../private/ident.inc");
              require("../private/func-admin.inc");
              ident();
              autoritzar($_COOKIE["login"], "usuaris");
              $link=Conectar();
              $login=addslashes($_POST["login"]);
              $result=mysql_query("SELECT * FROM usuaris WHERE 
                login LIKE '$login'",$link);
              $row = mysql_fetch_array($result);
              $password = $row["password"];
              $novetats = $row["novetats"];
              $personal = $row["personal"];
              $personal_propi = $row["personal_propi"];
              $tesis_total = $row["tesis_total"];
              $tesis_propies = $row["tesis_propies"];
              $deiminaris = $row["deiminaris"];
              $usuaris = $row["usuaris"];
              $cercador = $row["cercador"];
              $id = nom($row["id"]);
              mysql_free_result($result);
        ?>
        <h2>Administració Usuaris: Modificar</h2>
        <form action="modificardb.php" method="post">
          <input name="oldlogin" type="hidden"
          <?php echo "value=\"" . $login ."\""; ?>
          >
          <b>Login:</b><br>
          <input name="login" size="10" maxlength="10" type="text"
          <?php
            echo "value=\"" . $login . "\"";
          ?>
          >
          <?php
            // No modificar el nostre password per aqui, obliguem a utilitzar el link
            // directe de canvi de password
            if ($_COOKIE["login"] != $login) {
              echo "<br><br>
                <b>Nou Password:</b> <i>Deixar en blanc si no es vol canviar</i><br>
                <input name=\"password\" size=\"16\" maxlength=\"16\" type=\"password\"><br><br>
                <b>Validació nou password:</b><br>
                <input name=\"password2\" size=\"16\" maxlength=\"16\" type=\"password\">";
            } else {
              echo "<br><br><i>Per modificar el password utilitzar el link del menu
              d'administració</i>";
            }
          ?>
          <br><br>
          <select name="id">
          <?php
	    $link=Conectar();
            $result=mysql_query("SELECT nom FROM personal ORDER BY nom");
            while($row = mysql_fetch_array($result)){
              echo "<option ";
              if ($id == $row["nom"]) {
                echo " selected ";
              }
              echo ">" . $row["nom"] . "</option>";
            }
            mysql_free_result($result);
          ?>
          </select>
          <br><br>
          <b>Privilegis per afegir/modificar/esborrar:</b><br>
          <input type="checkbox" name="novetats" value="true"
          <?php
            if ($novetats == "true"){
              echo " checked ";
            }
          ?>
          >Novetats/Notícies i links ràpids</input><br>
          <input type="checkbox" name="personal" value="true"
          <?php
            if ($personal == "true"){
              echo " checked ";
            }
          ?>
          >Personal (totes)</input><br>
          <input type="checkbox" name="personal_propi" value="true"
          <?php
            if ($personal_propi == "true"){
              echo " checked ";
            }
          ?>
          >Fitxa personal pròpia</input><br>
          <input type="checkbox" name="tesis_total" value="true"
          <?php
            if ($tesis_total == "true"){
              echo " checked ";
            }
          ?>
          >Totes les Tesis i Categories</input><br>
          <input type="checkbox" name="tesis_propies" value="true"
          <?php
            if ($tesis_propies == "true"){
              echo " checked ";
            }
          ?>
          >Només les seves Tesis</input><br>
          <input type="checkbox" name="deiminaris" value="true"
          <?php
            if ($deiminaris == "true"){
              echo " checked ";
            }
          ?>
          >Deiminaris</input><br>
          <input type="checkbox" name="usuaris" value="true"
          <?php
            if ($usuaris == "true"){
              echo " checked ";
            }
          ?>
          >Usuaris</input><br>
<!--          <input type="checkbox" name="cercador" value="true"
          <?php
/*            if ($cercador == "true"){
              echo " checked ";
            }*/
          ?>
          >Cercador</input><br>-->
	  <br>

          &nbsp;&nbsp;<input type="image" border="0" src="images/modificar.jpg">
        
	</form>
        <input type="image" onClick="history.go(-1)" src="images/tornar.jpg">
        </blockquote></div>
        </td>
        <td align="left" valign="top" width="100">
          <br />
          <br />
          <br />
          <br />
          <a href="../desconectar.php" class="link2"><img src="images/tancar.jpg" border="0"></a>
        </td>
      </tr>
    </table>
  </body>
</html>

