-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshortcut.install
50 lines (45 loc) · 1.88 KB
/
shortcut.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
<?php
/**
* Implementation of hook_install().
*/
function shortcut_install() {
drupal_install_schema('shortcut');
}
/**
* Implementation of hook_uninstall().
*/
function shortcut_uninstall() {
drupal_uninstall_schema('shortcut');
}
/**
* Implementation of hook_schema().
*/
function shortcut_schema() {
$schema['shortcut'] = array(
'fields' => array(
'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => 'The node id associated.'),
'keys_mask' => array('type' => 'int', 'not null' => TRUE, 'size' => 'tiny', 'default' => 0, 'description' => 'Mask containing the meta keys.'),
'char_text' => array('type' => 'char', 'not null' => FALSE, 'length' => 1, 'description' => 'Character key. Optional, could be used the char code instead.'),
'char_code' => array('type' => 'int', 'not null' => FALSE, 'size' => 'tiny', 'description' => 'Key code. Optional, could be used the char text instead.'),
's_type' => array('type' => 'int', 'not null' => TRUE, 'size' => 'tiny', 'default' => 0, 'description' => 'Integer that indicates the type of action.'),
's_action' => array('type' => 'varchar', 'not null' => TRUE, 'length' => 255, 'description' => 'The text that contains the action path or function name.'),
),
'unique key' => array(
'masks' => array('key_mask', 'char_text', 'char_code'),
),
'primary key' => array('nid'),
'description' => 'The extra information for each shortcut.',
);
return $schema;
}
function shortcut_update_6200() {
$shortcuts = db_query("SELECT nid, char_text, char_code FROM {shortcut}");
$ret = array();
while( $tmp = db_fetch_object($shortcuts) ) {
if(!empty($tmp->char_text)) {
$code = ord(strtoupper($tmp->char_text));
$ret[] = update_sql("UPDATE {shortcut} SET char_code = ".$code." WHERE nid = ".$tmp->nid);
}
}
return $ret;
}