summaryrefslogtreecommitdiffstats
path: root/tinymce.install
blob: b8db577f9793b5e5c9377631090a6adc4c21771f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
// $Id$

/**
 * Implementation of hook_install()
 *
 * This will automatically install the database tables for the TinyMCE module for both the MySQL and PostgreSQL databases.
 *
 * If you are using another database, you will have to install the tables by hand, using the queries below as a reference.
 *
 * Note that the curly braces around table names are a drupal-specific feature to allow for automatic database table prefixing,
 * and will need to be removed.
 */
function tinymce_install() {
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      $query1 = db_query("CREATE TABLE IF NOT EXISTS {tinymce_settings} (
                          name varchar(128) NOT NULL default '',
                          settings text NOT NULL default '',
                          PRIMARY KEY (name)
                          ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
  
      $query2 = db_query("CREATE TABLE IF NOT EXISTS {tinymce_role} (
                          name varchar(128) NOT NULL default '',
                          rid tinyint(3) unsigned NOT NULL default '0',
                          PRIMARY KEY (name,rid)
                          ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");

      if ($query1 && $query2) {
        $created = TRUE;
      }
      break;
      
    case 'pgsql':
      $query1 = db_query("CREATE TABLE {tinymce_settings} (
                          name varchar(128) NOT NULL default '',
                          settings text NOT NULL default '',
                          PRIMARY KEY (name));");
     
      $query2 = db_query("CREATE TABLE {tinymce_role} (
                          name varchar(128) NOT NULL default '',
                          rid smallint NOT NULL default '0',
                          PRIMARY KEY (name,rid));");
   
      if ($query1 && $query2) {
        $created = TRUE;
      }
      break;
      
    default:
      break;
  }
  
  if ($created) {
    drupal_set_message(t('TinyMCE module installed successfully.'));
  }
  else {
    drupal_set_message(t('Table installation for the TinyMCE module was unsuccessful. The tables may need to be installed by hand. See tinymce.install file for a list of the installation queries.'), 'error');
  }
}

function tinymce_update_1() {
  return _system_update_utf8(array('tinymce_settings', 'tinymce_role'));
}