Ctools access plugin to provide access/visiblity if two values are equal. Supported by a comparison of several values.

Summary

Configure

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

m.lebedev’s picture

m.lebedev’s picture

Title: New access plugin [D7] » New access plugin to compare value [D7]
andypost’s picture

Nice idea, +1 rtbc but that need another pier review

+++ b/plugins/access/compare_value.inc
@@ -0,0 +1,103 @@
+    $form['available_tokens'] = array(
...
+      '#theme' => 'token_tree',
+      '#token_types' => array(),
...
+    $form['contexts'] = array(
+      '#title' => t('Substitutions'),
...
+function ctools_compare_value_access_check($conf, $contexts) {
...
+  $value = token_replace(ctools_context_keyword_substitute(trim($conf['value']), array(), $contexts));
+  $values = array_filter(explode("\n", $conf['values']));
...
+    if ($value === token_replace(ctools_context_keyword_substitute(trim($item), array(), $contexts))) {
+      return TRUE;

so this requires that entities has to be configured their token view mode

+++ b/plugins/access/compare_value.inc
@@ -0,0 +1,103 @@
+  $text = implode(' OR ', $values);

nice to have configured as #1955954: entity_field_value.inc is mostly useless

andypost’s picture

Issue summary: View changes
maximpodorov’s picture

Token view mode is not required since global tokens only are supported without specified context of the ctools plugin.
Andrey, do you mean we should add operator setting to the plugin?

andypost’s picture

add operator setting to the plugin?

sure

m.lebedev’s picture

FileSize
20.17 KB
m.lebedev’s picture

I added the conditions comparing the value.

m.lebedev’s picture

FileSize
29.03 KB
7.42 KB

Fixed bug and added descriptions of the fields.

m.lebedev’s picture

Issue summary: View changes
DamienMcKenna’s picture

Version: 7.x-1.4 » 7.x-1.x-dev

maximpodorov’s picture

Here's the simplified plugin.

Chris Matthews’s picture

The 3 year old patch in #13 to token_equal.inc applied cleanly to the latest ctools 7.x-1.x-dev and if still applicable needs to be reviewed.

Checking patch plugins/access/token_equal.inc...
Applied patch plugins/access/token_equal.inc cleanly.