Correción de tabla en datos de usuario.
[CLab.git] / contenido / admin.php
blob2db891ae47d1eba5a929ad0f263848fa2dd506af
1 <?
3 function CONTENIDO_admin() {
4 global $session, $database, $form;
6 function displayUsers(){
7 global $database;
8 $q = "SELECT username,nombre,userlevel,email,timestamp FROM ".TBL_USERS." ORDER BY userlevel DESC;";
9 $result = $database->query($q);
10 /* Error occurred, return given name by default */
11 $num_rows = mysql_numrows($result);
12 if(!$result || ($num_rows < 0)){
13 echo "Error displaying info";
14 return;
16 if($num_rows == 0){
17 echo "Database table empty";
18 return;
20 /* Display table contents */
21 echo '<table border="1" cellspacing="0" cellpadding="3">';
22 echo "<tr><td><b>Código</b></td><td><b>Nombre</b></td><td><b>Nivel</b></td><td><b>Email</b></td><td><b>Última actividad</b></td></tr>\n";
23 for($i=0; $i<$num_rows; $i++){
24 $uname = mysql_result($result,$i,"username");
25 $nombre = mysql_result($result,$i,"nombre");
26 $ulevel = mysql_result($result,$i,"userlevel");
27 $email = mysql_result($result,$i,"email");
28 $time = mysql_result($result,$i,"timestamp");
29 //$horarios ='<a href="./?x=hr&amp;forzar='.$uname.'">Ver</a>';
30 $uname = '<a href=./?'._ACC_.'=usuario+info&amp;usr='.$uname.'>'.$uname.'</a>';
31 echo "<tr><td>$uname</td><td>$nombre</td><td>$ulevel</td><td>$email</td><td>$time</td></tr>\n";
33 echo "</table><br>\n";
36 echo '<h2>Centro de Administración</h2><hr />';
37 if($form->num_errors > 0){
38 echo "<font size=\"4\" color=\"#ff0000\">"
39 ."!*** Error con petición, por favor corregir</font><br><br>";
41 echo '<h3>Instructores registrados en el sistema:</h3>';
42 displayUsers();
44 echo '<h3>Establecer permisos a instructor</h3>';
45 echo $form->error("upduser");
47 <form action="include/adminprocess.php" method="POST">
48 <table>
49 <tr>
50 <td>Código:
51 <input type="text" name="upduser" maxlength="30" value="<? echo $form->value("upduser"); ?>"></td>
52 <td>
53 Level:<br>
54 <select name="updlevel">
55 <option value="1">1
56 <option value="9">9
57 </select>
58 </td>
59 <td>
60 <br>
61 <input type="hidden" name="subupdlevel" value="1">
62 <input type="submit" value="Actualizar">
63 </td></tr>
64 </table>
65 </form>
66 <h3>Quitar Instructor</h3>
67 <? echo $form->error("deluser"); ?>
68 <form action="contenido/adminprocess.php" method="POST">
69 <table>
70 <td>Código:
71 <input type="text" name="deluser" maxlength="30" value="<? echo $form->value("deluser"); ?>"></td>
72 <td><input type="hidden" name="subdeluser" value="1"></td>
73 <td><input type="submit" value="Quitar Instructor"></td>
74 </table>
75 </form>
76 <?php