Notification
system
Since version 0.9.4, Lemonldap::NG can be used to
notify some messages to users: if a user has a message, the message will
be displayed when he will access to the portal. If the message contains
checkboxes, the user has to check all of them else he can not access to
the portal and get his session cookie.
Installation
Activation
You just have to set "notification => 1" in
the portal.
Storage
By default, notifications will be stored in the
same database as configuration :
- if you use "File" system and your "dirName" is set to
/usr/local/lemonldap-ng/conf/, the notifications will be stored in
/usr/local/lemonldap-ng/notifications/
- if you use "DBI" system, the notifications will be stored in the
same database as configuration and in a table called "notifications".
You have to create the table by yourself
CREATE TABLE 'notifications' (
'date' datetime NOT NULL,
'uid' varchar(255) NOT NULL,
'ref' varchar(255) NOT NULL,
'xml' longblob NOT NULL,
'done' datetime default NULL,
PRIMARY KEY ('date','uid','ref')
)
You can change default parameters using the
"notificationStorage" parameter with the same syntax as configStorage.
Example :
notificationStorage => {
type => 'File',
dirName => '/var/lib/lemonldap-ng/notifications/',
},
Using
notification system
Insert new
notifications
New notifications can be insert using SOAP
request (described in the WSDL file generated by buildPortalWSDL tool).
Notification
format
Notifications are XML files containing :
- "<notification>" element(s) :
- required attributes :
- "date" in format YYYY-MM-DD
- "ref" : a reference that can be used later to know what has
been notified and when
- "uid" : the user (it must correspond to the attibute set in
whatToTrace parameter : uid by default)
- sub-elements :
- <text> : paragraph to display : inserted in HTML page
enclosed in <p class="notifText">...</p>)
- <check> : paragraph to display with a checkbox :
inserted in HTML page enclosed in <p
class="notifCheck"><input
type="checkbox/>...</p>
All other elements will be removed including HTML elemants like
<b>
Example :
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
<notification uid="foo.bar" date="2009-01-27" reference="ABC">
<text> You have been granted to access to appli-1 </text>
<text> You have been granted to access to appli-2 </text>
<check> I know that I can acces to appli-1 </check>
<check> I know that I can acces to appli-2 </check>
</notification>
</root>
Insertion
example in Perl
#!/usr/bin/perl
use SOAP::Lite;
use utf8;
my $lite = SOAP::Lite
->uri('urn:Lemonldap::NG::Common::CGI::SOAPService')
->proxy('http://auth.example.com/index.pl/notification');
$r = $lite->newNotification('<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
<notification uid="foo.bar" date="2009-01-27" reference="ABC">
<text> You have been granted to access to appli-1 </text>
<text> You have been granted to access to appli-2 </text>
<check> I know that I can acces to appli-1 </check>
<check> I know that I can acces to appli-2 </check>
</notification>
</root>');
if ( $r->fault ) {
print STDERR "SOAP Error: " . $r->fault->{faultstring};
}
else {
my $res = $r->result();
print "$res notification(s) have been inserted";
}
Test
notification
You've simply to insert a notification and
connect to the portal using the same UID. You will be prompted.