noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
user.inc.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 if ( !defined ('ALLOWED')) die('Forbidden');
00022 /*!\file
00023  *
00024  *
00025  * \brief user managemnt, included from admin_repo,
00026  * action=user_mgt
00027  *
00028  */
00029 require_once 'class_sort_table.php';
00030 echo '<div class="content" style="width:80%;margin-left:10%">';
00031 /******************************************************/
00032 // Add user
00033 /******************************************************/
00034 if ( isset ($_POST["ADD"]) )
00035 {
00036     $cn=new Database();
00037     $pass5=md5($_POST['PASS']);
00038 
00039     $first_name=Database::escape_string($_POST['FNAME']);
00040     $last_name=Database::escape_string($_POST['LNAME']);
00041     $login=$_POST['LOGIN'];
00042     $login=str_replace("'","",$login);
00043     $login=str_replace('"',"",$login);
00044     $login=str_replace(" ","",$login);
00045     $login=strtolower($login);
00046         if ( trim($login)=="")
00047         {
00048                 alert("Le login ne peut pas être vide");
00049         }
00050         else
00051         {
00052     $Res=$cn->exec_sql("insert into ac_users(use_first_name,use_name,use_login,use_active,use_pass)
00053                        values ($1,$2,$3,1,$4)",
00054                        array($first_name,$last_name,$login,$pass5));
00055 
00056         }
00057 } //SET login
00058 
00059 // View user detail
00060 if ( isset($_REQUEST['det']))
00061 {
00062     require_once("user_detail.inc.php");
00063 
00064     exit();
00065 }
00066 ?>
00067 
00068 <div id="create_user" style="display:none">
00069 <h2>Gestion Utilisateurs</h2>
00070 <TABLE> <TR>
00071 <form action="admin_repo.php?action=user_mgt" method="POST">
00072              <TD><H3>
00073              <?php
00074              echo _("Ajout d'utilisateur");
00075 echo '<H3></TD></TR>';
00076 echo '<TR><TD> First Name </TD><TD><INPUT class="input_text" TYPE="TEXT" NAME="FNAME"></TD>';
00077 echo '<TD> Last Name </TD><TD><INPUT class="input_text"  TYPE="TEXT" NAME="LNAME"></TD></TR>';
00078 echo '<TR><TD> login </TD><TD><INPUT class="input_text"  TYPE="TEXT" NAME="LOGIN"></TD>';
00079 echo '<TD> password </TD><TD> <INPUT class="input_text" TYPE="TEXT" NAME="PASS"></TD></TR>';
00080 echo '</TABLE>';
00081 echo HtmlInput::submit("ADD",'Créer Utilisateur');
00082 echo HtmlInput::button_action("Fermer", "$('create_user').style.display='none';$('cu').style.display='block'");
00083 
00084 
00085 ?>
00086 </FORM>
00087 </div>
00088 
00089 <?php
00090 echo '<p>';
00091 echo HtmlInput::button_action("Ajout utilisateur", "$('create_user').show();$('cu').hide()","cu");
00092 echo '</p>';
00093 // Show all the existing user on 7 columns
00094 $repo=new Dossier(0);
00095 /******************************************************/
00096 // Detail of a user
00097 /******************************************************/
00098 
00099 
00100 
00101 $compteur=0;
00102 $header=new Sort_Table();
00103 $url=basename($_SERVER['PHP_SELF'])."?action=".$_REQUEST['action'];
00104 $header->add("Login", $url," order by use_login asc", "order by use_login desc","la", "ld");
00105 $header->add("Nom", $url," order by use_name asc,use_first_name asc", "order by use_name desc,use_first_name desc","na", "nd");
00106 $header->add('Dossier',$url,' order by ag_dossier asc','order by ag_dossier desc',
00107         'da','dd');
00108 $header->add("Actif", $url," order by use_active asc", "order by  use_active desc","aa", "ad");
00109 $ord=(isset($_REQUEST['ord']))?$_REQUEST['ord']:'la';
00110 $sql=$header->get_sql_order($ord);
00111 
00112 $a_user=$repo->get_user_folder($sql);
00113 
00114 if ( !empty ($a_user) )
00115 {
00116         echo '<span style="display:block">';
00117         echo _('Filtre').HtmlInput::infobulle(22);
00118         echo HtmlInput::filter_table("user", "0,1,2,5","1");
00119         echo '</span>';
00120     echo '<table id="user" class="result">';
00121     echo '<tr>';
00122     echo '<th>'.$header->get_header(0).'</th>';
00123     echo '<th>'.$header->get_header(1).'</th>';
00124     echo th("Prénom");
00125     echo '<th>'.$header->get_header(3).'</th>';
00126         echo "<th>Type</th>";
00127     echo '<th>'.$header->get_header(2).'</th>';
00128     echo '</tr>';
00129 
00130     foreach ( $a_user as $r_user)
00131     {
00132         $compteur++;
00133         $class=($compteur%2==0)?"odd":"even";
00134 
00135         echo "<tr class=\"$class\">";
00136         if ( $r_user['use_active'] == 0 )
00137         {
00138             $Active="non actif";
00139         }
00140         else
00141         {
00142             $Active="Actif";
00143         }
00144         $det_url=$url."&det&use_id=".$r_user['use_id'];
00145         echo "<td>";
00146         echo HtmlInput::anchor($r_user['use_login'],$det_url);
00147         echo "</td>";
00148 
00149         echo td($r_user['use_name']);
00150         echo td($r_user['use_first_name']);
00151         echo td($Active);
00152                 $type=($r_user['use_admin']==1)?"Administrateur":"Utilisateur";
00153                 echo "<td>".$type."</td>";
00154                 echo td($r_user['ag_dossier']);
00155         echo '</tr>';
00156     }// foreach
00157     echo '</table>';
00158 } // $cn != null
00159 ?>
00160 
00161 </div>
 All Data Structures Namespaces Files Functions Variables Enumerations