X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd7%2Fctools-plugin%2Faccess.twig;fp=vendor%2Fchi-teck%2Fdrupal-code-generator%2Ftemplates%2Fd7%2Fctools-plugin%2Faccess.twig;h=d817869b733d86dbd4f0ae1a430e78aef873d4f9;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=0000000000000000000000000000000000000000;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0;p=yaffs-website diff --git a/vendor/chi-teck/drupal-code-generator/templates/d7/ctools-plugin/access.twig b/vendor/chi-teck/drupal-code-generator/templates/d7/ctools-plugin/access.twig new file mode 100644 index 000000000..d817869b7 --- /dev/null +++ b/vendor/chi-teck/drupal-code-generator/templates/d7/ctools-plugin/access.twig @@ -0,0 +1,53 @@ + TRUE, + 'title' => t('{{ plugin_name }}'), + 'description' => t('{{ description }}'), +{% if context == 'Node' or context == 'User' %} + 'required context' => new ctools_context_required(t('{{ context }}'), '{{ context | lower }}'), +{% elseif context == 'Term' %} + 'required context' => new ctools_context_required(t('{{ context }}'), array('term', 'taxonomy_term')), +{% endif %} + 'category' => t('{{ category }}'), + 'callback' => '{{ machine_name }}_{{ plugin_machine_name }}_access_check', + 'summary' => '{{ machine_name }}_{{ plugin_machine_name }}_access_summary', +); + +/** + * Access callback. + */ +function {{ machine_name }}_{{ plugin_machine_name }}_access_check($conf, $context) { +{% if context != '-' %} + + if (empty($context->data)) { + return; + } +{% endif %} + +{% if context == 'Node' or context == 'Term' %} + ${{ context | lower }} = clone $context->data; + +{% elseif context == 'User' %} +{# Use $account variable avoid confusion with the global $user object #} + $account = clone $context->data; + +{% endif %} + // @TODO: Check access here. + return TRUE; +} + +/** + * Summary callback. + */ +function {{ machine_name }}_{{ plugin_machine_name }}_access_summary($conf, $context) { + return t('Summary placeholder'); +}