Projet

Général

Profil

Paste
Télécharger (2,48 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ctools / ctools_access_ruleset / ctools_access_ruleset.module @ 6e3ce7c2

1
<?php
2

    
3
/**
4
 * @file
5
 * The ctools_access_ruleset module.
6
 *
7
 * This module allows styles to be created and managed on behalf of modules
8
 * that implement styles.
9
 *
10
 * The ctools_access_ruleset tool allows recolorable styles to be created via a miniature
11
 * scripting language. Panels utilizes this to allow administrators to add
12
 * styles directly to any panel display.
13
 */
14

    
15
/**
16
 * Implementation of hook_permission()
17
 */
18
function ctools_access_ruleset_permission() {
19
  return array(
20
    'administer ctools access ruleset' => array(
21
      'title' => t('Administer access rulesets'),
22
      'description' => t('Add, delete and edit custom access rulesets.'),
23
    ),
24
  );
25
}
26

    
27
/**
28
 * Implementation of hook_ctools_plugin_directory() to let the system know
29
 * we implement task and task_handler plugins.
30
 */
31
function ctools_access_ruleset_ctools_plugin_directory($module, $plugin) {
32
  // Most of this module is implemented as an export ui plugin, and the
33
  // rest is in ctools/includes/ctools_access_ruleset.inc.
34
  if ($module == 'ctools' && ($plugin == 'export_ui' || $plugin == 'access')) {
35
    return 'plugins/' . $plugin;
36
  }
37
}
38

    
39
/**
40
 * Implementation of hook_panels_dashboard_blocks().
41
 *
42
 * Adds page information to the Panels dashboard.
43
 */
44
function ctools_access_ruleset_panels_dashboard_blocks(&$vars) {
45
  $vars['links']['ctools_access_ruleset'] = array(
46
    'title' => l(t('Custom ruleset'), 'admin/structure/ctools-rulesets/add'),
47
    'description' => t('Custom rulesets are combinations of access plugins you can use for access control, selection criteria and pane visibility.'),
48
  );
49

    
50
  // Load all mini panels and their displays.
51
  ctools_include('export');
52
  $items = ctools_export_crud_load_all('ctools_access_ruleset');
53
  $count = 0;
54
  $rows = array();
55

    
56
  foreach ($items as $item) {
57
    $rows[] = array(
58
      check_plain($item->admin_title),
59
      array(
60
        'data' => l(t('Edit'), "admin/structure/ctools-rulesets/list/$item->name/edit"),
61
        'class' => 'links',
62
      ),
63
    );
64

    
65
    // Only show 10.
66
    if (++$count >= 10) {
67
      break;
68
    }
69
  }
70

    
71
  if ($rows) {
72
    $content = theme('table', array('rows' => $rows, 'attributes' => array('class' => 'panels-manage')));
73
  }
74
  else {
75
    $content = '<p>' . t('There are no custom rulesets.') . '</p>';
76
  }
77

    
78
  $vars['blocks']['ctools_access_ruleset'] = array(
79
    'title' => t('Manage custom rulesets'),
80
    'link' => l(t('Go to list'), 'admin/structure/ctools-rulesets'),
81
    'content' => $content,
82
    'class' => 'dashboard-ruleset',
83
    'section' => 'right',
84
  );
85
}