ctools_access_ruleset.module 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * @file
  4. * The ctools_access_ruleset module.
  5. *
  6. * This module allows styles to be created and managed on behalf of modules
  7. * that implement styles.
  8. *
  9. * The ctools_access_ruleset tool allows recolorable styles to be created via a miniature
  10. * scripting language. Panels utilizes this to allow administrators to add
  11. * styles directly to any panel display.
  12. */
  13. /**
  14. * Implementation of hook_permission()
  15. */
  16. function ctools_access_ruleset_permission() {
  17. return array(
  18. 'administer ctools access ruleset' => array(
  19. 'title' => t('Administer access rulesets'),
  20. 'description' => t('Add, delete and edit custom access rulesets.'),
  21. ),
  22. );
  23. }
  24. /**
  25. * Implementation of hook_ctools_plugin_directory() to let the system know
  26. * we implement task and task_handler plugins.
  27. */
  28. function ctools_access_ruleset_ctools_plugin_directory($module, $plugin) {
  29. // Most of this module is implemented as an export ui plugin, and the
  30. // rest is in ctools/includes/ctools_access_ruleset.inc.
  31. if ($module == 'ctools' && ($plugin == 'export_ui' || $plugin == 'access')) {
  32. return 'plugins/' . $plugin;
  33. }
  34. }
  35. /**
  36. * Implementation of hook_panels_dashboard_blocks().
  37. *
  38. * Adds page information to the Panels dashboard.
  39. */
  40. function ctools_access_ruleset_panels_dashboard_blocks(&$vars) {
  41. $vars['links']['ctools_access_ruleset'] = array(
  42. 'title' => l(t('Custom ruleset'), 'admin/structure/ctools-rulesets/add'),
  43. 'description' => t('Custom rulesets are combinations of access plugins you can use for access control, selection criteria and pane visibility.'),
  44. );
  45. // Load all mini panels and their displays.
  46. ctools_include('export');
  47. $items = ctools_export_crud_load_all('ctools_access_ruleset');
  48. $count = 0;
  49. $rows = array();
  50. foreach ($items as $item) {
  51. $rows[] = array(
  52. check_plain($item->admin_title),
  53. array(
  54. 'data' => l(t('Edit'), "admin/structure/ctools-rulesets/list/$item->name/edit"),
  55. 'class' => 'links',
  56. ),
  57. );
  58. // Only show 10.
  59. if (++$count >= 10) {
  60. break;
  61. }
  62. }
  63. if ($rows) {
  64. $content = theme('table', array('rows' => $rows, 'attributes' => array('class' => 'panels-manage')));
  65. }
  66. else {
  67. $content = '<p>' . t('There are no custom rulesets.') . '</p>';
  68. }
  69. $vars['blocks']['ctools_access_ruleset'] = array(
  70. 'title' => t('Manage custom rulesets'),
  71. 'link' => l(t('Go to list'), 'admin/structure/ctools-rulesets'),
  72. 'content' => $content,
  73. 'class' => 'dashboard-ruleset',
  74. 'section' => 'right',
  75. );
  76. }