0) {
$req = "SELECT * FROM empr $clause ORDER BY empr_cb, empr_prenom, empr_nom ";
$res = @mysql_query($req, $dbh);
while(($empr=mysql_fetch_object($res))) {
$filter = "(uid=$empr->empr_cb)";
$r = ldap_search($conn, LDAP_BASEDN,$filter,$fields,0,0);
$info = ldap_get_entries($conn, $r);
# if empr n'existe pas dans ldap...
$uid=$info[0][uid][0];
if (!$uid){
# cherche prĂȘts
$req = "SELECT COUNT(1) FROM pret,empr WHERE pret.pret_idempr = ".$empr->id_empr;
$rpr = mysql_query($req, $dbh);
$npr = mysql_result($rpr, 0, 0);
# s'il n'y a pas des prĂȘts...
if (!$npr){
$ret .= $empr->id_empr.'|'.$empr->empr_cb.'|'.$empr->empr_nom.'|'.$empr->empr_prenom.';' ;
}
}
}
}
ldap_close($conn);
$fp=fopen("./temp/exldap_users.txt","w");
fwrite($fp,$ret);
fclose($fp);
return $ret;
}
function show_exldap_users($uu,$pag,$npp) {
global $msg;
global $charset;
global $current_module ;
global $form_show_exldap_users;
$auu=explode(';',$uu);
$nuu=count($auu);
if (!$npp) $npp=10;
$npag = ceil($nuu/$npp);
$nextp = $pag+1;
$precp = $pag-1;
$npp_ctrl="
";
if($precp > 0){
$nav_barL = "";
}else{
$nav_barL = "";
}
$nav_barC = "$pag/$npag";
if($nextp<=$npag) {
$nav_barR .= "";
}else{
$nav_barR = " ";
}
if(!$pag) $pag=1;
$iniz=($pag-1)*$npp;
$fine=min($nuu,$iniz+$npp);
$r=1;
for ($k=$iniz;$k<$fine;$k++){
$cc=explode('|',$auu[$k]);
if ($cc[0]){
$usr_entry="
|
$cc[1] |
$cc[2] |
$cc[3] | ";
if ($k % 2) $pair_impair = "even"; else $pair_impair = "odd";
$tr_javascript=" onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='$pair_impair'\" onmousedown=\"setCheckboxColumn('id_to_del$r')\" ";
$usr_list .= "
$usr_entry |
";
}
$r++;
}
// $pag++;
$hid_vars="
";
$form_show_exldap_users=str_replace('!!npp_ctrl!!',$npp_ctrl,$form_show_exldap_users);
$form_show_exldap_users=str_replace('!!nav_barL!!',$nav_barL,$form_show_exldap_users);
$form_show_exldap_users=str_replace('!!nav_barC!!',$nav_barC,$form_show_exldap_users);
$form_show_exldap_users=str_replace('!!nav_barR!!',$nav_barR,$form_show_exldap_users);
$form_show_exldap_users=str_replace('!!usr_list!!',$usr_list,$form_show_exldap_users);
$form_show_exldap_users=str_replace('!!hid_vars!!',$hid_vars,$form_show_exldap_users);
print $form_show_exldap_users;
}
function erase_exldap_users($uu){
$auu=explode(';',$uu);
$nuu=count($auu);
$n=0;
foreach ($auu as $u){
$cc=explode('|',$u);
$id=$cc[0];
$res=emprunteur::del_empr($id);
if ($res) ++$n;
}
// print " utenti exldap eliminati: $n su $nuu
";
}
//------------------- main -------------------
$op=$_POST[btsubmit];
switch($action)
{
case 'exldapDEL':
switch($op){
case '=':
//$pag=$_POST['pag'];
$npp=$_POST['npp'];
show_exldap_users($uu,1,$npp);
break;
case '<':
$pag=max(1,$_POST['pag']-1);
$npp=$_POST['npp'];
show_exldap_users($uu,$pag,$npp);
break;
case '>':
$pag=$_POST['pag']+1;
show_exldap_users($uu,$pag,$npp);
break;
case $msg[exldap_elimina]:
$uu=$_POST['uu'];
erase_exldap_users($uu);
$uu=find_exldap_users();
$pag=1;
$npp=10;
show_exldap_users($uu,$pag,$npp);
break;
case $msg[exldap_conserva]:
$xx=$_POST['usrdel'];
$uu=$_POST['uu'];
$pag=$_POST['pag'];
$npp=$_POST['npp'];
foreach ($xx as $dummykey=>$x){
$u="/$x"."[^;]+;/";
$uu=preg_replace($u,'',$uu,1);
}
show_exldap_users($uu,$pag,$npp);
break;
case $msg[exldap_normale]:
$xx=$_POST['usrdel'];
$uu=$_POST['uu'];
$pag=$_POST['pag'];
$npp=$_POST['npp'];
foreach ($xx as $dummykey=>$x){
$u="/$x"."[^;]+;/";
$uu=preg_replace($u,'',$uu,1);
$req = "UPDATE empr SET empr_ldap=0 WHERE id_empr=$x";
$res = mysql_query($req, $dbh);
}
show_exldap_users($uu,$pag,$npp);
break;
default:
$pag=$_POST['pag'];
$npp=$_POST['npp'];
if (!$pag) $pag=1;
show_exldap_users($uu,$pag,$npp);
break;
}
break;
default:
$uu=find_exldap_users();
$pag=$_POST['pag'];
$npp=$_POST['npp'];
if (!$pag) $pag=1;
show_exldap_users($uu,$pag,$npp);
break;
}