[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/var/www/se3/fond_ecran/ -> search_login.php (source)

   1  <?php
   2  
   3  
   4  /**
   5  
   6  * Interface de gestion des acl
   7  * @Version $Id: search_login.php 6259 2011-03-16 18:31:24Z crob $ 
   8  
   9  
  10  * @Projet LCS / SambaEdu 
  11  
  12  * @auteurs  Equipe Tice academie de Caen
  13  
  14  * @Licence Distribue selon les termes de la licence GPL
  15  
  16  * @note 
  17  
  18  */
  19  
  20  /**
  21  
  22  * @Repertoire: acls
  23  * file: searchacls.php
  24  
  25  */    
  26  
  27  
  28  include  "entete.inc.php";
  29  include  "ldap.inc.php";
  30  include  "ihm.inc.php";
  31  
  32  //include "crob_ldap_functions.php";
  33  
  34  require_once ("lang.inc.php");
  35  bindtextdomain('se3-fond',"/var/www/se3/locale");
  36  textdomain ('se3-fond');
  37  
  38  //aide
  39  $_SESSION["pageaide"]="Le_module_Syst%C3%A8me_fond_d\'%C3%A9cran";
  40  
  41  //aff_trailer ("2");
  42  
  43  $is_posted=isset($_POST['is_posted']) ? $_POST['is_posted'] : (isset($_GET['is_posted']) ? $_GET['is_posted'] : NULL);
  44  
  45  function affiche_sur_N_colonnes($tableau,$nb_col=3) {
  46      $retour="";
  47  
  48      $nb_lignes_par_colonne=round(count($tableau)/$nb_col);
  49  
  50      $retour.="<table width='100%'>\n";
  51      $retour.="<tr valign='top' align='center'>\n";
  52  
  53      $cpt = 0;
  54  
  55      $retour.="<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>\n";
  56      $retour.="<td align='left'>\n";
  57  
  58      for($loop=0;$loop<count($tableau);$loop++) {
  59  
  60          //affichage $nb_col colonnes
  61          if(($cpt>0)&&(round($cpt/$nb_lignes_par_colonne)==$cpt/$nb_lignes_par_colonne)){
  62              $retour.="</td>\n";
  63              $retour.="<td align='left'>\n";
  64          }
  65  
  66          $retour.=$tableau[$loop];
  67          $retour.="<br />\n";
  68          $cpt++;
  69      }
  70  
  71      $retour.="</td>\n";
  72      $retour.="</tr>\n";
  73      $retour.="</table>\n";
  74  
  75      return $retour;
  76  }
  77  
  78  //if(!isset($_POST['is_posted'])) {
  79  if(!isset($is_posted)) {
  80      $titre=gettext("Rechercher un utilisateur");
  81  
  82      $texte ="<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n";
  83      $texte .= "<table>\n";
  84      $texte .= "<tbody>\n";
  85      $texte .= "<tr>\n";
  86      $texte .= "<td>".gettext("Nom complet :")."</td>\n";
  87      $texte .= "<td>\n";
  88      $texte .= "<select name=\"priority_surname\">\n";
  89      $texte .= "<option value=\"contient\">".gettext("contient")."</option>\n";
  90      $texte .= "<option value=\"commence\">".gettext("commence par")."</option>\n";
  91      $texte .= "<option value=\"finit\">".gettext("finit par")."</option>\n";
  92      $texte .= "</select>\n";
  93      $texte .= "</td>\n";
  94      $texte .= "<td><input type=\"text\" name=\"fullname\"></td>\n";
  95      $texte .= "</tr>\n";
  96      $texte .= "<tr>\n";
  97      $texte .= "<td>".gettext("Nom :")."</td>\n";
  98      $texte .= "<td>\n";
  99      $texte .= "<select name=\"priority_name\">\n";
 100      $texte .= "<option value=\"contient\">".gettext("contient")."</option>\n";
 101      $texte .= "<option value=\"commence\">".gettext("commence par")."</option>\n";
 102      $texte .= "<option value=\"finit\">".gettext("finit par")."</option>\n";
 103      $texte .= "</select>\n";
 104      $texte .= "</td>\n";
 105      $texte .= "<td><input type=\"text\" name=\"nom\"></td>\n";
 106      $texte .= "</tr>\n";
 107      $texte .= "<tr>\n";
 108      $texte .= "</tbody>\n";
 109      $texte .= "</table>\n";
 110      $texte .= "<input type=\"hidden\" name=\"is_posted\" value=\"1\" />\n";
 111      $texte .= "<div align=center><input type=\"submit\" Value=\"".gettext("Lancer la requ&#234;te")."\"></div>";
 112      $texte .= "</form>\n";
 113      mktable($titre,$texte);
 114  
 115      // Recherche d'un groupe (classe, Equipe, Cours ...)
 116      $titre = gettext("Rechercher un groupe (classe, &#233;quipe, cours ...)")."</h2>\n";
 117  
 118      $texte = "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n";
 119      $texte .= "<table>\n";
 120      $texte .= "<tbody>\n";
 121      $texte .= "<tr>\n";
 122      $texte .= "<td>".gettext("Groupe :")."</td>\n";
 123      $texte .= "<td>\n";
 124      $texte .= "<select name=\"priority_group\">\n";
 125      $texte .= "<option value=\"contient\">".gettext("contient")."</option>\n";
 126      $texte .= "<option value=\"commence\">".gettext("commence par")."</option>\n";
 127      $texte .= "<option value=\"finit\">".gettext("finit par")."</option>\n";
 128      $texte .= "</select>\n";
 129      $texte .= "</td>\n";
 130      $texte .= "<td><input type=\"text\" name=\"group\"></td>\n";
 131      $texte .= "</tr>\n";
 132      $texte .= "</tbody>\n";
 133      $texte .= "</table>\n";
 134      $texte .= "<input type=\"hidden\" name=\"is_posted\" value=\"2\" />\n";
 135      $texte .= "<div align=center><input type=\"submit\" Value=\"".gettext("Lancer la requ&#234;te")."\"></div>\n";
 136      $texte .= "</form>\n";
 137      echo "<br />";
 138      mktable($titre,$texte);
 139  
 140      echo "<br /><br /><br /><br /><br /><center><B><a href=\"#\" onClick=\"window.close ();\">".gettext("Fermer la fen&#234;tre")."</a></B></center>";
 141      
 142      include ("pdp.inc.php");
 143      
 144      die();
 145  }
 146  //elseif($_POST['is_posted']=='1') {
 147  elseif($is_posted=='1') {
 148  
 149      // Recuperation des variables
 150      $nom=isset($_POST['nom']) ? $_POST['nom'] : '';
 151      $classe=isset($_POST['classe']) ? $_POST['classe'] : '';
 152      $fullname=isset($_POST['fullname']) ? $_POST['fullname'] : '';
 153      $priority_name=isset($_POST['priority_name']) ? $_POST['priority_name'] : '';
 154      $priority_surname=isset($_POST['priority_surname']) ? $_POST['priority_surname'] : '';
 155      $priority_classe=isset($_POST['priority_classe']) ? $_POST['priority_classe'] : '';
 156      
 157      
 158      // Convertion en utf_8
 159      $nom = utf8_encode($nom);
 160      $fullname = utf8_encode($fullname);
 161      // Construction du filtre de la branche people
 162      if ($nom!='' && $fullname=='') {
 163          // Recherche sur sn
 164          if ($priority_name=="contient") {
 165              $filter_people="(sn=*$nom*)";
 166          } elseif($priority_name=="commence") {
 167              $filter_people="(sn=$nom*)";
 168          } else {
 169              $filter_people="(sn=*$nom)";
 170          }
 171      } elseif ($fullname!='' && $nom=='') {
 172          // Recherche sur cn
 173          if ($priority_surname=="contient") {
 174              $filter_people="(cn=*$fullname*)";
 175          } elseif($priority_surname=="commence") {
 176              $filter_people="(cn=$fullname*)";
 177          } else {
 178              $filter_people="(cn=*$fullname)";
 179          }
 180      } elseif ($fullname!='' && $nom!='') {
 181          // Recherche sur sn ET cn
 182          if ($priority_name=="contient") {
 183              if ($priority_surname=="contient") {
 184                  $filter_people="(&(sn=*$nom*)(cn=*$fullname*))";
 185              } elseif($priority_surname=="commence") {
 186                  $filter_people="(&(sn=*$nom*)(cn=$fullname*))";
 187              } else {
 188                  $filter_people="(&(sn=*$nom*)(cn=*$fullname))";
 189              }
 190  
 191          } elseif($priority_name=="commence") {
 192              if ($priority_surname=="contient") {
 193                  $filter_people="(&(sn=$nom*)(cn=*$fullname*))";
 194              } elseif($priority_surname=="commence") {
 195                  $filter_people="(&(sn=$nom*)(cn=$fullname*))";
 196              } else {
 197                  $filter_people="(&(sn=$nom*)(cn=*$fullname))";
 198              }
 199          } else {
 200              if ($priority_surname=="contient") {
 201                  $filter_people="(&(sn=*$nom)(cn=*$fullname*))";
 202              } elseif($priority_surname=="commence") {
 203                  $filter_people="(&(sn=*$nom)(cn=$fullname*))";
 204              } else {
 205                  $filter_people="(&(sn=*$nom)(cn=*$fullname))";
 206              }
 207          }
 208      }
 209      
 210      echo "<br /><br /><br /><center><B><a href=\"#\" onClick=\"window.close ();\">".gettext("Fermer la fen&#234;tre")."</a></B></center><br /><br /><br />";
 211      if ($filter_people ) {
 212          // recherche dans la branche People
 213          $users = search_people ($filter_people);
 214          if (count($users)) {
 215              if (count($users)==1) {
 216                  echo "<p><STRONG>".count($users)."</STRONG> ".gettext(" utilisateur r&#233;pond &#224; ces crit&#232;res de recherche")."</p>\n";
 217              } else {
 218                  echo "<p><STRONG>".count($users)."</STRONG> ".gettext("utilisateurs r&#233;pondent &#224; ces crit&#232;res de recherche")."</p>\n";
 219              }
 220  
 221              /*
 222              echo "<UL>\n";
 223              echo "<form><select name=\"liste\" onChange=\"Reporter(this)\">";
 224              echo "<option value=\"\">".gettext("Votre choix ...")."</option>";
 225              for ($loop=0; $loop<count($users);$loop++) {
 226                  echo "<option value=\"".$users[$loop]["uid"]."\">".$users[$loop]["fullname"]."</option>";  
 227              }
 228              
 229              echo "<br /><br /><br /><br /><br /><center><B><a href=\"#\" onClick=\"window.close ();\">".gettext("Fermer la fen&#234;tre")."</a></B></center>";
 230              echo "</form></UL>\n";
 231              */
 232  
 233              $tab=array();
 234              for ($loop=0; $loop<count($users);$loop++) {
 235                  //echo "<a href=\"javascript: update_login('".$users[$loop]["uid"]."')\">".$users[$loop]["fullname"]."</a><br />";
 236                  $tab[]="<a href=\"javascript: update_login('".$users[$loop]["uid"]."')\">".$users[$loop]["fullname"]."</a>";
 237              }
 238              echo affiche_sur_N_colonnes($tab,3);
 239  
 240              echo "<script type='text/javascript'>
 241  	function update_login(login) {
 242          window.opener.document.forms['form1'].elements['cible'].value=login;
 243          window.close ();
 244      }
 245  
 246      window.scrollbars.visible='true';
 247  </script>";
 248          } else {
 249              echo " <STRONG>".gettext("Pas de r&#233;sultats")."</STRONG> ".gettext("correspondant aux crit&#232;res s&#233;lectionn&#233;s.")."<br />\n";
 250          }
 251      } else {
 252          // Aucun critere de recherche
 253          echo " <STRONG>".gettext("Pas de r&#233;sultats !")."</STRONG><br />".gettext("
 254          Veuillez compl&#233;ter au moins l'un des deux champs (nom, pr&#233;nom) du formulaire de recherche !")."<br />\n";
 255      }
 256  }
 257  //elseif($_POST['is_posted']=='2') {
 258  elseif($is_posted=='2') {
 259      $group=isset($_POST['group']) ? $_POST['group'] : "";
 260      $priority_group=isset($_POST['priority_group']) ? $_POST['priority_group'] : "contient";
 261  
 262      if ($group=='') {
 263          $filter = "(cn=*)";
 264      } else {
 265          if ($priority_group == "contient") {
 266              $filter = "(cn=*$group*)";
 267          } elseif ($priority_group == "commence") {
 268              $filter = "(|(cn=Classe_$group*)(cn=Cours_$group*)(cn=Equipe_$group*)(cn=Matiere_$group*)(cn=$group*))";
 269          } else {
 270              $filter = "(|(cn=Classe_*$group)(cn=Cours_*$group)(cn=Equipe_*$group)(cn=Matiere_*$group)(cn=*$group))";
 271          }
 272      }
 273      
 274      $groups=search_groups($filter);
 275      
 276      echo "<br><br><br><center><B><a href=\"#\" onClick=\"window.close ();\">".gettext("Fermer la fen&#234;tre")."</a></B></center><br><br><br>";
 277      
 278      if (count($groups)) {
 279          if (count($groups)==1) {
 280              echo "<p><STRONG>".count($groups)."</STRONG>".gettext(" groupe r&#233;pond &#224; ces crit&#232;res de recherche")."</p>\n";
 281          } else {
 282              echo "<p><STRONG>".count($groups)."</STRONG>".gettext(" groupes r&#233;pondent &#224; ces crit&#232;res de recherche")."</p>\n";
 283          }
 284  
 285          /*
 286          echo "<UL>\n";
 287          echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">\n";
 288          echo "<select name=\"group\">\n";
 289          echo "<option value=\"\">".gettext("Votre choix ...")."</option>";
 290          for ($loop=0; $loop<count($groups);$loop++) {
 291              echo "<option value=\"".$groups[$loop]["cn"]."\">".$groups[$loop]["cn"]."</option>";
 292          }
 293          echo "</form></UL>\n";
 294          */
 295  
 296          $tab=array();
 297          for ($loop=0; $loop<count($groups);$loop++) {
 298              //echo "<a href=\"".$_SERVER['PHP_SELF']."?group=".$groups[$loop]["cn"]."&amp;is_posted=3\">".$groups[$loop]["cn"]."</a><br />";
 299              $tab[]="<a href=\"".$_SERVER['PHP_SELF']."?group=".$groups[$loop]["cn"]."&amp;is_posted=3\">".$groups[$loop]["cn"]."</a>";
 300          }
 301          echo affiche_sur_N_colonnes($tab,3);
 302  
 303          echo "<script type='text/javascript'>
 304      window.scrollbars.visible='true';
 305  </script>";
 306  
 307      } else {
 308          echo "<STRONG>".gettext("Pas de r&#233;sultats")."</STRONG>".gettext(" correspondant aux crit&#232;res s&#233;lectionn&#233;s.")."<BR>";
 309      }
 310      
 311  }
 312  elseif($is_posted=='3') {
 313      $group=isset($_GET['group']) ? $_GET['group'] : "";
 314  
 315      if($group!='') {
 316          $filter="cn=$group";
 317  
 318          $users=search_uids($filter);
 319  
 320          if (count($users)) {
 321              if (count($users)==1) {
 322                  echo "<p><STRONG>".count($users)."</STRONG> ".gettext(" utilisateur r&#233;pond &#224; ces crit&#232;res de recherche")."</p>\n";
 323              } else {
 324                  echo "<p><STRONG>".count($users)."</STRONG> ".gettext("utilisateurs r&#233;pondent &#224; ces crit&#232;res de recherche")."</p>\n";
 325              }
 326  
 327              $tab=array();
 328              for ($loop=0; $loop<count($users);$loop++) {
 329                  $current_user=search_people("uid=".$users[$loop]["uid"]);
 330                  if($current_user) {
 331                      //echo "<a href=\"javascript: update_login('".$users[$loop]["uid"]."')\">".$current_user[0]["fullname"]."</a><br />";
 332                      $tab[]="<a href=\"javascript: update_login('".$users[$loop]["uid"]."')\">".$current_user[0]["fullname"]."</a>";
 333                  }
 334              }
 335              echo affiche_sur_N_colonnes($tab,3);
 336  
 337              echo "<script type='text/javascript'>
 338  	function update_login(login) {
 339          window.opener.document.forms['form1'].elements['cible'].value=login;
 340          window.close ();
 341      }
 342  
 343      window.scrollbars.visible='true';
 344  </script>";
 345          } else {
 346              echo " <STRONG>".gettext("Pas de r&#233;sultats")."</STRONG> ".gettext("correspondant aux crit&#232;res s&#233;lectionn&#233;s.")."<br />\n";
 347          }
 348      }
 349      else {
 350          echo "<STRONG>".gettext("Pas de r&#233;sultats")."</STRONG>".gettext(" correspondant aux crit&#232;res s&#233;lectionn&#233;s.")."<BR>";
 351      }
 352  }
 353  else {
 354      echo " <STRONG>".gettext("Anomalie !")."</STRONG><br />".gettext("Veuillez valider un des deux formulaires de recherche !")."<br />\n";
 355  }
 356  
 357  echo "<p><a href='".$_SERVER['PHP_SELF']."'>".gettext("Effectuer une autre recherche")."</a></p>\n";
 358  
 359  include ("pdp.inc.php");
 360  ?>


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1