--- /dev/null
+/*******************************************************************************
+ * 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>.
+ ******************************************************************************/
+/**
+ * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package com.pentila.entSavoie.portlets.annuaire;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import javax.naming.NamingException;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.ResourceRequest;
+import javax.portlet.ResourceResponse;
+import javax.servlet.http.HttpServletResponse;
+
+import com.liferay.portal.kernel.dao.orm.QueryUtil;
+import com.liferay.portal.kernel.dao.search.DAOParamUtil;
+import com.liferay.portal.kernel.exception.PortalException;
+import com.liferay.portal.kernel.exception.SystemException;
+import com.liferay.portal.kernel.json.JSONFactoryUtil;
+import com.liferay.portal.kernel.json.JSONObject;
+import com.liferay.portal.kernel.log.Log;
+import com.liferay.portal.kernel.log.LogFactoryUtil;
+import com.liferay.portal.kernel.servlet.SessionErrors;
+import com.liferay.portal.kernel.util.ContentTypes;
+import com.liferay.portal.kernel.util.OrderByComparator;
+import com.liferay.portal.kernel.util.ParamUtil;
+import com.liferay.portal.kernel.util.Validator;
+import com.liferay.portal.kernel.util.WebKeys;
+import com.liferay.portal.kernel.workflow.WorkflowConstants;
+import com.liferay.portal.model.Organization;
+import com.liferay.portal.model.User;
+import com.liferay.portal.service.RoleLocalServiceUtil;
+import com.liferay.portal.service.UserLocalServiceUtil;
+import com.liferay.portal.theme.ThemeDisplay;
+import com.liferay.portal.util.PortalUtil;
+import com.liferay.portal.util.comparator.UserLastNameComparator;
+import com.liferay.portal.webserver.WebServerServletTokenUtil;
+import com.pentila.entSavoie.ENTDisplayUtil;
+import com.pentila.entSavoie.ENTRoleUtilFactory;
+import com.pentila.entSavoie.ENTRolesConstants;
+import com.pentila.entSavoie.carnetDAdresses.model.Fiche;
+import com.pentila.entSavoie.carnetDAdresses.model.Liste;
+import com.pentila.entSavoie.carnetDAdresses.service.FicheLocalServiceUtil;
+import com.pentila.entSavoie.carnetDAdresses.service.ListeLocalServiceUtil;
+import com.pentila.entSavoie.directory.OrganizationFinderServiceUtil;
+import com.pentila.entSavoie.userProperties.model.UserProperties;
+import com.pentila.entSavoie.userProperties.service.UserPropertiesLocalServiceUtil;
+import com.pentila.entSavoie.utils.ENTMainUtilsLocalServiceUtil;
+import com.pentila.entSavoie.utils.JSPPortletUtil;
+import com.pentila.entSavoie.utils.LDAPUtilsLocalServiceUtil;
+
+/**
+ * <a href="JSPPortlet.java.html"><b><i>View Source</i></b></a>
+ *
+ * @author Brian Wing Shun Chan
+ *
+ */
+public class JSPPortlet extends GenericPortlet {
+
+ public void init() throws PortletException {
+ editJSP = getInitParameter("edit-jsp");
+ helpJSP = getInitParameter("help-jsp");
+ viewJSP = getInitParameter("view-jsp");
+ }
+
+ public void doDispatch(
+ RenderRequest renderRequest, RenderResponse renderResponse)
+ throws IOException, PortletException {
+
+ String jspPage = renderRequest.getParameter("jspPage");
+
+ if (jspPage != null) {
+ include(jspPage, renderRequest, renderResponse);
+ }
+ else {
+ super.doDispatch(renderRequest, renderResponse);
+ }
+ }
+
+ public void doEdit(
+ RenderRequest renderRequest, RenderResponse renderResponse)
+ throws IOException, PortletException {
+
+ if (renderRequest.getPreferences() == null) {
+ super.doEdit(renderRequest, renderResponse);
+ }
+ else {
+ include(editJSP, renderRequest, renderResponse);
+ }
+ }
+
+ public void doHelp(
+ RenderRequest renderRequest, RenderResponse renderResponse)
+ throws IOException, PortletException {
+
+ include(helpJSP, renderRequest, renderResponse);
+ }
+
+ public void doView(
+ RenderRequest renderRequest, RenderResponse renderResponse)
+ throws IOException, PortletException {
+
+ include(viewJSP, renderRequest, renderResponse);
+ }
+
+ @Override
+ public void serveResource(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
+ throws PortletException, IOException {
+
+ final String cmd = ParamUtil.getString(resourceRequest, "cmd");
+
+ HttpServletResponse httpResponse = PortalUtil.getHttpServletResponse(resourceResponse);
+ httpResponse.setContentType(ContentTypes.APPLICATION_JSON);
+
+ JSONObject result = JSONFactoryUtil.createJSONObject();
+ result.put("success", false);
+
+ if (cmd.equals("addUsersToList")) {
+ try {
+ result = this.addUsersToList(resourceRequest);
+ } catch (Exception e) {
+ _log.error(e);
+ }
+ }
+ else if (cmd.equals("addUsersToNewList")) {
+ try {
+ result = this.addUsersToNewList(resourceRequest);
+ } catch (Exception e) {
+ _log.error(e);
+ }
+ }
+ else if (cmd.equals("createMessage") || cmd.equals("createMessageCasier")) {
+ try {
+ result = this.createMessage(resourceRequest);
+ } catch (Exception e) {
+ if (_log.isErrorEnabled()) {
+ _log.error(e);
+ }
+ SessionErrors.add(resourceRequest, "error");
+ }
+ }
+ else if (cmd.equals("getUserDetails")) {
+ try {
+ result = getUserDetails(resourceRequest);
+ } catch (Exception e) {
+ _log.error(e);
+ }
+ }
+ // Ajout d'un nouveau fichier depuis le disk
+ else if (cmd.equals("addFileEntry")) {
+ try {
+ result = this.addFileEntry(resourceRequest);
+ } catch (Exception e) {
+ //File Size Exception
+ try {
+ User user = PortalUtil.getUser(resourceRequest);
+ ResourceBundle messages = ResourceBundle.getBundle("content.Language", user.getLocale());
+ String messageSizeTooImportant = messages.getString("file-uploaded-overweight");
+ long maxUploadSize = JSPPortletUtil.getSizeInMegaOctet(
+ ENTMainUtilsLocalServiceUtil.getUploadServletRequestMaxSize(user.getCompanyId()));
+ result.put("portal_message", messageSizeTooImportant.replace("$1", String.valueOf(maxUploadSize)));
+ } catch (PortalException e1) {
+ _log.error(e1);
+ } catch (SystemException e1) {
+ _log.error(e1);
+ }
+ }
+ }
+ else if (cmd.equals("useAllResultsAction")) {
+ try {
+ result = this.useAllSearchResult(resourceRequest);
+ } catch (Exception e) {
+ _log.error(e);
+ }
+ }
+ //get the max file upload size
+ else if (cmd.equals("getMaxFileUploadSize")) {
+ try {
+ User user = PortalUtil.getUser(resourceRequest);
+ long uploadMaxSize = ENTMainUtilsLocalServiceUtil.getUploadServletRequestMaxSize(user.getCompanyId());
+ result.put("uploadMaxSize", JSPPortletUtil.getSizeInMegaOctet(uploadMaxSize));
+ result.put("success", true);
+ } catch(Exception e){
+ _log.error(e);
+ }
+ }
+ //Ajout d'une image pour le CKEditor
+ else if(cmd.equals("uploadPictureCKEditor")){
+ try {
+ result = this.uploadPictureCKEditor(resourceRequest);
+ } catch (Exception e) {
+ //File Size Exception
+ _log.error(e);
+ }
+ }
+ //Ajout d'une image sur le ckeditor depuis le cartable
+ else if(cmd.equals("pictureChoosedCKEditor")){
+ try{
+ result = this.pictureChoosedCKEditor(resourceRequest);
+ } catch(Exception e){
+ _log.error(e);
+ }
+ }
+ else if(cmd.equals("countListMember")){
+ try {
+ result = this.countListMember(resourceRequest);
+ } catch (Exception e) {
+ _log.error(e);
+ }
+ }
+
+ httpResponse.getWriter().write(result.toString());
+ }
+
+ public void processAction(
+ ActionRequest actionRequest, ActionResponse actionResponse)
+ throws IOException, PortletException {
+
+ }
+
+ // Création d'un nouveau message
+ private JSONObject createMessage(ResourceRequest resourceRequest) throws NamingException, Exception {
+ return JSPPortletUtil.createMessage(resourceRequest);
+ }
+
+ private JSONObject addUsersToNewList(ResourceRequest resourceRequest) throws PortalException, SystemException {
+ JSONObject result = JSONFactoryUtil.createJSONObject();
+
+ final User currUser = PortalUtil.getUser(resourceRequest);
+ final long groupId = currUser.getGroup().getGroupId();
+ final String name = ParamUtil.getString(resourceRequest, "listName");
+ final long[] userIds = ParamUtil.getLongValues(resourceRequest, "userIds");
+
+ if (Validator.isNull(name) || name.equals("")) {
+ result.put("success", false);
+ return result;
+ }
+ try {
+ if (_log.isDebugEnabled()) {
+ _log.debug("Creation de la liste '"+name+"' dans le groupe "+groupId);
+ }
+ Liste newListe = ListeLocalServiceUtil.addListe(groupId, name);
+
+ Collection<Fiche> createdFiche = FicheLocalServiceUtil.getOrCreateContactFromUsersId(currUser, userIds);
+ List<Long> ficheIdsToAddToList = new ArrayList<Long> ();
+ for (Fiche aUserFiche : createdFiche) {
+ ficheIdsToAddToList.add(aUserFiche.getFicheId());
+ }
+
+ // add contact to list
+ if(ficheIdsToAddToList != null){
+ ListeLocalServiceUtil.insertFichesToAList(newListe.getListeId(), ficheIdsToAddToList);
+ }
+ result.put("success", true);
+
+ } catch (Exception e) {
+ if (_log.isErrorEnabled()) {
+ _log.error(e);
+ }
+ result.put("success", false);
+ }
+
+ return result;
+ }
+
+ /**
+ * Count the number of result
+ * @param resourceRequest HTTP resquest
+ * @param resourceResponse HTTP response
+ * @return the number of user expected in new list, -1 in case of error
+ * @throws PortalException
+ * @throws SystemException
+ */
+ private JSONObject countListMember(ResourceRequest resourceRequest) throws PortalException, SystemException {
+ JSONObject result = JSONFactoryUtil.createJSONObject();
+
+ long listId = ParamUtil.getLong(resourceRequest, "listId", 0);
+
+ try{
+ result.put("size", ListeLocalServiceUtil.countListMember(listId));
+ result.put("success", true);
+ } catch (Exception e) {
+ _log.error(e);
+ result.put("size", -1);
+ result.put("success", true);
+ }
+ return result;
+ }
+
+ private JSONObject useAllSearchResult(ResourceRequest resourceRequest) throws PortalException, SystemException {
+ JSONObject result = JSONFactoryUtil.createJSONObject();
+
+ final User currUser = PortalUtil.getUser(resourceRequest);
+ final long groupId = currUser.getGroup().getGroupId();
+ final String name = ParamUtil.getString(resourceRequest, "listName", "");
+ final long listId = ParamUtil.getLong(resourceRequest, "listId", -1000);
+
+ try {
+ Liste liste = null;
+ if(listId == -1000){
+ if (Validator.isNull(name) || name.equals("")) {
+ result.put("success", false);
+ return result;
+ }
+ liste = ListeLocalServiceUtil.addListe(groupId, name);
+ } else if(listId > 0) {
+ liste = ListeLocalServiceUtil.getListe(listId);
+ }
+
+ List<User> lesUsers = searchUsers(resourceRequest);
+ long[] userIds = new long[lesUsers.size()];
+ int i = 0;
+ for(User aUser: lesUsers){
+ userIds[i] = aUser.getUserId();
+ i++;
+ }
+
+ // create all contact fiche
+ Collection<Fiche> createdFiche = FicheLocalServiceUtil.getOrCreateContactFromUsersId(currUser, userIds);
+ List<Long> ficheIdsToAddToList = new ArrayList<Long> ();
+ for (Fiche aUserFiche : createdFiche) {
+ ficheIdsToAddToList.add(aUserFiche.getFicheId());
+ }
+
+ // add contact to list
+ if(ficheIdsToAddToList != null){
+ ListeLocalServiceUtil.insertFichesToAList(liste.getListeId(), ficheIdsToAddToList);
+ }
+ result.put("success", true);
+ } catch (Exception e) {
+ _log.error(e);
+ result.put("success", false);
+ }
+
+ return result;
+ }
+
+ private JSONObject addUsersToList(ResourceRequest resourceRequest) throws PortalException, SystemException {
+ JSONObject result = JSONFactoryUtil.createJSONObject();
+
+ final User currUser = PortalUtil.getUser(resourceRequest);
+ final long listeId = ParamUtil.getLong(resourceRequest, "listId");
+ final long[] userIds = ParamUtil.getLongValues(resourceRequest, "userIds");
+
+ // on traite le cas des users
+ try {
+ Collection<Fiche> createdFiche = FicheLocalServiceUtil.getOrCreateContactFromUsersId(currUser, userIds);
+ List<Long> ficheIdsToAddToList = new ArrayList<Long> ();
+ for (Fiche aUserFiche : createdFiche) {
+ ficheIdsToAddToList.add(aUserFiche.getFicheId());
+ }
+
+ // add contact to list
+ if(ficheIdsToAddToList != null){
+ ListeLocalServiceUtil.insertFichesToAList(listeId, ficheIdsToAddToList);
+ }
+ result.put("success", true);
+
+ } catch (SystemException e) {
+ if (_log.isErrorEnabled()) {
+ _log.error(e);
+ }
+ result.put("success", false);
+ }
+
+ return result;
+ }
+
+ private List<User> searchUsers(ResourceRequest resourceRequest) throws NamingException, Exception{
+
+ final User currUser = PortalUtil.getUser(resourceRequest);
+ //Recuperation des parametres de recherche
+ final String firstName = DAOParamUtil.getLike(resourceRequest, "firstName", null);
+ final String middleName = null;
+ final String lastName = DAOParamUtil.getLike(resourceRequest, "lastName", null);
+ final String email = null;
+ long roleId = ParamUtil.getLong(resourceRequest, "statut", 0);
+ long organizationId = ParamUtil.getLong(resourceRequest, "organizationId", 0);
+ long etabId = ParamUtil.getLong(resourceRequest, "etabId", 0);
+ long matiereId = ParamUtil.getLong(resourceRequest, "matiereId", 0);
+
+ long[] etabStore = ParamUtil.getLongValues(resourceRequest, "etabStore", null);
+
+ final LinkedHashMap<String, Object> userParams = new LinkedHashMap<String, Object>();
+
+ // si restriction --> uniquement l'etab de rattachement
+ if (OrganizationFinderServiceUtil.hasRestriction(currUser)) {
+ final Organization etabRattach = OrganizationFinderServiceUtil.getEtabRatachement(currUser);
+ etabId = etabRattach.getOrganizationId();
+ }
+ //si eleve --> uniquement sur des users eleves
+ if (RoleLocalServiceUtil.hasUserRole(currUser.getUserId(), currUser.getCompanyId(),
+ ENTRolesConstants.NATIONAL_1, false)) {
+ roleId = ENTRoleUtilFactory.getInstance(currUser.getCompanyId()).getRole(ENTRolesConstants.NATIONAL_1).getRoleId();
+ }
+
+ //Filtrage sur les roles et organisations.
+
+ //If a shool is selected we search only in this one, else we look for restrictions in which case we search only in the user etab
+ //or we choose a shool list depending on the user role
+ if (organizationId>0) {
+ userParams.put("usersOrgs", new Long(organizationId));
+ } else if (etabId>0) { //If user has restrictions
+ userParams.put("usersOrgs", new Long(etabId));
+ } else {
+ //we delete the first empty value from the array
+ Long[] etabList = new Long[etabStore.length-1];
+ for (int i=1 ; i<etabStore.length ; ++i) {
+ etabList[i-1] = etabStore[i];
+ }
+ userParams.put("usersOrgs", etabList);
+ }
+
+ //Filtrage sur les roles
+ if (roleId>0){
+ userParams.put("usersRoles", new Long(roleId));
+ }
+
+ // filtre sur les matieres
+ if (matiereId>0) {
+ userParams.put("userEnseignement", new Long(matiereId));
+ }
+
+ //cas par defaut
+ OrderByComparator odb = new UserLastNameComparator();
+
+ return UserLocalServiceUtil.search(
+ currUser.getCompanyId(),
+ firstName,
+ middleName,
+ lastName,
+ null,
+ email,
+ WorkflowConstants.STATUS_APPROVED,
+ userParams,
+ true,
+ QueryUtil.ALL_POS,
+ QueryUtil.ALL_POS,
+ odb);
+ }
+
+ // Ajout d'un nouveau fichier depluis le disk
+ private JSONObject addFileEntry(ResourceRequest resourceRequest) throws PortalException, SystemException {
+ final User user = PortalUtil.getUser(resourceRequest);
+ ResourceBundle messages = ResourceBundle.getBundle("content.Language", user.getLocale());
+
+ return JSPPortletUtil.addFileEntry(resourceRequest, messages);
+ }
+
+ //Ajout d'une image sur le ckeditor depuis le cartable
+ private JSONObject pictureChoosedCKEditor(ResourceRequest resourceRequest) throws PortalException, SystemException, IOException {
+ return JSPPortletUtil.pictureChoosedCKEditor(resourceRequest);
+ }
+
+ //Ajout d'une image pour le CKEditor
+ private JSONObject uploadPictureCKEditor(ResourceRequest resourceRequest) throws PortalException, SystemException, IOException {
+ return JSPPortletUtil.uploadPictureCKEditor(resourceRequest);
+ }
+
+ private JSONObject getUserDetails(ResourceRequest resourceRequest) throws Exception {
+ JSONObject result = JSONFactoryUtil.createJSONObject();
+
+ long userId = ParamUtil.getLong(resourceRequest, "userId");
+ final User u = UserLocalServiceUtil.getUser(userId);
+ final User curUser = PortalUtil.getUser(resourceRequest);
+
+ ResourceBundle messages = ResourceBundle.getBundle("content.Language", curUser.getLocale());
+ ThemeDisplay themeDisplay = (ThemeDisplay) resourceRequest.getAttribute(WebKeys.THEME_DISPLAY);
+
+
+ UserProperties up = null;
+ try{
+ up = UserPropertiesLocalServiceUtil.getUserPropertiesByUserId(u.getUserId());
+ } catch(Exception e){
+ _log.error(e);
+ }
+
+ JSONObject details = JSONFactoryUtil.createJSONObject(up.getDetails());
+
+ String status = ENTDisplayUtil.displayUserRoles(curUser, u);
+
+ if(u.getRoles().contains(RoleLocalServiceUtil.getRole(curUser.getCompanyId(), ENTRolesConstants.NATIONAL_1))){
+ status += " - " + LDAPUtilsLocalServiceUtil.getStudentClassName(u);
+
+ }
+
+ 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 {
+ 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();
+ StringBuilder listOrga = new StringBuilder();
+ List<String> selectedOrgs = new LinkedList<String>();
+ for (Organization o : orgs) {
+ if (o.getSuborganizationsSize()>0) {
+ selectedOrgs.add(ENTDisplayUtil.formatSCONETName(curUser, o.getName()));
+ }
+ }
+ Iterator<String> it = selectedOrgs.iterator();
+ while (it.hasNext()) {
+ listOrga.append(it.next());
+ if (it.hasNext()) {
+ listOrga.append(", ");
+ }
+ }
+
+ boolean shareDetails = up.isShareDetails();
+ 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(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 = messages.getString("pas-d-information");
+ }else{
+ email = "<a href= \"mailto:"+ email + "\">" + email + "</a>";
+ }
+
+ String phoneSt = messages.getString("phone");
+ String mobileSt = messages.getString("mobile");
+ String faxSt = messages.getString("fax");
+ String mailSt = messages.getString("mail");
+
+ String adresseComplete = "";
+ if(address.equals("") && postCode.equals("") && city.equals("")){
+ adresseComplete = "<i>" + messages.getString("pas-d-information") + "</i>";
+ }else{
+ adresseComplete = "<p>" +address + " - " + postCode + " " + city + "</p>";
+ }
+
+
+ String html = "<table width=\"100%\" border=0>" +
+ "<tr align=\"center\">" +
+ "<td rowspan=\"4\" width=\"200\"><img height=\"190\" width=\"160\" src=\""+urlImg + "\"/></td>" +
+ "<td colspan=2 width=\"250\"><p>" + prenom + " " + nom + " <br/><i>" + status + "</i></p></td>" +
+ "</tr>" +
+ "<tr align=\"center\">" +
+ "<td colspan=2><p>" + organisation + "</p></td>" +
+ "</tr>" +
+ "<tr align=\"left\">" +
+ "<td width=\"150\"><b>"+ messages.getString("adresse") + "</b> : " + adresseComplete + "</td>" +
+ "<td width=\"150\"><p><b>"+ phoneSt + "</b> : " + phone + "<br/><b>" + mobileSt + "</b> : " + mobile + "<br/><b>" + faxSt + "</b> : " + fax +"<br/><b>"+ mailSt + "</b> : <i>" + email + "</i></p></td>" +
+ "</tr>" +
+ "<tr align=\"left\">" +
+ "<td colspan=2><p>" + note +"</p></td>" +
+ "</tr>" +
+ "</table>";
+
+ result.put("html", html);
+ result.put("success", true);
+
+ return result;
+ }
+
+ protected void include(
+ String path, RenderRequest renderRequest,
+ RenderResponse renderResponse)
+ throws IOException, PortletException {
+
+ PortletRequestDispatcher portletRequestDispatcher =
+ getPortletContext().getRequestDispatcher(path);
+
+ if (portletRequestDispatcher == null) {
+ _log.error(path + " is not a valid include");
+ }
+ else {
+ portletRequestDispatcher.include(renderRequest, renderResponse);
+ }
+ }
+
+ protected String editJSP;
+ protected String helpJSP;
+ protected String viewJSP;
+
+ private static Log _log = LogFactoryUtil.getLog(JSPPortlet.class);
+
+}