forked from lotia/lr_publish
-
Notifications
You must be signed in to change notification settings - Fork 1
/
lr_publish.install
95 lines (85 loc) · 2.78 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?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');
}
function lr_publish_enable() {
// set module weight lower than workflow or pathauto. This query lifted from
// http://drupal.org/node/110238#comment-3567274
$workFlowWeight =
db_result(db_query("SELECT weight FROM {system} WHERE type = 'module' AND name = 'workflow'"));
$pathautoWeight =
db_result(db_query("SELECT weight FROM {system} WHERE type = 'module' AND name = 'pathauto'"));
if ($pathautoWeight > $workFlowWeight) { $weight=$pathautoWeight; } else { $weight=$workFlowWeight; }
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,
),
'queued' => array(
'description' => t('Flag to determine if node is queued for processing.'),
'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;
}