| 
pierre@0
 | 
     1 <?php | 
| 
sly@2
 | 
     2 // $Id: ad.install,v 1.2.2.4.2.27.2.7.2.4 2009/04/03 17:01:02 jeremy Exp $ | 
| 
pierre@0
 | 
     3  | 
| 
pierre@0
 | 
     4 /** | 
| 
pierre@0
 | 
     5  * @file | 
| 
pierre@0
 | 
     6  * Advertisement module database schema. | 
| 
pierre@0
 | 
     7  * | 
| 
pierre@0
 | 
     8  * Copyright (c) 2005-2009. | 
| 
pierre@0
 | 
     9  *   Jeremy Andrews <jeremy@tag1consulting.com>. | 
| 
pierre@0
 | 
    10  */ | 
| 
pierre@0
 | 
    11  | 
| 
pierre@0
 | 
    12 /** | 
| 
pierre@0
 | 
    13  * Ad module database schema. | 
| 
pierre@0
 | 
    14  */ | 
| 
pierre@0
 | 
    15 function ad_schema() { | 
| 
pierre@0
 | 
    16  /** | 
| 
pierre@0
 | 
    17   * The ad table stores administrative information about each ad.  The | 
| 
pierre@0
 | 
    18   * actual ad itself can be found in the appropriate ad type table. | 
| 
pierre@0
 | 
    19   */ | 
| 
pierre@0
 | 
    20   $schema['ads'] = array( | 
| 
pierre@0
 | 
    21     'description' => 'The ad table stores administrative information about each ad.  The actual ad itself can be found in the appropriate ad type table.', | 
| 
pierre@0
 | 
    22     'fields' => array( | 
| 
pierre@0
 | 
    23       'aid' => array( | 
| 
pierre@0
 | 
    24         'type' => 'int', | 
| 
pierre@0
 | 
    25         'not null' => TRUE, | 
| 
pierre@0
 | 
    26         'unsigned' => TRUE, | 
| 
pierre@0
 | 
    27         'default' => 0, | 
| 
pierre@0
 | 
    28         'description' => 'Unique ad ID. Equals to ad nid.', | 
| 
pierre@0
 | 
    29       ), | 
| 
pierre@0
 | 
    30       'uid' => array( | 
| 
pierre@0
 | 
    31         'type' => 'int', | 
| 
pierre@0
 | 
    32         'not null' => TRUE, | 
| 
pierre@0
 | 
    33         'unsigned' => TRUE, | 
| 
pierre@0
 | 
    34         'default' => 0, | 
| 
pierre@0
 | 
    35         'description' => 'The {users}.uid that owns this node; initially, this is the user that created it.', | 
| 
pierre@0
 | 
    36       ), | 
| 
pierre@0
 | 
    37       'adstatus' => array( | 
| 
pierre@0
 | 
    38         'type' => 'varchar', | 
| 
pierre@0
 | 
    39         'length' => 255, | 
| 
pierre@0
 | 
    40         'not null' => TRUE, | 
| 
pierre@0
 | 
    41         'default' => '', | 
| 
pierre@0
 | 
    42         'description' => 'Ad status', | 
| 
pierre@0
 | 
    43       ), | 
| 
pierre@0
 | 
    44       'adtype' => array( | 
| 
pierre@0
 | 
    45         'type' => 'varchar', | 
| 
pierre@0
 | 
    46         'length' => 255, | 
| 
pierre@0
 | 
    47         'not null' => TRUE, | 
| 
pierre@0
 | 
    48         'default' => '', | 
| 
pierre@0
 | 
    49         'description' => 'Ad type', | 
| 
pierre@0
 | 
    50       ), | 
| 
pierre@0
 | 
    51       'redirect' => array( | 
| 
pierre@0
 | 
    52         'type' => 'varchar', | 
| 
pierre@0
 | 
    53         'length' => 255, | 
| 
pierre@0
 | 
    54         'not null' => TRUE, | 
| 
pierre@0
 | 
    55         'default' => '', | 
| 
pierre@0
 | 
    56         'description' => 'Ad redirect URL', | 
| 
pierre@0
 | 
    57       ), | 
| 
pierre@0
 | 
    58       'autoactivate' => array( | 
| 
pierre@0
 | 
    59         'type' => 'int', | 
| 
pierre@0
 | 
    60         'not null' => TRUE, | 
| 
pierre@0
 | 
    61         'unsigned' => TRUE, | 
| 
pierre@0
 | 
    62         'default' => 0, | 
| 
pierre@0
 | 
    63         'description' => 'Is ad autoactivating?', | 
| 
pierre@0
 | 
    64       ), | 
| 
pierre@0
 | 
    65       'autoactivated' => array( | 
| 
pierre@0
 | 
    66         'type' => 'int', | 
| 
pierre@0
 | 
    67         'not null' => TRUE, | 
| 
pierre@0
 | 
    68         'unsigned' => TRUE, | 
| 
pierre@0
 | 
    69         'default' => 0, | 
| 
pierre@0
 | 
    70         'description' => 'Is ad autoactivated?', | 
| 
pierre@0
 | 
    71       ), | 
| 
pierre@0
 | 
    72       'autoexpire' => array( | 
| 
pierre@0
 | 
    73         'type' => 'int', | 
| 
pierre@0
 | 
    74         'not null' => TRUE, | 
| 
pierre@0
 | 
    75         'unsigned' => TRUE, | 
| 
pierre@0
 | 
    76         'default' => 0, | 
| 
pierre@0
 | 
    77         'description' => 'Is ad autoexpiring?', | 
| 
pierre@0
 | 
    78       ), | 
| 
pierre@0
 | 
    79       'autoexpired' => array( | 
| 
pierre@0
 | 
    80         'type' => 'int', | 
| 
pierre@0
 | 
    81         'not null' => TRUE, | 
| 
pierre@0
 | 
    82         'unsigned' => TRUE, | 
| 
pierre@0
 | 
    83         'default' => 0, | 
| 
pierre@0
 | 
    84         'description' => 'Is ad autoexpired?', | 
| 
pierre@0
 | 
    85       ), | 
| 
pierre@0
 | 
    86       'activated' => array( | 
| 
pierre@0
 | 
    87         'type' => 'int', | 
| 
pierre@0
 | 
    88         'not null' => TRUE, | 
| 
pierre@0
 | 
    89         'unsigned' => TRUE, | 
| 
pierre@0
 | 
    90         'default' => 0, | 
| 
pierre@0
 | 
    91         'description' => 'Is ad activated?', | 
| 
pierre@0
 | 
    92       ), | 
| 
pierre@0
 | 
    93       'maxviews' => array( | 
| 
pierre@0
 | 
    94         'type' => 'int', | 
| 
pierre@0
 | 
    95         'not null' => TRUE, | 
| 
pierre@0
 | 
    96         'unsigned' => TRUE, | 
| 
pierre@0
 | 
    97         'default' => 0, | 
| 
pierre@0
 | 
    98         'description' => 'Maximum ad impressions', | 
| 
pierre@0
 | 
    99       ), | 
| 
pierre@0
 | 
   100       'maxclicks' => array( | 
| 
pierre@0
 | 
   101         'type' => 'int', | 
| 
pierre@0
 | 
   102         'not null' => TRUE, | 
| 
pierre@0
 | 
   103         'unsigned' => TRUE, | 
| 
pierre@0
 | 
   104         'default' => 0, | 
| 
pierre@0
 | 
   105         'description' => 'Maximum ad clicks', | 
| 
pierre@0
 | 
   106       ), | 
| 
pierre@0
 | 
   107       'expired' => array( | 
| 
pierre@0
 | 
   108         'type' => 'int', | 
| 
pierre@0
 | 
   109         'not null' => TRUE, | 
| 
pierre@0
 | 
   110         'unsigned' => TRUE, | 
| 
pierre@0
 | 
   111         'default' => 0, | 
| 
pierre@0
 | 
   112         'description' => 'Is ad expired?', | 
| 
pierre@0
 | 
   113       ), | 
| 
pierre@0
 | 
   114     ), | 
| 
pierre@0
 | 
   115     'primary key' => array('aid'), | 
| 
pierre@0
 | 
   116     'indexes' => array( | 
| 
pierre@0
 | 
   117       'uid' => array('uid'), | 
| 
pierre@0
 | 
   118       'autoactivate' => array('autoactivate'), | 
| 
pierre@0
 | 
   119       'autoactivate' => array('autoactivate'), | 
| 
pierre@0
 | 
   120     ), | 
| 
pierre@0
 | 
   121   ); | 
| 
pierre@0
 | 
   122  | 
| 
pierre@0
 | 
   123  /** | 
| 
pierre@0
 | 
   124   * This table counts each time a given action occurs on an ad.  Actions | 
| 
pierre@0
 | 
   125   * include when the ad is viewed, clicked, enabled and disabled. | 
| 
pierre@0
 | 
   126   * Statistics are collected at an hourly granularity. | 
| 
pierre@0
 | 
   127   * | 
| 
pierre@0
 | 
   128   * The source column is used for tracking statistics for externally | 
| 
pierre@0
 | 
   129   * hosted ads. | 
| 
pierre@0
 | 
   130   * | 
| 
pierre@0
 | 
   131   * Actions: | 
| 
pierre@0
 | 
   132   *  'view', 'click', 'enable', 'disable' | 
| 
pierre@0
 | 
   133   */ | 
| 
pierre@0
 | 
   134   $schema['ad_statistics'] = array( | 
| 
pierre@0
 | 
   135     'description' => 'Stores ad statistics.', | 
| 
pierre@0
 | 
   136     'fields' => array( | 
| 
pierre@0
 | 
   137       'sid' => array( | 
| 
pierre@0
 | 
   138         'type' => 'serial', | 
| 
pierre@0
 | 
   139         'not null' => TRUE, | 
| 
pierre@0
 | 
   140         'unsigned' => TRUE, | 
| 
pierre@0
 | 
   141         'description' => 'Statistics entry ID.', | 
| 
pierre@0
 | 
   142       ), | 
| 
pierre@0
 | 
   143       'aid' => array( | 
| 
pierre@0
 | 
   144         'type' => 'int', | 
| 
pierre@0
 | 
   145         'not null' => TRUE, | 
| 
pierre@0
 | 
   146         'unsigned' => TRUE, | 
| 
pierre@0
 | 
   147         'default' => 0, | 
| 
pierre@0
 | 
   148         'description' => 'Ad id.', | 
| 
pierre@0
 | 
   149       ), | 
| 
pierre@0
 | 
   150       'date' => array( | 
| 
pierre@0
 | 
   151         'type' => 'int', | 
| 
pierre@0
 | 
   152         'not null' => TRUE, | 
| 
pierre@0
 | 
   153         'unsigned' => TRUE, | 
| 
pierre@0
 | 
   154         'default' => 0, | 
| 
pierre@0
 | 
   155         'description' => 'Date when action was made.', | 
| 
pierre@0
 | 
   156       ), | 
| 
pierre@0
 | 
   157       'action' => array( | 
| 
pierre@0
 | 
   158         'type' => 'varchar', | 
| 
pierre@0
 | 
   159         'length' => 255, | 
| 
pierre@0
 | 
   160         'not null' => TRUE, | 
| 
pierre@0
 | 
   161         'default' => '', | 
| 
pierre@0
 | 
   162         'description' => 'Actions: "view", "click", "enable", "disable".', | 
| 
pierre@0
 | 
   163       ), | 
| 
pierre@0
 | 
   164       'adgroup' => array( | 
| 
pierre@0
 | 
   165         'type' => 'varchar', | 
| 
pierre@0
 | 
   166         'length' => 255, | 
| 
pierre@0
 | 
   167         'not null' => FALSE, | 
| 
pierre@0
 | 
   168         'default' => '', | 
| 
pierre@0
 | 
   169         'description' => 'Ad group.', | 
| 
pierre@0
 | 
   170       ), | 
| 
pierre@0
 | 
   171       'hostid' => array( | 
| 
pierre@0
 | 
   172         'type' => 'varchar', | 
| 
pierre@0
 | 
   173         'length' => 32, | 
| 
pierre@0
 | 
   174         'not null' => TRUE, | 
| 
pierre@0
 | 
   175         'default' => '', | 
| 
pierre@0
 | 
   176         'description' => 'Host from which acion was made.', | 
| 
pierre@0
 | 
   177       ), | 
| 
pierre@0
 | 
   178       'count' => array( | 
| 
pierre@0
 | 
   179         'type' => 'int', | 
| 
pierre@0
 | 
   180         'not null' => TRUE, | 
| 
pierre@0
 | 
   181         'unsigned' => TRUE, | 
| 
pierre@0
 | 
   182         'default' => 0, | 
| 
pierre@0
 | 
   183         'description' => 'Count of actions triggered.', | 
| 
pierre@0
 | 
   184       ), | 
| 
sly@2
 | 
   185       'extra' => array( | 
| 
sly@2
 | 
   186         'type' => 'varchar', | 
| 
sly@2
 | 
   187         'length' => 255, | 
| 
sly@2
 | 
   188         'not null' => TRUE, | 
| 
sly@2
 | 
   189         'default' => '', | 
| 
sly@2
 | 
   190         'description' => 'Alow add-on modules to provide additional statistics granularity.', | 
| 
sly@2
 | 
   191       ), | 
| 
pierre@0
 | 
   192     ), | 
| 
pierre@0
 | 
   193     'primary key' => array('sid'), | 
| 
pierre@0
 | 
   194     'indexes' => array( | 
| 
pierre@0
 | 
   195       'aid' => array('aid'), | 
| 
pierre@0
 | 
   196       'date' => array('date'), | 
| 
pierre@0
 | 
   197       'action' => array('action'), | 
| 
pierre@0
 | 
   198       'adgroup' => array('adgroup'), | 
| 
pierre@0
 | 
   199       'hostid' => array('hostid'), | 
| 
sly@2
 | 
   200       'extra' => array('extra'), | 
| 
pierre@0
 | 
   201     ), | 
| 
pierre@0
 | 
   202   ); | 
| 
pierre@0
 | 
   203  | 
| 
pierre@0
 | 
   204  /** | 
| 
pierre@0
 | 
   205   * The ad_clicks table tracks when a given advertisement was clicked, | 
| 
pierre@0
 | 
   206   * who clicked it (uid if any and IP address), and what page they were | 
| 
pierre@0
 | 
   207   * on when they clicked it. | 
| 
pierre@0
 | 
   208   */ | 
| 
pierre@0
 | 
   209   $schema['ad_clicks'] = array( | 
| 
pierre@0
 | 
   210     'description' => 'The ad_clicks table tracks when a given advertisement was clicked, who clicked it (uid if any and IP address), and what page they were on when they clicked it.', | 
| 
pierre@0
 | 
   211     'fields' => array( | 
| 
pierre@0
 | 
   212       'cid' => array( | 
| 
pierre@0
 | 
   213         'type' => 'serial', | 
| 
pierre@0
 | 
   214         'not null' => TRUE, | 
| 
pierre@0
 | 
   215         'unsigned' => TRUE, | 
| 
pierre@0
 | 
   216         'description' => 'Statistics entry ID.', | 
| 
pierre@0
 | 
   217       ), | 
| 
pierre@0
 | 
   218       'aid' => array( | 
| 
pierre@0
 | 
   219         'type' => 'int', | 
| 
pierre@0
 | 
   220         'not null' => TRUE, | 
| 
pierre@0
 | 
   221         'unsigned' => TRUE, | 
| 
pierre@0
 | 
   222         'default' => 0, | 
| 
pierre@0
 | 
   223         'description' => 'Ad id.', | 
| 
pierre@0
 | 
   224       ), | 
| 
pierre@0
 | 
   225       'uid' => array( | 
| 
pierre@0
 | 
   226         'type' => 'int', | 
| 
pierre@0
 | 
   227         'not null' => TRUE, | 
| 
pierre@0
 | 
   228         'unsigned' => TRUE, | 
| 
pierre@0
 | 
   229         'default' => 0, | 
| 
pierre@0
 | 
   230         'description' => '', | 
| 
pierre@0
 | 
   231       ), | 
| 
pierre@0
 | 
   232       'status' => array( | 
| 
pierre@0
 | 
   233         'type' => 'int', | 
| 
pierre@0
 | 
   234         'size' => 'tiny', | 
| 
pierre@0
 | 
   235         'not null' => TRUE, | 
| 
pierre@0
 | 
   236         'unsigned' => TRUE, | 
| 
pierre@0
 | 
   237         'default' => 0, | 
| 
pierre@0
 | 
   238         'description' => '', | 
| 
pierre@0
 | 
   239       ), | 
| 
pierre@0
 | 
   240       'hostname' => array( | 
| 
pierre@0
 | 
   241         'type' => 'varchar', | 
| 
pierre@0
 | 
   242         'length' => 128, | 
| 
pierre@0
 | 
   243         'not null' => TRUE, | 
| 
pierre@0
 | 
   244         'default' => '', | 
| 
pierre@0
 | 
   245         'description' => 'Host from which acion was made.', | 
| 
pierre@0
 | 
   246       ), | 
| 
pierre@0
 | 
   247       'user_agent' => array( | 
| 
pierre@0
 | 
   248         'type' => 'varchar', | 
| 
pierre@0
 | 
   249         'length' => 255, | 
| 
pierre@0
 | 
   250         'not null' => TRUE, | 
| 
pierre@0
 | 
   251         'default' => '', | 
| 
pierre@0
 | 
   252         'description' => 'Clicker\'s browser agent.', | 
| 
pierre@0
 | 
   253       ), | 
| 
pierre@0
 | 
   254       'adgroup' => array( | 
| 
pierre@0
 | 
   255         'type' => 'varchar', | 
| 
pierre@0
 | 
   256         'length' => 255, | 
| 
pierre@0
 | 
   257         'not null' => TRUE, | 
| 
pierre@0
 | 
   258         'default' => '', | 
| 
pierre@0
 | 
   259         'description' => 'Ad group.', | 
| 
pierre@0
 | 
   260       ), | 
| 
pierre@0
 | 
   261       'hostid' => array( | 
| 
pierre@0
 | 
   262         'type' => 'varchar', | 
| 
pierre@0
 | 
   263         'length' => 32, | 
| 
pierre@0
 | 
   264         'not null' => TRUE, | 
| 
pierre@0
 | 
   265         'default' => '', | 
| 
pierre@0
 | 
   266         'description' => 'Host from which acion was made.', | 
| 
pierre@0
 | 
   267       ), | 
| 
pierre@0
 | 
   268       'url' => array( | 
| 
pierre@0
 | 
   269         'type' => 'varchar', | 
| 
pierre@0
 | 
   270         'length' => 255, | 
| 
pierre@0
 | 
   271         'not null' => FALSE, | 
| 
pierre@0
 | 
   272         'default' => '', | 
| 
pierre@0
 | 
   273         'description' => 'Clicked URL.', | 
| 
pierre@0
 | 
   274       ), | 
| 
pierre@0
 | 
   275       'timestamp' => array( | 
| 
pierre@0
 | 
   276         'type' => 'int', | 
| 
pierre@0
 | 
   277         'not null' => TRUE, | 
| 
pierre@0
 | 
   278         'unsigned' => TRUE, | 
| 
pierre@0
 | 
   279         'default' => 0, | 
| 
pierre@0
 | 
   280         'description' => 'Date when action was made.', | 
| 
pierre@0
 | 
   281       ), | 
| 
sly@2
 | 
   282       'extra' => array( | 
| 
sly@2
 | 
   283         'type' => 'varchar', | 
| 
sly@2
 | 
   284         'length' => 255, | 
| 
sly@2
 | 
   285         'not null' => TRUE, | 
| 
sly@2
 | 
   286         'default' => '', | 
| 
sly@2
 | 
   287         'description' => 'Alow add-on modules to provide additional statistics granularity.', | 
| 
sly@2
 | 
   288       ), | 
| 
pierre@0
 | 
   289     ), | 
| 
pierre@0
 | 
   290     'primary key' => array('cid'), | 
| 
pierre@0
 | 
   291     'indexes' => array( | 
| 
pierre@0
 | 
   292       'aid' => array('aid'), | 
| 
pierre@0
 | 
   293       'status' => array('status'), | 
| 
pierre@0
 | 
   294       'hostname' => array('hostname'), | 
| 
pierre@0
 | 
   295       'user_agent' => array('user_agent'), | 
| 
pierre@0
 | 
   296       'adgroup' => array('adgroup'), | 
| 
pierre@0
 | 
   297       'hostid' => array('hostid'), | 
| 
pierre@0
 | 
   298       'url' => array('url'), | 
| 
sly@2
 | 
   299       'extra' => array('extra'), | 
| 
pierre@0
 | 
   300     ), | 
| 
pierre@0
 | 
   301   ); | 
| 
pierre@0
 | 
   302  | 
| 
pierre@0
 | 
   303   return $schema; | 
| 
pierre@0
 | 
   304 } | 
