Fix deleteNotification web service with DBI backend (#537)

This commit is contained in:
Clément Oudot 2012-09-25 15:09:31 +00:00
parent 0bf0f9579c
commit 290a4ce0e8
2 changed files with 11 additions and 5 deletions

View File

@ -433,7 +433,7 @@ sub deleteNotification {
# Delete the notification (really)
foreach (@data) {
if ( $self->purge($_) ) {
if ( $self->purge( $_, 1 ) ) {
$self->lmLog( "Notification $_ was removed.", 'debug' );
$count++;
}
@ -462,9 +462,10 @@ sub getDone {
return &{ $_[0]->{type} . '::getDone' }(@_);
}
## @method boolean purge(string myref)
## @method boolean purge(string myref, boolean force)
# Purge notification (really delete record). Wrapper for storage module purge()
# @param $myref identifier returned by get or getAll
# @param $force force purge for not deleted session
# @return true if something was deleted
sub purge {
no strict 'refs';

View File

@ -107,23 +107,28 @@ sub delete {
. "WHERE done IS NULL AND uid='$u' AND ref='$r' AND date='$d'" );
}
## @method boolean purge(string myref)
## @method boolean purge(string myref, boolean force)
# Purge notification (really delete record)
# @param $myref identifier returned by get or getAll
# @param $force force purge for not deleted session
# @return true if something was deleted
sub purge {
my ( $self, $myref ) = @_;
my ( $self, $myref, $force ) = @_;
my ( $d, $u, $r );
unless ( ( $d, $u, $r ) = ( $myref =~ /^([^#]+)#(.+?)#(.+)$/ ) ) {
$self->lmLog( "Bad reference $myref", 'warn' );
return 0;
}
my $clause;
$clause = "done IS NOT NULL AND" unless ($force);
$u =~ s/'/''/g;
$r =~ s/'/''/g;
$d =~ s/'/''/g;
return _execute( $self,
"DELETE FROM $self->{dbiTable} "
. "WHERE done IS NOT NULL AND uid='$u' AND ref='$r' AND date='$d'" );
. "WHERE $clause AND uid='$u' AND ref='$r' AND date='$d'" );
}
## @method boolean newNotif(string date, string uid, string ref, string condition, string xml)