[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/devel/ -> devel.install (source)

   1  <?php
   2  // $Id: devel.install,v 1.24.2.10 2010/09/11 22:27:32 salvis Exp $
   3  /**
   4   * @file
   5   *   Install file for devel module.
   6   */
   7  
   8  /**
   9   * Implementation of hook_schema().
  10   */
  11  function devel_schema() {
  12    $schema['devel_queries'] = array(
  13      'fields' => array(
  14        'qid' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '10'),
  15        'function' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => ''),
  16        'query' => array('type' => 'text', 'not null' => TRUE),
  17        'hash' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE, 'default' => '')),
  18      'primary key' => array('hash'),
  19      'indexes' => array(
  20        'qid' => array('qid'))
  21    );
  22    $schema['devel_times'] = array(
  23      'fields' => array(
  24        'tid' => array('type' => 'serial', 'not null' => TRUE, 'disp-width' => '10'),
  25        'qid' => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
  26        'time' => array('type' => 'float', 'not null' => FALSE)),
  27      'primary key' => array('tid'),
  28      'indexes' => array(
  29        'qid' => array('qid'))
  30    );
  31    return $schema;
  32  }
  33   
  34   /**
  35   * Implementation of hook_install()
  36   */
  37  function devel_install() {
  38    drupal_install_schema('devel');
  39       
  40    // New module weights in core: put devel as the very last in the chain.
  41    db_query("UPDATE {system} SET weight = 88 WHERE name = 'devel'");
  42    
  43    // Create our menu. See menu.install for an example.
  44    $t = get_t();
  45    db_query("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('%s', '%s', '%s')", 'devel', $t('Development'), $t('Development links.'));
  46    
  47    $item = array(
  48      'link_title' => 'Run cron',
  49      'link_path' => 'admin/reports/status/run-cron',
  50      'menu_name' => 'devel',
  51      'module' => 'devel',
  52    );
  53    menu_link_save($item);
  54    
  55    $item = array(
  56      'link_title' => 'Devel settings',
  57      'link_path' => 'admin/settings/devel',
  58      'menu_name' => 'devel',
  59      'module' => 'devel',
  60    );
  61    menu_link_save($item);
  62  }
  63  
  64   /**
  65   * Implementation of hook_uninstall().
  66   */
  67  function devel_uninstall() {
  68    drupal_uninstall_schema('devel');
  69    variable_del('dev_query');
  70    variable_del('devel_old_smtp_library');
  71    variable_del('devel_form_weights');
  72    variable_del('devel_store_random');
  73    variable_del('devel_execution');
  74    variable_del('dev_timer');
  75    variable_del('devel_query_display');
  76    variable_del('devel_redirect_page');
  77    variable_del('devel_api_url');
  78    variable_del('dev_mem');
  79    variable_del('devel_error_handler');
  80    variable_del('devel_store_queries');
  81    variable_del('devel_switch_user_list_size');
  82    variable_del('devel_switch_user_show_form');
  83    
  84    db_query("DELETE FROM {menu_custom} WHERE menu_name = 'devel'");
  85    db_query("DELETE FROM {menu_links} WHERE module = 'devel'");
  86  }
  87  
  88  /**
  89   * Implementation of hook_disable().
  90   */
  91  function devel_disable() {
  92    // Query logging should probably not be set if devel.module is disabled.
  93    if (variable_get('dev_query', 0)) {
  94      variable_set('dev_query', 0);
  95      drupal_set_message(t('Disabled query logging since devel module is disabled.'));
  96    }
  97    
  98    // The SMTP server should also be restored.
  99    variable_set('smtp_library', variable_get('devel_old_smtp_library', ''));
 100    variable_del('devel_old_smtp_library');
 101    
 102    // Same for storing queries
 103    variable_del('devel_store_queries');
 104  
 105    // Disable Devel Block
 106    db_query("UPDATE {blocks} SET status = %d WHERE module = '%s' AND delta = '%s'", 0, 'menu', 'devel');
 107  }
 108  
 109  /**
 110   * Do update 1 again as the hook_install() was missing and new
 111   * installations are not having the weight set.
 112   */
 113  function devel_update_2() {
 114    // New module weights in core: put devel as the very last in the chain.
 115    $ret = array();
 116    $ret[] = update_sql('UPDATE {system} SET weight = 10 WHERE name = "devel"');
 117    return $ret;
 118  }
 119  
 120  function devel_update_3() {
 121    switch ($GLOBALS['db_type']) {
 122      case 'mysqli':
 123      case 'mysql':
 124        $sql = "CREATE TABLE {devel_queries} (
 125          qid int(10) NOT NULL auto_increment,
 126          query varchar(255) NOT NULL default '',
 127          hash varchar(255) NOT NULL default '',
 128          PRIMARY KEY (`hash`),
 129          KEY qid (qid)
 130          ) /*!40100 DEFAULT CHARACTER SET utf8 */;";
 131        $ret[] = update_sql($sql);
 132  
 133        $sql = "CREATE TABLE {devel_times} (
 134          tid int(10) NOT NULL auto_increment,
 135          qid int(10) NOT NULL default 0,
 136          time float default NULL,
 137          PRIMARY KEY (tid),
 138          KEY qid (qid)
 139        ) /*!40100 DEFAULT CHARACTER SET utf8 */;";
 140        $ret[] = update_sql($sql);
 141        return $ret;
 142    }
 143  }
 144  
 145  function devel_update_4() {
 146    $ret = array();
 147    
 148    db_add_field($ret, 'devel_queries', 'function', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
 149    
 150    return $ret;
 151  }
 152  
 153  function devel_update_5() {
 154    $ret = array();
 155    
 156    db_change_field($ret, 'devel_queries', 'query', 'query text', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
 157    
 158    return $ret;
 159  }
 160  
 161  function devel_update_6001() {
 162    // Create our menu. See menu.install for an example.
 163    $ret[] = update_sql("INSERT INTO {menu_custom} (menu_name, title, description) VALUES ('devel', 'Development', 'Development links.')");
 164    return $ret;
 165  }
 166  
 167  function devel_update_6002() {
 168    $item = array(
 169      'link_title' => 'Run cron',
 170      'link_path' => 'admin/reports/status/run-cron',
 171      'menu_name' => 'devel',
 172      'module' => 'devel',
 173    );
 174    menu_link_save($item);
 175    return array();
 176  }
 177  
 178  /**
 179   * As per issue #813132: change schablon.com to white for krumo.
 180   */
 181  function devel_update_6003() {
 182    if (variable_get('devel_krumo_skin', 'white') == 'schablon.com') {
 183      variable_set('devel_krumo_skin', 'white');
 184    }
 185    return array();
 186  }


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