--- /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>.
+*/ %>
+<%@page import="com.pentila.entSavoie.incidents.util.IncidentsUtils"%>
+<%@page import="com.pentila.entSavoie.gestionMenus.service.InternationalMenuLocalServiceUtil"%>
+<%@page import="com.pentila.entSavoie.gestionMenus.model.InternationalMenu"%>
+<%@page import="java.util.HashMap"%>
+<%@page import="java.util.Map"%>
+<%@page import="com.liferay.portal.service.LayoutLocalServiceUtil"%>
+<%@page import="com.liferay.portal.model.Layout"%>
+<%@page import="com.pentila.entSavoie.gestionMenus.service.EntityMenuLocalServiceUtil"%>
+<%@page import="java.util.List"%>
+<%@page import="com.pentila.entSavoie.gestionMenus.model.EntityMenu"%>
+<%@page import="java.util.ArrayList"%>
+<%@page import="com.pentila.entSavoie.directory.OrganizationFinderServiceUtil"%>
+<%@page import="com.liferay.portal.model.Organization"%>
+<%@page import="java.util.ResourceBundle"%>
+<%@ include file="./initAjax.jsp" %>
+
+<%
+ResourceBundle messages = portletConfig.getResourceBundle(locale);
+%>
+
+<%
+
+ JSONObject result = JSONFactoryUtil.createJSONObject();
+ JSONArray items = JSONFactoryUtil.createJSONArray();
+
+ /*JSONObject service = JSONFactoryUtil.createJSONObject();
+ service.put("id", 0);
+ service.put("name", messages.getString("actualite"));
+ items.put(service);
+
+ JSONObject service1 = JSONFactoryUtil.createJSONObject();
+ service1.put("id", 1);
+ service1.put("name", messages.getString("amis"));
+ items.put(service1);
+
+ JSONObject service2 = JSONFactoryUtil.createJSONObject();
+ service2.put("id", 2);
+ service2.put("name", messages.getString("annuaire"));
+ items.put(service2);
+
+ JSONObject service3 = JSONFactoryUtil.createJSONObject();
+ service3.put("id", 3);
+ service3.put("name", messages.getString("carnet-d-adresse"));
+ items.put(service3);
+
+ JSONObject service4 = JSONFactoryUtil.createJSONObject();
+ service4.put("id", 4);
+ service4.put("name", messages.getString("casier"));
+ items.put(service4);
+
+ JSONObject service5 = JSONFactoryUtil.createJSONObject();
+ service5.put("id", 5);
+ service5.put("name", messages.getString("cahier-de-textes"));
+ items.put(service5);
+
+ JSONObject service6 = JSONFactoryUtil.createJSONObject();
+ service6.put("id", 6);
+ service6.put("name", messages.getString("documents"));
+ items.put(service6);
+
+ JSONObject service7 = JSONFactoryUtil.createJSONObject();
+ service7.put("id", 7);
+ service7.put("name", messages.getString("forums"));
+ items.put(service7);
+
+ JSONObject service8 = JSONFactoryUtil.createJSONObject();
+ service8.put("id", 8);
+ service8.put("name", messages.getString("groupes"));
+ items.put(service8);
+
+ JSONObject service9 = JSONFactoryUtil.createJSONObject();
+ service9.put("id", 9);
+ service9.put("name", messages.getString("podcast"));
+ items.put(service9);
+
+ JSONObject service10 = JSONFactoryUtil.createJSONObject();
+ service10.put("id", 10);
+ service10.put("name", messages.getString("messagerie"));
+ items.put(service10);
+
+ JSONObject service11 = JSONFactoryUtil.createJSONObject();
+ service11.put("id", 11);
+ service11.put("name", messages.getString("autres-services"));
+ items.put(service11);*/
+
+ // pages privees du user
+ List<Layout> privatePages = LayoutLocalServiceUtil.getLayouts(user.getGroup().getGroupId(), true);
+
+ // on construit un map a partir des pages privees du user
+ Map<String, Layout> privateUserPagesMap = new HashMap<String, Layout>();
+
+ for (Layout l: privatePages) {
+ privateUserPagesMap.put(l.getFriendlyURL(), l);
+ }
+
+ Organization etabRattach = OrganizationFinderServiceUtil.getEtabRatachement(user);
+
+ List<EntityMenu> listEntityMenu = new ArrayList<EntityMenu>(EntityMenuLocalServiceUtil.getEntityMenusByEtabId(etabRattach.getOrganizationId()));
+
+ int i = 1;
+ for (EntityMenu entityMenu : listEntityMenu) {
+ // Si c'est une feuille
+ if (entityMenu.getIsLeaf()) {
+ for (Layout l: IncidentsUtils.getAppliFromUserGrp(entityMenu.getAppRoleId())) {
+ String furl = l.getFriendlyURL();
+ if (privateUserPagesMap.containsKey(furl)) {
+ JSONObject service = JSONFactoryUtil.createJSONObject();
+ service.put("id", i);
+ InternationalMenu im = InternationalMenuLocalServiceUtil.getByEntityMenuId_Locale(entityMenu.getEntityId(), user.getLocale().getLanguage());
+ if(im != null){
+ service.put("name", im.getMenuName());
+ } else {
+ service.put("name", entityMenu.getEntityName());
+ }
+ items.put(service);
+ i++;
+ }
+ }
+ }
+ }
+
+
+ result.put("items", items);
+
+ result.put("success", true);
+
+%>
+<%= result.toString() %>