📄 cmschacc.java
字号:
* Returns the resource on which the specified access control entry was set.<p>
*
* @param entry the current access control entry
* @param parents the parent resources to determine the connected resource
* @return the resource name of the corresponding resource
*/
protected String getConnectedResource(CmsAccessControlEntry entry, Map parents) {
CmsUUID resId = entry.getResource();
String resName = (String)parents.get(resId);
if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(resName)) {
return resName;
}
return resId.toString();
}
/**
* Returns the current editable flag for the user to change ACEs.<p>
*
* @return true if user can edit the permissions, otherwise false
*/
protected boolean getEditable() {
return m_editable;
}
/**
* Determines the type of the current access control entry.<p>
*
* @param flags the value of the current flags
* @param all to include all types, or just user and groups
*
* @return String representation of the ace type
*/
protected String getEntryType(int flags, boolean all) {
for (int i = 0; i < getTypes(all).length; i++) {
if ((flags & getTypesInt()[i]) > 0) {
return getTypes(all)[i];
}
}
return UNKNOWN_TYPE;
}
/**
* Determines the int type of the current access control entry.<p>
*
* @param flags the value of the current flags
* @return int representation of the ace type as int
*/
protected int getEntryTypeInt(int flags) {
for (int i = 0; i < getTypesInt().length; i++) {
if ((flags & getTypesInt()[i]) > 0) {
return i;
}
}
return -1;
}
/**
* Returns if the access control entry can be inherited to subfolders and can overwrite inherited permissions.<p>
*
* @return true to show the checkbox, otherwise false
*/
protected boolean getInheritOption() {
return m_inherit;
}
/**
* Returns a String array with the possible entry types.<p>
*
* @param all to include all types, or just user, groups and roles
*
* @return the possible types
*/
protected String[] getTypes(boolean all) {
if (!all) {
String[] array = new String[3];
return (String[])Arrays.asList(m_types).subList(0, 3).toArray(array);
}
return m_types;
}
/**
* Returns an int array with possible entry types.<p>
*
* @return the possible types as int array
*/
protected int[] getTypesInt() {
return m_typesInt;
}
/**
* Returns a String array with the possible localized entry types.<p>
*
* @return the possible localized types
*/
protected String[] getTypesLocalized() {
return m_typesLocalized;
}
/**
* @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest)
*/
protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) {
// fill the parameter values in the get/set methods
fillParamValues(request);
// set the detail mode of the "inherited" list view
String detail = request.getParameter(PARAM_VIEW);
if (detail != null) {
settings.setPermissionDetailView(detail);
setShowInheritedPermissions(true);
}
// determine which action has to be performed
if (DIALOG_TYPE.equals(getParamAction())) {
setAction(ACTION_DEFAULT);
} else if (DIALOG_SET.equals(getParamAction())) {
setAction(ACTION_SET);
} else if (DIALOG_DELETE.equals(getParamAction())) {
setAction(ACTION_DELETE);
} else if (DIALOG_ADDACE.equals(getParamAction())) {
setAction(ACTION_ADDACE);
} else if (DIALOG_LOCKS_CONFIRMED.equals(getParamAction())) {
setAction(ACTION_LOCKS_CONFIRMED);
} else if (DIALOG_CANCEL.equals(getParamAction())) {
setAction(ACTION_CANCEL);
} else if (DIALOG_INTERNALUSE.equals(getParamAction())) {
setAction(ACTION_INTERNALUSE);
} else {
setAction(ACTION_DEFAULT);
// build the title for chacc dialog
setParamTitle(key(Messages.GUI_PERMISSION_CHANGE_1, new Object[] {CmsResource.getName(getParamResource())}));
}
}
/**
* Checks if a certain permission of a permission set is allowed.<p>
*
* @param p the current CmsPermissionSet
* @param value the int value of the permission to check
* @return true if the permission is allowed, otherwise false
*/
protected boolean isAllowed(CmsPermissionSet p, int value) {
if ((p.getAllowedPermissions() & value) > 0) {
return true;
}
return false;
}
/**
* Checks if a certain permission of a permission set is denied.<p>
*
* @param p the current CmsPermissionSet
* @param value the int value of the permission to check
* @return true if the permission is denied, otherwise false
*/
protected boolean isDenied(CmsPermissionSet p, int value) {
if ((p.getDeniedPermissions() & value) > 0) {
return true;
}
return false;
}
/**
* Check if the current permissions are overwriting the inherited ones.<p>
*
* @param flags value of all flags of the current entry
* @return true if permissions are overwriting the inherited ones, otherwise false
*/
protected boolean isOverWritingInherited(int flags) {
if ((flags & CmsAccessControlEntry.ACCESS_FLAGS_OVERWRITE) > 0) {
return true;
}
return false;
}
/**
* Check if the user is a responsible for the resource.<p>
*
* @param flags value of all flags of the current entry
* @return true if user is responsible for the resource, otherwise false
*/
protected boolean isResponsible(int flags) {
if ((flags & CmsAccessControlEntry.ACCESS_FLAGS_RESPONSIBLE) > 0) {
return true;
}
return false;
}
/**
* Sets the current users permissions on the resource.
* This is set in the init() method.<p>
*
* @param value the CmsPermissionSet
*/
protected void setCurPermissions(CmsPermissionSet value) {
m_curPermissions = value;
}
/**
* Sets the editable flag for the forms.
* This is set in the init() method.<p>
*
* @param value true if user can edit the permissions, otherwise false
*/
protected void setEditable(boolean value) {
m_editable = value;
}
/**
* Sets if the access control entry can be inherited to subfolders and can overwrite inherited permissions.<p>
*
* This is set in the init() method.<p>
*
* @param value set to true for folders, otherwise false
*/
protected void setInheritOption(boolean value) {
m_inherit = value;
}
/**
* Sets if the inherited permissions information should be displayed.<p>
*
* @param showInheritedPermissions true if the inherited permissions information should be displayed, otherwise false
*/
protected void setShowInheritedPermissions(boolean showInheritedPermissions) {
m_showInheritedPermissions = showInheritedPermissions;
}
/**
* Builds a String with HTML code to display the form to add a new access control entry for the current resource.<p>
*
* @return HTML String with the form
*/
private String buildAddForm() {
StringBuffer result = new StringBuffer(256);
// only display form if the current user has the "control" right
if (getEditable()) {
result.append(dialogSpacer());
result.append(dialogBlockStart(key(Messages.GUI_PERMISSION_ADD_ACE_0)));
// get all possible entry types
ArrayList options = new ArrayList();
ArrayList optionValues = new ArrayList();
for (int i = 0; i < getTypes(false).length - 1 * (isRoleEditable() ? 0 : 1); i++) {
options.add(getTypesLocalized()[i]);
optionValues.add(Integer.toString(i));
}
// create the input form for adding an ace
result.append("<form action=\"").append(getDialogUri()).append(
"\" method=\"post\" name=\"add\" class=\"nomargin\">\n");
// set parameters to show correct hidden input fields
setParamAction(DIALOG_ADDACE);
setParamType(null);
setParamName(null);
result.append(paramsAsHidden());
result.append("<table border=\"0\" width=\"100%\">\n");
result.append("<tr>\n");
result.append("\t<td>").append(buildSelect("name=\"" + PARAM_TYPE + "\"", options, optionValues, -1)).append(
"</td>\n");
result.append("\t<td class=\"maxwidth\"><input type=\"text\" class=\"maxwidth\" name=\"");
result.append(PARAM_NAME);
result.append("\" value=\"\"></td>\n");
result.append("<td><span style='display: block; height: 1px; width: 10px;'/></td>");
result.append(button(
new CmsPrincipalWidget().getButtonJs(PARAM_NAME, "add"),
null,
"principal",
org.opencms.workplace.Messages.GUI_DIALOG_BUTTON_SEARCH_0,
getSettings().getUserSettings().getEditorButtonStyle()));
result.append(button(
"javascript:document.forms['add'].submit();",
null,
"new",
Messages.GUI_LABEL_ADD_0,
getSettings().getUserSettings().getEditorButtonStyle()));
result.append("</tr>\n");
result.append("</form>\n");
result.append("</table>\n");
result.append(dialogBlockEnd());
}
return result.toString();
}
/**
* Builds a StringBuffer with HTML code to show a list of all inherited access control entries.<p>
*
* @param entries ArrayList with all entries to show for the long view
* @param parents Map of parent resources needed to get the connected resources for the detailed view
* @return StringBuffer with HTML code for all entries
*/
private StringBuffer buildInheritedList(ArrayList entries, Map parents) {
StringBuffer result = new StringBuffer(32);
String view = getSettings().getPermissionDetailView();
// display the long view
if ("long".equals(view)) {
Iterator i = entries.iterator();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -