mirror of
https://github.com/processwire/processwire.git
synced 2025-08-24 15:23:11 +02:00
Add some extra descriptive text in ProcessRole for page-edit and page-view permissions.
This commit is contained in:
@@ -95,8 +95,8 @@ class ProcessRole extends ProcessPageType {
|
|||||||
'page-create' => $pageEditRequired,
|
'page-create' => $pageEditRequired,
|
||||||
'page-publish' => $pageEditRequired,
|
'page-publish' => $pageEditRequired,
|
||||||
'page-add' => $this->_('Unlike most other permissions, page-edit permission to a template is not a pre-requisite for this permission.'),
|
'page-add' => $this->_('Unlike most other permissions, page-edit permission to a template is not a pre-requisite for this permission.'),
|
||||||
'page-edit' => '',
|
'page-edit' => $this->_('Templates with an asterisk (*) are configured for edit-related permissions to also inherit to children and through the page tree, unless/until overridden by a page using a different access controlled template.'),
|
||||||
'page-view' => '',
|
'page-view' => $this->_('This permission is also inherited to children and through the page tree, unless/until overridden by a page using a different access controlled template.'),
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -208,7 +208,7 @@ class ProcessRole extends ProcessPageType {
|
|||||||
* @param $inputfieldValue
|
* @param $inputfieldValue
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function addPermissionOptions(array $permissions, Inputfield $f, $level = 0, &$inputfieldValue) {
|
protected function addPermissionOptions(array $permissions, Inputfield $f, $level, &$inputfieldValue) {
|
||||||
|
|
||||||
/** @var InputfieldCheckboxes $f */
|
/** @var InputfieldCheckboxes $f */
|
||||||
/** @var Role $role */
|
/** @var Role $role */
|
||||||
@@ -255,7 +255,7 @@ class ProcessRole extends ProcessPageType {
|
|||||||
}
|
}
|
||||||
if(($parent->name == 'page-edit' || $rootParent->name == 'page-edit') && strpos($name, 'page-') === 0) {
|
if(($parent->name == 'page-edit' || $rootParent->name == 'page-edit') && strpos($name, 'page-') === 0) {
|
||||||
if($name == 'page-add' || $name == 'page-create') {
|
if($name == 'page-add' || $name == 'page-create') {
|
||||||
$title = $title;
|
// $title = $title;
|
||||||
} else {
|
} else {
|
||||||
$appliesAllEditable = true;
|
$appliesAllEditable = true;
|
||||||
$title .= $this->renderDetail('(' . $this->_('applies to all editable templates') . ')', 'permission-all-templates');
|
$title .= $this->renderDetail('(' . $this->_('applies to all editable templates') . ')', 'permission-all-templates');
|
||||||
@@ -464,12 +464,16 @@ class ProcessRole extends ProcessPageType {
|
|||||||
protected function renderTemplatePermissionCheckbox(Template $template, Permission $permission, $checked) {
|
protected function renderTemplatePermissionCheckbox(Template $template, Permission $permission, $checked) {
|
||||||
|
|
||||||
$disabled = false;
|
$disabled = false;
|
||||||
|
$perm = $permission->name;
|
||||||
|
$templateLabel = $template->name;
|
||||||
$note = '';
|
$note = '';
|
||||||
|
|
||||||
if($permission->name == 'page-view' && $this->guestRole->hasPermission('page-view', $template)) {
|
if($perm == 'page-view' && $this->guestRole->hasPermission('page-view', $template)) {
|
||||||
$checked = true;
|
$checked = true;
|
||||||
$disabled = true;
|
$disabled = true;
|
||||||
$note = $this->_('(required because inherited from guest role)');
|
$note = $this->_('(required because inherited from guest role)');
|
||||||
|
} else if($perm == 'page-edit' && !$template->noInherit) {
|
||||||
|
$templateLabel .= '*';
|
||||||
}
|
}
|
||||||
|
|
||||||
$checked = $checked ? 'checked' : '';
|
$checked = $checked ? 'checked' : '';
|
||||||
@@ -478,11 +482,11 @@ class ProcessRole extends ProcessPageType {
|
|||||||
|
|
||||||
// note: pt=permission+template, tp=template+permission
|
// note: pt=permission+template, tp=template+permission
|
||||||
|
|
||||||
if($permission->name == 'page-add') {
|
if($perm == 'page-add') {
|
||||||
$name = "pt_add_$template->id";
|
$name = "pt_add_$template->id";
|
||||||
} else if($permission->name == 'page-create') {
|
} else if($perm == 'page-create') {
|
||||||
$name = "pt_create_$template->id";
|
$name = "pt_create_$template->id";
|
||||||
} else if(in_array($permission->name, array('page-edit', 'page-view'))) {
|
} else if($perm == 'page-edit' || $perm == 'page-view') {
|
||||||
$name = "pt_{$permission->id}_{$template->id}";
|
$name = "pt_{$permission->id}_{$template->id}";
|
||||||
} else {
|
} else {
|
||||||
$name = '';
|
$name = '';
|
||||||
@@ -493,7 +497,7 @@ class ProcessRole extends ProcessPageType {
|
|||||||
$out =
|
$out =
|
||||||
"<label>" .
|
"<label>" .
|
||||||
"<input type='checkbox' $checked $disabled name='$name' value='1' class='$class'>" .
|
"<input type='checkbox' $checked $disabled name='$name' value='1' class='$class'>" .
|
||||||
"$template->name <span class='detail'>$note</span>" .
|
"$templateLabel <span class='detail'>$note</span>" .
|
||||||
"</label>";
|
"</label>";
|
||||||
} else {
|
} else {
|
||||||
// select add or revoke
|
// select add or revoke
|
||||||
@@ -507,11 +511,11 @@ class ProcessRole extends ProcessPageType {
|
|||||||
$out =
|
$out =
|
||||||
"<label class='template-permission-add'>" .
|
"<label class='template-permission-add'>" .
|
||||||
"<input type='checkbox' name='add_$name' value='$permission->id' $addChecked class='$class'>" .
|
"<input type='checkbox' name='add_$name' value='$permission->id' $addChecked class='$class'>" .
|
||||||
sprintf($this->_('Add to: %s'), $template->name) .
|
sprintf($this->_('Add to: %s'), $templateLabel) .
|
||||||
"</label>" .
|
"</label>" .
|
||||||
"<label class='template-permission-revoke'>" .
|
"<label class='template-permission-revoke'>" .
|
||||||
"<input type='checkbox' name='revoke_$name' value='$permission->id' $revokeChecked class='$class'>" .
|
"<input type='checkbox' name='revoke_$name' value='$permission->id' $revokeChecked class='$class'>" .
|
||||||
sprintf($this->_('Revoke from: %s'), $template->name) .
|
sprintf($this->_('Revoke from: %s'), $templateLabel) .
|
||||||
"</label>";
|
"</label>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user