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

📄 cmsadminusers.java

📁 内容管理
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            xmlTemplateDocument.setData("USERDESC", desc);
            xmlTemplateDocument.setData("USERSTREET", street);
            xmlTemplateDocument.setData("PWD", pwd);
            xmlTemplateDocument.setData("PWD2", pwd2);
            xmlTemplateDocument.setData("USER", user);
            xmlTemplateDocument.setData("USERNAME", userLastname);
            xmlTemplateDocument.setData("TOWN", town);
            xmlTemplateDocument.setData("ZIP", zipcode);
            xmlTemplateDocument.setData("EMAIL", email);
        } // belongs to: 'if perspective is newuser or changeuser'
        else {
            if(perspective.equals("deleteuser")) {
                String user = (String)parameters.get("USER");
                xmlTemplateDocument.setData("USER", user);
                templateSelector = "RUsureDelete";
            }else {
                if(perspective.equals("reallydeleteuser")) {

                    // deleting a user
                    String user = (String)parameters.get("USER");
                    try {
                        cms.deleteUser(user);
                        templateSelector = "";
                    }catch(Exception e) {

                        // user == null or delete failed
                        xmlTemplateDocument.setData("DELETEDETAILS", Utils.getStackTrace(e));
                        templateSelector = "deleteerror";
                    }
                } // delete user
            }
        }

        // Now load the template file and start the processing
        return startProcessing(cms, xmlTemplateDocument, elementName, parameters,
                templateSelector);
    }

    /**
     * Gets all groups, that may work for a project.
     * <P>
     * The given vectors <code>names</code> and <code>values</code> will
     * be filled with the appropriate information to be used for building
     * a select box.
     *
     * @param cms CmsObject Object for accessing system resources.
     * @param names Vector to be filled with the appropriate values in this method.
     * @param values Vector to be filled with the appropriate values in this method.
     * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
     * @return Index representing the current value in the vectors.
     * @throws CmsException
     */

    public Integer getGroups(CmsObject cms, CmsXmlLanguageFile lang, Vector names,
            Vector values, Hashtable parameters) throws CmsException {

        // get all groups
        Vector groups = cms.getGroups();
        int retValue = -1;

        // fill the names and values
        for(int z = 0;z < groups.size();z++) {
            String name = ((CmsGroup)groups.elementAt(z)).getName();
            if(C_GROUP_USERS.equals(name)) {
                retValue = z;
            }
            names.addElement(name);
            values.addElement(name);
        }
        return new Integer(retValue);
    }

    /**
     * Gets all groups in which the user is, i.e. the selected ones and the indirect ones
     * The given vectors <code>names</code> and <code>values</code> will
     * be filled with the appropriate information to be used for building
     * a select box.
     *
     * @param cms CmsObject Object for accessing system resources.
     * @param names Vector to be filled with the appropriate values in this method.
     * @param values Vector to be filled with the appropriate values in this method.
     * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
     * @return Index representing the default Group of the user
     * @throws CmsException
     */

    public Integer getGroupsOfUser(CmsObject cms, CmsXmlLanguageFile lang, Vector names,
            Vector values, Hashtable parameters) throws CmsException {
        I_CmsSession session = cms.getRequestContext().getSession(true);
        String defaultGroup = (String)session.getValue("DEFAULTGROUP");
        if(defaultGroup == null) {
            defaultGroup = "";
        }
        getSelectedGroups(cms, lang, names, values, parameters);
        getIndirectGroups(cms, lang, names, values, parameters);
        return new Integer(names.indexOf(defaultGroup));
    }

    /**
     * Gets all groups in which the user is but not the direct ones
     * <P>
     * The given vectors <code>names</code> and <code>values</code> will
     * be filled with the appropriate information to be used for building
     * a select box.
     *
     * @param cms CmsObject Object for accessing system resources.
     * @param names Vector to be filled with the appropriate values in this method.
     * @param values Vector to be filled with the appropriate values in this method.
     * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
     * @return Index representing the default Group of the user
     * @throws CmsException
     */

    public Integer getIndirectGroups(CmsObject cms, CmsXmlLanguageFile lang, Vector names,
            Vector values, Hashtable parameters) throws CmsException {
        I_CmsSession session = cms.getRequestContext().getSession(true);
        Vector selectedGroups = (Vector)session.getValue("selectedGroups");
        Vector indirectGroups = new Vector();
        String groupname, superGroupName;
        CmsGroup superGroup;
        if(selectedGroups != null) {

            // get all parents of the groups
            Enumeration enu = selectedGroups.elements();
            while(enu.hasMoreElements()) {
                groupname = (String)enu.nextElement();
                superGroup = cms.getParent(groupname);
                while((superGroup != null) && (!indirectGroups.contains(superGroup.getName()))) {
                    superGroupName = superGroup.getName();
                    indirectGroups.addElement(superGroupName);

                    // read next super group
                    superGroup = cms.getParent(superGroupName);
                }
            }

            // now remove the direct groups off the list
            for(int z = 0;z < selectedGroups.size();z++) {
                String name = (String)selectedGroups.elementAt(z);
                indirectGroups.removeElement(name);
            }
        }
        for(int z = 0;z < indirectGroups.size();z++) {
            String name = (String)indirectGroups.elementAt(z);
            names.addElement(name);
            values.addElement(name);
        }
        return new Integer(-1); // none preselected
    }

    /**
     * Gets all groups, that have not yet been selected for the user
     * <P>
     * The given vectors <code>names</code> and <code>values</code> will
     * be filled with the appropriate information to be used for building
     * a select box.
     *
     * @param cms CmsObject Object for accessing system resources.
     * @param names Vector to be filled with the appropriate values in this method.
     * @param values Vector to be filled with the appropriate values in this method.
     * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
     * @return Index representing the current value in the vectors.
     * @throws CmsException
     */

    public Integer getNotSelectedGroups(CmsObject cms, CmsXmlLanguageFile lang, Vector names,
            Vector values, Hashtable parameters) throws CmsException {
        int retValue = -1;
        I_CmsSession session = cms.getRequestContext().getSession(true);
        Vector notSelectedGroups = (Vector)session.getValue("notSelectedGroups");
        if(notSelectedGroups != null) {

            // fill the names and values
            for(int z = 0;z < notSelectedGroups.size();z++) {
                String name = (String)notSelectedGroups.elementAt(z);
                if(C_GROUP_USERS.equals(name)) {
                    retValue = z;
                }
                names.addElement(name);
                values.addElement(name);
            }
        }

        // no current group, set index to -1
        return new Integer(retValue);
    }

    /**
     * Gets all groups that have been selected for the user to be in
     * <P>
     * The given vectors <code>names</code> and <code>values</code> will
     * be filled with the appropriate information to be used for building
     * a select box.
     *
     * @param cms CmsObject Object for accessing system resources.
     * @param names Vector to be filled with the appropriate values in this method.
     * @param values Vector to be filled with the appropriate values in this method.
     * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
     * @return Index representing the default Group of the user
     * @throws CmsException
     */

    public Integer getSelectedGroups(CmsObject cms, CmsXmlLanguageFile lang, Vector names,
            Vector values, Hashtable parameters) throws CmsException {
        int retValue = -1;
        I_CmsSession session = cms.getRequestContext().getSession(true);
        String defaultGroup = (String)session.getValue("DEFAULTGROUP");
        if(defaultGroup == null) {
            defaultGroup = "";
        }
        Vector selectedGroups = (Vector)session.getValue("selectedGroups");
        if(selectedGroups != null) {
            for(int z = 0;z < selectedGroups.size();z++) {
                String name = (String)selectedGroups.elementAt(z);
                if(name.equals(defaultGroup)) {
                    retValue = z;
                }
                names.addElement(name);
                values.addElement(name);
            }
        }else {
            selectedGroups = new Vector();
        }
        return new Integer(retValue);
    }

    /**
     * Gets all users
     * <P>
     * The given vectors <code>names</code> and <code>values</code> will
     * be filled with the appropriate information to be used for building
     * a select box.
     *
     * @param cms CmsObject Object for accessing system resources.
     * @param names Vector to be filled with the appropriate values in this method.
     * @param values Vector to be filled with the appropriate values in this method.
     * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
     * @return Index representing the current value in the vectors.
     * @throws CmsException
     */

    public Integer getUsers(CmsObject cms, CmsXmlLanguageFile lang, Vector names,
            Vector values, Hashtable parameters) throws CmsException {

        // get all users
        Vector users = cms.getUsers();
        int retValue = -1;
		String firsname;
		String lastname;
		String username;
		String nameToShow;

        // fill the names and values
        for(int z = 0;z < users.size();z++) {
			firsname = ((CmsUser)users.elementAt(z)).getFirstname();
			//Changed by Le (comundus GmbH)
			lastname = ((CmsUser)users.elementAt(z)).getLastname();
            username = ((CmsUser)users.elementAt(z)).getName();
			nameToShow = username + "   -   " + firsname + " " + lastname;
			//***
            names.addElement(nameToShow);
            values.addElement(username);
        }
        if(users.size() > 0) {
            retValue = 0; // preselect first user
        }
        return new Integer(retValue);


    }

    /**
     * Indicates if the results of this class are cacheable.
     *
     * @param cms CmsObject Object for accessing system resources
     * @param templateFile Filename of the template file
     * @param elementName Element name of this template in our parent template.
     * @param parameters Hashtable with all template class parameters.
     * @param templateSelector template section that should be processed.
     * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
     */

    public boolean isCacheable(CmsObject cms, String templateFile, String elementName,
            Hashtable parameters, String templateSelector) {
        return false;
    }
}

⌨️ 快捷键说明

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