/[drupal]/contributions/modules/schedule/schedule.install
ViewVC logotype

Diff of /contributions/modules/schedule/schedule.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2, Fri Mar 9 21:58:11 2007 UTC revision 1.3, Sun Aug 30 21:52:30 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: $  // $Id$
3    
4  /**  /**
5   * Implementation of hook_install()   * Implementation of hook_install().
6   *   *
7   * This will automatically install the database tables for the schedule module for the MySQL database.   * This will automatically install the database tables for the schedule module
8     * for the MySQL database.
9   *   *
10   * If you are using another database, you will have to install the tables by hand, using the queries below as a reference.   * If you are using another database, you will have to install the tables by
11     * hand, using the queries below as a reference.
12   *   *
13   * Note that the curly braces around table names are a drupal-specific feature to allow for automatic database table prefixing,   * Note that the curly braces around table names are a drupal-specific feature
14   * and will need to be removed.   * to allow for automatic database table prefixing, and will need to be removed.
15   */   */
16  function schedule_install() {  function schedule_install() {
17    switch ($GLOBALS['db_type']) {    switch ($GLOBALS['db_type']) {
18      case 'mysqli':      case 'mysqli':
19      case 'mysql':      case 'mysql':
20        $query1 = db_query("CREATE TABLE IF NOT EXISTS {schedule} (        $query1 = db_query("CREATE TABLE {schedule} (
21                        schedule_id int(10) NOT NULL auto_increment,          schedule_id int(10) NOT NULL auto_increment,
22                        schedule_title varchar(100) NOT NULL,          schedule_title varchar(100) NOT NULL,
23                        type varchar(20) NOT NULL,          type varchar(20) NOT NULL,
24                        publication_id int(10) NOT NULL default '0',          publication_id int(10) NOT NULL default '0',
25                        start int(11) NOT NULL default '0',          start int(11) NOT NULL default '0',
26                        first int(11) NOT NULL default '0',          first int(11) NOT NULL default '0',
27                        next int(11) NOT NULL default '0',          previous int(11) NOT NULL default '0',
28                        last int(11) NOT NULL default '0',          last int(11) NOT NULL default '0',
29                        every int(3) NOT NULL default '0',          next int(11) NOT NULL default '0',
30                        frequency varchar(6) NOT NULL,          every int(3) NOT NULL default '0',
31                        relative varchar(6) NOT NULL,          frequency varchar(6) NOT NULL,
32                        relative_date varchar(25) NOT NULL,          relative varchar(6) NOT NULL,
33                        timeout int(4) NOT NULL default '0',          relative_date varchar(25) NOT NULL,
34                        PRIMARY KEY  (schedule_id)          timeout int(4) NOT NULL default '0',
35                          ) /*!40100 DEFAULT CHARACTER SET utf8 */;");          PRIMARY KEY (schedule_id)
36          ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
37    
38        $query2 = db_query("CREATE TABLE IF NOT EXISTS {schedule_action} (        $query2 = db_query("CREATE TABLE {schedule_action} (
39                          action_id INT( 10 ) NOT NULL AUTO_INCREMENT ,          action_id INT(10) NOT NULL AUTO_INCREMENT,
40                          type varchar(20) NOT NULL,          type varchar(20) NOT NULL,
41                          publication_id INT( 10 ) NOT NULL ,          publication_id INT(10) NOT NULL,
42                          schedule_id INT( 10 ) NOT NULL ,          schedule_id INT(10) NOT NULL,
43                          pub_time INT( 11 ) NOT NULL ,          vid varchar(255) NOT NULL,
44                          PRIMARY KEY ( action_id )          pub_time INT(11) NOT NULL ,
45                          ) /*!40100 DEFAULT CHARACTER SET utf8 */;");          PRIMARY KEY (action_id)
46          ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
47    
48        if ($query1 && $query2) {        if ($query1 && $query2) {
49          $created = TRUE;          $created = TRUE;
# Line 55  function schedule_install() { Line 59  function schedule_install() {
59    else {    else {
60      drupal_set_message(t('Table installation for the schedule module was unsuccessful. The tables may need to be installed by hand. See schedule.install file for a list of the installation queries.'), 'error');      drupal_set_message(t('Table installation for the schedule module was unsuccessful. The tables may need to be installed by hand. See schedule.install file for a list of the installation queries.'), 'error');
61    }    }
   
   return;  
62  }  }
63    
64  function schedule_update_1() {  function schedule_update_1() {
65      _system_update_utf8(array('schedules', 'schedules_action'));
     _system_update_utf8(array('schedules', 'schedules_action'));  
   
   return;  
66  }  }
67    
68  function schedule_update_2() {  function schedule_update_2() {
   
69    $ret = array();    $ret = array();
70    
71    if ($GLOBALS['db_type'] == 'mysql' || $GLOBALS['db_type'] == 'mysqli') {    if ($GLOBALS['db_type'] == 'mysql' || $GLOBALS['db_type'] == 'mysqli') {
# Line 78  function schedule_update_2() { Line 76  function schedule_update_2() {
76    return $ret;    return $ret;
77  }  }
78    
79    function schedule_update_3() {
80      $ret = array();
81    
82      switch ($GLOBALS['db_type']) {
83        case 'mysql':
84        case 'mysqli':
85          $ret[] = update_sql("ALTER TABLE {schedule} ADD previous int(11) NOT NULL default '0'");
86          break;
87      }
88    
89      return $ret;
90    }
91    
92  ?>  function schedule_update_4() {
93      $ret = array();
94    
95      switch ($GLOBALS['db_type']) {
96        case 'mysql':
97        case 'mysqli':
98          $ret[] = update_sql("ALTER TABLE {schedule_action} ADD vid varchar(255) NOT NULL");
99          break;
100      }
101    
102      return $ret;
103    }
104    
105    /**
106     * Implementation of hook_uninstall().
107     * TODO: Delete variables.
108     */
109    function schedule_uninstall() {
110      db_query('DROP TABLE {schedule}');
111      db_query('DROP TABLE {schedule_action}');
112    }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.2