documentation:1.0:notifications

Notifications 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.

You just have to set "notification" to "activate" in the manager (or notification=1 in lemonldap-ng.ini, section "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.

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 : will be inserted in HTML page enclosed in <p class="notifText">…</p>
      • <check> : paragraph to display with a checkbox : will be inserted in HTML page enclosed in <p class="notifCheck"><input type="checkbox/>…</p>

All other elements will be removed including HTML elements 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\";
}

You've simply to insert a notification and connect to the portal using the same UID. You will be prompted.