Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the processor permission response error message #15402

Merged
merged 4 commits into from
Feb 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/lexicon/en/default.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@
$_lang['per_page'] = 'Per Page';
$_lang['permissions'] = 'Permissions';
$_lang['permission_denied'] = 'Permission denied!';
$_lang['permission_denied_processor'] = 'Permission \'[[+permission]]\' required for \'[[+action]]\'!';
$_lang['permission_denied_msg'] = 'You do not have the proper access policy permissions to view this page. If you feel this is in error, please contact your systems administrator.';
$_lang['please_wait'] = 'Please wait...';
$_lang['plugin'] = 'Plugin';
Expand Down
12 changes: 9 additions & 3 deletions core/model/modx/modprocessor.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ abstract class modProcessor {
* @var array $properties
*/
public $properties = array();
/**
* The Permission to use when checking against
* @var string $permission
*/
public $permission = '';

/**
* Creates a modProcessor object.
Expand Down Expand Up @@ -163,7 +168,10 @@ abstract public function process();
*/
public function run() {
if (!$this->checkPermissions()) {
$o = $this->failure($this->modx->lexicon('permission_denied'));
$o = $this->failure($this->modx->lexicon('permission_denied_processor', array(
'action' => preg_replace('/[^\w\-_\/]+/i', '', $this->getProperty('action')),
'permission' => ($this->permission != '') ? $this->permission : '- unknown -'
)));
} else {
$topics = $this->getLanguageTopics();
foreach ($topics as $topic) {
Expand Down Expand Up @@ -390,8 +398,6 @@ abstract class modObjectProcessor extends modProcessor {
public $classKey;
/** @var string $primaryKeyField The primary key field to grab the object by */
public $primaryKeyField = 'id';
/** @var string $permission The Permission to use when checking against */
public $permission = '';
/** @var array $languageTopics An array of language topics to load */
public $languageTopics = array();

Expand Down
2 changes: 1 addition & 1 deletion manager/assets/modext/modx.jsgrps-min.js

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions manager/assets/modext/widgets/core/modx.combo.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ MODx.combo.ComboBox = function(config,getStore) {
,remoteSort: config.remoteSort || false
,autoDestroy: true
,listeners: {
'loadexception': {fn: function(o,trans,resp) {
var status = _('code') + ': ' + resp.status + ' ' + resp.statusText + '<br/>';
MODx.msg.alert(_('error'), status + resp.responseText);
}}
loadexception: {
fn: function (o, trans, resp) {
var status = _('code') + ': ' + resp.status + ' ' + resp.statusText;
var response = Ext.decode(resp.responseText || '[]');
MODx.msg.alert(_('error'), (response.message || status));
}
}
}
})
});
Expand All @@ -106,7 +109,7 @@ MODx.combo.ComboBox = function(config,getStore) {
// Workaround to let the combobox know the store is loaded (to help hide/display the pagination if required)
this.fireEvent('loaded', this);
this.loaded = true;

// Show the pagination panel if it didn't show up earlier
if (this.isExpanded() && this.pageSize < this.store.getTotalCount() && this.pageTb.hidden === true) {
this.collapse();
Expand Down