| 
pierre@0
 | 
   305  | 
| 
pierre@0
 | 
   306 /** | 
| 
pierre@0
 | 
   307  * Ad module installation. | 
| 
pierre@0
 | 
   308  */ | 
| 
pierre@0
 | 
   309 function ad_install() { | 
| 
pierre@0
 | 
   310   // Create tables. | 
| 
pierre@0
 | 
   311   drupal_install_schema('ad'); | 
| 
pierre@0
 | 
   312 } | 
| 
pierre@0
 | 
   313  | 
| 
pierre@0
 | 
   314 /** | 
| 
pierre@0
 | 
   315  * Allow complete uninstallation of the ad module. | 
| 
pierre@0
 | 
   316  */ | 
| 
pierre@0
 | 
   317 function ad_uninstall() { | 
| 
pierre@0
 | 
   318   // Delete all ad content. | 
| 
pierre@0
 | 
   319   $result = db_query("SELECT nid FROM {node} WHERE type = 'ad'"); | 
| 
pierre@0
 | 
   320   while ($node = db_fetch_object($result)) { | 
| 
pierre@0
 | 
   321     node_delete($node->nid); | 
| 
pierre@0
 | 
   322     variable_del("ad_autoactivate_warning_$node->nid"); | 
| 
pierre@0
 | 
   323   } | 
| 
pierre@0
 | 
   324  | 
| 
pierre@0
 | 
   325   // Delete all remaining ad module variables. | 
| 
pierre@0
 | 
   326   $variables = array('ad_cron_timestamp', 'ad_link_target', 'ad_cache', 'ad_cache_file', 'adserve', 'ad_group_vid', 'ad_groups', 'ad_validate_url', 'ad_display'); | 
| 
pierre@0
 | 
   327   foreach ($variables as $variable) { | 
| 
pierre@0
 | 
   328     variable_del($variable); | 
| 
pierre@0
 | 
   329   } | 
| 
pierre@0
 | 
   330   db_query("DELETE FROM {variable} WHERE name LIKE 'ad_block_quantity_%'"); | 
| 
pierre@1
 | 
   331  | 
| 
pierre@1
 | 
   332   // Remove tables. | 
| 
pierre@1
 | 
   333   drupal_uninstall_schema('ad'); | 
| 
pierre@0
 | 
   334 } | 
