[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/modules/statistics/ -> statistics.install (source)

   1  <?php
   2  // $Id: statistics.install,v 1.13.2.3 2009/09/14 08:19:24 goba Exp $
   3  
   4  /**
   5   * Implementation of hook_install().
   6   */
   7  function statistics_install() {
   8    // Create tables.
   9    drupal_install_schema('statistics');
  10  }
  11  
  12  /**
  13   * Changes session ID  field to VARCHAR(64) to add support for SHA-1 hashes.
  14   */
  15  function statistics_update_1000() {
  16    $ret = array();
  17  
  18    switch ($GLOBALS['db_type']) {
  19      case 'mysql':
  20      case 'mysqli':
  21        $ret[] = update_sql("ALTER TABLE {accesslog} CHANGE COLUMN sid sid varchar(64) NOT NULL default ''");
  22        break;
  23      case 'pgsql':
  24        db_change_column($ret, 'accesslog', 'sid', 'sid', 'varchar(64)', array('not null' => TRUE, 'default' => "''"));
  25        break;
  26    }
  27  
  28    return $ret;
  29  }
  30  
  31  /**
  32   * Implementation of hook_uninstall().
  33   */
  34  function statistics_uninstall() {
  35    // Remove tables.
  36    drupal_uninstall_schema('statistics');
  37  
  38    variable_del('statistics_count_content_views');
  39    variable_del('statistics_enable_access_log');
  40    variable_del('statistics_flush_accesslog_timer');
  41    variable_del('statistics_day_timestamp');
  42    variable_del('statistics_block_top_day_num');
  43    variable_del('statistics_block_top_all_num');
  44    variable_del('statistics_block_top_last_num');
  45  }
  46  
  47  /**
  48   * Implementation of hook_schema().
  49   */
  50  function statistics_schema() {
  51    $schema['accesslog'] = array(
  52      'description' => 'Stores site access information for statistics.',
  53      'fields' => array(
  54        'aid' => array(
  55          'type' => 'serial',
  56          'not null' => TRUE,
  57          'description' => 'Primary Key: Unique accesslog ID.',
  58        ),
  59        'sid' => array(
  60          'type' => 'varchar',
  61          'length' => 64,
  62          'not null' => TRUE,
  63          'default' => '',
  64          'description' => 'Browser session ID of user that visited page.',
  65        ),
  66        'title' => array(
  67          'type' => 'varchar',
  68          'length' => 255,
  69          'not null' => FALSE,
  70          'description' => 'Title of page visited.',
  71        ),
  72        'path' => array(
  73          'type' => 'varchar',
  74          'length' => 255,
  75          'not null' => FALSE,
  76          'description' => 'Internal path to page visited (relative to Drupal root.)',
  77        ),
  78        'url' => array(
  79          'type' => 'text',
  80          'not null' => FALSE,
  81          'description' => 'Referrer URI.',
  82        ),
  83        'hostname' => array(
  84          'type' => 'varchar',
  85          'length' => 128,
  86          'not null' => FALSE,
  87          'description' => 'Hostname of user that visited the page.',
  88        ),
  89        'uid' => array(
  90          'type' => 'int',
  91          'unsigned' => TRUE,
  92          'not null' => FALSE,
  93          'default' => 0,
  94          'description' => 'User {users}.uid that visited the page.',
  95        ),
  96        'timer' => array(
  97          'type' => 'int',
  98          'unsigned' => TRUE,
  99          'not null' => TRUE,
 100          'default' => 0,
 101          'description' => 'Time in milliseconds that the page took to load.',
 102        ),
 103        'timestamp' => array(
 104          'type' => 'int',
 105          'unsigned' => TRUE,
 106          'not null' => TRUE,
 107          'default' => 0,
 108          'description' => 'Timestamp of when the page was visited.',
 109        ),
 110      ),
 111      'indexes' => array(
 112        'accesslog_timestamp' => array('timestamp'),
 113        'uid' => array('uid'),
 114      ),
 115      'primary key' => array('aid'),
 116    );
 117  
 118    return $schema;
 119  }
 120  
 121  /**
 122   * @defgroup updates-6.x-extra Extra statistics updates for 6.x
 123   * @{
 124   */
 125  
 126  /**
 127   * Allow longer referrers.
 128   */
 129  function statistics_update_6000() {
 130    $ret = array();
 131    db_change_field($ret, 'accesslog', 'url', 'url', array('type' => 'text', 'not null' => FALSE));
 132    return $ret;
 133  }
 134  
 135  /**
 136   * @} End of "defgroup updates-6.x-extra"
 137   * The next series of updates should start at 7000.
 138   */


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7