Working on notifications (#595)

This commit is contained in:
Xavier Guimard 2016-05-30 11:32:21 +00:00
parent 12b23f18e6
commit c138514b34

View File

@ -235,42 +235,60 @@ sub getNotifBack {
$self->p->importHandlerDatas($req); $self->p->importHandlerDatas($req);
my $uid = $req->sessionInfo->{ $self->notifField }; my $uid = $req->sessionInfo->{ $self->notifField };
if ( if ( my $notifs = $self->getNotifications($uid) ) {
my $notifs = $self->getNotifications($uid){
#TODO # Get accepted notifications
$req->parseBody;
# Get accepted notifications my ( $refs, $checks );
$req->parseBody; my $prms = $req->params;
my ( $refs, $checks ); foreach ( keys %$prms ) {
my $prms = $req->params; my $v = $prms ($_);
foreach ( keys %$prms ) { if (s/^reference//) {
my $v = $prms ($_); $refs->{$_} = $v;
if (s/^reference//) { }
$refs->{$_} = $v; elsif ( s/^check// and /^(\d+x\d+)x(\d+)$/ ) {
push @{ $checks->{$1} }, $2;
}
}
foreach my $file (values %$notifs) {
my $xml = $self->parser->parse_string($file);
foreach my $notif ($xml->documentElement->getElementsByTagName('notification') ) {
my $condition = $notif->getAttribute('condition');
my $reference = $notif->getAttribute('reference');
if(defined $refs->{$reference}) {
if(defined $condition) {
# Verity that checkboxes have been checked
}
else {
# TODO: Do the job
delete $refs->{$reference};
}
} }
elsif ( s/^check// and /^(\d+x\d+)x(\d+)$/ ) { else {
push @{ $checks->{$1} }, $2; # TODO: launch checkForUnauthUser()
} }
} }
} }
}
# Else uncipher cookie, restore args and launch autoredirect else {
# TODO # TODO: redirect to portal
$self->p->do( $req, [] );
} }
sub getNotifications { # Else uncipher cookie, restore args and launch autoredirect
my ( $self, $uid ) = @_; # TODO
my $forUser = $self->notifObject->get($uid); $self->p->do( $req, [] );
my $forAll = }
$self->notifObject->get( $self->conf->{notificationWildcard} );
if ( $forUser and $forAll ) {
return { %$forUser, %$forAll };
}
else {
return ( $forUser ? $forUser : $forAll );
}
}
1; sub getNotifications {
my ( $self, $uid ) = @_;
my $forUser = $self->notifObject->get($uid);
my $forAll = $self->notifObject->get( $self->conf->{notificationWildcard} );
if ( $forUser and $forAll ) {
return { %$forUser, %$forAll };
}
else {
return ( $forUser ? $forUser : $forAll );
}
}
1;