| 
pierre@0
 | 
   335  | 
| 
pierre@0
 | 
   336 /** | 
| 
pierre@0
 | 
   337  * Convert some things from absolete dev. schema to new schema API | 
| 
pierre@0
 | 
   338  */ | 
| 
pierre@0
 | 
   339 function ad_update_6001() { | 
| 
pierre@0
 | 
   340   $ret = array(); | 
| 
pierre@0
 | 
   341   // When we touching index columns, we should first remove it from schema | 
| 
pierre@0
 | 
   342   db_drop_index($ret, 'ad_clicks', 'status'); | 
| 
pierre@0
 | 
   343   db_change_field($ret, 'ad_clicks', 'status', 'status', | 
| 
pierre@0
 | 
   344       array( | 
| 
pierre@0
 | 
   345         'type' => 'int', | 
| 
pierre@0
 | 
   346         'size' => 'tiny', | 
| 
pierre@0
 | 
   347         'not null' => TRUE, | 
| 
pierre@0
 | 
   348         'unsigned' => TRUE, | 
| 
pierre@0
 | 
   349         'default' => 0, | 
| 
pierre@0
 | 
   350         'description' => '', | 
| 
pierre@0
 | 
   351       ), | 
| 
pierre@0
 | 
   352       array('indexes' => array( | 
| 
pierre@0
 | 
   353         'status' => array('status'), | 
| 
pierre@0
 | 
   354       ), | 
| 
pierre@0
 | 
   355     ) | 
| 
pierre@0
 | 
   356   ); | 
| 
pierre@0
 | 
   357   db_drop_index($ret, 'ad_hosts', 'status'); | 
| 
pierre@0
 | 
   358   db_change_field($ret, 'ad_hosts', 'status', 'status', | 
| 
pierre@0
 | 
   359       array( | 
| 
pierre@0
 | 
   360         'type' => 'int', | 
| 
pierre@0
 | 
   361         'size' => 'tiny', | 
| 
pierre@0
 | 
   362         'not null' => TRUE, | 
| 
pierre@0
 | 
   363         'unsigned' => TRUE, | 
| 
pierre@0
 | 
   364         'default' => 0, | 
| 
pierre@0
 | 
   365         'description' => '', | 
| 
pierre@0
 | 
   366       ), | 
| 
pierre@0
 | 
   367       array('indexes' => array( | 
| 
pierre@0
 | 
   368         'status' => array('status'), | 
| 
pierre@0
 | 
   369       ), | 
| 
pierre@0
 | 
   370     ) | 
| 
pierre@0
 | 
   371   ); | 
| 
pierre@0
 | 
   372  | 
| 
pierre@0
 | 
   373   db_drop_index($ret, 'ad_statistics', 'hostid'); | 
| 
pierre@0
 | 
   374   db_change_field($ret, 'ad_statistics', 'hostid', 'hostid', | 
| 
pierre@0
 | 
   375       array( | 
| 
pierre@0
 | 
   376         'type' => 'varchar', | 
| 
pierre@0
 | 
   377         'length' => 32, | 
| 
pierre@0
 | 
   378         'not null' => TRUE, | 
| 
pierre@0
 | 
   379         'default' => '', | 
| 
pierre@0
 | 
   380         'description' => 'Host from which acion was made.', | 
| 
pierre@0
 | 
   381       ), | 
| 
pierre@0
 | 
   382       array('indexes' => array( | 
| 
pierre@0
 | 
   383         'hostid' => array('hostid'), | 
| 
pierre@0
 | 
   384       ), | 
| 
pierre@0
 | 
   385     ) | 
| 
pierre@0
 | 
   386   ); | 
| 
pierre@0
 | 
   387  | 
| 
pierre@0
 | 
   388   db_drop_index($ret, 'ad_hosts', 'hostid'); | 
| 
pierre@0
 | 
   389   db_change_field($ret, 'ad_hosts', 'hostid', 'hostid', | 
| 
pierre@0
 | 
   390       array( | 
| 
pierre@0
 | 
   391         'type' => 'varchar', | 
| 
pierre@0
 | 
   392         'length' => 32, | 
| 
pierre@0
 | 
   393         'not null' => TRUE, | 
| 
pierre@0
 | 
   394         'default' => '', | 
| 
pierre@0
 | 
   395         'description' => 'Host from which acion was made.', | 
| 
pierre@0
 | 
   396       ), | 
| 
pierre@0
 | 
   397       array('indexes' => array( | 
| 
pierre@0
 | 
   398         'hostid' => array('hostid'), | 
| 
pierre@0
 | 
   399       ), | 
| 
pierre@0
 | 
   400     ) | 
| 
pierre@0
 | 
   401   ); | 
| 
pierre@0
 | 
   402   return $ret; | 
| 
pierre@0
 | 
   403 } | 
