patched loggintobogan fixed bug against field_permissions

removed field_collection (gonna dev own custom modules for showroom
updated field-permissions to last dev
This commit is contained in:
Bachir Soussi Chiadmi
2016-11-22 19:05:44 +01:00
parent b9ac935de6
commit b26db27098
37 changed files with 773 additions and 6069 deletions

View File

@@ -0,0 +1,91 @@
--- logintoboggan.permissions.js
+++ logintoboggan.permissions.js
@@ -1,77 +1,25 @@
/**
- * This is a custom implementation of user.permissions.js, which is necessary
- * because LoginToboggan needs its pre-auth role to not be explicitly tied to
- * the auth role. The change is minor -- simply exclude the pre-auth role from
- * all the auto-checking as the anon and auth user roles are.
+ * LoginToboggan needs its pre-auth role to not be explicitly tied to
+ * the auth role.
*/
-
(function ($) {
/**
* Shows checked and disabled checkboxes for inherited permissions.
*/
-Drupal.behaviors.permissions = {
- attach: function (context) {
- var self = this;
- $('table#permissions').once('permissions', function () {
- // On a site with many roles and permissions, this behavior initially has
- // to perform thousands of DOM manipulations to inject checkboxes and hide
- // them. By detaching the table from the DOM, all operations can be
- // performed without triggering internal layout and re-rendering processes
- // in the browser.
- var $table = $(this);
- if ($table.prev().length) {
- var $ancestor = $table.prev(), method = 'after';
- }
- else {
- var $ancestor = $table.parent(), method = 'append';
- }
- $table.detach();
-
- // Create dummy checkboxes. We use dummy checkboxes instead of reusing
- // the existing checkboxes here because new checkboxes don't alter the
- // submitted form. If we'd automatically check existing checkboxes, the
- // permission table would be polluted with redundant entries. This
- // is deliberate, but desirable when we automatically check them.
- var $dummy = $('<input type="checkbox" class="dummy-checkbox" disabled="disabled" checked="checked" />')
- .attr('title', Drupal.t("This permission is inherited from the authenticated user role."))
- .hide();
-
- $('input[type=checkbox]', this).not('.rid-2, .rid-1, .rid-' + Drupal.settings.LoginToboggan.preAuthID).addClass('real-checkbox').each(function () {
- $dummy.clone().insertAfter(this);
+Drupal.behaviors.LoginTobogganPermissions = {
+ attach: function (context, settings) {
+ // Revert changes made by modules/user/user.permissions.js
+ $('table#permissions', context).once('tobogganPermissions', function () {
+ $('input[type=checkbox]', this).filter('.rid-' + settings.LoginToboggan.preAuthID).removeClass('real-checkbox').each(function () {
+ $(this).next().filter('.dummy-checkbox').remove();
+ $('input.rid-' + settings.LoginToboggan.preAuthID).each(function () {
+ this.style.display = '';
+ });
});
-
- // Initialize the authenticated user checkbox.
- $('input[type=checkbox].rid-2', this)
- .bind('click.permissions', self.toggle)
- // .triggerHandler() cannot be used here, as it only affects the first
- // element.
- .each(self.toggle);
-
- // Re-insert the table into the DOM.
- $ancestor[method]($table);
});
},
-
- /**
- * Toggles all dummy checkboxes based on the checkboxes' state.
- *
- * If the "authenticated user" checkbox is checked, the checked and disabled
- * checkboxes are shown, the real checkboxes otherwise.
- */
- toggle: function () {
- var authCheckbox = this, $row = $(this).closest('tr');
- // jQuery performs too many layout calculations for .hide() and .show(),
- // leading to a major page rendering lag on sites with many roles and
- // permissions. Therefore, we toggle visibility directly.
- $row.find('.real-checkbox').each(function () {
- this.style.display = (authCheckbox.checked ? 'none' : '');
- });
- $row.find('.dummy-checkbox').each(function () {
- this.style.display = (authCheckbox.checked ? '' : 'none');
- });
- }
};
})(jQuery);

View File

@@ -0,0 +1,14 @@
diff --git a/logintoboggan.permissions.js b/logintoboggan.permissions.js
index d463d29..492b64c 100644
--- a/logintoboggan.permissions.js
+++ b/logintoboggan.permissions.js
@@ -14,6 +14,9 @@ Drupal.behaviors.LoginTobogganPermissions = {
$('table#permissions', context).once('tobogganPermissions', function () {
$('input[type=checkbox]', this).filter('.rid-' + settings.LoginToboggan.preAuthID).removeClass('real-checkbox').each(function () {
$(this).next().filter('.dummy-checkbox').remove();
+ $('input.rid-' + settings.LoginToboggan.preAuthID).each(function () {
+ this.style.display = '';
+ });
});
});
},

View File

@@ -0,0 +1,136 @@
diff --git a/logintoboggan.module b/logintoboggan.module
index 55b93fe..4e4e0fc 100644
--- a/logintoboggan.module
+++ b/logintoboggan.module
@@ -306,26 +306,6 @@ function logintoboggan_form_user_pass_reset_alter(&$form, &$form_state) {
}
/**
- * Implement hook_form_user_admin_permissions_alter().
- *
- * @ingroup logintoboggan_core
- */
-function logintoboggan_form_user_admin_permissions_alter(&$form, &$form_state) {
- // If the pre-auth role isn't the auth user, then add it as a setting.
- $id = logintoboggan_validating_id();
- if ($id != DRUPAL_AUTHENTICATED_RID) {
- $form['#attached']['js'][] = array(
- 'data' => array(
- 'LoginToboggan' => array(
- 'preAuthID' => $id,
- ),
- ),
- 'type' => 'setting',
- );
- }
-}
-
-/**
* Implement hook_form_alter().
*
* @ingroup logintoboggan_core
@@ -410,7 +390,10 @@ function logintoboggan_js_alter(&$javascript) {
// prevent the pre-auth role's checkboxes from being automatically disabled
// when the auth user's checkboxes are checked.
if ($id != DRUPAL_AUTHENTICATED_RID) {
- $javascript['modules/user/user.permissions.js']['data'] = drupal_get_path('module', 'logintoboggan') . '/logintoboggan.permissions.js';
+ $javascript['settings']['data'][] = array('LoginToboggan' => array('preAuthID' => $id));
+ $file = drupal_get_path('module', 'logintoboggan') . '/logintoboggan.permissions.js';
+ $javascript[$file] = drupal_js_defaults($file);
+ $javascript[$file]['weight'] = 999;
}
}
}
diff --git a/logintoboggan.permissions.js b/logintoboggan.permissions.js
index 1d406cc..492b64c 100644
--- a/logintoboggan.permissions.js
+++ b/logintoboggan.permissions.js
@@ -1,77 +1,25 @@
/**
- * This is a custom implementation of user.permissions.js, which is necessary
- * because LoginToboggan needs its pre-auth role to not be explicitly tied to
- * the auth role. The change is minor -- simply exclude the pre-auth role from
- * all the auto-checking as the anon and auth user roles are.
+ * LoginToboggan needs its pre-auth role to not be explicitly tied to
+ * the auth role.
*/
-
(function ($) {
/**
* Shows checked and disabled checkboxes for inherited permissions.
*/
-Drupal.behaviors.permissions = {
- attach: function (context) {
- var self = this;
- $('table#permissions').once('permissions', function () {
- // On a site with many roles and permissions, this behavior initially has
- // to perform thousands of DOM manipulations to inject checkboxes and hide
- // them. By detaching the table from the DOM, all operations can be
- // performed without triggering internal layout and re-rendering processes
- // in the browser.
- var $table = $(this);
- if ($table.prev().length) {
- var $ancestor = $table.prev(), method = 'after';
- }
- else {
- var $ancestor = $table.parent(), method = 'append';
- }
- $table.detach();
-
- // Create dummy checkboxes. We use dummy checkboxes instead of reusing
- // the existing checkboxes here because new checkboxes don't alter the
- // submitted form. If we'd automatically check existing checkboxes, the
- // permission table would be polluted with redundant entries. This
- // is deliberate, but desirable when we automatically check them.
- var $dummy = $('<input type="checkbox" class="dummy-checkbox" disabled="disabled" checked="checked" />')
- .attr('title', Drupal.t("This permission is inherited from the authenticated user role."))
- .hide();
-
- $('input[type=checkbox]', this).not('.rid-2, .rid-1, .rid-' + Drupal.settings.LoginToboggan.preAuthID).addClass('real-checkbox').each(function () {
- $dummy.clone().insertAfter(this);
+Drupal.behaviors.LoginTobogganPermissions = {
+ attach: function (context, settings) {
+ // Revert changes made by modules/user/user.permissions.js
+ $('table#permissions', context).once('tobogganPermissions', function () {
+ $('input[type=checkbox]', this).filter('.rid-' + settings.LoginToboggan.preAuthID).removeClass('real-checkbox').each(function () {
+ $(this).next().filter('.dummy-checkbox').remove();
+ $('input.rid-' + settings.LoginToboggan.preAuthID).each(function () {
+ this.style.display = '';
+ });
});
-
- // Initialize the authenticated user checkbox.
- $('input[type=checkbox].rid-2', this)
- .bind('click.permissions', self.toggle)
- // .triggerHandler() cannot be used here, as it only affects the first
- // element.
- .each(self.toggle);
-
- // Re-insert the table into the DOM.
- $ancestor[method]($table);
});
},
-
- /**
- * Toggles all dummy checkboxes based on the checkboxes' state.
- *
- * If the "authenticated user" checkbox is checked, the checked and disabled
- * checkboxes are shown, the real checkboxes otherwise.
- */
- toggle: function () {
- var authCheckbox = this, $row = $(this).closest('tr');
- // jQuery performs too many layout calculations for .hide() and .show(),
- // leading to a major page rendering lag on sites with many roles and
- // permissions. Therefore, we toggle visibility directly.
- $row.find('.real-checkbox').each(function () {
- this.style.display = (authCheckbox.checked ? 'none' : '');
- });
- $row.find('.dummy-checkbox').each(function () {
- this.style.display = (authCheckbox.checked ? '' : 'none');
- });
- }
};
})(jQuery);

View File

@@ -305,26 +305,6 @@ function logintoboggan_form_user_pass_reset_alter(&$form, &$form_state) {
}
}
/**
* Implement hook_form_user_admin_permissions_alter().
*
* @ingroup logintoboggan_core
*/
function logintoboggan_form_user_admin_permissions_alter(&$form, &$form_state) {
// If the pre-auth role isn't the auth user, then add it as a setting.
$id = logintoboggan_validating_id();
if ($id != DRUPAL_AUTHENTICATED_RID) {
$form['#attached']['js'][] = array(
'data' => array(
'LoginToboggan' => array(
'preAuthID' => $id,
),
),
'type' => 'setting',
);
}
}
/**
* Implement hook_form_alter().
*
@@ -410,7 +390,10 @@ function logintoboggan_js_alter(&$javascript) {
// prevent the pre-auth role's checkboxes from being automatically disabled
// when the auth user's checkboxes are checked.
if ($id != DRUPAL_AUTHENTICATED_RID) {
$javascript['modules/user/user.permissions.js']['data'] = drupal_get_path('module', 'logintoboggan') . '/logintoboggan.permissions.js';
$javascript['settings']['data'][] = array('LoginToboggan' => array('preAuthID' => $id));
$file = drupal_get_path('module', 'logintoboggan') . '/logintoboggan.permissions.js';
$javascript[$file] = drupal_js_defaults($file);
$javascript[$file]['weight'] = 999;
}
}
}

View File

@@ -1,77 +1,25 @@
/**
* This is a custom implementation of user.permissions.js, which is necessary
* because LoginToboggan needs its pre-auth role to not be explicitly tied to
* the auth role. The change is minor -- simply exclude the pre-auth role from
* all the auto-checking as the anon and auth user roles are.
* LoginToboggan needs its pre-auth role to not be explicitly tied to
* the auth role.
*/
(function ($) {
/**
* Shows checked and disabled checkboxes for inherited permissions.
*/
Drupal.behaviors.permissions = {
attach: function (context) {
var self = this;
$('table#permissions').once('permissions', function () {
// On a site with many roles and permissions, this behavior initially has
// to perform thousands of DOM manipulations to inject checkboxes and hide
// them. By detaching the table from the DOM, all operations can be
// performed without triggering internal layout and re-rendering processes
// in the browser.
var $table = $(this);
if ($table.prev().length) {
var $ancestor = $table.prev(), method = 'after';
}
else {
var $ancestor = $table.parent(), method = 'append';
}
$table.detach();
// Create dummy checkboxes. We use dummy checkboxes instead of reusing
// the existing checkboxes here because new checkboxes don't alter the
// submitted form. If we'd automatically check existing checkboxes, the
// permission table would be polluted with redundant entries. This
// is deliberate, but desirable when we automatically check them.
var $dummy = $('<input type="checkbox" class="dummy-checkbox" disabled="disabled" checked="checked" />')
.attr('title', Drupal.t("This permission is inherited from the authenticated user role."))
.hide();
$('input[type=checkbox]', this).not('.rid-2, .rid-1, .rid-' + Drupal.settings.LoginToboggan.preAuthID).addClass('real-checkbox').each(function () {
$dummy.clone().insertAfter(this);
Drupal.behaviors.LoginTobogganPermissions = {
attach: function (context, settings) {
// Revert changes made by modules/user/user.permissions.js
$('table#permissions', context).once('tobogganPermissions', function () {
$('input[type=checkbox]', this).filter('.rid-' + settings.LoginToboggan.preAuthID).removeClass('real-checkbox').each(function () {
$(this).next().filter('.dummy-checkbox').remove();
$('input.rid-' + settings.LoginToboggan.preAuthID).each(function () {
this.style.display = '';
});
});
// Initialize the authenticated user checkbox.
$('input[type=checkbox].rid-2', this)
.bind('click.permissions', self.toggle)
// .triggerHandler() cannot be used here, as it only affects the first
// element.
.each(self.toggle);
// Re-insert the table into the DOM.
$ancestor[method]($table);
});
},
/**
* Toggles all dummy checkboxes based on the checkboxes' state.
*
* If the "authenticated user" checkbox is checked, the checked and disabled
* checkboxes are shown, the real checkboxes otherwise.
*/
toggle: function () {
var authCheckbox = this, $row = $(this).closest('tr');
// jQuery performs too many layout calculations for .hide() and .show(),
// leading to a major page rendering lag on sites with many roles and
// permissions. Therefore, we toggle visibility directly.
$row.find('.real-checkbox').each(function () {
this.style.display = (authCheckbox.checked ? 'none' : '');
});
$row.find('.dummy-checkbox').each(function () {
this.style.display = (authCheckbox.checked ? '' : 'none');
});
}
};
})(jQuery);

View File

@@ -0,0 +1,12 @@
--- logintoboggan.permissions.js
+++ logintoboggan.permissions.js
@@ -14,6 +14,9 @@ Drupal.behaviors.LoginTobogganPermissions = {
$('table#permissions', context).once('tobogganPermissions', function () {
$('input[type=checkbox]', this).filter('.rid-' + settings.LoginToboggan.preAuthID).removeClass('real-checkbox').each(function () {
$(this).next().filter('.dummy-checkbox').remove();
+ $('input.rid-' + settings.LoginToboggan.preAuthID).each(function () {
+ this.style.display = '';
+ });
});
});
},