📄 cmschacc.java
字号:
image = "commons/role.png";
} else {
name = entry.getKey().toString();
image = "explorer/project_none.gif";
}
}
result.append("<div class=\"dialogrow\"><img src=\"");
result.append(getSkinUri());
result.append(image);
result.append("\" class='noborder' width='16' height='16' alt='Principal' title='Principal'> <span class=\"textbold\">");
result.append(name);
result.append("</span>");
if ("long".equals(getSettings().getPermissionDetailView())) {
String resourceName = (String)entry.getValue();
if (!resourceRootPath.equals(resourceName)) {
result.append("<div class=\"dialogpermissioninherit\">");
result.append(key(Messages.GUI_PERMISSION_INHERITED_FROM_1, new Object[] {resourceName}));
result.append("</div>");
}
}
try {
if ((ou != null)
&& (OpenCms.getOrgUnitManager().getOrganizationalUnits(getCms(), "", true).size() > 1)) {
result.append("<br>");
result.append("<img src='").append(getSkinUri()).append(
"explorer/project_none.gif' class='noborder' width='16' height='16' >");
result.append("<img src='").append(getSkinUri()).append(
"explorer/project_none.gif' class='noborder' width='16' height='16' >");
result.append(" ");
try {
result.append(OpenCms.getOrgUnitManager().readOrganizationalUnit(getCms(), ou).getDisplayName(
getLocale()));
} catch (CmsException e) {
result.append(ou);
}
}
} catch (CmsException e) {
// should never happen
if (LOG.isErrorEnabled()) {
LOG.error(e.getLocalizedMessage(), e);
}
}
result.append("</div>\n");
}
result.append(dialogWhiteBoxEnd());
result.append("</div>\n");
return result.toString();
} finally {
cms.getRequestContext().setSiteRoot(site);
}
}
/**
* Builds a String with HTML code to display the inherited and own access control entries of a resource.<p>
*
* @return HTML code for inherited and own entries of the current resource
*/
public String buildRightsList() {
StringBuffer result = new StringBuffer(dialogToggleStart(
key(Messages.GUI_PERMISSION_BEQUEATH_SUBFOLDER_0),
"inheritedpermissions",
getSettings().getUserSettings().getDialogExpandInheritedPermissions() || getShowInheritedPermissions()));
// store all parent folder ids together with path in a map
Map parents = new HashMap();
String path = CmsResource.getParentFolder(getParamResource());
List parentResources = new ArrayList();
try {
// get all parent folders of the current file
parentResources = getCms().readPath(path, CmsResourceFilter.IGNORE_EXPIRATION);
} catch (CmsException e) {
// can usually be ignored
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
}
Iterator k = parentResources.iterator();
while (k.hasNext()) {
// add the current folder to the map
CmsResource curRes = (CmsResource)k.next();
parents.put(curRes.getResourceId(), curRes.getRootPath());
}
// create new ArrayLists in which inherited and non inherited entries are stored
ArrayList ownEntries = new ArrayList();
try {
Iterator itAces = getCms().getAccessControlEntries(getParamResource(), false).iterator();
while (itAces.hasNext()) {
CmsAccessControlEntry curEntry = (CmsAccessControlEntry)itAces.next();
if (!curEntry.isInherited()) {
// add the entry to the own rights list
ownEntries.add(curEntry);
}
}
} catch (CmsException e) {
// can usually be ignored
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
}
ArrayList inheritedEntries = new ArrayList();
try {
Iterator itAces = getCms().getAccessControlEntries(path, true).iterator();
while (itAces.hasNext()) {
CmsAccessControlEntry curEntry = (CmsAccessControlEntry)itAces.next();
// add the entry to the inherited rights list for the "long" view
if ("long".equals(getSettings().getPermissionDetailView())) {
inheritedEntries.add(curEntry);
}
}
} catch (CmsException e) {
// can usually be ignored
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
}
// now create the inherited entries box
result.append(dialogWhiteBox(HTML_START));
result.append(buildInheritedList(inheritedEntries, parents));
result.append(dialogWhiteBox(HTML_END));
// close div that toggles visibility of inherited permissions
result.append("</div>");
// create the add user/group form
result.append(buildAddForm());
// create the resource entries box
result.append(buildResourceList(ownEntries));
return result.toString();
}
/**
* Returns the current users permission set on the resource.<p>
*
* @return the users permission set
*/
public CmsPermissionSet getCurPermissions() {
return m_curPermissions;
}
/**
* Returns a list with all error messages which occured when trying to add a new access control entry.<p>
*
* @return List of error message Strings
*/
public List getErrorMessages() {
return m_errorMessages;
}
/**
* Returns a String with all error messages occuring when trying to add a new access control entry.<p>
*
* @return String with error messages, separated by <br>
*/
public String getErrorMessagesString() {
StringBuffer errors = new StringBuffer(8);
Iterator i = getErrorMessages().iterator();
while (i.hasNext()) {
errors.append((String)i.next());
if (i.hasNext()) {
errors.append("<br>");
}
}
return errors.toString();
}
/**
* Returns the value of the name parameter,
* or null if this parameter was not provided.<p>
*
* The name parameter stores the name of the group or user.<p>
*
* @return the value of the name parameter
*/
public String getParamName() {
return m_paramName;
}
/**
* Returns the value of the type parameter,
* or null if this parameter was not provided.<p>
*
* The type parameter stores the type of an ace (group or user).<p>
*
* @return the value of the type parameter
*/
public String getParamType() {
return m_paramType;
}
/**
* Returns if the inherited permissions information should be displayed.<p>
*
* @return true if the inherited permissions information should be displayed, otherwise false
*/
public boolean getShowInheritedPermissions() {
return m_showInheritedPermissions;
}
/**
* @see org.opencms.workplace.CmsDialog#htmlStart()
*/
public String htmlStart() {
StringBuffer result = new StringBuffer(256);
result.append(super.htmlStart());
result.append((new CmsPrincipalWidget().getDialogIncludes(getCms(), null)));
result.append("<script type='text/javascript' >");
result.append("typeField = '").append(PARAM_TYPE).append("';");
result.append("</script>");
return result.toString();
}
/**
* Initializes some member variables to display the form with the right options for the current user.<p>
*
* This method must be called after initWorkplaceRequestValues().<p>
*/
public void init() {
// the current user name
String userName = getSettings().getUser().getName();
if (m_typesLocalized[0] == null) {
m_typesLocalized[0] = key(Messages.GUI_LABEL_GROUP_0);
m_typesLocalized[1] = key(Messages.GUI_LABEL_USER_0);
m_typesLocalized[2] = key(Messages.GUI_LABEL_ROLE_0);
m_typesLocalized[3] = key(Messages.GUI_LABEL_ALLOTHERS_0);
m_typesLocalized[4] = key(Messages.GUI_LABEL_OVERWRITEALL_0);
}
// set flags to show editable or non editable entries
setEditable(false);
setInheritOption(false);
String resName = getParamResource();
try {
// get the current users' permissions
setCurPermissions(getCms().getPermissions(getParamResource(), userName));
// check if the current resource is a folder
CmsResource resource = getCms().readResource(getParamResource(), CmsResourceFilter.ALL);
if (resource.isFolder()) {
// only folders have the inherit option activated
setInheritOption(true);
if (!resName.endsWith("/")) {
// append manually a "/" to folder name to avoid issues with check if resource is in project
resName += "/";
}
}
} catch (CmsException e) {
// can usually be ignored
if (LOG.isInfoEnabled()) {
LOG.info(e.getLocalizedMessage());
}
}
// check the current users permission to change access control entries
if ((!getCms().getRequestContext().currentProject().isOnlineProject() && getCms().isInsideCurrentProject(
resName))
&& (OpenCms.getRoleManager().hasRole(getCms(), CmsRole.VFS_MANAGER) || (((m_curPermissions.getAllowedPermissions() & CmsPermissionSet.PERMISSION_CONTROL) > 0) && !((m_curPermissions.getDeniedPermissions() & CmsPermissionSet.PERMISSION_CONTROL) > 0)))) {
setEditable(true);
}
}
/**
* Sets the value of the name parameter.<p>
*
* @param value the value to set
*/
public void setParamName(String value) {
m_paramName = value;
}
/**
* Sets the value of the type parameter.<p>
*
* @param value the value to set
*/
public void setParamType(String value) {
m_paramType = value;
}
/**
* Validates the user input when creating a new access control entry.<p>
*
* @param name the name of the new user/group
* @param arrayPosition the position in the types array
*
* @return true if everything is ok, otherwise false
*/
protected boolean checkNewEntry(String name, int arrayPosition) {
m_errorMessages.clear();
boolean inArray = false;
if (getTypes(false)[arrayPosition] != null) {
inArray = true;
}
if (!inArray) {
m_errorMessages.add(key(Messages.ERR_PERMISSION_SELECT_TYPE_0));
}
if (CmsStringUtil.isEmptyOrWhitespaceOnly(name)) {
m_errorMessages.add(key(Messages.ERR_MISSING_GROUP_OR_USER_NAME_0));
}
if (m_errorMessages.size() > 0) {
return false;
}
return true;
}
/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -