⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmsloginnew.java

📁 内容管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
             (cms.userInGroup(cms.getRequestContext().currentUser().getName(), C_GROUP_PROJECTLEADER)) ||
             (cms.userInGroup(cms.getRequestContext().currentUser().getName(), C_GROUP_ADMIN)) )) {
            // the user is already logged in and no logout parameter is present, open a new window
            if (DEBUG > 1) System.err.println("CmsLoginNew: re-using old login");            
            xmlTemplateDocument.setData("onload", "onload='login();'");        
        } else {
            // no user logged in, no call to "login()" JavaScript
            if (DEBUG > 1) System.err.println("CmsLoginNew: no login or logout, displaying template");            
            xmlTemplateDocument.setData("onload", "onload='init();'");
        }

        long id = System.currentTimeMillis();
        xmlTemplateDocument.setData("windowId", new Long(id).toString());
        xmlTemplateDocument.setData("startTaskId", startTaskId);
        xmlTemplateDocument.setData("startProjectId", startProjectId);

        if (DEBUG > 1) System.err.println("CmsLoginNew: Login process finished");

        // process the selected template
        return startProcessing(cms, xmlTemplateDocument, "", parameters, templateSelector);
    }

    /**
     * Sets the startup project to the one read from the user
     * preferences or the one from the request parameters.
     * 
     * @param cms the initialized CmsObject
     * @param session the initialized user session 
     * @param startProjectId the id value of the request parameter (might be null)
     * @throws CmeSxception in case of issues reading the registry
     */
    private void setStartProjectId(CmsObject cms, I_CmsSession session, String startProjectId) 
    throws CmsException 
    {
        // set current project to the default online project or to 
        // project specified in the users preferences
        int currentProject = cms.onlineProject().getId();
        
        if ((startProjectId != null) && (! "".equals(startProjectId))) {
            // try to set project to id from parameters
            try {
                currentProject = (new Integer(startProjectId)).intValue();
            } catch (NumberFormatException e) {
                // currentProject will still have online project value
            }            
        } else {    
            // check out the user information if a default project is stored there.
            Hashtable startSettings = (Hashtable)cms.getRequestContext().currentUser().getAdditionalInfo(C_ADDITIONAL_INFO_STARTSETTINGS);
            if(startSettings != null) {
                Integer i = (Integer)startSettings.get(C_START_PROJECT);
                if (i != null) currentProject = i.intValue();
            }
        }

        // try to set the current project
        try {
            if (! cms.accessProject(currentProject)) {
                // user has no access to the project
                currentProject = cms.onlineProject().getId();
            }
        } catch(Exception e) {
            // project will default to online project
            currentProject = cms.onlineProject().getId();
        }
        
        // set the current project id
        cms.getRequestContext().setCurrentProject(currentProject);
    }

    /**
     * Sets the startup view to display the selected start task.
     * 
     * @param cms the initialized CmsObject
     * @param session the initialized user session 
     * @param startTaskId the id of the task to display
     * @throws CmeSxception in case of issues reading the registry
     */
    private void setStartTaskId(CmsObject cms, I_CmsSession session, String startTaskId) 
    throws CmsException 
    {
        if ((startTaskId == null) || ("".equals(startTaskId))) return;
        Vector viewNames = new Vector();
        Vector viewLinks = new Vector();
        // this will initialize the Vectors with the values from the registry.xml
        cms.getRegistry().getViews(viewNames, viewLinks);
        String link = "";
        for(int i = 0;i < viewNames.size();i++) {
            if(((String)viewNames.elementAt(i)).equals("select.tasks")) {
                link = (String)viewLinks.elementAt(i);
                break;
            }
        }
        session.putValue(I_CmsWpConstants.C_PARA_STARTTASKID, startTaskId);
        session.putValue(I_CmsWpConstants.C_PARA_VIEW, link);
    }

    private CmsMessages m_messages;

    /**
     * Sets the default preferences for the current user if those values are not available.
     * @return Hashtable with default preferences.
     */

    private Hashtable getDefaultPreferences() {
        Hashtable pref = new Hashtable();
        // set the default columns in the filelist
        int filelist = 4095 + 512;
        pref.put(I_CmsWpConstants.C_USERPREF_FILELIST, new Integer(filelist));
        return pref;
    }

    /**
     * Customized <code>getTitle()</code> method for adding the current 
     * version information to the title of the login screen.
     *
     * @param cms for accessing system resources
     * @param tagcontent (unused)
     * @param doc reference to the A_CmsXmlContent object of the initiating XML document.
     * @param userObj must ba a <code>java.util.Hashtable</code> with request parameters
     * @return String with customized title information
     * @throws CmsException
     */
    public Object getTitle(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObject) 
    throws CmsException {
        String title = (String)super.getTitle(cms, tagcontent, doc, userObject);
        if(title == null) title = "";
        title += " - " + A_OpenCms.getVersionName();
        return title;
    }

    /**
     * Returns a String with the version information of this OpenCms instance
     *
     * @param cms for accessing system resources
     * @param tagcontent (unused)
     * @param doc reference to the A_CmsXmlContent object of the initiating XML document.
     * @param userObj must ba a <code>java.util.Hashtable</code> with request parameters
     * @return String with the version information of this OpenCms instance
     * @throws CmsException in case of errors processing the template
     */
    public Object version(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObject) 
    throws CmsException {
        return A_OpenCms.getVersionName();
    }

    /**
     * Returns a localized String for the key value given as <code>tagcontent</code> 
     * parameter.
     *
     * @param cms for accessing system resources
     * @param tagcontent key value for the resource bundle
     * @param doc reference to the A_CmsXmlContent object of the initiating XML document.
     * @param userObj must ba a <code>java.util.Hashtable</code> with request parameters
     * @return String with the version information of this OpenCms instance
     * @throws CmsException in case of errors processing the template
     */
    public Object message(CmsObject cms, String tagcontent, A_CmsXmlContent doc, Object userObject) 
    throws CmsException {
        return m_messages.key(tagcontent);
    }

    /**
     * Prevent caching of this template
     *
     * @param cms for accessing system resources
     * @param templateFile filename of the template file
     * @param elementName element name of this template in our parent template.
     * @param parameters hash with all template class parameters
     * @param templateSelector template section that should be processed
     * @return false
     */
    public boolean isCacheable(CmsObject cms, String templateFile, String elementName,
            Hashtable parameters, String templateSelector) {
        return false;
    }
    
    /**
     * Prevent caching of this template in the element cache
     *
     * @param cms for accessing system resources
     * @param templateFile filename of the template file
     * @param elementName element name of this template in our parent template.
     * @param parameters hash with all template class parameters
     * @param templateSelector template section that should be processed
     * @return <code>new CmsCacheDirectives(false)</code>
     */
    public CmsCacheDirectives getCacheDirectives(CmsObject cms, String templateFile, String elementName, Hashtable parameters, String templateSelector) {
        return new CmsCacheDirectives(false);
    }    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -