function imagepicker_install in Image Picker 5.2
Same name and namespace in other branches
- 5 imagepicker.install \imagepicker_install()
- 6.2 imagepicker.install \imagepicker_install()
- 7 imagepicker.install \imagepicker_install()
@file imagepicker install, update and uninstall functions
File
- ./
imagepicker.install, line 9 - imagepicker install, update and uninstall functions
Code
function imagepicker_install() {
$drupaldir = str_replace('/', DIRECTORY_SEPARATOR, getcwd()) . DIRECTORY_SEPARATOR;
$dir = $drupaldir . file_directory_path() . DIRECTORY_SEPARATOR . 'imagepicker';
if (file_check_directory($dir, TRUE)) {
$created1 = db_query("INSERT INTO {sequences} (name, id) VALUES ('imagepicker_img_id', 0);");
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$created2 = db_query("\n CREATE TABLE IF NOT EXISTS {imagepicker} (\n `img_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n `uid` int(10) unsigned NOT NULL default '0',\n `img_name` varchar(255) NOT NULL default '',\n `img_title` varchar(255) NOT NULL default '',\n `img_description` varchar(255) NOT NULL default '',\n `img_date` timestamp NOT NULL,\n PRIMARY KEY (`img_id`),\n KEY `uid` (`uid`)\n )\n ");
$created3 = db_query("\n CREATE TABLE IF NOT EXISTS {imagepicker_user_groups} (\n `gid` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `uid` int(10) unsigned NOT NULL default '0',\n `group_name` varchar(255) NOT NULL default '',\n `group_description` varchar(255) default NULL,\n `state` tinyint(4) unsigned NOT NULL default '0',\n `public` tinyint(1) unsigned NOT NULL default '0',\n `avail_roles` varchar(255) NOT NULL default 'all',\n PRIMARY KEY (`gid`),\n KEY `uid` (`uid`)\n )\n ");
$created4 = db_query("\n CREATE TABLE IF NOT EXISTS {imagepicker_group_images} (\n `gid` int(10) unsigned NOT NULL default '0',\n `img_id` int(10) unsigned NOT NULL default '0')\n ");
break;
}
if (!$created1 || !$created2 || !$created3 || !$created4) {
drupal_set_message(t('Table installation for the Imagepicker module was unsuccessful.'), 'error');
}
else {
drupal_set_message(t('Table installation for the Imagepicker module was successful. Go to Site Configuration to set preferences.'), '');
}
}
else {
drupal_set_message(t('Directory creation for the Imagepicker module was unsuccessful.'), 'error');
}
}