lemonldap-ng/build/lemonldap-ng/doc/4.4-Configure-and-use-notification-system.html
2009-02-17 17:05:02 +00:00

262 lines
8.0 KiB
HTML

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="fr" xml:lang="fr">
<head>
<meta name="generator" content=
"HTML Tidy for Linux/x86 (vers 7 December 2008), see www.w3.org" />
<title>Lemonldap::NG documentation:
4.4-Configure-and-use-notification-system.html</title>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii" />
<style type="text/css">
/*<![CDATA[*/
body{
background: #ddd;
font-family: sans-serif;
font-size: 11pt;
padding: 0 50px;
}
div.main-content{
padding: 10px;
background: #fff;
border: 2px #ccc solid;
}
a{
text-decoration: none;
}
p.footer{
text-align: center;
margin: 5px 0 0 0;
}
.heading-1{
text-align: center;
color: orange;
font-variant: small-caps;
font-size: 20pt;
}
.heading-1-1{
color: orange;
font-size: 14pt;
border-bottom: 2px #ccc solid;
}
pre{
background: #eee;
border: 2px #ccc solid;
padding: 5px;
border-left: 10px #ccc solid;
}
ul.star li{
list-style-type: square;
}
/*]]>*/
</style>
</head>
<body>
<div class="main-content">
<h2 class="heading-1"><span id="HNotificationsystem">Notification
system</span></h2>
<p class="paragraph"></p>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.
<p class="paragraph"></p>
<ul>
<li>
<a href="#HInstallation">Installation</a>
<ul>
<li><a href="#HActivation">Activation</a></li>
<li><a href="#HStorage">Storage</a></li>
</ul>
</li>
<li>
<a href="#HUsingnotificationsystem">Using notification system</a>
<ul>
<li>
<a href="#HInsertnewnotifications">Insert new notifications</a>
<ul>
<li><a href="#HNotificationformat">Notification format</a></li>
<li><a href="#HInsertionexampleinPerl">Insertion example in
Perl</a></li>
</ul>
</li>
<li><a href="#HTestnotification">Test notification</a></li>
</ul>
</li>
</ul>
<h3 class="heading-1-1"><span id="HInstallation">Installation</span></h3>
<h4 class="heading-1-1-1"><span id="HActivation">Activation</span></h4>
<p class="paragraph"></p>You just have to set "notification =&gt; 1" in
the portal.
<h4 class="heading-1-1-1"><span id="HStorage">Storage</span></h4>
<p class="paragraph"></p>By default, notifications will be stored in the
same database as configuration&nbsp;:
<ul class="star">
<li>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/</li>
<li>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&nbsp;</li>
</ul>
<div class="code">
<pre>
CREATE TABLE 'notifications' (
'date' datetime NOT NULL,
'uid' varchar(255) NOT NULL,
'ref' varchar(255) NOT NULL,
'xml' longblob NOT NULL,
'done' datetime <span class="java-keyword">default</span> NULL,
PRIMARY KEY ('date','uid','ref')
)
</pre>
</div>
<p class="paragraph"></p>You can change default parameters using the
"notificationStorage" parameter with the same syntax as configStorage.
Example&nbsp;:
<div class="code">
<pre>
notificationStorage =&gt; {
type =&gt; 'File',
dirName =&gt; '/<span class=
"java-keyword">var</span>/lib/lemonldap-ng/notifications/',
},
</pre>
</div>
<h3 class="heading-1-1"><span id="HUsingnotificationsystem">Using
notification system</span></h3>
<h4 class="heading-1-1-1"><span id="HInsertnewnotifications">Insert new
notifications</span></h4>
<p class="paragraph"></p>New notifications can be insert using SOAP
request (described in the WSDL file generated by buildPortalWSDL tool).
<h5 class="heading-1-1-1-1"><span id="HNotificationformat">Notification
format</span></h5>
<p class="paragraph"></p>Notifications are XML files containing&nbsp;:
<ul class="star">
<li>"&lt;notification&gt;" element(s) :
<ul class="star">
<li>required attributes :
<ul class="star">
<li>"date" in format YYYY-MM-DD</li>
<li>"ref" : a reference that can be used later to know what has
been notified and when</li>
<li>"uid" : the user (it must correspond to the attibute set in
whatToTrace parameter : uid by default)</li>
</ul>
</li>
<li>sub-elements :
<ul class="star">
<li>&lt;text&gt; : paragraph to display : inserted in HTML page
enclosed in &lt;p class="notifText"&gt;...&lt;/p&gt;)</li>
<li>&lt;check&gt; : paragraph to display with a checkbox :
inserted in HTML page enclosed in &lt;p
class="notifCheck"&gt;&lt;input
type="checkbox/&gt;...&lt;/p&gt;</li>
</ul>
</li>
</ul>
</li>
</ul>All other elements will be removed including HTML elemants like
&lt;b&gt;
<p class="paragraph"></p>Example :
<div class="code">
<pre>
&lt;?xml version=<span class="java-quote">"1.0"</span> encoding=<span class=
"java-quote">"UTF-8"</span> standalone=<span class=
"java-quote">"no"</span>?&gt;
&lt;root&gt;
&lt;notification uid=<span class=
"java-quote">"foo.bar"</span> date=<span class=
"java-quote">"2009-01-27"</span> reference=<span class=
"java-quote">"ABC"</span>&gt;
&lt;text&gt; You have been granted to access to appli-1 &lt;/text&gt;
&lt;text&gt; You have been granted to access to appli-2 &lt;/text&gt;
&lt;check&gt; I know that I can acces to appli-1 &lt;/check&gt;
&lt;check&gt; I know that I can acces to appli-2 &lt;/check&gt;
&lt;/notification&gt;
&lt;/root&gt;
</pre>
</div>
<h5 class="heading-1-1-1-1"><span id="HInsertionexampleinPerl">Insertion
example in Perl</span></h5>
<p class="paragraph"></p>
<div class="code">
<pre>
#!/usr/bin/perl<br /><br />use SOAP::Lite;
use utf8;<br /><br />my $lite = SOAP::Lite
-&gt;uri('urn:Lemonldap::NG::Common::CGI::SOAPService')
-&gt;proxy('http://auth.example.com/index.pl/notification');<br /><br />$r = $lite-&gt;newNotification('&lt;?xml version=<span class="java-quote">"1.0"</span> encoding=<span class="java-quote">"UTF-8"</span> standalone=<span class="java-quote">"no"</span>?&gt;
&lt;root&gt;
&lt;notification uid=<span class=
"java-quote">"foo.bar"</span> date=<span class=
"java-quote">"2009-01-27"</span> reference=<span class=
"java-quote">"ABC"</span>&gt;
&lt;text&gt; You have been granted to access to appli-1 &lt;/text&gt;
&lt;text&gt; You have been granted to access to appli-2 &lt;/text&gt;
&lt;check&gt; I know that I can acces to appli-1 &lt;/check&gt;
&lt;check&gt; I know that I can acces to appli-2 &lt;/check&gt;
&lt;/notification&gt;
&lt;/root&gt;');<br /><br /><span class=
"java-keyword">if</span> ( $r-&gt;fault ) {
print STDERR <span class=
"java-quote">"SOAP Error: "</span> . $r-&gt;fault-&gt;{faultstring};
}
<span class="java-keyword">else</span> {
my $res = $r-&gt;result();
print "$res notification(s) have been inserted";
}
</pre>
</div>
<h4 class="heading-1-1-1"><span id="HTestnotification">Test
notification</span></h4>
<p class="paragraph"></p>You've simply to insert a notification and
connect to the portal using the same UID. You will be prompted.
</div>
<p class="footer"><a href="index.html">Index</a></p>
</body>
</html>