--- /dev/null
+<% /**
+*Copyright © Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
+*
+*This file is part of the work and learning management system Pentila Nero.
+*
+*Pentila Nero is free software. You can redistribute it and/or modify since
+*you respect the terms of either (at least one of the both license) :
+*- under the terms of the GNU Affero General Public License as
+*published by the Free Software Foundation, either version 3 of the
+*License, or (at your option) any later version.
+*- the CeCILL-C as published by CeCILL-C; either version 1 of the
+*License, or any later version
+*- the GNU Lesser General Public License as published by the
+*Free Software Foundation, either version 3 of the license,
+*or (at your option) any later version.
+*
+*There are special exceptions to the terms and conditions of the
+*licenses as they are applied to this software. View the full text of
+*the exception in file LICENSE-PROJECT.txt in the directory of this software
+*distribution.
+*
+*Pentila Nero is distributed in the hope that it will be useful,
+*but WITHOUT ANY WARRANTY; without even the implied warranty of
+*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+*Licenses for more details.
+*
+*You should have received a copy of the GNU Affero General Public License
+*and the CeCILL-C and the GNU Lesser General Public License along with
+*Pentila Nero. If not, see :
+*<http://www.gnu.org/licenses/> and
+*<http://www.cecill.info/licences.fr.html>.
+*/ %>
+<?xml version="1.0" encoding="UTF-8" ?>
+<%@page import="com.liferay.portal.kernel.dao.orm.QueryUtil"%>
+<%@page import="com.liferay.portal.util.comparator.GroupNameComparator"%>
+<%@page import="java.util.LinkedHashMap"%>
+<%@page import="com.liferay.portal.service.GroupLocalServiceUtil"%>
+<%@page import="com.pentila.entSavoie.communityInfos.service.CommunityInfosLocalServiceUtil"%>
+<%@page import="com.pentila.entSavoie.communityInfos.model.CommunityInfos"%>
+<%@page import="com.liferay.contacts.util.OrganizationFilter"%>
+<%@page import="com.pentila.entSavoie.ENTRolesConstants"%>
+<%@page import="com.pentila.entSavoie.carnetDAdresses.service.ListeLocalServiceUtil"%>
+<%@page import="com.pentila.entSavoie.carnetDAdresses.model.Liste"%>
+<%@ page import="com.liferay.portal.kernel.servlet.HttpHeaders" %>
+<%@page import="java.util.List"%>
+<%@page import="com.liferay.portal.kernel.util.ParamUtil"%>
+<%@ include file="/init.jsp" %>
+<%@page import="com.liferay.portal.model.Organization"%>
+<%@page import="com.liferay.portal.service.OrganizationLocalServiceUtil"%>
+<%@page import="com.liferay.portal.service.RoleLocalServiceUtil"%>
+<%@page import="com.liferay.portal.util.PortalUtil"%>
+<%@page import="com.liferay.portal.model.Organization"%>
+<%@page import="com.pentila.entSavoie.ENTDisplayUtil"%>
+<%@page import="java.util.ArrayList"%>
+<%@page import="com.liferay.contacts.util.InstitutionalListsFactory"%>
+<%@page import="com.liferay.contacts.util.ProxyList"%>
+<%@page import="java.text.Normalizer"%>
+<%@page import="com.pentila.entSavoie.amis.model.FriendFolder"%>
+<%@page import="com.pentila.entSavoie.amis.service.FriendFolderLocalServiceUtil"%>
+<%@page import="javax.portlet.PortletPreferences"%>
+<%@page import="com.pentila.entSavoie.carnetDAdresses.model.ListProperty"%>
+<%@page import="java.util.Map"%>
+
+
+
+
+<%
+ //Recupère l'ensemble des listes de l'utilisateur
+
+ List<Liste> lesListes = ListeLocalServiceUtil.findByGroupId(user.getGroup().getGroupId());
+ String listName = "";
+ renderResponse.setContentType("text/xml");
+ response.setContentType("text/xml");
+ response.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache");
+
+ /*Instantiation de l'operateur de comparaison avec Collator*/
+ //Collator compareOperator = Collator.getInstance(Locale.FRENCH);
+ //compareOperator.setStrength (Collator.PRIMARY);
+
+ final String recherche = ParamUtil.getString(renderRequest, "recherche", "").toLowerCase();
+ int sizeRecherche = recherche.length();
+
+%>
+
+
+ <listes>
+ <liste>
+ <name><%= messages.getString("tous-mes-contacts") %></name>
+ <type>all</type>
+ <orgId></orgId>
+ <roleId></roleId>
+ <listId></listId>
+ <id>all</id>
+ <groupId>1</groupId>
+ <grouping><![CDATA[<%= messages.getString("generales") %>]]></grouping>
+ </liste>
+ <liste>
+ <name><%= messages.getString("tous-mes-contacts-inst") %></name>
+ <type>inst</type>
+ <orgId></orgId>
+ <roleId></roleId>
+ <listId></listId>
+ <id>inst</id>
+ <groupId>1</groupId>
+ <grouping><![CDATA[<%= messages.getString("generales") %>]]></grouping>
+ </liste>
+ <liste>
+ <name><%= messages.getString("tous-mes-contacts-perso") %></name>
+ <type>perso</type>
+ <orgId></orgId>
+ <roleId></roleId>
+ <listId></listId>
+ <id>perso</id>
+ <groupId>1</groupId>
+ <grouping><![CDATA[<%= messages.getString("generales") %>]]></grouping>
+ </liste>
+ <liste>
+ <name><%= messages.getString("tous-mes-contacts-amis") %></name>
+ <type>allAmis</type>
+ <orgId></orgId>
+ <roleId></roleId>
+ <listId></listId>
+ <id>allAmis</id>
+ <groupId>1</groupId>
+ <grouping><![CDATA[<%= messages.getString("generales") %>]]></grouping>
+ </liste>
+
+
+ <%
+ List<ProxyList> listInstResult = new ArrayList<ProxyList>();
+ List<ProxyList> listArchiveInstResult = new ArrayList<ProxyList>();
+ InstitutionalListsFactory ilf = new InstitutionalListsFactory(user);
+ List<ProxyList> pls = ilf.getInstitutionnalProxyLists();
+ for (ProxyList pl : pls) {
+
+ try{
+
+ Organization org = OrganizationLocalServiceUtil.getOrganization(Long.valueOf(pl.getOrgId()));
+ // on teste pour ne pas prendre les orgs migrate=done
+ PortletPreferences prefs = org.getPreferences();
+
+ //Listes des organizations archivés
+ if (prefs.getValue("migrate", "none").equals("done")) {
+
+ listName = pl.getName().toLowerCase();
+ listName = Normalizer.normalize(listName, Normalizer.Form.NFD);
+ String listNameWithNoCute = listName.replaceAll("[^\\p{ASCII}]","");
+
+ //test de recherche
+ String rechercheTemp = recherche.toLowerCase();
+ rechercheTemp = Normalizer.normalize(rechercheTemp, Normalizer.Form.NFD);
+ String rechercheWithNoCute = rechercheTemp.replaceAll("[^\\p{ASCII}]","");
+
+ boolean testContain = listNameWithNoCute.contains(rechercheWithNoCute);
+ boolean testRecherche = (listName.length()>=sizeRecherche && testContain);
+
+ //on test le list name(rech)
+ if (recherche.equals("") || testRecherche) {
+ listArchiveInstResult.add(pl);
+ }
+
+ }
+
+ //Liste des organizations courantes
+ else {
+
+ listName = pl.getName().toLowerCase();
+ listName = Normalizer.normalize(listName, Normalizer.Form.NFD);
+ String listNameWithNoCute = listName.replaceAll("[^\\p{ASCII}]","");
+
+ //test de recherche
+ String rechercheTemp = recherche.toLowerCase();
+ rechercheTemp = Normalizer.normalize(rechercheTemp, Normalizer.Form.NFD);
+ String rechercheWithNoCute = rechercheTemp.replaceAll("[^\\p{ASCII}]","");
+
+ boolean testContain = listNameWithNoCute.contains(rechercheWithNoCute);
+ boolean testRecherche = (listName.length()>=sizeRecherche && testContain);
+
+ //on test le list name(rech)
+ if (recherche.equals("") || testRecherche) {
+ listInstResult.add(pl);
+ }
+
+ }
+ } catch (Exception e) {
+
+ }
+
+ }
+
+
+ for (ProxyList pl : listInstResult) {
+
+ %>
+ <liste>
+ <name><![CDATA[<%= pl.getName() %>]]></name>
+ <type><![CDATA[<%= pl.getType() %>]]></type>
+ <orgId><%= pl.getOrgId() %></orgId>
+ <roleId><%= pl.getRoleId() %></roleId>
+ <listId><%= pl.getListeId() %></listId>
+ <id><![CDATA[<%= pl.getName() %><%= pl.getType() %><%= pl.getOrgId() %><%= pl.getRoleId() %><%= pl.getListeId() %>]]></id>
+ <groupId>2</groupId>
+ <grouping><![CDATA[<%= messages.getString("institutionnelles") %>]]></grouping>
+ </liste>
+ <% } %>
+
+
+ <%
+
+ for (ProxyList pl : listArchiveInstResult) {
+
+ %>
+ <liste>
+ <name><![CDATA[<%= pl.getName() %>]]></name>
+ <type><![CDATA[<%= pl.getType() %>]]></type>
+ <orgId><%= pl.getOrgId() %></orgId>
+ <roleId><%= pl.getRoleId() %></roleId>
+ <listId><%= pl.getListeId() %></listId>
+ <id><![CDATA[<%= pl.getName() %><%= pl.getType() %><%= pl.getOrgId() %><%= pl.getRoleId() %><%= pl.getListeId() %>]]></id>
+ <groupId>5</groupId>
+ <grouping><![CDATA[<%= messages.getString("archives") %>]]></grouping>
+ </liste>
+ <% } %>
+
+
+ <%
+ List<Liste> listPersoResult = new ArrayList<Liste>();
+ String lName = "";
+ for (Liste list : lesListes) {
+ listName = "";
+ Map<String, List<ListProperty>> propsMap = ListeLocalServiceUtil.getPropertiesMap(list.getListeId());
+ if (propsMap.containsKey("name") && !propsMap.get("name").isEmpty()){
+ listName = propsMap.get("name").get(0).getValue().toLowerCase();
+ }
+
+ listName = Normalizer.normalize(listName, Normalizer.Form.NFD);
+ String listNameWithNoCute = listName.replaceAll("[^\\p{ASCII}]","");
+
+ //test de recherche
+ String rechercheTemp = recherche.toLowerCase();
+ rechercheTemp = Normalizer.normalize(rechercheTemp, Normalizer.Form.NFD);
+ String rechercheWithNoCute = rechercheTemp.replaceAll("[^\\p{ASCII}]","");
+
+ boolean testContain = listNameWithNoCute.contains(rechercheWithNoCute);
+ boolean testRecherche = (listName.length()>=sizeRecherche && testContain);
+
+ //on test le list name(rech)
+ if (recherche.equals("") || testRecherche) {
+ listPersoResult.add(list);
+ }
+
+ }
+
+ for (Liste l : listPersoResult) {
+ Map<String, List<ListProperty>> propsMapRes = ListeLocalServiceUtil.getPropertiesMap(l.getListeId());
+ lName = propsMapRes.get("name").get(0).getValue();
+ %>
+ <liste>
+ <name><![CDATA[<%= lName %>]]></name>
+ <type>local</type>
+ <orgId></orgId>
+ <roleId></roleId>
+ <listId><%= l.getListeId() %></listId>
+ <id>local<%= l.getListeId() %></id>
+ <groupId>3</groupId>
+ <grouping><![CDATA[<%= messages.getString("personnelles") %>]]></grouping>
+ </liste>
+ <% } %>
+
+ <%
+ List<FriendFolder> listAmisResult = new ArrayList<FriendFolder>();
+ List<FriendFolder> listesAmis= FriendFolderLocalServiceUtil.getFriendFolderByUserIDParentFolderId(user.getUserId(),0);
+ for (FriendFolder ff : listesAmis) {
+ String listAmisName = ff.getName().toLowerCase();
+
+ listAmisName = Normalizer.normalize(listAmisName, Normalizer.Form.NFD);
+ String listNameWithNoCute = listAmisName.replaceAll("[^\\p{ASCII}]","");
+
+ //test de recherche
+ String rechercheTemp = recherche.toLowerCase();
+ rechercheTemp = Normalizer.normalize(rechercheTemp, Normalizer.Form.NFD);
+ String rechercheWithNoCute = rechercheTemp.replaceAll("[^\\p{ASCII}]","");
+
+ boolean testContain = listNameWithNoCute.contains(rechercheWithNoCute);
+ boolean testRecherche = (listAmisName.length()>=sizeRecherche && testContain);
+
+ //on test le list name(rech)
+ if (recherche.equals("") || testRecherche) {
+ listAmisResult.add(ff);
+ }
+
+ }
+
+ for (FriendFolder ff : listAmisResult) {
+ %>
+ <liste>
+ <name><![CDATA[<%= ff.getName() %>]]></name>
+ <type>amis</type>
+ <orgId></orgId>
+ <roleId></roleId>
+ <listId><%= ff.getFriendFolderId() %></listId>
+ <id>amis<%= ff.getFriendFolderId() %></id>
+ <groupId>4</groupId>
+ <grouping><![CDATA[<%= messages.getString("amis") %>]]></grouping>
+ </liste>
+ <% } %>
+
+ <%
+
+ //CAS DES COMMUNAUTES
+ // presente l ensemble des groupes de l'utilisateur
+ LinkedHashMap<String, Object> groupParams = new LinkedHashMap<String, Object>();
+ groupParams.put("usersGroups", new Long(user.getUserId()));
+ groupParams.put("active", Boolean.TRUE);
+ GroupNameComparator gnc = new GroupNameComparator();
+
+ List<Group> resultsTmp = GroupLocalServiceUtil.search(user.getCompanyId(), null, null, groupParams, QueryUtil.ALL_POS, QueryUtil.ALL_POS, gnc);
+
+ List<Group> groupListResult = new ArrayList<Group>();
+
+ for (Group gTmp: resultsTmp) {
+ try {
+ CommunityInfos ci = CommunityInfosLocalServiceUtil.getCommunityInfosByGroupId(gTmp.getGroupId());
+ if (ci.getStatus()==0) {
+ String name = gTmp.getName().toLowerCase();
+ name = Normalizer.normalize(name, Normalizer.Form.NFD);
+ String listNameWithNoCute = name.replaceAll("[^\\p{ASCII}]","");
+
+ //test de recherche
+ String rechercheTemp = recherche.toLowerCase();
+ rechercheTemp = Normalizer.normalize(rechercheTemp, Normalizer.Form.NFD);
+ String rechercheWithNoCute = rechercheTemp.replaceAll("[^\\p{ASCII}]","");
+
+ boolean testContain = listNameWithNoCute.contains(rechercheWithNoCute);
+ boolean testRecherche = (name.length()>=sizeRecherche && testContain);
+
+ //on test le list name(rech)
+ if (recherche.equals("") || testRecherche) {
+ groupListResult.add(gTmp);
+ }
+ }
+ }
+ catch(Exception e) {
+ // aucune info pour ce groupe --> surement le groupe Guest
+ }
+ }
+
+ for (Group gr : groupListResult) {
+ %>
+ <liste>
+ <name><![CDATA[<%= gr.getName() %>]]></name>
+ <type>search</type>
+ <orgId></orgId>
+ <roleId></roleId>
+ <listId><%= gr.getGroupId() %></listId>
+ <id>groupsearch<%= gr.getGroupId() %></id>
+ <groupId>3</groupId>
+ <grouping><![CDATA[<%= messages.getString("personnelles") %>]]></grouping>
+ </liste>
+ <% } %>
+
+
+</listes>