imagepicker.install in Image Picker 5.2
Same filename and directory in other branches
imagepicker install, update and uninstall functions
File
imagepicker.installView source
<?php
// $Name$
/**
* @file
* imagepicker install, update and uninstall functions
*/
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');
}
}
function imagepicker_uninstall() {
db_query('DROP TABLE {imagepicker};');
db_query('DROP TABLE {imagepicker_user_groups};');
db_query('DROP TABLE {imagepicker_group_images};');
db_query("DELETE FROM {sequences} WHERE name = 'imagepicker_img_id';");
db_query("DELETE FROM {variable} WHERE name LIKE 'imagepicker_%';");
}
function imagepicker_update_1() {
$ret = array();
$sql = "ALTER TABLE {imagepicker} CHANGE img_id img_id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT";
$ret[] = update_sql($sql);
return $ret;
}
function imagepicker_update_2() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$created1 = 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 PRIMARY KEY (`gid`),\n KEY `uid` (`uid`)\n )\n ");
$created2 = 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) {
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.'), '');
}
}
function imagepicker_update_5103() {
$ret = array();
$sql = "ALTER TABLE {imagepicker_user_groups} ADD `public` tinyint(1) unsigned NOT NULL default '0'";
$ret[] = update_sql($sql);
return $ret;
}
function imagepicker_update_5201() {
$ret = array();
$sql = "ALTER TABLE {imagepicker_user_groups} ADD `avail_roles` VARCHAR(255) NOT NULL DEFAULT 'all'";
$ret[] = update_sql($sql);
return $ret;
}
Functions
Name![]() |
Description |
---|---|
imagepicker_install | @file imagepicker install, update and uninstall functions |
imagepicker_uninstall | |
imagepicker_update_1 | |
imagepicker_update_2 | |
imagepicker_update_5103 | |
imagepicker_update_5201 |