lemonldap-ng/doc/pages/documentation/current/notifications.html
2019-09-23 22:41:16 +02:00

528 lines
30 KiB
HTML

<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<title>documentation:2.0:notifications</title>
<meta name="generator" content="DokuWiki"/>
<meta name="robots" content="index,follow"/>
<meta name="keywords" content="documentation,2.0,notifications"/>
<link rel="search" type="application/opensearchdescription+xml" href="lib/exe/opensearch.html" title="LemonLDAP::NG"/>
<link rel="start" href="notifications.html"/>
<link rel="contents" href="notifications.html" title="Sitemap"/>
<link rel="stylesheet" type="text/css" href="lib/exe/css.php.t.bootstrap3.css"/>
<!-- //if:usedebianlibs
<link rel="stylesheet" type="text/css" href="/javascript/bootstrap/css/bootstrap.min.css" />
//elsif:useexternallibs
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"></script>
//elsif:cssminified
<link rel="stylesheet" type="text/css" href="/static/bwr/bootstrap/dist/css/bootstrap.min.css" />
//else -->
<link rel="stylesheet" type="text/css" href="/static/bwr/bootstrap/dist/css/bootstrap.css" />
<!-- //endif -->
<script type="text/javascript">/*<![CDATA[*/var NS='documentation:2.0';var JSINFO = {"id":"documentation:2.0:notifications","namespace":"documentation:2.0"};
/*!]]>*/</script>
<script type="text/javascript" charset="utf-8" src="lib/exe/js.php.t.bootstrap3.js"></script>
<!-- //if:usedebianlibs
<script type="text/javascript" src="/javascript/jquery/jquery.min.js"></script>
//elsif:useexternallibs
<script type="text/javascript" src="http://code.jquery.com/jquery-2.2.0.min.js"></script>
//elsif:jsminified
<script type="text/javascript" src="/static/bwr/jquery/dist/jquery.min.js"></script>
//else -->
<script type="text/javascript" src="/static/bwr/jquery/dist/jquery.js"></script>
<!-- //endif -->
<!-- //if:usedebianlibs
<script type="text/javascript" src="/javascript/jquery-ui/jquery-ui.min.js"></script>
//elsif:useexternallibs
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
//elsif:jsminified
<script type="text/javascript" src="/static/bwr/jquery-ui/jquery-ui.min.js"></script>
//else -->
<script type="text/javascript" src="/static/bwr/jquery-ui/jquery-ui.js"></script>
<!-- //endif -->
</head>
<body>
<div class="dokuwiki export container">
<!-- TOC START -->
<div id="dw__toc">
<h3 class="toggle">Table of Contents</h3>
<div>
<ul class="toc">
<li class="level1"><div class="li"><a href="#installation">Installation</a></div>
<ul class="toc">
<li class="level2"><div class="li"><a href="#activation">Activation</a></div></li>
<li class="level2"><div class="li"><a href="#storage">Storage</a></div>
<ul class="toc">
<li class="level3"><div class="li"><a href="#file">File</a></div></li>
<li class="level3"><div class="li"><a href="#dbi">DBI</a></div></li>
<li class="level3"><div class="li"><a href="#ldap">LDAP</a></div></li>
</ul>
</li>
<li class="level2"><div class="li"><a href="#wildcard">Wildcard</a></div></li>
</ul>
</li>
<li class="level1"><div class="li"><a href="#using_notification_system">Using notification system</a></div>
<ul class="toc">
<li class="level2"><div class="li"><a href="#notification_format">Notification format</a></div>
<ul class="toc">
<li class="level3"><div class="li"><a href="#examples">Examples</a></div></li>
</ul>
</li>
<li class="level2"><div class="li"><a href="#create_new_notifications_with_notifications_explorer">Create new notifications with notifications explorer</a></div></li>
<li class="level2"><div class="li"><a href="#notification_server">Notification server</a></div>
<ul class="toc">
<li class="level3"><div class="li"><a href="#xml_notifications_trough_soap">XML notifications trough SOAP</a></div></li>
<li class="level3"><div class="li"><a href="#json_notifications_trough_rest">JSON notifications trough REST</a></div></li>
</ul>
</li>
<li class="level2"><div class="li"><a href="#test_notification">Test notification</a></div></li>
</ul></li>
</ul>
</div>
</div>
<!-- TOC END -->
<h1 class="sectionedit1" id="notifications_system">Notifications system</h1>
<div class="level1">
<p>
Since version 0.9.4, LemonLDAP::NG can be used to notify some messages to users: if a user has got messages, they will be displayed when he access to the portal. If a message contains some check boxes, the user has to check all of them else he can not access to the portal and retrieves his session cookie.
</p>
<p>
Since 1.1.0, a notification explorer is available in Manager, and notifications can be set for all users, with possibility to use display conditions. When the user accept the notification, notification reference is stored in his persistent session.
</p>
</div>
<!-- EDIT1 SECTION "Notifications system" [1-594] -->
<h2 class="sectionedit2" id="installation">Installation</h2>
<div class="level2">
</div>
<!-- EDIT2 SECTION "Installation" [595-620] -->
<h3 class="sectionedit3" id="activation">Activation</h3>
<div class="level3">
<p>
You just have to activate Notifications in the Manager (General Parameters &gt; Advanced Parameters &gt; Notifications &gt; Activation) or in <code>lemonldap-ng.ini</code> [portal] section:
</p>
<pre class="code file ini"><span class="re0"><span class="br0">&#91;</span>portal<span class="br0">&#93;</span></span>
<span class="re1">notification</span> <span class="sy0">=</span><span class="re2"> 1</span></pre>
</div>
<!-- EDIT3 SECTION "Activation" [621-860] -->
<h3 class="sectionedit4" id="storage">Storage</h3>
<div class="level3">
<p>
By default, notifications will be stored in the same database as configuration:
</p>
<ul>
<li class="level1"><div class="li"> if you use &quot;File&quot; system and your &quot;dirName&quot; is set to /usr/local/lemonldap-ng/conf/, the notifications will be stored in /usr/local/lemonldap-ng/notifications/</div>
</li>
<li class="level1"><div class="li"> if you use &quot;CDBI&quot; or &quot;RDBI&quot; system, the notifications will be stored in the same database as configuration and in a table called &quot;notifications&quot;.</div>
</li>
<li class="level1"><div class="li"> if you use &quot;LDAP&quot; system, the notifications will be stored in the same directory as configuration and in a branch called &quot;notifications&quot;.</div>
</li>
</ul>
<p>
You can change default parameters using the &quot;notificationStorage&quot; and &quot;notificationStorageOptions&quot; parameters with the same syntax as configuration storage parameters. To do this in Manager, go in General Parameters &gt; Advanced Parameters &gt; Notifications.
</p>
</div>
<h4 id="file">File</h4>
<div class="level4">
<p>
Parameters for File backend are the same as <a href="fileconfbackend.html" class="wikilink1" title="documentation:2.0:fileconfbackend">File configuration backend</a>.
</p>
<div class="noteimportant">You need to create yourself the directory and set write access to Apache user. For example:
<pre class="code">mkdir /usr/local/lemonldap-ng/notifications/
chown www-data /usr/local/lemonldap-ng/notifications/</pre>
</div><div class="notetip">The file name default separator is <code>_</code>, this can be a problem if you register notifications for users having <code>_</code> in their login. You can change the separator with the <code>fileNameSeparator</code> option, and set another value, for example <code>@</code>.
</div>
<p>
To summary available options:
</p>
<ul>
<li class="level1"><div class="li"> <strong>dirName</strong>: directory where notifications are stored.</div>
</li>
<li class="level1"><div class="li"> <strong>fileNameSeparator</strong>: file name separator.</div>
</li>
</ul>
</div>
<h4 id="dbi">DBI</h4>
<div class="level4">
<p>
Parameters for <abbr title="Database Interface">DBI</abbr> backend are the same as <a href="sqlconfbackend.html" class="wikilink1" title="documentation:2.0:sqlconfbackend">DBI configuration backend</a>.
</p>
<div class="noteimportant">You have to create the table by yourself:
<pre class="code sql"><span class="kw1">CREATE</span> <span class="kw1">TABLE</span> notifications <span class="br0">&#40;</span>
<span class="kw1">DATE</span> datetime <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span>
uid <span class="kw1">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">255</span><span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span>
<span class="kw1">REF</span> <span class="kw1">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">255</span><span class="br0">&#41;</span> <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span>
cond <span class="kw1">VARCHAR</span><span class="br0">&#40;</span><span class="nu0">255</span><span class="br0">&#41;</span> <span class="kw1">DEFAULT</span> <span class="kw1">NULL</span><span class="sy0">,</span>
xml longblob <span class="kw1">NOT</span> <span class="kw1">NULL</span><span class="sy0">,</span>
done datetime <span class="kw1">DEFAULT</span> <span class="kw1">NULL</span><span class="sy0">,</span>
<span class="kw1">PRIMARY</span> <span class="kw1">KEY</span> <span class="br0">&#40;</span><span class="kw1">DATE</span><span class="sy0">,</span> uid<span class="sy0">,</span><span class="kw1">REF</span><span class="br0">&#41;</span>
<span class="br0">&#41;</span></pre>
</div>
<p>
To summary available options:
</p>
<ul>
<li class="level1"><div class="li"> <strong>dbiChain</strong>: <abbr title="Database Interface">DBI</abbr> connection.</div>
</li>
<li class="level1"><div class="li"> <strong>dbiUser</strong>: <abbr title="Database Interface">DBI</abbr> user.</div>
</li>
<li class="level1"><div class="li"> <strong>dbiPassword</strong>: <abbr title="Database Interface">DBI</abbr> password.</div>
</li>
<li class="level1"><div class="li"> <strong>dbiTable</strong>: Notifications table name.</div>
</li>
</ul>
</div>
<h4 id="ldap">LDAP</h4>
<div class="level4">
<p>
Parameters for LDAP backend are the same as <a href="ldapconfbackend.html" class="wikilink1" title="documentation:2.0:ldapconfbackend">LDAP configuration backend</a>.
</p>
<div class="noteimportant">You have to create the branch by yourself
</div>
<p>
To summary available options:
</p>
<ul>
<li class="level1"><div class="li"> <strong>ldapServer</strong>: LDAP <abbr title="Uniform Resource Locator">URL</abbr>.</div>
</li>
<li class="level1"><div class="li"> <strong>ldapBindDN</strong>: LDAP user.</div>
</li>
<li class="level1"><div class="li"> <strong>ldapBindPassword</strong>: LDAP password.</div>
</li>
<li class="level1"><div class="li"> <strong>ldapConfBase</strong>: Notifications branch <abbr title="Distinguished Name">DN</abbr>.</div>
</li>
</ul>
</div>
<!-- EDIT4 SECTION "Storage" [861-3358] -->
<h3 class="sectionedit5" id="wildcard">Wildcard</h3>
<div class="level3">
<p>
The notifications module uses a wildcard to manage notifications for all users. The default value of this wildcard is <code>allusers</code>, but you can change it if <code>allusers</code> is a known identifier in your system.
</p>
<p>
To change it, go in General Parameters &gt; Advanced Parameters &gt; Notifications &gt; Wildcard for all users, and set for example <code>alluserscustom</code>.
</p>
<p>
Then creating a notification for <code>alluserscustom</code> will display the notification for all users.
</p>
</div>
<!-- EDIT5 SECTION "Wildcard" [3359-3829] -->
<h2 class="sectionedit6" id="using_notification_system">Using notification system</h2>
<div class="level2">
<div class="noteimportant">Since version 2.0, notifications are now stored in JSON format. If you want to keep old format, select &quot;use old format&quot; in the Manager. Note that notification server depends on chosen format: REST for JSON and SOAP for XML.
</div>
</div>
<!-- EDIT6 SECTION "Using notification system" [3830-4116] -->
<h3 class="sectionedit7" id="notification_format">Notification format</h3>
<div class="level3">
<p>
Notifications are JSON (default) or XML files containing:
</p>
<ul>
<li class="level1"><div class="li"> &lt;notification&gt; element(s) :</div>
<ul>
<li class="level2"><div class="li"> Required attributes:</div>
<ul>
<li class="level3"><div class="li"> date: creation date (format YYYY-MM-DD)</div>
</li>
<li class="level3"><div class="li"> ref: a reference that can be used later to know what has been notified and when</div>
</li>
<li class="level3"><div class="li"> uid: the user login (it must correspond to the attribute set in whatToTrace parameter, uid by default), or the wildcard string (by default: <code>allusers</code>) if the notification should be displayed for every user.</div>
</li>
</ul>
</li>
<li class="level2"><div class="li"> Optional attributes:</div>
<ul>
<li class="level3"><div class="li"> condition: condition to display the notification, can use all session variables.</div>
</li>
</ul>
</li>
<li class="level2"><div class="li"> Sub elements:</div>
<ul>
<li class="level3"><div class="li"> &lt;title&gt;: title to display: will be inserted in <abbr title="HyperText Markup Language">HTML</abbr> page enclosed in &lt;h2 class=&quot;notifText&quot;&gt;...&lt;/h2&gt;</div>
</li>
<li class="level3"><div class="li"> &lt;subtitle&gt;: subtitle to display: will be inserted in <abbr title="HyperText Markup Language">HTML</abbr> page enclosed in &lt;h2 class=&quot;notifText&quot;&gt;...&lt;/h2&gt;</div>
</li>
<li class="level3"><div class="li"> &lt;text&gt;: paragraph to display: will be inserted in <abbr title="HyperText Markup Language">HTML</abbr> page enclosed in &lt;p class=&quot;notifText&quot;&gt;...&lt;/p&gt;</div>
</li>
<li class="level3"><div class="li"> &lt;check&gt;: paragraph to display with a checkbox: will be inserted in <abbr title="HyperText Markup Language">HTML</abbr> page enclosed in &lt;p class=&quot;notifCheck&quot;&gt;&lt;input type=&quot;checkbox&quot; /&gt;...&lt;/p&gt;</div>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<div class="noteimportant">All other elements will be removed including <abbr title="HyperText Markup Language">HTML</abbr> elements like &lt;b&gt;.
</div><div class="notetip">One notification XML document can contain several notifications messages.
</div>
</div>
<h4 id="examples">Examples</h4>
<div class="level4">
</div>
<h5 id="json">JSON</h5>
<div class="level5">
<pre class="code file javascript"><span class="br0">&#123;</span>
<span class="st0">&quot;uid&quot;</span><span class="sy0">:</span> <span class="st0">&quot;foo.bar&quot;</span><span class="sy0">,</span>
<span class="st0">&quot;date&quot;</span><span class="sy0">:</span> <span class="st0">&quot;2009-01-27&quot;</span><span class="sy0">,</span>
<span class="st0">&quot;reference&quot;</span><span class="sy0">:</span> <span class="st0">&quot;ABC&quot;</span><span class="sy0">,</span>
<span class="st0">&quot;title&quot;</span><span class="sy0">:</span> <span class="st0">&quot;You have new authorizations&quot;</span><span class="sy0">,</span>
<span class="st0">&quot;subtitle&quot;</span><span class="sy0">:</span> <span class="st0">&quot;Application 1&quot;</span><span class="sy0">,</span>
<span class="st0">&quot;text&quot;</span><span class="sy0">:</span> <span class="st0">&quot;You have been granted to access to appli-1&quot;</span><span class="sy0">,</span>
<span class="st0">&quot;check&quot;</span><span class="sy0">:</span> <span class="br0">&#91;</span>
<span class="st0">&quot;I agree&quot;</span><span class="sy0">,</span>
<span class="st0">&quot;Yes, I'm sure&quot;</span>
<span class="br0">&#93;</span>
<span class="br0">&#125;</span></pre>
</div>
<h5 id="xml">XML</h5>
<div class="level5">
<pre class="code file xml"><span class="sc3"><span class="re1">&lt;?xml</span> <span class="re0">version</span>=<span class="st0">&quot;1.0&quot;</span> <span class="re0">encoding</span>=<span class="st0">&quot;UTF-8&quot;</span> <span class="re0">standalone</span>=<span class="st0">&quot;no&quot;</span><span class="re2">?&gt;</span></span>
<span class="sc3"><span class="re1">&lt;root<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;notification</span> <span class="re0">uid</span>=<span class="st0">&quot;foo.bar&quot;</span> <span class="re0">date</span>=<span class="st0">&quot;2009-01-27&quot;</span> <span class="re0">reference</span>=<span class="st0">&quot;ABC&quot;</span><span class="re2">&gt;</span></span>
<span class="sc3"><span class="re1">&lt;title<span class="re2">&gt;</span></span></span>You have new authorizations<span class="sc3"><span class="re1">&lt;/title<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;subtitle<span class="re2">&gt;</span></span></span>Application 1<span class="sc3"><span class="re1">&lt;/subtitle<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;text<span class="re2">&gt;</span></span></span>You have been granted to access to appli-1<span class="sc3"><span class="re1">&lt;/text<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;subtitle<span class="re2">&gt;</span></span></span>Application 2<span class="sc3"><span class="re1">&lt;/subtitle<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;text<span class="re2">&gt;</span></span></span>You have been granted to access to appli-2<span class="sc3"><span class="re1">&lt;/text<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;subtitle<span class="re2">&gt;</span></span></span>Acceptation<span class="sc3"><span class="re1">&lt;/subtitle<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;check<span class="re2">&gt;</span></span></span>I know that I can access to appli-1 <span class="sc3"><span class="re1">&lt;/check<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;check<span class="re2">&gt;</span></span></span>I know that I can access to appli-2 <span class="sc3"><span class="re1">&lt;/check<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;/notification<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;notification</span> <span class="re0">uid</span>=<span class="st0">&quot;allusers&quot;</span> <span class="re0">date</span>=<span class="st0">&quot;2009-01-27&quot;</span> <span class="re0">reference</span>=<span class="st0">&quot;disclaimer&quot;</span> <span class="re0">condition</span>=<span class="st0">&quot;$ipAddr =~ /^192/&quot;</span><span class="re2">&gt;</span></span>
<span class="sc3"><span class="re1">&lt;title<span class="re2">&gt;</span></span></span>This is your first access on this system<span class="sc3"><span class="re1">&lt;/title<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;text<span class="re2">&gt;</span></span></span>Be a nice user and do not break it please.<span class="sc3"><span class="re1">&lt;/text<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;check<span class="re2">&gt;</span></span></span>Of course I am not evil!<span class="sc3"><span class="re1">&lt;/check<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;/notification<span class="re2">&gt;</span></span></span>
<span class="sc3"><span class="re1">&lt;/root<span class="re2">&gt;</span></span></span></pre>
<div class="notetip">JSON format notifications are displayed sorted by date and reference
</div>
</div>
<!-- EDIT7 SECTION "Notification format" [4117-6608] -->
<h3 class="sectionedit8" id="create_new_notifications_with_notifications_explorer">Create new notifications with notifications explorer</h3>
<div class="level3">
<p>
In Manager, click on <code>Notifications</code> and then on the <code>Create</code> button.
</p>
<p>
<img src="documentation/manager-notification.png" class="mediacenter" alt="" />
</p>
<p>
Then fill all inputs to create the notification. Only the condition is not mandatory.
</p>
<p>
When all is ok, click on <code>Save</code>.
</p>
</div>
<!-- EDIT8 SECTION "Create new notifications with notifications explorer" [6609-6927] -->
<h3 class="sectionedit9" id="notification_server">Notification server</h3>
<div class="level3">
<p>
LemonLDAP::NG provides two notification servers : SOAP and REST depending on format.
</p>
<p>
If enabled, the server <abbr title="Uniform Resource Locator">URL</abbr> is <a href="https://auth.your.domain/notifications" class="urlextern" title="https://auth.your.domain/notifications" rel="nofollow">https://auth.your.domain/notifications</a>.
</p>
<div class="noteimportant">If notification server is enabled, you have to protect this <abbr title="Uniform Resource Locator">URL</abbr> using the webserver because there is no authentication required to use it.
</div>
<p>
Example:
</p>
<pre class="code file apache"><span class="co1"># REST/SOAP functions for insert/delete/list notifications (disabled by default)</span>
&lt;<span class="kw3">LocationMatch</span> ^/(index\.fcgi/)?notifications&gt;
&lt;<span class="kw3">IfVersion</span> &gt;= <span class="nu0">2.3</span>&gt;
<span class="kw1">Require</span> ip 192.168.2.0/<span class="nu0">24</span>
&lt;/<span class="kw3">IfVersion</span>&gt;
&lt;<span class="kw3">IfVersion</span> &lt; <span class="nu0">2.3</span>&gt;
<span class="kw1">Order</span> <span class="kw1">Deny</span>,<span class="kw1">Allow</span>
<span class="kw1">Deny</span> from <span class="kw2">all</span>
<span class="kw1">Allow</span> from 192.168.2.0/<span class="nu0">24</span>
&lt;/<span class="kw3">IfVersion</span>&gt;
&lt;/<span class="kw3">LocationMatch</span>&gt;</pre>
</div>
<h4 id="xml_notifications_trough_soap">XML notifications trough SOAP</h4>
<div class="level4">
<p>
If you use old XML format, new notifications can be inserted or deleted by using SOAP request, once SOAP is activated:
</p>
</div>
<h5 id="insertion_example_in_perl">* Insertion example in Perl</h5>
<div class="level5">
<pre class="code perl"><span class="co1">#!/usr/bin/perl</span>
&nbsp;
<span class="kw2">use</span> SOAP<span class="sy0">::</span><span class="me2">Lite</span><span class="sy0">;</span>
<span class="kw2">use</span> utf8<span class="sy0">;</span>
&nbsp;
<span class="kw1">my</span> <span class="re0">$lite</span> <span class="sy0">=</span> SOAP<span class="sy0">::</span><span class="me2">Lite</span>
<span class="sy0">-&gt;</span><span class="me1">uri</span><span class="br0">&#40;</span><span class="st_h">'urn:Lemonldap::NG::Common::PSGI::SOAPService'</span><span class="br0">&#41;</span>
<span class="sy0">-&gt;</span><span class="me1">proxy</span><span class="br0">&#40;</span><span class="st_h">'http://auth.example.com/notifications'</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
&nbsp;
<span class="re0">$r</span> <span class="sy0">=</span> <span class="re0">$lite</span><span class="sy0">-&gt;</span><span class="me1">newNotification</span><span class="br0">&#40;</span>
<span class="st_h">'&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;
&lt;root&gt;
&lt;notification uid=&quot;foo.bar&quot; date=&quot;2009-01-27&quot; reference=&quot;ABC&quot;&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 access to appli-1 &lt;/check&gt;
&lt;check&gt; I know that I can access to appli-2 &lt;/check&gt;
&lt;/notification&gt;
&lt;/root&gt;
'</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
<span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$r</span><span class="sy0">-&gt;</span><span class="me1">fault</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span>
<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="kw2">STDERR</span> <span class="st0">&quot;SOAP Error: &quot;</span> <span class="sy0">.</span> <span class="re0">$r</span><span class="sy0">-&gt;</span><span class="me1">fault</span><span class="sy0">-&gt;</span><span class="br0">&#123;</span>faultstring<span class="br0">&#125;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="kw1">else</span> <span class="br0">&#123;</span>
<span class="kw1">my</span> <span class="re0">$res</span> <span class="sy0">=</span> <span class="re0">$r</span><span class="sy0">-&gt;</span><span class="me1">result</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;$res notification(s) have been inserted<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre>
</div>
<h5 id="deletion_example_in_perl">* Deletion example in Perl</h5>
<div class="level5">
<pre class="code perl"><span class="co1">#!/usr/bin/perl</span>
&nbsp;
<span class="kw2">use</span> SOAP<span class="sy0">::</span><span class="me2">Lite</span><span class="sy0">;</span>
<span class="kw2">use</span> utf8<span class="sy0">;</span>
&nbsp;
<span class="kw1">my</span> <span class="re0">$lite</span> <span class="sy0">=</span> SOAP<span class="sy0">::</span><span class="me2">Lite</span>
<span class="sy0">-&gt;</span><span class="me1">uri</span><span class="br0">&#40;</span><span class="st_h">'urn:Lemonldap::NG::Common::CGI::SOAPService'</span><span class="br0">&#41;</span>
<span class="sy0">-&gt;</span><span class="me1">proxy</span><span class="br0">&#40;</span><span class="st_h">'http://auth.example.com/index.pl/notification'</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
&nbsp;
<span class="re0">$r</span> <span class="sy0">=</span> <span class="re0">$lite</span><span class="sy0">-&gt;</span><span class="me1">deleteNotification</span><span class="br0">&#40;</span><span class="st_h">'foo.bar'</span><span class="sy0">,</span> <span class="st_h">'ABC'</span><span class="br0">&#41;</span><span class="sy0">;</span>
&nbsp;
<span class="kw1">if</span> <span class="br0">&#40;</span> <span class="re0">$r</span><span class="sy0">-&gt;</span><span class="me1">fault</span> <span class="br0">&#41;</span> <span class="br0">&#123;</span>
<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="kw2">STDERR</span> <span class="st0">&quot;SOAP Error: &quot;</span> <span class="sy0">.</span> <span class="re0">$r</span><span class="sy0">-&gt;</span><span class="me1">fault</span><span class="sy0">-&gt;</span><span class="br0">&#123;</span>faultstring<span class="br0">&#125;</span><span class="sy0">;</span>
<span class="br0">&#125;</span>
<span class="kw1">else</span> <span class="br0">&#123;</span>
<span class="kw1">my</span> <span class="re0">$res</span> <span class="sy0">=</span> <span class="re0">$r</span><span class="sy0">-&gt;</span><span class="me1">result</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<a href="http://perldoc.perl.org/functions/print.html"><span class="kw3">print</span></a> <span class="st0">&quot;$res notification(s) have been deleted<span class="es0">\n</span>&quot;</span><span class="sy0">;</span>
<span class="br0">&#125;</span></pre>
</div>
<h4 id="json_notifications_trough_rest">JSON notifications trough REST</h4>
<div class="level4">
<p>
REST server provides three <abbr title="Application Programming Interface">API</abbr> to insert (POST), delete (DELETE) or list (GET) notification(s).
HTTP methods can enabled/disabled in Manager, <code>General Parameters</code> » <code>Plugins</code> » <code>Notifications</code> » <code>Server</code> » <code>HTTP methods</code>.
</p>
<p>
Notifications parameters returned by <code>GET</code> method can be specfied in Manager, <code>General Parameters</code> » <code>Plugins</code> » <code>Notifications</code> » <code>Server</code> » <code>Notifications parameters to send</code>. By default: &#039;uid reference date title subtitle text check&#039;
</p>
</div>
<h5 id="insertion_example_with_rest_api">* Insertion example with REST API</h5>
<div class="level5">
<p>
Using JSON, you just have to POST json files.
</p>
<p>
For example with curl:
</p>
<pre class="code">curl -X POST -H &quot;Content-Type: application/json&quot; -H &quot;Accept: application/json&quot; -d @notif.json http://auth.example.com/notifications</pre>
</div>
<h5 id="deletion_example_with_rest_api">* Deletion example with REST API</h5>
<div class="level5">
<p>
DELETE <abbr title="Application Programming Interface">API</abbr> is available with LLNG ≥ 2.0.6
</p>
<p>
For example with curl:
</p>
<pre class="code">curl -X DELETE -H &quot;Content-Type: application/json&quot; -H &quot;Accept: application/json&quot; http://auth.example.com/notifications/&lt;uid&gt;/&lt;reference&gt;</pre>
</div>
<h5 id="list_example_with_rest_api">* List example with REST API</h5>
<div class="level5">
<p>
GET <abbr title="Application Programming Interface">API</abbr> is available with LLNG ≥ 2.0.6
</p>
<p>
For example with curl:
</p>
<pre class="code">curl -X GET -H &quot;Content-Type: application/json&quot; -H &quot;Accept: application/json&quot; http://auth.example.com/notifications
curl -X GET -H &quot;Content-Type: application/json&quot; -H &quot;Accept: application/json&quot; http://auth.example.com/notifications/&lt;uid&gt;
curl -X GET -H &quot;Content-Type: application/json&quot; -H &quot;Accept: application/json&quot; http://auth.example.com/notifications/&lt;uid&gt;/&lt;reference&gt;</pre>
</div>
<!-- EDIT9 SECTION "Notification server" [6928-10646] -->
<h3 class="sectionedit10" id="test_notification">Test notification</h3>
<div class="level3">
<p>
You&#039;ve just to insert a notification and connect to the portal using the same UID. You will be prompted.
</p>
<p>
<img src="documentation/portal-notification.png" class="mediacenter" alt="" />
</p>
<p>
Try also to create a global notification (to the uid &quot;allusers&quot;), and connect with any user, the message will be prompted.
</p>
</div>
<!-- EDIT10 SECTION "Test notification" [10647-] --></div>
</body>
</html>