pierre@0: . pierre@0: */ pierre@0: pierre@0: /** pierre@0: * Implementation of hook_schema(). pierre@0: */ pierre@0: function ad_notify_schema() { pierre@0: $schema['ad_notify'] = array( pierre@0: 'description' => 'The ad_notify table stores notifications data such as recepient, message body, event, etc.', pierre@0: 'fields' => array( pierre@0: 'notid' => array( pierre@0: 'type' => 'serial', pierre@0: 'unsigned' => TRUE, pierre@0: 'not null' => TRUE, pierre@0: ), pierre@0: 'aid' => array( pierre@0: 'type' => 'int', pierre@0: 'unsigned' => TRUE, pierre@0: 'not null' => TRUE, pierre@0: 'default' => 0, pierre@0: ), pierre@0: 'oid' => array( pierre@0: 'type' => 'int', pierre@0: 'unsigned' => TRUE, pierre@0: 'not null' => TRUE, pierre@0: 'default' => 0, pierre@0: ), pierre@0: 'event' => array( pierre@0: 'type' => 'varchar', pierre@0: 'length' => '255', pierre@0: 'not null' => TRUE, pierre@0: 'default' => '' pierre@0: ), pierre@0: 'delay' => array( pierre@0: 'type' => 'int', pierre@0: 'not null' => TRUE, pierre@0: 'default' => 0, pierre@0: ), pierre@0: 'queued' => array( pierre@0: 'type' => 'int', pierre@0: 'not null' => TRUE, pierre@0: 'default' => 0, pierre@0: ), pierre@0: 'sent' => array( pierre@0: 'type' => 'int', pierre@0: 'not null' => TRUE, pierre@0: 'default' => 0, pierre@0: ), pierre@0: 'counter' => array( pierre@0: 'type' => 'int', pierre@0: 'unsigned' => TRUE, pierre@0: 'not null' => TRUE, pierre@0: 'default' => 0, pierre@0: ), pierre@0: 'locked' => array( pierre@0: 'type' => 'int', pierre@0: 'unsigned' => TRUE, pierre@0: 'size' => 'tiny', pierre@0: 'not null' => TRUE, pierre@0: 'default' => 0, pierre@0: ), pierre@0: 'expire' => array( pierre@0: 'type' => 'int', pierre@0: 'unsigned' => TRUE, pierre@0: 'size' => 'tiny', pierre@0: 'not null' => TRUE, pierre@0: 'default' => 0, pierre@0: ), pierre@0: 'status' => array( pierre@0: 'type' => 'int', pierre@0: 'unsigned' => TRUE, pierre@0: 'size' => 'tiny', pierre@0: 'not null' => TRUE, pierre@0: 'default' => 0, pierre@0: ), pierre@0: 'address' => array( pierre@0: 'type' => 'varchar', pierre@0: 'length' => '255', pierre@0: 'not null' => TRUE, pierre@0: 'default' => '', pierre@0: ), pierre@0: 'subject' => array( pierre@0: 'type' => 'varchar', pierre@0: 'length' => '255', pierre@0: 'not null' => TRUE, pierre@0: 'default' => '', pierre@0: ), pierre@0: 'body' => array( pierre@0: 'type' => 'text', pierre@0: 'not null' => FALSE, pierre@0: ), pierre@1: 'roles' => array( pierre@1: 'type' => 'varchar', pierre@1: 'length' => '255', pierre@1: 'not null' => TRUE, pierre@1: 'default' => '', pierre@1: ), pierre@1: 'template' => array( pierre@1: 'type' => 'int', pierre@1: 'unsigned' => TRUE, pierre@1: 'not null' => TRUE, pierre@1: 'default' => 0, pierre@1: ), pierre@0: ), pierre@0: 'primary key' => array('notid'), pierre@0: 'unique keys' => array( pierre@0: 'oid' => array('oid', 'event', 'delay'), pierre@0: ), pierre@0: 'indexes' => array( pierre@0: 'delay' => array('delay'), pierre@0: 'event' => array('event'), pierre@0: 'oid_2' => array('oid'), pierre@0: 'queued' => array('queued'), pierre@0: 'sent' => array('sent'), pierre@0: 'status' => array('status'), pierre@0: ), pierre@0: ); pierre@0: pierre@0: return $schema; pierre@0: } pierre@0: pierre@0: /** pierre@0: * ad_notify module installation. pierre@0: */ pierre@0: function ad_notify_install() { pierre@0: drupal_install_schema('ad_notify'); pierre@0: } pierre@0: pierre@0: /** pierre@0: * Allow complete uninstallation of the ad_notify module. pierre@0: */ pierre@0: function ad_notify_uninstall() { pierre@0: // Remove tables. pierre@0: drupal_uninstall_schema('ad_notify'); pierre@0: } pierre@1: pierre@1: /** pierre@1: * Introduce new roles field to allow per-role notifications. pierre@1: * Replace nonstandard %sitename with standard %site-name. pierre@1: * Replace nonstandard %siteurl with standard %site-url. pierre@1: */ pierre@1: function ad_notify_update_6001() { pierre@1: $ret = array(); pierre@1: db_add_field($ret, 'ad_notify', 'roles', array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '')); pierre@1: pierre@1: $ret[] = update_sql('UPDATE {ad_notify} SET subject = REPLACE(subject, "%sitename", "%site-name")'); pierre@1: $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%siteurl", "%site-url")'); pierre@1: pierre@1: } pierre@1: pierre@1: /** pierre@1: * Introduce new template field. pierre@1: */ pierre@1: function ad_notify_update_6002() { pierre@1: $ret = array(); pierre@1: db_add_field($ret, 'ad_notify', 'template', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)); pierre@1: return $ret; pierre@1: } pierre@1: pierre@1: /** pierre@1: * Replace nonstandard %sitename with standard %site-name. pierre@1: * Replace nonstandard %siteurl with standard %site-url. pierre@1: * (Repeating update_6001 as there were more instances of these old variables pierre@1: * in the code.) pierre@1: */ pierre@1: function ad_notify_update_6003() { pierre@1: $ret = array(); pierre@1: $ret[] = update_sql('UPDATE {ad_notify} SET subject = REPLACE(subject, "%%sitename", "%%site-name")'); pierre@1: $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%sitename", "%%site-name")'); pierre@1: $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%max_views", "%%max_impressions")'); pierre@1: $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%global_views", "%%global_impressions")'); pierre@1: $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%last_year_views", "%%last_year_impressions")'); pierre@1: $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%this_year_views", "%%this_year_impressions")'); pierre@1: $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%last_month_views", "%%last_month_impressions")'); pierre@1: $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%this_month_views", "%%this_month_impressions")'); pierre@1: $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%yesterday_views", "%%yesterday_impressions")'); pierre@1: $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%today_views", "%%today_impressions")'); pierre@1: $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%last_hour_views", "%%last_hour_impressions")'); pierre@1: $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%this_hour_views", "%%this_hour_impressions")'); pierre@1: return $ret; pierre@1: } pierre@1: