-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdomain_blocks.install
88 lines (83 loc) · 2.88 KB
/
domain_blocks.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
// $Id: domain_blocks.install,v 1.1.2.2 2009/01/06 23:45:14 nonsie Exp $
/**
* @file
* Provides domain specific visibility settings for blocks based on user domain access settings
*/
/**
* Implementation of hook_install().
*/
function domain_blocks_install() {
// Create database tables
drupal_install_schema('domain_blocks');
// Make all blocks accesible by all sites by default
// Since {blocks} stores a separate row for each theme a block will appear on,
// we'll use DISTINCT to make sure we're not getting doubles.
//Update: we now have domain_site records for each id, and we will create these records later, when the blocks are called for each id, se we can comment this out
//$existing_blocks = db_query('SELECT DISTINCT module, delta, region, weight FROM {blocks}');
//while ($block = db_fetch_object($existing_blocks)) {
//db_query("INSERT INTO {domain_blocks}(module, delta, realm, domain_id, region, weight) VALUES('%s', '%s', '%s', %d, '%s', %d)", $block->module, $block->delta, 'domain_site', 0, $block->region, $block->weight);
//}
}
/**
* Implementation of hook_uninstall().
*/
function domain_blocks_uninstall() {
drupal_uninstall_schema('domain_blocks');
}
/**
* Implementation of hook_schema().
* Notice the length of domain_blocks.realm field is not the same as domain_access.realm.
* This is due to MySQL key length limitations (applies to UTF-8 only) - http://bugs.mysql.com/bug.php?id=4541
* Since Domain Access only uses grants with length < 14 characters this inconsistency is irrelevant.
*/
function domain_blocks_schema() {
$schema['domain_blocks'] = array(
'description' => t('Domain Access specific blocks'),
'fields' => array(
'module' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'description' => t("The block's origin module, from {blocks}.module."),
),
'delta' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '0',
'description' => t('Unique ID for block within a module.'),
),
'realm' => array(
'type' => 'varchar',
'length' => '20',
'not null' => TRUE,
'default' => '',
),
'domain_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'description' => t("Block domain id"),
'not null' => TRUE,
'default' => 0,
),
'region' => array(
'type' => 'varchar',
'length' => '64',
'not null' => TRUE,
),
'weight' => array(
'type' => 'int',
'description' => t("Block weight within domain"),
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array('module', 'delta', 'realm', 'domain_id'),
'indexes' => array(
'domain_id' => array('domain_id'),
'domain_realm_grant' => array('domain_id', 'realm'),
),
);
return $schema;
}