| 
pierre@0
 | 
   404  | 
| 
pierre@0
 | 
   405 /** | 
| 
pierre@0
 | 
   406  * Rebuild menu for anyone using the ad_embed module. | 
| 
pierre@0
 | 
   407  */ | 
| 
pierre@0
 | 
   408 function ad_update_6002() { | 
| 
pierre@0
 | 
   409   menu_rebuild(); | 
| 
pierre@0
 | 
   410   return array(); | 
| 
pierre@0
 | 
   411 } | 
| 
pierre@0
 | 
   412  | 
| 
pierre@0
 | 
   413 /** | 
| 
pierre@0
 | 
   414  * Flush all caches for new themeable ad display functions. | 
| 
pierre@0
 | 
   415  */ | 
| 
pierre@0
 | 
   416 function ad_update_6003() { | 
| 
pierre@0
 | 
   417   drupal_flush_all_caches(); | 
| 
pierre@0
 | 
   418   return array(); | 
| 
pierre@0
 | 
   419 } | 
| 
pierre@1
 | 
   420  | 
| 
pierre@1
 | 
   421 /** | 
| 
pierre@1
 | 
   422  * Introduce "extra" field for ad statistics and clicks, optionally allowing | 
| 
pierre@1
 | 
   423  * add-on modules to provide additional granularity. | 
| 
pierre@1
 | 
   424  */ | 
