--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+<%
+ /**
+*Copyright © Igor Barma, Alexandre Desoubeaux, Christian Martel, Eric Brun, Mathieu Amblard, Gwenael Gevet, Pierre Guillot, 2012
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Alexandre Lefevre, Marc Salvat 2014-2016
+ * Copyright Alexandre Desoubeaux, Christian Martel, Cedric Lecarpentier, Marc Salvat, Marc Suarez, Harifetra Ramamonjy 2017
+*
+*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>.
+*/
+%>
+<%@page import="com.liferay.portal.webserver.WebServerServletTokenUtil"%>
+<%@page import="com.pentila.entSavoie.carnetDAdresses.FicheConstant"%>
+<%@page import="com.pentila.entSavoie.userProperties.model.UserProperties"%>
+<%@page import="com.pentila.entSavoie.userProperties.service.UserPropertiesLocalServiceUtil"%>
+<%@page import="com.pentila.entSavoie.carnetDAdresses.service.FicheLocalServiceUtil"%>
+<%@page import="com.liferay.portal.kernel.util.ParamUtil"%>
+<%@page import="com.pentila.entSavoie.carnetDAdresses.model.Fiche"%>
+<%@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"%>
+<%@ include file="/init.jsp" %>
+
+<%@page import="java.util.ArrayList"%>
+
+<%
+ //Recupère l'ensemble des listes de l'utilisateur
+
+ renderResponse.setContentType("text/xml");
+ response.setContentType("text/xml");
+ response.setHeader(HttpHeaders.CACHE_CONTROL, "no-cache");
+
+
+
+ final long contactIdR = ParamUtil.getLong(renderRequest, "contactId");
+ final String contactType = ParamUtil.getString(renderRequest, "contactType");
+
+ if (contactType.equals("fiche")) {
+
+ final Fiche contactFiche = FicheLocalServiceUtil.getFiche(contactIdR);
+%>
+
+
+
+<%@page import="com.liferay.portal.service.ExtUserLocalServiceUtil"%>
+<%@page import="com.liferay.portal.model.User"%>
+<%@page import="com.liferay.portal.model.Organization"%>
+
+<%@page import="com.pentila.entSavoie.ENTDisplayUtil"%>
+
+<%@page import="java.util.LinkedList"%>
+<%@page import="java.util.Iterator"%>
+<%@page import="com.liferay.portal.kernel.json.JSONObject"%>
+<%@page import="com.liferay.portal.kernel.json.JSONFactoryUtil"%>
+<%@page import="com.pentila.entSavoie.utils.ENTMainUtilsLocalServiceUtil"%>
+
+<fiches>
+ <fiche>
+ <id><%=contactFiche.getFicheId()%></id>
+ <relUserId><%=contactFiche.getRelUserId()%></relUserId>
+ <%
+ JSONObject properties = JSONFactoryUtil.createJSONObject(contactFiche.getProperties());
+
+ for(String property: FicheConstant.PROPERTIES){
+ if (property.equals(FicheConstant.ORGANIZATION)) {
+ String[] org = properties.getString(property).split(",");
+ String lesOrgs = "";
+ // on prend les informations importantes
+ if (org.length==0) {
+ lesOrgs = "";
+ }
+ else if(org.length==1) {
+ lesOrgs = org[0];
+ }
+ else {
+ lesOrgs = org[0] + ", " + org [1];
+ }
+ %> <<%= property %>><![CDATA[<%=lesOrgs%>]]></<%= property %>>
+ <%
+ } else {
+ String email = "";
+ if(property.equals("email")){
+ email = properties.getString(property);
+ if(contactFiche.getRelUserId() != 0) {
+ User u = ExtUserLocalServiceUtil.getUser(contactFiche.getRelUserId());
+ final String cartableSuffixMail = ENTMainUtilsLocalServiceUtil.getENTOrgRootSuffixeMail(u.getCompanyId());
+
+ if(email.contains(cartableSuffixMail)){
+ email = "";
+ }
+ }
+ %>
+ <<%= property %>><![CDATA[<%=email%>]]></<%= property %>>
+ <%
+ } else {
+ %>
+ <<%= property %>><![CDATA[<%=properties.getString(property)%>]]></<%= property %>>
+ <%
+ }}}
+ %>
+ <%
+ if(contactFiche.getRelUserId() != 0) {
+
+
+ User u = ExtUserLocalServiceUtil.getUser(contactFiche.getRelUserId());
+
+ String url = "";
+
+ if (u.isFemale()) {
+ url = themeDisplay.getPathImage() + "/user_female_portrait?img_id=";
+ } else {
+ url = themeDisplay.getPathImage() + "/user_male_portrait?img_id=";
+ }
+
+ boolean portraitVisible = true;
+
+ try {
+ UserProperties up = UserPropertiesLocalServiceUtil.getUserPropertiesByUserId(contactFiche.getRelUserId());
+ portraitVisible = up.getPortraitVisible();
+ } catch (Exception e){
+ }
+
+ String urlImg = "";
+
+ if(portraitVisible){
+ urlImg = url + u.getPortraitId() + "&t=" + WebServerServletTokenUtil.getToken(u.getPortraitId());
+ } else {
+ urlImg = url + "0";
+ }
+ %> <urlImage><![CDATA[<%=urlImg%>]]></urlImage> <%
+ }
+ %>
+ </fiche>
+</fiches>
+
+<%
+ }
+ if (contactType.equals("user")) {
+
+ // on est dans le cas d'un contact provenant d'une organisation --> on recupere le user depuis la plateforme
+ User u = ExtUserLocalServiceUtil.getUser(contactIdR);
+
+ String url = "";
+
+ if (u.isFemale()) {
+ url = themeDisplay.getPathImage() + "/user_female_portrait?img_id=";
+ } else {
+ url = themeDisplay.getPathImage() + "/user_male_portrait?img_id=";
+ }
+
+ boolean portraitVisible = true;
+
+ try {
+ UserProperties up = UserPropertiesLocalServiceUtil.getUserPropertiesByUserId(contactIdR);
+ portraitVisible = up.getPortraitVisible();
+ } catch (Exception e){
+ }
+
+ String urlImg = "";
+
+ if(portraitVisible){
+ urlImg = url + u.getPortraitId() + "&t=" + WebServerServletTokenUtil.getToken(u.getPortraitId());
+ } else {
+ urlImg = url + "0";
+ }
+
+ List<Organization> orgs = u.getOrganizations();
+ int i = 0;
+ StringBuilder listOrga = new StringBuilder();
+ List<String> selectedOrgs = new LinkedList<String>();
+ for (Organization o : orgs) {
+ if (o.getSuborganizationsSize()>0) {
+ selectedOrgs.add(ENTDisplayUtil.formatSCONETName(user, o.getName()));
+ i++;
+ }
+ }
+ Iterator<String> it = selectedOrgs.iterator();
+ while (it.hasNext()) {
+ listOrga.append(it.next());
+ if (it.hasNext()) {
+ listOrga.append(", ");
+ }
+ }
+
+ UserProperties up = null;
+ try{
+ up = UserPropertiesLocalServiceUtil.getUserPropertiesByUserId(u.getUserId());
+ } catch(Exception e){
+ e.printStackTrace();
+ }
+
+ String nom = u.getLastName();
+ String prenom = u.getFirstName();
+ String email = u.getEmailAddress();
+ StringBuilder organisation = listOrga;
+ String phone = "";
+ String mobile = "";
+ String fax = "";
+ String address = "";
+ String city = "";
+ String postCode = "";
+ String note = "";
+ final String academicSuffixMail = ENTMainUtilsLocalServiceUtil.getMailAcademicSuffix(u.getCompanyId());
+ final String cartableSuffixMail = ENTMainUtilsLocalServiceUtil.getENTOrgRootSuffixeMail(u.getCompanyId());
+
+
+ if(!up.getDetails().isEmpty()){
+ JSONObject details = JSONFactoryUtil.createJSONObject(up.getDetails());
+
+ boolean shareDetails = up.isShareDetails();
+ if(shareDetails){
+ if(!details.getString("email").contains(academicSuffixMail)){
+ if(!details.getString("email").equals("")){
+ email = details.getString("email");
+ }
+ }
+ phone = details.getString("phone");
+ mobile = details.getString("mobile");
+ fax = details.getString("fax");
+ address = details.getString("address");
+ city = details.getString("city");
+ postCode = details.getString("postCode");
+ note = details.getString("note");
+ }
+ }
+
+ if(email.contains(cartableSuffixMail)){
+ email = "";
+ }
+%>
+
+ <fiches>
+ <fiche>
+ <id><%= contactIdR %></id>
+ <relUserId><%= contactIdR %></relUserId>
+ <nom><%= nom %></nom>
+ <prenom><%= prenom %></prenom>
+ <email><%= email %></email>
+ <organisation><%= organisation %></organisation>
+ <phone><%= phone %></phone>
+ <mobile><%= mobile %></mobile>
+ <fax><%= fax %></fax>
+ <adresse><%= address %></adresse>
+ <ville><%= city %></ville>
+ <codepostal><%= postCode %></codepostal>
+ <note><%= note %></note>
+ <urlImage><![CDATA[<%= urlImg %>]]></urlImage>
+ </fiche>
+ </fiches>
+
+<% } %>