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

Contents of /contributions/modules/guestbook/guestbook.install

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


Revision 1.11 - (show annotations) (download) (as text)
Thu Jan 8 05:29:04 2009 UTC (10 months, 2 weeks ago) by sun
Branch: MAIN
CVS Tags: HEAD
Changes since 1.10: +2 -2 lines
File MIME type: text/x-php
#355495 by sun: Fixed syntax error in module update to 2.x.
1 <?php
2 // $Id: guestbook.install,v 1.10 2008/09/24 15:13:39 sun Exp $
3
4 /**
5 * Implementation of hook_schema().
6 */
7 function guestbook_schema() {
8 $schema['guestbook'] = array(
9 'fields' => array(
10 'id' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
11 'recipient' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
12 'author' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
13 'anonname' => array('type' => 'varchar', 'length' => '128', 'not null' => FALSE),
14 'anonemail' => array('type' => 'varchar', 'length' => '128', 'not null' => FALSE),
15 'anonwebsite' => array('type' => 'varchar', 'length' => '128', 'not null' => FALSE),
16 'message' => array('type' => 'text', 'not null' => TRUE),
17 'commentauthor' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
18 'comment' => array('type' => 'text', 'not null' => TRUE),
19 'created' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
20 ),
21 'indexes' => array(
22 'recipient' => array('recipient'),
23 'commentauthor' => array('commentauthor'),
24 'created' => array('created'),
25 ),
26 'primary key' => array('id'),
27 );
28 return $schema;
29 }
30
31 /**
32 * Implementation of hook_install().
33 */
34 function guestbook_install() {
35 drupal_install_schema('guestbook');
36 }
37
38 /**
39 * Implementation of hook_uninstall().
40 */
41 function guestbook_uninstall() {
42 drupal_uninstall_schema('guestbook');
43 db_query("DELETE FROM {variable} WHERE name LIKE 'guestbook_%%'");
44 }
45
46 function guestbook_update_6001() {
47 $ret = array();
48
49 db_drop_primary_key($ret, 'guestbook');
50 db_change_field($ret, 'guestbook', 'id', 'id',
51 array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
52 array('primary key' => array('id')));
53 db_change_field($ret, 'guestbook', 'anonname', 'anonname',
54 array('type' => 'varchar', 'length' => '128', 'not null' => FALSE));
55
56 return $ret;
57 }
58
59 /**
60 * Rename permission "administer all guestbooks" to "moderate all guestbooks".
61 */
62 function guestbook_update_6200() {
63 $ret = array();
64 $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
65 while ($role = db_fetch_object($result)) {
66 $renamed_permission = strtr($role->perm, array('administer all guestbooks' => 'moderate all guestbooks'));
67 if ($renamed_permission != $role->perm) {
68 $ret[] = update_sql("UPDATE {permission} SET perm = '$renamed_permission' WHERE rid = " . $role->rid);
69 }
70 }
71 return $ret;
72 }
73
74

  ViewVC Help
Powered by ViewVC 1.1.2