Mercurial > defr > drupal > ad
diff notify/ad_notify.install @ 1:948362c2a207 ad
update advertisement
author | pierre |
---|---|
date | Thu, 02 Apr 2009 15:28:21 +0000 |
parents | d8a3998dac8e |
children |
line wrap: on
line diff
--- a/notify/ad_notify.install Fri Feb 20 14:04:09 2009 +0000 +++ b/notify/ad_notify.install Thu Apr 02 15:28:21 2009 +0000 @@ -1,5 +1,5 @@ <?php -// $Id: ad_notify.install,v 1.1.2.2.2.6.2.3 2009/02/16 17:06:49 jeremy Exp $ +// $Id: ad_notify.install,v 1.1.2.2.2.6.2.3.2.3 2009/03/29 20:17:21 jeremy Exp $ /** * @file @@ -97,6 +97,18 @@ 'type' => 'text', 'not null' => FALSE, ), + 'roles' => array( + 'type' => 'varchar', + 'length' => '255', + 'not null' => TRUE, + 'default' => '', + ), + 'template' => array( + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + ), ), 'primary key' => array('notid'), 'unique keys' => array( @@ -122,7 +134,6 @@ drupal_install_schema('ad_notify'); } - /** * Allow complete uninstallation of the ad_notify module. */ @@ -130,3 +141,50 @@ // Remove tables. drupal_uninstall_schema('ad_notify'); } + +/** + * Introduce new roles field to allow per-role notifications. + * Replace nonstandard %sitename with standard %site-name. + * Replace nonstandard %siteurl with standard %site-url. + */ +function ad_notify_update_6001() { + $ret = array(); + db_add_field($ret, 'ad_notify', 'roles', array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '')); + + $ret[] = update_sql('UPDATE {ad_notify} SET subject = REPLACE(subject, "%sitename", "%site-name")'); + $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%siteurl", "%site-url")'); + +} + +/** + * Introduce new template field. + */ +function ad_notify_update_6002() { + $ret = array(); + db_add_field($ret, 'ad_notify', 'template', array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)); + return $ret; +} + +/** + * Replace nonstandard %sitename with standard %site-name. + * Replace nonstandard %siteurl with standard %site-url. + * (Repeating update_6001 as there were more instances of these old variables + * in the code.) + */ +function ad_notify_update_6003() { + $ret = array(); + $ret[] = update_sql('UPDATE {ad_notify} SET subject = REPLACE(subject, "%%sitename", "%%site-name")'); + $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%sitename", "%%site-name")'); + $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%max_views", "%%max_impressions")'); + $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%global_views", "%%global_impressions")'); + $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%last_year_views", "%%last_year_impressions")'); + $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%this_year_views", "%%this_year_impressions")'); + $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%last_month_views", "%%last_month_impressions")'); + $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%this_month_views", "%%this_month_impressions")'); + $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%yesterday_views", "%%yesterday_impressions")'); + $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%today_views", "%%today_impressions")'); + $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%last_hour_views", "%%last_hour_impressions")'); + $ret[] = update_sql('UPDATE {ad_notify} SET body = REPLACE(body, "%%this_hour_views", "%%this_hour_impressions")'); + return $ret; +} +