-
Notifications
You must be signed in to change notification settings - Fork 2
/
lr_publish.install
81 lines (74 loc) · 2.3 KB
/
lr_publish.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
<?php
/**
* @file
* Installation file for the lr_publish module.
*
* This installation file sets up the database for the lr_publish module.
*/
/**
* Implementation of hook_install()
*/
function lr_publish_install() {
drupal_set_message((t('Installing lr_publish.')));
drupal_install_schema('lr_publish');
// set module weight lower than workflow. This query lifted from
// http://drupal.org/node/110238#comment-3567274
$weight =
db_result(db_query("SELECT weight FROM {system} WHERE type = 'module' AND name = 'workflow'"));
db_query("UPDATE {system} SET weight = %d WHERE type = 'module' AND name = 'lr_publish'", $weight + 1);
}
/**
* Implementation of hook_uninstall()
*/
function lr_publish_uninstall() {
drupal_uninstall_schema('lr_publish');
// remove any configuration values. shamelessly stolen from
// http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/variable_del/6#comment-10934
$result = db_query("SELECT name from {variable} WHERE name LIKE 'lr_publish_%'");
while ($var_name = db_result($result)) {
variable_del($var_name);
}
}
/**
* Implementation of hook_schema()
*
* @returns $schema
* An array providing the DB schema definition required by the schema API.
*/
function lr_publish_schema() {
$schema['lr_publish'] = array(
'description' => t('Tracks which Drupal nodes have been published to the registry.'),
'fields' => array(
'nid' => array(
'description' => t('The primary identifier for a node.'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'published' => array(
'description' => t('The original date of publication to the LR node.'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'updated' => array(
'description' => t('The most recent update to the LR node.'),
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'docid' => array(
'description' => t('The doc ID returned on successful submission to the Learning Registry.'),
'type' => 'varchar',
'length' => 1024,
'not null' => TRUE,
'default' => '',
),
),
'indexes' => array(
'changed' => array('updated',),
),
'primary key' => array('nid'),
);
return $schema;
}