[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/var/www/se3/annu/ -> peoples_list.php (source)

   1  <?php
   2  
   3  
   4     /**
   5     
   6     * Affiche une liste d'utilisateurs a partir de l'annuaire
   7     * @Version $Id: peoples_list.php 6176 2011-02-27 23:00:23Z dbo $ 
   8     
   9     * @Projet LCS / SambaEdu 
  10     
  11     * @auteurs jLCF jean-luc.chretien@tice.ac-caen.fr
  12     * @auteurs oluve olivier.le_monnier@crdp.ac-caen.fr
  13     * @auteurs wawa  olivier.lecluse@crdp.ac-caen.fr
  14     * @auteurs Equipe Tice academie de Caen
  15  
  16     * @Licence Distribue selon les termes de la licence GPL
  17     
  18     * @note 
  19     */
  20  
  21     /**
  22  
  23     * @Repertoire: annu
  24     * file: peoples_list.php
  25     */
  26  
  27  
  28  
  29  include  "entete.inc.php";
  30  include  "ldap.inc.php";
  31  include  "ihm.inc.php";
  32  
  33  require_once  ("lang.inc.php");
  34  bindtextdomain('se3-annu',"/var/www/se3/locale");
  35  textdomain ('se3-annu');
  36  
  37  
  38  if ((is_admin("Annu_is_admin",$login)=="Y") || (is_admin("Annu_can_read",$login)=="Y") || (is_admin("sovajon_is_admin",$login)=="Y")) {
  39  
  40      $priority_surname=$_POST['priority_surname'];
  41      $fullname=$_POST['fullname'];
  42      $priority_name=$_POST['priority_name'];
  43      $nom=$_POST['nom']; 
  44      $priority_classe=$_POST['priority_classe'];
  45      $classe=$_POST['classe'];
  46  
  47      // Aide
  48      $_SESSION["pageaide"]="Annuaire";
  49  
  50      echo "<h1>".gettext("Annuaire")."</h1>\n";
  51  
  52      // Convertion en utf_8
  53      $nom = utf8_encode($nom);
  54      $fullname = utf8_encode($fullname);
  55  
  56      // Construction du filtre de la branche people
  57      if ($nom && !$fullname) {
  58          // Recherche sur sn
  59              if ($priority_name=="contient") {
  60                    $filter_people="(sn=*$nom*)";
  61              } elseif($priority_name=="commence") {
  62                    $filter_people="(sn=$nom*)";
  63              } else {
  64                    $filter_people="(sn=*$nom)";
  65              }
  66      } elseif ($fullname && !$nom) {
  67          // Recherche sur cn
  68              if ($priority_surname=="contient") {
  69                    $filter_people="(cn=*$fullname*)";
  70              } elseif($priority_surname=="commence") {
  71                    $filter_people="(cn=$fullname*)";
  72              } else {
  73                    $filter_people="(cn=*$fullname)";
  74              }
  75      } elseif ($fullname && $nom) {
  76          // Recherche sur sn ET cn
  77              if ($priority_name=="contient") {
  78                    if ($priority_surname=="contient") {
  79                      $filter_people="(&(sn=*$nom*)(cn=*$fullname*))";
  80                    } elseif($priority_surname=="commence") {
  81                      $filter_people="(&(sn=*$nom*)(cn=$fullname*))";
  82                    } else {
  83                      $filter_people="(&(sn=*$nom*)(cn=*$fullname))";
  84                    }
  85  
  86              } elseif($priority_name=="commence") {
  87                    if ($priority_surname=="contient") {
  88                      $filter_people="(&(sn=$nom*)(cn=*$fullname*))";
  89                    } elseif($priority_surname=="commence") {
  90                      $filter_people="(&(sn=$nom*)(cn=$fullname*))";
  91                    } else {
  92                      $filter_people="(&(sn=$nom*)(cn=*$fullname))";
  93                    }
  94              } else {
  95                    if ($priority_surname=="contient") {
  96                      $filter_people="(&(sn=*$nom)(cn=*$fullname*))";
  97                    } elseif($priority_surname=="commence") {
  98                      $filter_people="(&(sn=*$nom)(cn=$fullname*))";
  99                    } else {
 100                      $filter_people="(&(sn=*$nom)(cn=*$fullname))";
 101                    }
 102              }
 103      }
 104  
 105      // Remplacement de *** ou ** par *
 106      $filter_people = preg_replace("/\*\*\*/","*",$filter_people);
 107      $filter_people = preg_replace("/\*\*/","*",$filter_people);
 108      if ($filter_people && !$classe) {
 109          // recherche dans la branche People
 110          #$TimeStamp_0=microtime();
 111              $users = search_people ($filter_people);
 112              #$TimeStamp_1=microtime();
 113      
 114              // Affichage menu haut de page
 115              aff_trailer("3");
 116              #############
 117              # DEBUG     #
 118              #############
 119              #echo "<u>debug</u> :Temps de recherche = ".duree($TimeStamp_0,$TimeStamp_1)."&nbsp;s<BR>";
 120              #############
 121              # Fin DEBUG #
 122              #############
 123              if (count($users)) {
 124                    if (count($users)==1) {
 125                      echo "<p><STRONG>".count($users)."</STRONG>".gettext(" utilisateur r&#233;pond &#224; ces crit&#232;res de recherche")."</p>\n";
 126                    } else {
 127                      echo "<p><STRONG>".count($users)."</STRONG>".gettext(" utilisateurs r&#233;pondent &#224; ces crit&#232;res de recherche")."</p>\n";
 128                    }
 129  
 130                    echo "<UL>\n";
 131                    for ($loop=0; $loop<count($users);$loop++) {
 132                      echo "<LI><A href=\"people.php?uid=".$users[$loop]["uid"]."\">".$users[$loop]["fullname"]."</A></LI>\n";
 133                    }
 134                    echo "</UL>\n";
 135              } else {
 136                  echo " <STRONG>".gettext("Pas de r&#233;sultats")."</STRONG>".gettext(" correspondant aux crit&#232;res s&#233;lectionn&#233;s.")."<BR>\n";
 137              }
 138  
 139      } elseif ($classe) {
 140                 // Recherche des classes et equipes dans la branche groups de l'annuaire
 141                 if ($priority_classe=="contient") {
 142                     $filter_classe="(cn=Classe_*$classe*)";
 143                 } elseif($priority_classe=="commence") {
 144                  $filter_classe="(cn=Classe_$classe*)";
 145                 } else {
 146                   $filter_classe="(cn=Classe_*$classe)";
 147                 }
 148                 // Remplacement de *** ou ** par *
 149                 $filter_classe = preg_replace("/\*\*\*/","*",$filter_classe);
 150                 $filter_classe = preg_replace("/\*\*/","*",$filter_classe);
 151                 #$TimeStamp_0=microtime();
 152                 $uids = search_uids ($filter_classe);
 153                 $people = search_people_groups ($uids,$filter_people,"group");
 154                 #$TimeStamp_1=microtime();
 155                 // Affichage menu haut de page
 156                 aff_trailer("3");
 157                 #############
 158                 # DEBUG     #
 159                 #############
 160                 # echo "<u>debug</u> :Temps de recherche = ".duree($TimeStamp_0,$TimeStamp_1)."&nbsp;s<BR>";
 161                 #############
 162                 # DEBUG     #
 163                 #############
 164                 if (count($people)) {
 165                  if (count($people)==1) {
 166                         echo "<p><STRONG>".count($people)."</STRONG>".gettext(" utilisateur r&#233;pond &#224; ces crit&#232;res de recherche.")."</p>\n";
 167                   } else {
 168                         echo "<p><STRONG>".count($people)."</STRONG>".gettext(" utilisateurs r&#233;pondent &#224; ces crit&#232;res de recherche.")."</p>\n";
 169                   }
 170                   // affichage des resultats
 171                   for ($loop=0; $loop < count($people); $loop++) {
 172                         if ( $people[$loop]["group"] != $people[$loop-1]["group"]) {
 173                               echo "<U>Classe</U> : ".$people[$loop]["group"]."<BR>\n";
 174                         }
 175  
 176                         if ($people[$loop]["cat"] == "Equipe") {
 177                                 echo "<img src=\"images/gender_teacher.gif\" width=18 height=18 hspace=1 border=0>\n";
 178                         } else {
 179                               if ($people[$loop]["sexe"]=="F") {
 180                                     echo "<img src=\"images/gender_girl.gif\" width=14 height=14 hspace=3 border=0>\n";
 181                               } else {
 182                                     echo "<img src=\"images/gender_boy.gif\" width=14 height=14 hspace=3 border=0>\n";
 183                               }
 184                         }
 185                         echo "<A href=\"people.php?uid=".$people[$loop]["uid"]."\">".$people[$loop]["fullname"]."</A><BR>\n";
 186                   }
 187      
 188                 } else {
 189                     echo " <STRONG>".gettext("Pas de r&#233;sultats")."</STRONG>".gettext(" correspondant aux crit&#232;res s&#233;lectionn&#233;s.")."<BR>
 190                        ".gettext("Retour au")." <A href=\"annu.php\">".gettext("formulaire de recherche")."</A>...<BR>\n";
 191                 }
 192  
 193      } else {
 194                 // Aucun criteres de recherche
 195          echo " <STRONG>".gettext("Pas de r&#233;sultats !")."</STRONG><BR>
 196                 ".gettext("Veuillez compl&#233;ter au moins l'un des trois champs (nom, pr&#233;nom, classe) du")." <A href=\"annu.php\">".gettext("formulaire de recherche")."</A> !<BR>\n";
 197      }
 198  
 199  }
 200  
 201  include ("pdp.inc.php");
 202  ?>


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