diff --git a/nconnector.php b/nconnector.php index 3fa7028..a18877c 100755 --- a/nconnector.php +++ b/nconnector.php @@ -31,7 +31,7 @@ $data = array("displayname"=>array("value"=>"","scope"=>"contacts","verified"=>" $doldb = new db("dolibarr"); $ncdb = new db("nextcloud"); -$doldb->query("SELECT login, firstname, lastname, pass_crypted, fk_adherent_type, address, email, phone_perso, phone_mobile, zip, town 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 FROM llx_adherent"); //print_r ($ncdb); while ($user = $doldb->result->fetch_assoc()) { @@ -42,6 +42,21 @@ while ($user = $doldb->result->fetch_assoc()) { $ncuser = $ncdb->result->fetch_assoc(); echo "uid:" . $ncuser["uid"] . "existe" . EOL; + $ncdb->query("SELECT uid FROM oc_preferences WHERE user_id='" . $user["login"] . "' AND appid='core' AND configkey='enabled'"); + if ( $ncdb->result->num_rows != 0 ) + { + $r = $ncdb->result->fetch_assoc(); + $status = $r["configkey"] ; + }else + { + $status = 1; + } + if ( $user["fk_user_valid"] != $status ) + { + $query = "UPDATE oc_preferences SET configvalue = '" . $user["fk_user_valid"] ."' WHERE user_id='" . $user["login"] . "' AND appid='core' AND configkey='enabled'" ; + $ncdb->query( $query ); + echo $query; + } }else { //echo $user["login"] . " n'existe pas";