| webmaster@1 | 1 <?php | 
| webmaster@1 | 2 // $Id: dblog.install,v 1.6 2007/11/04 14:33:06 goba Exp $ | 
| webmaster@1 | 3 | 
| webmaster@1 | 4 /** | 
| webmaster@1 | 5  * Implementation of hook_install(). | 
| webmaster@1 | 6  */ | 
| webmaster@1 | 7 function dblog_install() { | 
| webmaster@1 | 8   // Create tables. | 
| webmaster@1 | 9   drupal_install_schema('dblog'); | 
| webmaster@1 | 10 } | 
| webmaster@1 | 11 | 
| webmaster@1 | 12 /** | 
| webmaster@1 | 13  * Implementation of hook_uninstall(). | 
| webmaster@1 | 14  */ | 
| webmaster@1 | 15 function dblog_uninstall() { | 
| webmaster@1 | 16   // Remove tables. | 
| webmaster@1 | 17   drupal_uninstall_schema('dblog'); | 
| webmaster@1 | 18 } | 
| webmaster@1 | 19 | 
| webmaster@1 | 20 /** | 
| webmaster@1 | 21  * Implementation of hook_schema(). | 
| webmaster@1 | 22  */ | 
| webmaster@1 | 23 function dblog_schema() { | 
| webmaster@1 | 24   $schema['watchdog'] = array( | 
| webmaster@1 | 25     'description' => t('Table that contains logs of all system events.'), | 
| webmaster@1 | 26     'fields' => array( | 
| webmaster@1 | 27       'wid' => array( | 
| webmaster@1 | 28         'type' => 'serial', | 
| webmaster@1 | 29         'not null' => TRUE, | 
| webmaster@1 | 30         'description' => t('Primary Key: Unique watchdog event ID.'), | 
| webmaster@1 | 31       ), | 
| webmaster@1 | 32       'uid' => array( | 
| webmaster@1 | 33         'type' => 'int', | 
| webmaster@1 | 34         'not null' => TRUE, | 
| webmaster@1 | 35         'default' => 0, | 
| webmaster@1 | 36         'description' => t('The {users}.uid of the user who triggered the event.'), | 
| webmaster@1 | 37       ), | 
| webmaster@1 | 38       'type' => array( | 
| webmaster@1 | 39         'type' => 'varchar', | 
| webmaster@1 | 40         'length' => 16, | 
| webmaster@1 | 41         'not null' => TRUE, | 
| webmaster@1 | 42         'default' => '', | 
| webmaster@1 | 43         'description' => t('Type of log message, for example "user" or "page not found."'), | 
| webmaster@1 | 44       ), | 
| webmaster@1 | 45       'message' => array( | 
| webmaster@1 | 46         'type' => 'text', | 
| webmaster@1 | 47         'not null' => TRUE, | 
| webmaster@1 | 48         'size' => 'big', | 
| webmaster@1 | 49         'description' => t('Text of log message to be passed into the t() function.'), | 
| webmaster@1 | 50       ), | 
| webmaster@1 | 51       'variables' => array( | 
| webmaster@1 | 52         'type' => 'text', | 
| webmaster@1 | 53         'not null' => TRUE, | 
| webmaster@1 | 54         'size' => 'big', | 
| webmaster@1 | 55         'description' => t('Serialized array of variables that match the message string and that is passed into the t() function.'), | 
| webmaster@1 | 56       ), | 
| webmaster@1 | 57       'severity' => array( | 
| webmaster@1 | 58         'type' => 'int', | 
| webmaster@1 | 59         'unsigned' => TRUE, | 
| webmaster@1 | 60         'not null' => TRUE, | 
| webmaster@1 | 61         'default' => 0, | 
| webmaster@1 | 62         'size' => 'tiny', | 
| webmaster@1 | 63         'description' => t('The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)'), | 
| webmaster@1 | 64       ), | 
| webmaster@1 | 65       'link' => array( | 
| webmaster@1 | 66         'type' => 'varchar', | 
| webmaster@1 | 67         'length' => 255, | 
| webmaster@1 | 68         'not null' => TRUE, | 
| webmaster@1 | 69         'default' => '', | 
| webmaster@1 | 70         'description' => t('Link to view the result of the event.'), | 
| webmaster@1 | 71       ), | 
| webmaster@1 | 72       'location'  => array( | 
| webmaster@1 | 73         'type' => 'text', | 
| webmaster@1 | 74         'not null' => TRUE, | 
| webmaster@1 | 75         'description' => t('URL of the origin of the event.'), | 
| webmaster@1 | 76       ), | 
| webmaster@1 | 77       'referer' => array( | 
| webmaster@1 | 78         'type' => 'varchar', | 
| webmaster@1 | 79         'length' => 128, | 
| webmaster@1 | 80         'not null' => TRUE, | 
| webmaster@1 | 81         'default' => '', | 
| webmaster@1 | 82         'description' => t('URL of referring page.'), | 
| webmaster@1 | 83       ), | 
| webmaster@1 | 84       'hostname' => array( | 
| webmaster@1 | 85         'type' => 'varchar', | 
| webmaster@1 | 86         'length' => 128, | 
| webmaster@1 | 87         'not null' => TRUE, | 
| webmaster@1 | 88         'default' => '', | 
| webmaster@1 | 89         'description' => t('Hostname of the user who triggered the event.'), | 
| webmaster@1 | 90       ), | 
| webmaster@1 | 91       'timestamp' => array( | 
| webmaster@1 | 92         'type' => 'int', | 
| webmaster@1 | 93         'not null' => TRUE, | 
| webmaster@1 | 94         'default' => 0, | 
| webmaster@1 | 95         'description' => t('Unix timestamp of when event occurred.'), | 
| webmaster@1 | 96       ), | 
| webmaster@1 | 97     ), | 
| webmaster@1 | 98     'primary key' => array('wid'), | 
| webmaster@1 | 99     'indexes' => array('type' => array('type')), | 
| webmaster@1 | 100   ); | 
| webmaster@1 | 101 | 
| webmaster@1 | 102   return $schema; | 
| webmaster@1 | 103 } | 
| webmaster@1 | 104 |