| 
pierre@1
 | 
   425 function ad_update_6004() { | 
| 
pierre@1
 | 
   426   $ret = array(); | 
| 
pierre@1
 | 
   427   db_add_field($ret, 'ad_statistics', 'extra', | 
| 
pierre@1
 | 
   428     array( | 
| 
pierre@1
 | 
   429       'type' => 'varchar', | 
| 
pierre@1
 | 
   430       'length' => 255, | 
| 
pierre@1
 | 
   431       'not null' => TRUE, | 
| 
pierre@1
 | 
   432       'default' => '', | 
| 
pierre@1
 | 
   433       'description' => 'Alow add-on modules to provide additional statistics granularity.', | 
| 
pierre@1
 | 
   434     ), | 
| 
pierre@1
 | 
   435     array('indexes' => array( | 
| 
pierre@1
 | 
   436       'extra' => array('extra')) | 
| 
pierre@1
 | 
   437     )); | 
| 
pierre@1
 | 
   438   db_add_field($ret, 'ad_clicks', 'extra', | 
| 
pierre@1
 | 
   439     array( | 
| 
pierre@1
 | 
   440       'type' => 'varchar', | 
| 
pierre@1
 | 
   441       'length' => 255, | 
| 
pierre@1
 | 
   442       'not null' => TRUE, | 
| 
pierre@1
 | 
   443       'default' => '', | 
| 
pierre@1
 | 
   444       'description' => 'Alow add-on modules to provide additional statistics granularity.', | 
| 
pierre@1
 | 
   445     ), | 
| 
pierre@1
 | 
   446     array('indexes' => array( | 
| 
pierre@1
 | 
   447       'extra' => array('extra')) | 
| 
pierre@1
 | 
   448     )); | 
| 
pierre@1
 | 
   449   return $ret; | 
| 
pierre@1
 | 
   450 } | 
| 
pierre@1
 | 
   451  | 
| 
pierre@1
 | 
   452 /** | 
| 
pierre@1
 | 
   453  * Flush all caches for AHAH ad type switcher to work. | 
| 
pierre@1
 | 
   454  */ | 
| 
pierre@1
 | 
   455 function ad_update_6005() { | 
| 
pierre@1
 | 
   456   drupal_flush_all_caches(); | 
| 
pierre@1
 | 
   457   return array(); | 
| 
pierre@1
 | 
   458 } | 
| 
pierre@1
 | 
   459  |