/*
 * $Id: InitTag.java,v 1.10 2006/02/27 16:16:22 marbobo Exp $
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 *
 * $Log: InitTag.java,v $
 * Revision 1.10  2006/02/27 16:16:22  marbobo
 * + Systemsichten hinzugefügt
 * + SysLinks angepasst
 * + Benutzer können falls gewünscht Dokumentqueries anlegen
 *
 * Revision 1.9  2004/07/20 09:11:59  jonyp
 * added copyright info + cvs log
 *
 *
 */

package vkc.view.tag;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import vkc.db.entities.VKCUser;
import vkc.view.TabId;
import vkc.view.WebShare;

/**
 * Class handles the custom tag "init"
 * <p>
 * @author Hardy Höfer
 */
public final class InitTag extends TagSupport {
    public int doEndTag() throws JspException {
        HttpServletRequest request  = (HttpServletRequest) pageContext.getRequest();
        HttpSession session  = request.getSession();
        
        int tabId = TabId.DOCUMENT_TAB;
        
        if (request.getParameter("tabId") != null) {
            tabId = Integer.parseInt(request.getParameter("tabId"));
        }

        VKCUser user = (VKCUser)session.getAttribute(WebShare.USER_KEY);
        
        if (user != null) {
            request.setAttribute("user", user);
            request.setAttribute("tabId", new Integer(tabId));
            request.setAttribute("ctxPath", request.getContextPath());
            request.setAttribute("template", user.getTemplate().getName());
			request.setAttribute("categorySettings", WebShare.getCategorySettings());
			request.setAttribute("documentViewSettings", WebShare.getDocumentViewSettings(user.getUserId()));
        }
        
        return EVAL_PAGE;
    }

    public int doStartTag() throws JspException {
        return SKIP_BODY;
    }
}