Put sondage deletion in a function
This commit is contained in:
parent
c665ece920
commit
f86f2e3d76
@ -87,33 +87,13 @@ while($dsondage = $sondage->FetchNextObject(false)) {
|
|||||||
// On inclut la routine de suppression
|
// On inclut la routine de suppression
|
||||||
$date=date('H:i:s d/m/Y');
|
$date=date('H:i:s d/m/Y');
|
||||||
|
|
||||||
$connect->StartTrans();
|
if ( remove_sondage( $dsondage->id_sondage ) ) {
|
||||||
|
|
||||||
$req = 'DELETE FROM sondage WHERE id_sondage = ' . $connect->Param('id_sondage') ;
|
|
||||||
$sql = $connect->Prepare($req);
|
|
||||||
$connect->Execute($sql, array($dsondage->id_sondage));
|
|
||||||
|
|
||||||
$req = 'DELETE FROM sujet_studs WHERE id_sondage = ' . $connect->Param('id_sondage') ;
|
|
||||||
$sql = $connect->Prepare($req);
|
|
||||||
$connect->Execute($sql, array($dsondage->id_sondage));
|
|
||||||
|
|
||||||
$req = 'DELETE FROM user_studs WHERE id_sondage = ' . $connect->Param('id_sondage') ;
|
|
||||||
$sql = $connect->Prepare($req);
|
|
||||||
$connect->Execute($sql, array($dsondage->id_sondage));
|
|
||||||
|
|
||||||
$req = 'DELETE FROM comments WHERE id_sondage = ' . $connect->Param('id_sondage') ;
|
|
||||||
$sql = $connect->Prepare($req);
|
|
||||||
$connect->Execute($sql, array($dsondage->id_sondage));
|
|
||||||
|
|
||||||
if (! $connect->HasFailedTrans() ) {
|
|
||||||
|
|
||||||
// ecriture des traces dans le fichier de logs
|
// ecriture des traces dans le fichier de logs
|
||||||
error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\n", 3, 'logs_studs.txt');
|
error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\n", 3, 'logs_studs.txt');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$connect->CompleteTrans();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
@ -313,29 +313,9 @@ if (isset($_POST["confirmesuppression"]) || isset($_POST["confirmesuppression_x"
|
|||||||
$nbuser=$user_studs->RecordCount();
|
$nbuser=$user_studs->RecordCount();
|
||||||
$date=date('H:i:s d/m/Y:');
|
$date=date('H:i:s d/m/Y:');
|
||||||
|
|
||||||
$connect->StartTrans();
|
remove_sondage( $numsondage ) ;
|
||||||
|
|
||||||
$req = 'DELETE FROM sondage WHERE id_sondage = ' . $connect->Param('numsondage') ;
|
if ( remove_sondage( $numsondage ) ) {
|
||||||
$sql = $connect->Prepare($req);
|
|
||||||
$connect->Execute($sql, array($numsondage));
|
|
||||||
|
|
||||||
$req = 'DELETE FROM sujet_studs WHERE id_sondage = ' . $connect->Param('numsondage') ;
|
|
||||||
$sql = $connect->Prepare($req);
|
|
||||||
$connect->Execute($sql, array($numsondage));
|
|
||||||
|
|
||||||
$req = 'DELETE FROM user_studs WHERE id_sondage = ' . $connect->Param('numsondage') ;
|
|
||||||
$sql = $connect->Prepare($req);
|
|
||||||
$connect->Execute($sql, array($numsondage));
|
|
||||||
|
|
||||||
$req = 'DELETE FROM comments WHERE id_sondage = ' . $connect->Param('numsondage') ;
|
|
||||||
$sql = $connect->Prepare($req);
|
|
||||||
$connect->Execute($sql, array($numsondage));
|
|
||||||
|
|
||||||
$suppression_OK = ! $connect->HasFailedTrans() ;
|
|
||||||
$connect->CompleteTrans();
|
|
||||||
|
|
||||||
|
|
||||||
if ( $suppression_OK ) {
|
|
||||||
// on ecrit dans le fichier de logs la suppression du sondage
|
// on ecrit dans le fichier de logs la suppression du sondage
|
||||||
error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\n", 3, 'admin/logs_studs.txt');
|
error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\n", 3, 'admin/logs_studs.txt');
|
||||||
|
|
||||||
|
@ -203,6 +203,33 @@ function getUrlSondage($id, $admin = false)
|
|||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function remove_sondage( $numsondage ){
|
||||||
|
|
||||||
|
$connect->StartTrans();
|
||||||
|
|
||||||
|
$req = 'DELETE FROM sondage WHERE id_sondage = ' . $connect->Param('numsondage') ;
|
||||||
|
$sql = $connect->Prepare($req);
|
||||||
|
$connect->Execute($sql, array($numsondage));
|
||||||
|
|
||||||
|
$req = 'DELETE FROM sujet_studs WHERE id_sondage = ' . $connect->Param('numsondage') ;
|
||||||
|
$sql = $connect->Prepare($req);
|
||||||
|
$connect->Execute($sql, array($numsondage));
|
||||||
|
|
||||||
|
$req = 'DELETE FROM user_studs WHERE id_sondage = ' . $connect->Param('numsondage') ;
|
||||||
|
$sql = $connect->Prepare($req);
|
||||||
|
$connect->Execute($sql, array($numsondage));
|
||||||
|
|
||||||
|
$req = 'DELETE FROM comments WHERE id_sondage = ' . $connect->Param('numsondage') ;
|
||||||
|
$sql = $connect->Prepare($req);
|
||||||
|
$connect->Execute($sql, array( $numsondage ));
|
||||||
|
|
||||||
|
$suppression_OK = ! $connect->HasFailedTrans() ;
|
||||||
|
$connect->CompleteTrans();
|
||||||
|
|
||||||
|
return $suppression_OK ;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$connect=connexion_base();
|
$connect=connexion_base();
|
||||||
|
|
||||||
|
@ -49,32 +49,13 @@ $sondage=$connect->Execute("select * from sondage");
|
|||||||
while ($dsondage=$sondage->FetchNextObject(false)) {
|
while ($dsondage=$sondage->FetchNextObject(false)) {
|
||||||
if ($date_courante > strtotime($dsondage->date_fin)) {
|
if ($date_courante > strtotime($dsondage->date_fin)) {
|
||||||
//destruction des données dans la base
|
//destruction des données dans la base
|
||||||
$connect->StartTrans();
|
|
||||||
|
|
||||||
$req = 'DELETE FROM sondage WHERE id_sondage = ' . $connect->Param('id_sondage') ;
|
if ( remove_sondage( $dsondage->id_sondage ) ) {
|
||||||
$sql = $connect->Prepare($req);
|
|
||||||
$connect->Execute($sql, array($dsondage->id_sondage));
|
|
||||||
|
|
||||||
$req = 'DELETE FROM sujet_studs WHERE id_sondage = ' . $connect->Param('id_sondage') ;
|
|
||||||
$sql = $connect->Prepare($req);
|
|
||||||
$connect->Execute($sql, array($dsondage->id_sondage));
|
|
||||||
|
|
||||||
$req = 'DELETE FROM user_studs WHERE id_sondage = ' . $connect->Param('id_sondage') ;
|
|
||||||
$sql = $connect->Prepare($req);
|
|
||||||
$connect->Execute($sql, array($dsondage->id_sondage));
|
|
||||||
|
|
||||||
$req = 'DELETE FROM comments WHERE id_sondage = ' . $connect->Param('id_sondage') ;
|
|
||||||
$sql = $connect->Prepare($req);
|
|
||||||
$connect->Execute($sql, array($dsondage->id_sondage));
|
|
||||||
|
|
||||||
if ( ! $connect->HasFailedTrans() ) {
|
|
||||||
|
|
||||||
// ecriture des traces dans le fichier de logs
|
// ecriture des traces dans le fichier de logs
|
||||||
error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\n", 3, '../admin/logs_studs.txt');
|
error_log($date . " SUPPRESSION: $dsondage->id_sondage\t$dsondage->format\t$dsondage->nom_admin\t$dsondage->mail_admin\n", 3, '../admin/logs_studs.txt');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$connect->CompleteTrans();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user