[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/station/archive/ -> station_archive.install (source)

   1  <?php
   2  // $Id: station_archive.install,v 1.15 2009/11/28 22:06:44 drewish Exp $
   3  
   4  /**
   5   * Implementation of hook_schema().
   6   */
   7  function station_archive_install() {
   8    drupal_install_schema('station_archive');
   9  }
  10  
  11  /**
  12   * Implementation of hook_uninstall().
  13   */
  14  function station_archive_uninstall() {
  15    drupal_uninstall_schema('station_archive');
  16  
  17    // Remove our taxonomy.
  18    if ($vid = variable_get('station_archive_vid', '')) {
  19      taxonomy_del_vocabulary($vid);
  20    }
  21  
  22    // Remove our variables.
  23    $variables = array(
  24      'station_archive_cleanup_old',
  25      'station_archive_delete_unscheduled',
  26      'station_archive_import_new',
  27      'station_archive_import_dir',
  28      'station_archive_max_age',
  29      'station_archive_promote_scheduled',
  30      'station_archive_title_format',
  31      'station_archive_unscheduled_title',
  32      'station_archive_vid',
  33    );
  34    foreach ($variables as $variable) {
  35      variable_del($variable);
  36    }
  37  }
  38  
  39  /**
  40   * Implementation of hook_schema().
  41   */
  42  function station_archive_schema() {
  43    $schema['station_archive_item'] = array(
  44      'description' => t('Information on an archive audio node.'),
  45      'fields' => array(
  46        'audio_nid' => array(
  47          'description' => t("The audio {node}.nid."),
  48          'type' => 'int',
  49          'unsigned' => TRUE,
  50          'not null' => TRUE,
  51          'default' => 0,
  52        ),
  53        'program_nid' => array(
  54          'description' => t("The program {node}.nid."),
  55          'type' => 'int',
  56          'unsigned' => TRUE,
  57          'not null' => TRUE,
  58          'default' => 0,
  59        ),
  60        'aired' => array(
  61          'description' => 'The Unix timestamp when the audio aired.',
  62          'type' => 'int',
  63          'unsigned' => TRUE,
  64          'not null' => TRUE,
  65          'default' => 0,
  66        ),
  67        'imported' => array(
  68          'description' => 'The Unix timestamp when the audio was imported.',
  69          'type' => 'int',
  70          'unsigned' => TRUE,
  71          'not null' => TRUE,
  72          'default' => 0,
  73        ),
  74        'permanent' => array(
  75          'description' => t("Is this part of the permanent archive? If so it will not be deleted."),
  76          'type' => 'int',
  77          'unsigned' => TRUE,
  78          'not null' => TRUE,
  79          'size' => 'tiny',
  80          'default' => 0,
  81        ),
  82      ),
  83      'indexes' => array(
  84        'station_archive_cleanup' => array('permanent', 'imported'),
  85      ),
  86      'primary key' => array('audio_nid', 'program_nid'),
  87    );
  88  
  89    $schema['station_archive_program'] = array(
  90      'description' => t("Duplication of the program node title incase they're on another site."),
  91      'fields' => array(
  92        'program_nid' => array(
  93          'description' => t("The program {node}.nid."),
  94          'type' => 'int',
  95          'unsigned' => TRUE,
  96          'not null' => TRUE,
  97          'default' => 0,
  98        ),
  99        'title' => array(
 100          'description' => 'The title of this node, always treated as non-markup plain text.',
 101          'type' => 'varchar',
 102          'length' => 255,
 103          'not null' => TRUE,
 104          'default' => '',
 105        ),
 106      ),
 107      'primary key' => array('program_nid'),
 108    );
 109    return $schema;
 110  }
 111  
 112  /**
 113   * Implementation of hook_update_last_removed().
 114   */
 115  function station_archive_update_last_removed() {
 116    // We've removed the 5.x-1.x version of mymodule, including database updates.
 117    // The next update function is mymodule_update_5200().
 118    return 100;
 119  }
 120  
 121  /**
 122   * Correct the station archive's {vocabulary}.module value.
 123   */
 124  function station_archive_update_5200() {
 125    $ret = array();
 126    switch ($GLOBALS['db_type']) {
 127      case 'mysql':
 128      case 'mysqli':
 129        $ret[] = update_sql("UPDATE {vocabulary} SET module = 'station_archive' WHERE module = 'stationarchive'");
 130        break;
 131    }
 132    return $ret;
 133  }
 134  
 135  /**
 136   * Add rename {station_archive} to {station_archive_item} and add a .aired
 137   * column to record the node's original air date. Use the node's creation date
 138   * as a default value.
 139   */
 140  function station_archive_update_5201() {
 141    $ret = array();
 142    switch ($GLOBALS['db_type']) {
 143      case 'mysql':
 144      case 'mysqli':
 145        $ret[] = update_sql("ALTER TABLE {station_archive} RENAME TO {station_archive_item}");
 146        $ret[] = update_sql("ALTER TABLE {station_archive_item} ADD COLUMN `aired` INTEGER UNSIGNED NOT NULL DEFAULT 0 AFTER `program_nid`");
 147        $ret[] = update_sql("UPDATE {station_archive_item} sai INNER JOIN {node} n ON sai.audio_nid = n.nid SET sai.aired = n.created WHERE n.type = 'audio'");
 148        break;
 149    }
 150    return $ret;
 151  }
 152  
 153  /**
 154   * Clean up a couple of things on the schema.
 155   */
 156  function station_archive_update_6000() {
 157    $ret = array();
 158  
 159    $spec = array(
 160      'type' => 'int',
 161      'unsigned' => TRUE,
 162      'not null' => TRUE,
 163      'size' => 'tiny',
 164      'default' => 0,
 165    );
 166    db_change_field($ret, 'station_archive_item', 'permanent', 'permanent', $spec);
 167  
 168    $spec = array(
 169      'type' => 'varchar',
 170      'length' => 255,
 171      'not null' => TRUE,
 172      'default' => '',
 173    );
 174    db_change_field($ret, 'station_archive_program', 'title', 'title', $spec);
 175  
 176    return $ret;
 177  }


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