| Commit | Line | Data |
|---|---|---|
| 966f98ae | 1 | <?php |
| d20d32ba | 2 | // $Id$ |
| 966f98ae | 3 | |
| 758f4801 TS |
4 | /** |
| 5 | * Implementation of hook_install() | |
| 6 | * | |
| 7 | * This will automatically install the database tables for the TinyMCE module for both the MySQL and PostgreSQL databases. | |
| 8 | * | |
| 9 | * If you are using another database, you will have to install the tables by hand, using the queries below as a reference. | |
| 10 | * | |
| 11 | * Note that the curly braces around table names are a drupal-specific feature to allow for automatic database table prefixing, | |
| 12 | * and will need to be removed. | |
| 13 | */ | |
| d8e137a6 | 14 | function tinymce_install() { |
| 758f4801 TS |
15 | switch ($GLOBALS['db_type']) { |
| 16 | case 'mysqli': | |
| 17 | case 'mysql': | |
| 18 | $query1 = db_query("CREATE TABLE IF NOT EXISTS {tinymce_settings} ( | |
| 19 | name varchar(128) NOT NULL default '', | |
| 20 | settings text NOT NULL default '', | |
| 21 | PRIMARY KEY (name) | |
| 22 | ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;"); | |
| 23 | ||
| 24 | $query2 = db_query("CREATE TABLE IF NOT EXISTS {tinymce_role} ( | |
| 25 | name varchar(128) NOT NULL default '', | |
| 26 | rid tinyint(3) unsigned NOT NULL default '0', | |
| 27 | PRIMARY KEY (name,rid) | |
| 28 | ) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;"); | |
| d8e137a6 | 29 | |
| 758f4801 TS |
30 | if ($query1 && $query2) { |
| 31 | $created = TRUE; | |
| 32 | } | |
| 33 | break; | |
| 34 | ||
| 35 | case 'pgsql': | |
| 36 | $query1 = db_query("CREATE TABLE {tinymce_settings} ( | |
| 37 | name varchar(128) NOT NULL default '', | |
| 38 | settings text NOT NULL default '', | |
| 39 | PRIMARY KEY (name));"); | |
| 40 | ||
| 41 | $query2 = db_query("CREATE TABLE {tinymce_role} ( | |
| 42 | name varchar(128) NOT NULL default '', | |
| 43 | rid smallint NOT NULL default '0', | |
| 44 | PRIMARY KEY (name,rid));"); | |
| 45 | ||
| 46 | if ($query1 && $query2) { | |
| 47 | $created = TRUE; | |
| 48 | } | |
| 49 | break; | |
| 50 | ||
| 51 | default: | |
| 52 | break; | |
| 53 | } | |
| 54 | ||
| 55 | if ($created) { | |
| 56 | drupal_set_message(t('TinyMCE module installed successfully.')); | |
| 57 | } | |
| 58 | else { | |
| 59 | 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'); | |
| 60 | } | |
| d8e137a6 MW |
61 | } |
| 62 | ||
| 966f98ae TS |
63 | function tinymce_update_1() { |
| 64 | return _system_update_utf8(array('tinymce_settings', 'tinymce_role')); | |
| 65 | } |