| 1 |
<?php
|
| 2 |
// $Id: smileys.install,v 1.1 2006/07/05 16:58:33 unconed Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_install()
|
| 6 |
*/
|
| 7 |
function smileys_install() {
|
| 8 |
switch ($GLOBALS['db_type']) {
|
| 9 |
case 'mysql':
|
| 10 |
case 'mysqli':
|
| 11 |
$result = db_query("CREATE TABLE IF NOT EXISTS {smileys} (
|
| 12 |
id int(11) auto_increment,
|
| 13 |
acronyms varchar(255) DEFAULT '' NOT NULL,
|
| 14 |
image varchar(255) DEFAULT '' NOT NULL,
|
| 15 |
description varchar(64) DEFAULT '' NOT NULL,
|
| 16 |
standalone tinyint(1) DEFAULT '0' NOT NULL,
|
| 17 |
package varchar(64) DEFAULT 'Uncategorized' NOT NULL,
|
| 18 |
PRIMARY KEY (id)
|
| 19 |
) TYPE=MyISAM /*!40100 DEFAULT CHARACTER SET utf8 */;");
|
| 20 |
break;
|
| 21 |
case 'pgsql':
|
| 22 |
$result = db_query("CREATE TABLE {smileys} (
|
| 23 |
id SERIAL,
|
| 24 |
acronyms varchar(255) DEFAULT '' NOT NULL,
|
| 25 |
image varchar(255) DEFAULT '' NOT NULL,
|
| 26 |
description varchar(64) DEFAULT '' NOT NULL,
|
| 27 |
standalone INT2 NOT NULL DEFAULT '0',
|
| 28 |
package varchar(64) DEFAULT 'Uncategorized' NOT NULL,
|
| 29 |
PRIMARY KEY (id)
|
| 30 |
)");
|
| 31 |
break;
|
| 32 |
}
|
| 33 |
if ($result) {
|
| 34 |
$dir = drupal_get_path('module', 'smileys'). '/packs/examples/';
|
| 35 |
$examples = array(
|
| 36 |
array(':) :-) :smile:', 'smile.png', 'Smiling'),
|
| 37 |
array(';) ;-) :wink:', 'wink.png', 'Eye-wink'),
|
| 38 |
array(':( :-( :sad:', 'sad.png', 'Sad'),
|
| 39 |
array(':D :-D :lol:', 'lol.png', 'Laughing out loud'),
|
| 40 |
array('}:) }:-) :evil:', 'evil.png', 'Evil'),
|
| 41 |
array(':P :-P :tongue:', 'tongue.png', 'Sticking out tongue'),
|
| 42 |
array(':O :-O :shocked:', 'shock.png', 'Shocked'),
|
| 43 |
array(':? :-? :puzzled:', 'puzzled.png', 'Puzzled'),
|
| 44 |
array('8) 8-) :cool:', 'cool.png', 'Cool'),
|
| 45 |
array(':jawdrop:', 'jawdrop.gif', 'Jawdropping!'),
|
| 46 |
array(':sick: :barf:', 'barf.gif', 'Barf!'),
|
| 47 |
);
|
| 48 |
foreach ($examples as $data) {
|
| 49 |
db_query("INSERT INTO {smileys} (acronyms, image, description, standalone, package) VALUES ('%s', '%s', '%s', 1, '%s');", $data[0], $dir . $data[1], $data[2], 'example');
|
| 50 |
}
|
| 51 |
}
|
| 52 |
}
|
| 53 |
|
| 54 |
function hook_uninstall() {
|
| 55 |
db_query('DROP TABLE {smileys}');
|
| 56 |
//variable_del('profile_block_author_fields');
|
| 57 |
}
|
| 58 |
|
| 59 |
/**
|
| 60 |
* Updates
|
| 61 |
*/
|
| 62 |
function smileys_update_1() {
|
| 63 |
return _system_update_utf8(array('smileys'));
|
| 64 |
}
|