--- /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.liferay.portal.kernel.util.Validator"%>
+<%@page import="com.liferay.portal.model.RoleConstants"%>
+<%@page import="com.liferay.portal.service.RoleLocalServiceUtil"%>
+<%@page import="com.pentila.entSavoie.chat.service.ChatClassRestrictionLocalServiceUtil"%>
+<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
+<%@page import="javax.portlet.PortletMode"%>
+<%@page import="javax.portlet.PortletURL"%>
+<%@page import="com.pentila.entSavoie.ENTRolesConstants"%>
+<%@page import="com.liferay.portal.model.Role"%>
+<%@page import="com.pentila.entSavoie.ENTRoleUtilFactory"%>
+<%@page import="com.pentila.entSavoie.ENTRolesUtil"%>
+<%@page import="com.pentila.entSavoie.utils.ENTMainUtilsLocalServiceUtil"%>
+<%@page import="com.pentila.entSavoie.userProperties.model.UserProperties"%>
+<%@page import="com.pentila.entSavoie.userProperties.service.UserPropertiesLocalServiceUtil"%>
+<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
+<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
+<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
+<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
+<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %>
+<%@page import="com.pentila.entSavoie.chat.model.ChatActive"%>
+<%@page import="java.util.List"%>
+<%@page import="com.pentila.entSavoie.chat.service.ChatActiveLocalServiceUtil"%>
+<%@page import="com.liferay.portal.model.Organization"%>
+<%@page import="com.pentila.entSavoie.directory.OrganizationFinderServiceUtil"%>
+
+<%@page import="com.liferay.portal.service.PortletLocalServiceUtil"%>
+<%@page import="com.liferay.portal.model.Portlet"%>
+<%@page import="com.liferay.portal.util.PortalUtil"%>
+<%
+/**
+ * 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.
+ */
+%>
+
+<portlet:defineObjects />
+<liferay-theme:defineObjects/>
+
+<%
+
+ final PortletURL renderURLAjax = renderResponse.createRenderURL();
+ renderURLAjax.setPortletMode(PortletMode.VIEW);
+ renderURLAjax.setWindowState(LiferayWindowState.EXCLUSIVE);
+
+ final String renderURLAjaxString = renderURLAjax.toString();
+
+ Portlet portlet = PortletLocalServiceUtil.getPortletById(company.getCompanyId(), portletDisplay.getId());
+ Organization etab = OrganizationFinderServiceUtil.getEtabRatachement(user);
+
+ ChatActive ca = null;
+
+ if(Validator.isNotNull(etab)){
+ ca = ChatActiveLocalServiceUtil.getChatActiveByOrganizationId(etab.getOrganizationId());
+ }
+
+ UserProperties prop = UserPropertiesLocalServiceUtil.getUserPropertiesByUserId(user.getUserId());
+
+ if (ca != null && ENTMainUtilsLocalServiceUtil.isXmppEnable(etab.getCompanyId())) {
+ if (ca.isActive() && prop.getJabberId() != null && !prop.getJabberId().equals("")) {
+
+ boolean showConfig = false;
+ boolean isEleve = false;
+ boolean showChat = true;
+
+ Role administratorGrpRole = RoleLocalServiceUtil.getRole(user.getCompanyId(), RoleConstants.ADMINISTRATOR);
+ Boolean isAdministrator = RoleLocalServiceUtil.hasUserRole(user.getUserId(), administratorGrpRole.getRoleId());
+
+ ENTRolesUtil ru = ENTRoleUtilFactory.getInstance(user.getCompanyId());
+ for (Role r : ru.getENTRoles(user)) {
+ if (isAdministrator || r.getName().equals(ENTRolesConstants.NATIONAL_3) || r.getName().equals(ENTRolesConstants.NATIONAL_4) || r.getName().equals(ENTRolesConstants.GROUP_ADMIN)) {
+ showConfig = true;
+ break;
+ }
+ if (r.getName().equals(ENTRolesConstants.NATIONAL_1)) {
+ isEleve = true;
+ break;
+ }
+
+ }
+
+ //on traite les locale
+ String defaultLoc = "fr";
+ if (!locale.getLanguage().equals("")) {
+ defaultLoc = locale.getLanguage();
+ }
+
+ if (isEleve) {
+ if (ChatClassRestrictionLocalServiceUtil.hasRestriction(user.getUserId())) {
+ showChat = false;
+ }
+ }
+
+ //if (showChat) {
+%>
+ <script src="<%= PortalUtil.getStaticResourceURL(request, request.getContextPath() + "/js/configWindow.js", portlet.getTimestamp()) %>" type="text/javascript"></script>
+ <script src="<%= PortalUtil.getStaticResourceURL(request, request.getContextPath() + "/js/locale/app-lang-" + defaultLoc + ".js", portlet.getTimestamp()) %>" type="text/javascript"></script>
+ <script src="<%= PortalUtil.getStaticResourceURL(request, request.getContextPath() + "/js/utilities.js", portlet.getTimestamp()) %>" type="text/javascript"></script>
+
+ <%
+ //for local configuration with cross-domain enable :
+ //<script type="text/javascript" src="http://tice-a116.univ-savoie.fr/jappix/php/get.php?l=fr&t=js&g=mini.xml"></script>
+ %>
+
+ <% //!<---------- ATTENTION ---------->! %>
+ <% //for (pre)production configuration with apache proxy enable : %>
+ <script src="<%= PortalUtil.getStaticResourceURL(request, request.getContextPath() + "/js/browser-detect.js", portlet.getTimestamp()) %>" type="text/javascript"></script>
+ <script src="<%= PortalUtil.getStaticResourceURL(request, request.getContextPath() + "/js/constants.js", portlet.getTimestamp()) %>" type="text/javascript"></script>
+ <script src="<%= PortalUtil.getStaticResourceURL(request, request.getContextPath() + "/js/datastore.js", portlet.getTimestamp()) %>" type="text/javascript"></script>
+ <script src="<%= PortalUtil.getStaticResourceURL(request, request.getContextPath() + "/js/jquery.timers.js", portlet.getTimestamp()) %>" type="text/javascript"></script>
+ <script src="<%= PortalUtil.getStaticResourceURL(request, request.getContextPath() + "/js/date.js", portlet.getTimestamp()) %>" type="text/javascript"></script>
+ <script src="<%= PortalUtil.getStaticResourceURL(request, request.getContextPath() + "/js/filter.js", portlet.getTimestamp()) %>" type="text/javascript"></script>
+ <script src="<%= PortalUtil.getStaticResourceURL(request, request.getContextPath() + "/js/jxhr.js", portlet.getTimestamp()) %>" type="text/javascript"></script>
+ <% //!<------------------------------->! %>
+
+ <script src="<%= PortalUtil.getStaticResourceURL(request, request.getContextPath() + "/js/jsjac.js", portlet.getTimestamp()) %>" type="text/javascript"></script>
+ <script src="<%= PortalUtil.getStaticResourceURL(request, request.getContextPath() + "/js/mini.js", portlet.getTimestamp()) %>" type="text/javascript"></script>
+
+ <script type="text/javascript">
+ jQuery(document).ready(function() {
+
+ // Define groupchats here (useless)
+ MINI_GROUPCHATS = [];
+ MINI_PASSWORDS = [];
+
+ // Add an animation
+ MINI_ANIMATE = true;
+
+ // Define the user nickname
+ MINI_NICKNAME = "<%= user.getFullName() %>";
+
+ // Override the default session resource
+ MINI_RESOURCE = "Cartable-de-savoie";
+
+ SHOW_CONFIG = <%=showConfig%>;
+
+ if (SHOW_CONFIG) {
+ configWindow = new EntSavoie.Chat.ConfigWindow({
+ renderURLAjax : "<%= renderURLAjaxString %>",
+ actionURLAjax: '<portlet:resourceURL />'
+ });
+ }
+
+ // !<---------- ATTENTION ---------->!
+ //Enable this 2 var in (pre)prod env only :
+ //
+ JAPPIX_STATIC = "<%= request.getContextPath() %>";
+ HOST_BOSH = '/http-bind/';
+ // !<------------------------------->!
+
+ SHOW_CHAT = <%=showChat%>;
+ // Connect the user (autoconnect, show_pane, domain, username, password)
+ // Notice: put true/false to autoconnect and show_pane
+ // Notice: only put the domain if using anonymous login
+ if (SHOW_CHAT) {
+ launchMini(true, true, "<%= ENTMainUtilsLocalServiceUtil.getXmppDomain(etab.getCompanyId()) %>", "<%= prop.getJabberId() %>", "<%= prop.getJabberPwd() %>", SHOW_CONFIG);
+ }
+ else {
+ showDisableMsg();
+ }
+
+ });
+ </script>
+
+<%
+ //}
+ }
+
+ }
+
+%>