verification utilisateur à jour de cotisation
This commit is contained in:
parent
20a7b29d05
commit
956ed5d973
@ -31,7 +31,7 @@ $data = array("displayname"=>array("value"=>"","scope"=>"contacts","verified"=>"
|
|||||||
$doldb = new db("dolibarr");
|
$doldb = new db("dolibarr");
|
||||||
$ncdb = new db("nextcloud");
|
$ncdb = new db("nextcloud");
|
||||||
|
|
||||||
$doldb->query("SELECT login, firstname, lastname, pass_crypted, fk_adherent_type, address, email, phone_perso, phone_mobile, zip, town, fk_user_valid FROM llx_adherent");
|
$doldb->query("SELECT login, firstname, lastname, pass_crypted, fk_adherent_type, address, email, phone_perso, phone_mobile, zip, town, fk_user_valid, datefin FROM llx_adherent");
|
||||||
//print_r ($ncdb);
|
//print_r ($ncdb);
|
||||||
while ($user = $doldb->result->fetch_assoc())
|
while ($user = $doldb->result->fetch_assoc())
|
||||||
{
|
{
|
||||||
@ -42,32 +42,38 @@ while ($user = $doldb->result->fetch_assoc())
|
|||||||
echo "login:" . ($user["login"]) . EOL;
|
echo "login:" . ($user["login"]) . EOL;
|
||||||
if ( $ncdb->result->num_rows != 0 )
|
if ( $ncdb->result->num_rows != 0 )
|
||||||
{
|
{
|
||||||
|
// L'utilisateur existe déjà, on ne le crée pas, mais on vérifie sa validité et si il est à jour de cotisation.
|
||||||
$ncuser = $ncdb->result->fetch_assoc();
|
$ncuser = $ncdb->result->fetch_assoc();
|
||||||
echo "uid:" . $ncuser["uid"] . "existe" . EOL;
|
echo "uid:" . $ncuser["uid"] . "existe" . EOL;
|
||||||
$ncdb->query("SELECT configvalue FROM oc_preferences WHERE userid='" . $user["login"] . "' AND appid='core' AND configkey='enabled'");
|
$ncdb->query("SELECT configvalue FROM oc_preferences WHERE userid='" . $user["login"] . "' AND appid='core' AND configkey='enabled'");
|
||||||
if ( $ncdb->result->num_rows != 0 )
|
if ( $ncdb->result->num_rows != 0 )
|
||||||
{
|
{
|
||||||
|
// le validité de l'utilisateur est définie
|
||||||
$r = $ncdb->result->fetch_assoc();
|
$r = $ncdb->result->fetch_assoc();
|
||||||
$status = $r["configvalue"] ;
|
$status = $r["configvalue"] ;
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
$insert = true;
|
// pas de définition de la validité de l'utilisateur => par défaut utilisateur valide
|
||||||
|
$insert = true; // insertion de la validité dans la table préférence
|
||||||
$status = 1;
|
$status = 1;
|
||||||
}
|
}
|
||||||
if ( $user["fk_user_valid"] != $status )
|
if ( $user["fk_user_valid"] != $status )
|
||||||
{
|
{
|
||||||
echo "\ndifférent\n##############################\n" . $user['fk_user_valid'] . "!=" . $status . "\n";
|
// différence entre nexcloud et dolibarr
|
||||||
if ( $insert )
|
// echo "\ndifférent\n##############################\n" . $user['fk_user_valid'] . "!=" . $status . "\n";
|
||||||
{
|
write_status( $insert, $user["login"], $user["fk_user_valid"] );
|
||||||
$query = "INSERT INTO oc_preferences (userid, appid, configkey, configvalue) VALUES ( '" . $ncuser["uid"] . "', 'core', 'enabled', '" . ($user["fk_user_valid"]==1?"true":"false") . "' ) ";
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
$query = "UPDATE oc_preferences SET configvalue = '" . $user["fk_user_valid"] ."' WHERE userid='" . $user["login"] . "' AND appid='core' AND configkey='enabled'" ;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
$ncdb->query( $query );
|
// vérification si l'utilisateur est à jour de cotisation
|
||||||
echo $query;
|
$datefin = DateTime::createFromFormat("Y-m-d H:i:s", $user['datefin']);
|
||||||
|
$interval = new DateInterval('P0000Y02M00D');
|
||||||
|
$datefin->add($interval);
|
||||||
|
if ( $datefin->getTimestamp() <= mktime() )
|
||||||
|
{
|
||||||
|
echo "write_status( $insert, $user['login'], 0 )";
|
||||||
|
}elseif ( $status == 0 )
|
||||||
|
{
|
||||||
|
// ré active l'utlisateur désactivé à jour de cotisation.
|
||||||
|
echo "write_status( $insert, $user['login'], 1 )";
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
@ -133,4 +139,17 @@ while ($user = $doldb->result->fetch_assoc())
|
|||||||
//if ($flag > 12) exit;
|
//if ($flag > 12) exit;
|
||||||
}
|
}
|
||||||
//$doldb->result->close();
|
//$doldb->result->close();
|
||||||
|
function write_status( $insert, $uid, $status )
|
||||||
|
{
|
||||||
|
if ( $insert )
|
||||||
|
{
|
||||||
|
$query = "INSERT INTO oc_preferences (userid, appid, configkey, configvalue) VALUES ( '" . $uid . "', 'core', 'enabled', '" . ($status==1?"true":"false") . "' ) ";
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
$query = "UPDATE oc_preferences SET configvalue = '" . ($status==1?"true":"false") ."' WHERE userid='" . $uid . "' AND appid='core' AND configkey='enabled'" ;
|
||||||
|
|
||||||
|
}
|
||||||
|
$ncdb->query( $query );
|
||||||
|
echo $query;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
Reference in New Issue
Block a user