empr_cb)";
//Gestion encodage
if (!empty($ldap_encoding_utf8) && $charset != "utf-8") {
$filter = utf8_encode($filter);
} elseif (empty($ldap_encoding_utf8) && $charset == "utf-8") {
$filter = utf8_decode($filter);
}
$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 (!empty($ldap_encoding_utf8) && $charset != "utf-8") {
$uid = utf8_decode($uid);
} elseif (empty($ldap_encoding_utf8) && $charset == "utf-8") {
$uid = utf8_encode($uid);
}
if (empty($uid)) {
# cherche prĂȘts
$req = "SELECT COUNT(1) FROM pret,empr WHERE pret.pret_idempr = $empr->id_empr";
$rpr = pmb_mysql_query($req);
$npr = pmb_mysql_result($rpr, 0, 0);
# s'il n'y a pas des prĂȘts...
if (empty($npr)) {
$ret .= "$empr->id_empr|$empr->empr_cb|$empr->empr_nom|$empr->empr_prenom;";
}
}
}
}
ldap_unbind($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 = pmb_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;
}