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

Contents of /contributions/modules/gotwo/gotwo.install

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


Revision 1.2 - (show annotations) (download) (as text)
Wed Aug 26 19:13:26 2009 UTC (3 months ago) by hass
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +128 -26 lines
File MIME type: text/x-php
Sync latest D6 to HEAD
1 <?php
2 // $Id: gotwo.install,v 1.1.6.11 2009/08/22 19:31:55 hass Exp $
3
4 /**
5 * @file
6 * Installation script for the gotwo.module
7 */
8
9 function gotwo_install() {
10 drupal_install_schema('gotwo');
11 }
12
13 /**
14 * Implementation of hook_uninstall().
15 */
16 function gotwo_uninstall() {
17 drupal_uninstall_schema('gotwo');
18 }
19
20 /**
21 * Implementation of hook_schema().
22 */
23 function gotwo_schema() {
24
25 $schema['gotwo'] = array(
26 'description' => 'Stores gotwo settings.',
27 'fields' => array(
28 'gid' => array(
29 'type' => 'serial',
30 'not null' => TRUE,
31 'description' => 'Primary Key: Unique gotwo ID.',
32 ),
33 'src' => array(
34 'type' => 'varchar',
35 'length' => 128,
36 'not null' => TRUE,
37 'default' => '',
38 'description' => 'The label used in the go url, this will automatically be made suitable.',
39 ),
40 'dst' => array(
41 'type' => 'varchar',
42 'length' => 255,
43 'not null' => TRUE,
44 'default' => '',
45 'description' => 'The target url. Can be a relative drupal url or an absolute url.',
46 ),
47 'cnt' => array(
48 'type' => 'int',
49 'not null' => TRUE,
50 'default' => 0,
51 'description' => 'Count clicks on the link.',
52 )
53 ),
54 'unique keys' => array('src' => array('src')),
55 'primary key' => array('gid'),
56 );
57
58 /* TODO
59 'language' => array(
60 'type' => 'varchar',
61 'length' => 12,
62 'not null' => TRUE,
63 'default' => '',
64 'description' => 'Language dependend path',
65 )
66 */
67
68 return $schema;
69 }
70
71 /**
72 * Update the permissions table, to reflect changes to hook_perm.
73 */
74 function gotwo_update_5100() {
75 $ret = array();
76
77 $res = db_query('SELECT rid, perm FROM {permission}');
78 $perms = array();
79 while ($p = db_fetch_object($res)) {
80 $perm = $p->perm;
81 $perm = preg_replace('/Administrative Settings/', 'administer gotwo', $perm);
82 $perm = preg_replace('/view entry list/', 'view gotwo entries', $perm);
83 $perm = preg_replace('/edit entries/', 'edit gotwo entries', $perm);
84 $perms[$p->rid] = $perm;
85 }
86
87 foreach ($perms as $key => $value) {
88 db_query("UPDATE {permission} SET perm = '%s' WHERE rid = %d", $value, $key);
89 }
90
91 return $ret;
92 }
93
94 /**
95 * Update the permissions table, to reflect changes to hook_perm.
96 */
97 function gotwo_update_6100() {
98 $ret = array();
99
100 $res = db_query('SELECT rid, perm FROM {permission}');
101 $perms = array();
102 while ($p = db_fetch_object($res)) {
103 $perm = $p->perm;
104 $perm = preg_replace('/view gotwo entries/', 'view gotwo redirects', $perm);
105 $perm = preg_replace('/edit gotwo entries/', 'edit gotwo redirects', $perm);
106 $perms[$p->rid] = $perm;
107 }
108
109 foreach ($perms as $key => $value) {
110 db_query("UPDATE {permission} SET perm = '%s' WHERE rid = %d", $value, $key);
111 }
112
113 return $ret;
114 }
115
116 /**
117 * Change 'gid' column to auto increment.
118 */
119 function gotwo_update_6101() {
120 $ret = array();
121
122 db_change_field($ret, 'gotwo', 'gid', 'gid', array('type' => 'serial', 'not null' => TRUE));
123
124 return $ret;
125 }
126
127 /**
128 * Extend the length of 'dst' column to 255.
129 */
130 function gotwo_update_6102() {
131 $ret = array();
132
133 db_change_field($ret, 'gotwo', 'dst', 'dst', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
134
135 return $ret;
136 }

  ViewVC Help
Powered by ViewVC 1.1.2