diff --git a/administrator/components/com_config/Model/ApplicationModel.php b/administrator/components/com_config/Model/ApplicationModel.php
index 60e1e2cb96538..5f282ffc5ca63 100644
--- a/administrator/components/com_config/Model/ApplicationModel.php
+++ b/administrator/components/com_config/Model/ApplicationModel.php
@@ -520,11 +520,11 @@ public function storePermissions($permission = null)
{
// Get data from input.
$permission = array(
- 'component' => $app->input->get('comp'),
- 'action' => $app->input->get('action'),
- 'rule' => $app->input->get('rule'),
- 'value' => $app->input->get('value'),
- 'title' => $app->input->get('title', '', 'RAW')
+ 'component' => $app->input->Json->get('comp'),
+ 'action' => $app->input->Json->get('action'),
+ 'rule' => $app->input->Json->get('rule'),
+ 'value' => $app->input->Json->get('value'),
+ 'title' => $app->input->Json->get('title', '', 'RAW')
);
}
diff --git a/libraries/src/Form/Field/RulesField.php b/libraries/src/Form/Field/RulesField.php
index a284c414de111..b362eb9449083 100644
--- a/libraries/src/Form/Field/RulesField.php
+++ b/libraries/src/Form/Field/RulesField.php
@@ -309,8 +309,9 @@ protected function getInput()
$html[] = '';
$html[] = '
';
+ $html[] = ' ';
- $html[] = ' ';
$html[] = '';
+ $html[] = ' ';
$html[] = ' | ';
// Build the Calculated Settings column.
@@ -354,7 +356,7 @@ protected function getInput()
if ($isSuperUserGroup)
{
$result['class'] = 'badge badge-success';
- $result['text'] = '' . \JText::_('JLIB_RULES_ALLOWED_ADMIN');
+ $result['text'] = '' . \JText::_('JLIB_RULES_ALLOWED_ADMIN');
}
// Not super user.
else
@@ -412,7 +414,7 @@ protected function getInput()
elseif ($inheritedGroupParentAssetRule === false || $inheritedParentGroupRule === false)
{
$result['class'] = 'badge badge-danger';
- $result['text'] = '' . \JText::_('JLIB_RULES_NOT_ALLOWED_LOCKED');
+ $result['text'] = '' . \JText::_('JLIB_RULES_NOT_ALLOWED_LOCKED');
}
}
diff --git a/media/system/js/fields/permissions.js b/media/system/js/fields/permissions.js
index 65a40877e905a..d8767b19c70c3 100644
--- a/media/system/js/fields/permissions.js
+++ b/media/system/js/fields/permissions.js
@@ -1,138 +1,137 @@
/**
- * @package Joomla.JavaScript
- * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
- * @license GNU General Public License version 2 or later; see LICENSE.txt
+ * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
+ * @license GNU General Public License version 2 or later; see LICENSE.txt
*/
-/**
- * Function to send Permissions via Ajax to Com-Config Application Controller
- */
-function sendPermissions(event) {
- // set the icon while storing the values
- var icon = document.getElementById('icon_' + this.id);
- icon.removeAttribute('class');
- icon.setAttribute('class', 'fa fa-spinner fa-spin');
-
- //get values and prepare GET-Parameter
- var asset = 'not',
- component = getUrlParam('component'),
- extension = getUrlParam('extension'),
- option = getUrlParam('option'),
- view = getUrlParam('view'),
- title = component,
- value = this.value,
- context = '';
-
- if (document.getElementById('jform_context')){
- context = document.getElementById('jform_context').value;
- context = context.split('.')[0];
- }
+Joomla = window.Joomla || {};
+
+(function(Joomla, document) {
+ 'use strict';
+
+ /**
+ * Function to send Permissions via Ajax to Com-Config Application Controller
+ */
+ Joomla.sendPermissions = function(event) {
+ var target = event.target;
+ // Set the icon while storing the values
+ var icon = document.getElementById('icon_' + this.id);
+ icon.removeAttribute('class');
+ icon.setAttribute('class', 'fa fa-spinner fa-spin');
+
+ // Get values and prepare GET-Parameter
+ var asset = 'not',
+ component = Joomla.getUrlParam('component'),
+ extension = Joomla.getUrlParam('extension'),
+ option = Joomla.getUrlParam('option'),
+ view = Joomla.getUrlParam('view'),
+ title = component,
+ value = this.value,
+ context = '';
+
+ if (document.getElementById('jform_context')) {
+ context = document.getElementById('jform_context').value;
+ context = context.split('.')[0];
+ }
- if (option == 'com_config' && component == false && extension == false) {
- asset = 'root.1';
- }
- else if (extension == false && view == 'component'){
- asset = component;
- }
- else if (context){
- if (view == 'group') {
- asset = context + '.fieldgroup.' + getUrlParam('id');
+ if (option == 'com_config' && component == false && extension == false) {
+ asset = 'root.1';
}
- else {
- asset = context + '.field.' + getUrlParam('id');
+ else if (extension == false && view == 'component') {
+ asset = component;
}
- title = document.getElementById('jform_title').value;
- }
- else if (extension != false && view != false){
- asset = extension + '.' + view + '.' + getUrlParam('id');
- title = document.getElementById('jform_title').value;
- }
- else if (extension == false && view != false){
- asset = option + '.' + view + '.' + getUrlParam('id');
- title = document.getElementById('jform_title').value;
- }
-
- var id = this.id.replace('jform_rules_', ''),
- lastUnderscoreIndex = id.lastIndexOf('_');
-
- var permission_data = {
- comp : asset,
- action : id.substring(0, lastUnderscoreIndex),
- rule : id.substring(lastUnderscoreIndex + 1),
- value : value,
- title : title
- };
-
- // Remove js messages, if they exist.
- Joomla.removeMessages();
-
- // doing ajax request
- jQuery.ajax({
- method: 'POST',
- url: document.getElementById('permissions-sliders').getAttribute('data-ajaxuri'),
- data: permission_data,
- datatype: 'json'
- })
- .fail(function (jqXHR, textStatus, error) {
- // Remove the spinning icon.
- icon.removeAttribute('style');
-
- Joomla.renderMessages(Joomla.ajaxErrorsMessages(jqXHR, textStatus, error));
-
- window.scrollTo(0, 0);
-
- icon.setAttribute('class', 'fa fa-times');
- })
- .done(function (response) {
- // Remove the spinning icon.
- icon.removeAttribute('style');
-
- if (response.data)
- {
- // Check if everything is OK
- if (response.data.result == true)
- {
- icon.setAttribute('class', 'fa fa-check');
-
- jQuery(event.target).parents().next('td').find('span')
- .removeClass()
- .addClass(response['data']['class'])
- .html(response.data.text);
+ else if (context) {
+ if (view == 'group') {
+ asset = context + '.fieldgroup.' + Joomla.getUrlParam('id');
+ }
+ else {
+ asset = context + '.field.' + Joomla.getUrlParam('id');
}
+ title = document.getElementById('jform_title').value;
+ }
+ else if (extension != false && view != false) {
+ asset = extension + '.' + view + '.' + Joomla.getUrlParam('id');
+ title = document.getElementById('jform_title').value;
+ }
+ else if (extension == false && view != false) {
+ asset = option + '.' + view + '.' + Joomla.getUrlParam('id');
+ title = document.getElementById('jform_title').value;
}
- // Render messages, if any. There are only message in case of errors.
- if (typeof response.messages == 'object' && response.messages !== null)
- {
- Joomla.renderMessages(response.messages);
+ var id = this.id.replace('jform_rules_', ''),
+ lastUnderscoreIndex = id.lastIndexOf('_');
+
+ var permissionData = {
+ comp : asset,
+ action : id.substring(0, lastUnderscoreIndex),
+ rule : id.substring(lastUnderscoreIndex + 1),
+ value : value,
+ title : title
+ };
+
+ // Remove JS messages, if they exist.
+ Joomla.removeMessages();
+
+ // Ajax request
+ Joomla.request({
+ url: document.getElementById('permissions-sliders').getAttribute('data-ajaxuri'),
+ method: 'POST',
+ data: JSON.stringify(permissionData),
+ perform: true,
+ headers: {'Content-Type': 'application/json'},
+ onSuccess: function(response, xhr) {
+ try {
+ response = JSON.parse(response);
+ } catch(e) {
+ console.log(e)
+ }
+
+ icon.removeAttribute('class');
+
+ // Check if everything is OK
+ if (response.data && response.data.result === true) {
+ icon.setAttribute('class', 'fa fa-check');
+
+ var badgeSpan = target.parentNode.parentNode.nextElementSibling.querySelector('span');
+ badgeSpan.removeAttribute('class');
+ badgeSpan.setAttribute('class', response.data['class']);
+ badgeSpan.innerHTML = response.data.text;
+ }
+
+ // Render messages, if any. There are only message in case of errors.
+ if (typeof response.messages === 'object' && response.messages !== null) {
+ Joomla.renderMessages(response.messages);
+
+ if (response.data && response.data.result === true) {
+ icon.setAttribute('class', 'fa fa-check');
+ } else {
+ icon.setAttribute('class', 'fa fa-times');
+ }
+ }
+ },
+ onError: function(xhr) {
+ // Remove the spinning icon.
+ icon.removeAttribute('style');
+
+ Joomla.renderMessages(Joomla.ajaxErrorsMessages(jqXHR, textStatus, error));
- if (response.data && response.data.result == true)
- {
- icon.setAttribute('class', 'fa fa-check');
- }
- else
- {
icon.setAttribute('class', 'fa fa-times');
}
+ });
+ }
- window.scrollTo(0, 0);
- }
- });
-}
-
-/**
- * Function to get parameters out of the url
- */
-function getUrlParam(variable) {
- var query = window.location.search.substring(1);
- var vars = query.split('&');
- for (var i=0;i