| 1 |
<?php
|
| 2 |
// $Id: image_fupload.install,v 1.10 2009/06/09 22:25:54 grandcat Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
*/
|
| 7 |
|
| 8 |
/**
|
| 9 |
* Implementation of hook_install().
|
| 10 |
*/
|
| 11 |
function image_fupload_install() {
|
| 12 |
// install a default preview preset for image module so that it works when it is activated
|
| 13 |
// also preventing 403 errors)
|
| 14 |
$image_node_types = variable_get('image_node_types', array());
|
| 15 |
if (empty($image_node_types['image'])) {
|
| 16 |
$image_node_types['image'] = array(
|
| 17 |
'title' => 'Image',
|
| 18 |
'fieldname' => 'images',
|
| 19 |
'image_selection' => 'preview', // best choice I think; can be changed in admin menu
|
| 20 |
'imagecache_preset' => '',
|
| 21 |
);
|
| 22 |
variable_set('image_node_types', $image_node_types);
|
| 23 |
}
|
| 24 |
|
| 25 |
// create table for temporary images for image preview list
|
| 26 |
drupal_install_schema('image_fupload');
|
| 27 |
}
|
| 28 |
|
| 29 |
/**
|
| 30 |
* Implementation of hook_uninstall().
|
| 31 |
*/
|
| 32 |
function image_fupload_uninstall() {
|
| 33 |
// remove all used variables
|
| 34 |
$variables = array(
|
| 35 |
'fupload_title_replacements',
|
| 36 |
'fupload_previewlist_img_attributes',
|
| 37 |
'fupload_previewlist_field_settings',
|
| 38 |
'image_node_types',
|
| 39 |
);
|
| 40 |
for ($i = 0; $i < count($variables); $i++) {
|
| 41 |
variable_del($variables[$i]);
|
| 42 |
}
|
| 43 |
|
| 44 |
// drop our image preview table
|
| 45 |
drupal_uninstall_schema('image_fupload');
|
| 46 |
}
|
| 47 |
|
| 48 |
/**
|
| 49 |
* Implementation of hook_requirements().
|
| 50 |
*/
|
| 51 |
function image_fupload_requirements($phase) {
|
| 52 |
$requirements = array();
|
| 53 |
|
| 54 |
if ($phase == 'runtime') {
|
| 55 |
// Make sure that swfUpload Files which aren't bundled with this module, are located in swfupload directory
|
| 56 |
$path = drupal_get_path('module', 'image_fupload') .'/swfupload/';
|
| 57 |
if (!file_exists($path .'swfupload.js') || !file_exists($path .'swfupload.queue.js') || !file_exists($path .'swfupload.swf')) {
|
| 58 |
// One or more needed files are missing; give an error
|
| 59 |
$requirements['image_fupload'] = array(
|
| 60 |
'title' => t('Image FUpload'),
|
| 61 |
'value' => t('Missing or wrong files in subdirectory "swfupload"'),
|
| 62 |
'description' => t('Some needed files which are not bundled with this module, are missing or out-of-date! This can be either "swfupload.swf", "swfupload.js" or "swfupload.queue.js" which should be located in "%path". These files can be downloaded from !page. <em>Note:</em> Version 2.2.0 or higher is needed.', array('%path' => $path, '!page' => l(t('SWFUploads project page'), 'http://code.google.com/p/swfupload/'))),
|
| 63 |
'severity' => REQUIREMENT_ERROR,
|
| 64 |
);
|
| 65 |
}
|
| 66 |
}
|
| 67 |
|
| 68 |
return $requirements;
|
| 69 |
}
|
| 70 |
|
| 71 |
/**
|
| 72 |
* Implementation of hook_schema().
|
| 73 |
*/
|
| 74 |
function image_fupload_schema() {
|
| 75 |
// Currently, schema 1 is the only schema we have. As we make updates,
|
| 76 |
// we might either create a new schema 2 or make adjustments here.
|
| 77 |
return image_fupload_schema_1();
|
| 78 |
}
|
| 79 |
|
| 80 |
/**
|
| 81 |
* Image FUpload's initial schema; separated for the purposes of updates.
|
| 82 |
*/
|
| 83 |
function image_fupload_schema_1() {
|
| 84 |
$schema['fupload_previewlist'] = array(
|
| 85 |
'description' => t('Caches images for image preview list.'),
|
| 86 |
'fields' => array(
|
| 87 |
'fieldname' => array(
|
| 88 |
'type' => 'varchar',
|
| 89 |
'length' => '32',
|
| 90 |
'default' => '',
|
| 91 |
'not null' => TRUE,
|
| 92 |
'description' => t('Stores name of our image field depending on used node type.'),
|
| 93 |
'no export' => TRUE,
|
| 94 |
),
|
| 95 |
'uid' => array(
|
| 96 |
'type' => 'int',
|
| 97 |
'length' => 'normal',
|
| 98 |
'default' => 0,
|
| 99 |
'not null' => TRUE,
|
| 100 |
'description' => t('Stores user id.'),
|
| 101 |
'no export' => TRUE,
|
| 102 |
),
|
| 103 |
'nid' => array(
|
| 104 |
'type' => 'int',
|
| 105 |
'length' => 'normal',
|
| 106 |
'default' => 0,
|
| 107 |
'not null' => TRUE,
|
| 108 |
'description' => t('Stores node id.'),
|
| 109 |
'no export' => TRUE,
|
| 110 |
),
|
| 111 |
'fid' => array(
|
| 112 |
'type' => 'int',
|
| 113 |
'length' => 'normal',
|
| 114 |
'default' => 0,
|
| 115 |
'not null' => FALSE,
|
| 116 |
'description' => t('Stores file id of uploaded image.'),
|
| 117 |
'no export' => TRUE,
|
| 118 |
),
|
| 119 |
'created' => array(
|
| 120 |
'type' => 'int',
|
| 121 |
'length' => 'normal',
|
| 122 |
'default' => 0,
|
| 123 |
'not null' => TRUE,
|
| 124 |
'description' => t('Stores creation time to do some clean up by cron.'),
|
| 125 |
'no export' => TRUE,
|
| 126 |
),
|
| 127 |
),
|
| 128 |
'indexes' => array('fieldname' => array('fieldname'), 'uid' => array('uid')),
|
| 129 |
'primary key' => array('fid'),
|
| 130 |
);
|
| 131 |
|
| 132 |
return $schema;
|
| 133 |
}
|
| 134 |
|
| 135 |
/**
|
| 136 |
* Implementation of hook_update_N().
|
| 137 |
*/
|
| 138 |
function image_fupload_update_6100() {
|
| 139 |
$ret = array();
|
| 140 |
|
| 141 |
// activate image_fupload_image by default
|
| 142 |
/* module_enable(array('image_fupload_image'));
|
| 143 |
* why?
|
| 144 |
*/
|
| 145 |
|
| 146 |
return $ret;
|
| 147 |
}
|
| 148 |
|
| 149 |
function image_fupload_update_6110() {
|
| 150 |
$ret = array();
|
| 151 |
|
| 152 |
// Create default profile if nothing exists (preventing 403 errors)
|
| 153 |
$image_node_types = variable_get('image_node_types', array());
|
| 154 |
if (empty($image_node_types['image'])) {
|
| 155 |
$image_node_types['image'] = array(
|
| 156 |
'title' => 'Image',
|
| 157 |
'fieldname' => 'images',
|
| 158 |
'image_selection' => 'preview', // best choice I think; can be changed in admin menu
|
| 159 |
'imagecache_preset' => '',
|
| 160 |
);
|
| 161 |
variable_set('image_node_types', $image_node_types);
|
| 162 |
}
|
| 163 |
|
| 164 |
return $ret;
|
| 165 |
}
|
| 166 |
|
| 167 |
function image_fupload_update_6300() {
|
| 168 |
$ret = array();
|
| 169 |
|
| 170 |
// create our image preview list table
|
| 171 |
$schema = image_fupload_schema_1();
|
| 172 |
_drupal_initialize_schema('image_fupload', $schema);
|
| 173 |
|
| 174 |
foreach ($schema as $name => $table) {
|
| 175 |
db_create_table($ret, $name, $table);
|
| 176 |
}
|
| 177 |
|
| 178 |
return $ret;
|
| 179 |
}
|
| 180 |
|
| 181 |
/**
|
| 182 |
* Update from 3.0 alpha 1 to alpha 2
|
| 183 |
*/
|
| 184 |
function image_fupload_update_6301() {
|
| 185 |
$ret = array();
|
| 186 |
|
| 187 |
// it's not really an update, but we have to force the user to run update.php
|
| 188 |
// because some theme related things changed
|
| 189 |
|
| 190 |
return $ret;
|
| 191 |
}
|
| 192 |
|
| 193 |
/**
|
| 194 |
* Update from 3.0 alpha 3 to alpha 4
|
| 195 |
*/
|
| 196 |
function image_fupload_update_6304() {
|
| 197 |
$ret = array();
|
| 198 |
|
| 199 |
// it's not really an update, but we have to force the user to run update.php
|
| 200 |
// because some theme related things changed
|
| 201 |
|
| 202 |
return $ret;
|
| 203 |
}
|