/[drupal]/contributions/modules/node_images/node_images.install
ViewVC logotype

Contents of /contributions/modules/node_images/node_images.install

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Sun Aug 17 21:19:11 2008 UTC (15 months, 1 week ago) by stefano73
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +62 -40 lines
File MIME type: text/x-php
Initial relase for 6.x
1 <?php
2 // $Id: node_images.install,v 1.4 2007/03/29 14:42:51 stefano73 Exp $
3
4 /**
5 * Implementation of hook_install().
6 */
7 function node_images_install() {
8 // Create tables.
9 drupal_install_schema('node_images');
10 }
11
12 function node_images_uninstall(){
13 drupal_uninstall_schema('node_images');
14 variable_del('node_images_path');
15 variable_del('node_images_md5name');
16 variable_del('node_images_extensions');
17 variable_del('node_images_file_limit');
18 variable_del('node_images_large_resolution');
19 variable_del('node_images_thumb_resolution');
20 variable_del('node_images_uploadsize_default');
21 variable_del('node_images_max_images');
22
23 $names = node_get_types('names');
24 foreach ($names as $key => $name) {
25 variable_del('node_images_position_'. $key);
26 variable_del('node_images_teaser_images_'. $key);
27 variable_del('node_images_body_images_'. $key);
28 variable_del('node_images_teaser_format_'. $key);
29 variable_del('node_images_body_format_'. $key);
30 variable_del('node_images_roles_add_'. $key);
31 }
32 }
33
34 function node_images_schema(){
35 $schema['node_images'] = array(
36 'fields' => array(
37 'id' => array('type' =>'serial', 'unsigned' => TRUE, 'not null' => TRUE),
38 'nid' => array('type' =>'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
39 'uid' => array('type' =>'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
40 'filename' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
41 'filepath' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
42 'filemime' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
43 'filesize' => array('type' =>'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
44 'thumbpath' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
45 'thumbsize' => array('type' =>'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
46 'status' => array('type' =>'int', 'size' => 'small', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 1),
47 'weight' => array('type' =>'int', 'size' => 'small', 'unsigned' => FALSE, 'not null' => TRUE, 'default' => 0),
48 'description' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
49 'timestamp' => array('type' => 'int', 'unsigned' => TRUE, 'default' => 0),
50 'list' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'unsigned' => TRUE, 'default' => 1),
51 ),
52 'primary key' => array('id'),
53 'indexes' => array(
54 'uid' =>array('uid'),
55 'nid_status' => array('nid', 'status'),
56 )
57 );
58 return $schema;
59 }
60
61 function node_images_update_1() {
62 $names = node_get_types('names');
63 foreach ($names as $key => $name) {
64 if ($result = variable_get('node_images_'. $key, '')) {
65 variable_set('node_images_position_'. $key, $result);
66 variable_del('node_images_'. $key);
67 }
68 }
69 return array();
70 }
71
72 function node_images_update_2() {
73 $ret = array();
74 switch ($GLOBALS['db_type']) {
75 case 'mysql':
76 case 'mysqli':
77 $ret[] = update_sql('ALTER TABLE {node_images} ADD timestamp INT(11) NOT NULL default 0');
78 $ret[] = update_sql('ALTER TABLE {node_images} ADD list TINYINT(1) unsigned NOT NULL default 1');
79 break;
80 }
81 return $ret;
82 }

  ViewVC Help
Powered by ViewVC 1.1.2