-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode_limit.install
86 lines (80 loc) · 2.14 KB
/
node_limit.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
<?php
/**
* @file
* Installation functions for module node_limit.
*/
if (!defined("NODE_LIMIT_NO_LIMIT")) define("NODE_LIMIT_NO_LIMIT", -1);
/**
* Implements hook_schema().
*/
function node_limit_schema() {
$schema['node_limit'] = array(
'description' => 'The base Node Limit table',
'fields' => array(
'lid' => array(
'description' => 'The limit id',
'type' => 'int',
'not null' => TRUE
),
'type' => array(
'description' => 'The {node}.type to which this limit applies',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => ''
),
'nlimit' => array(
'description' => 'The node limit for this limit',
'type' => 'int',
'not null' => TRUE,
'default' => NODE_LIMIT_NO_LIMIT
),
'title' => array(
'description' => 'The display name for this limit',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => ''
),
'weight' => array(
'description' => 'The weight of this limit',
'type' => 'int',
'not null' => TRUE,
'default' => 0
),
),
'primary key' => array('lid')
);
return $schema;
}
/**
* Implements hook_update_N().
* Renaming limit field to avoid mysql restricted name usage.
*/
function node_limit_update_7001() {
// Cannot use db_change_field() because of the restricted name
$ret = db_query("ALTER TABLE {node_limit} CHANGE `limit` `limit_count` INT(11) NOT NULL DEFAULT '-1' COMMENT 'The node limit for this limit'");
return !empty($ret);
}
/**
* Implements hook_update_N().
* Renaming limit_count field to keep names consistency.
*/
function node_limit_update_7002() {
$ret = db_change_field('node_limit', 'limit_count', 'nlimit',
array(
'description' => 'The node limit for this limit',
'type' => 'int',
'not null' => TRUE,
'default' => NODE_LIMIT_NO_LIMIT
));
return !empty($ret);
}
/**
* Implements hook_disable().
*/
function node_limit_disable() {
db_delete('variable')
->condition('name', 'node_limit_%', 'LIKE')
->execute();
}