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

Contents of /contributions/modules/og_teampage/og_teampage.install

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


Revision 1.8 - (show annotations) (download) (as text)
Thu Jul 12 07:37:49 2007 UTC (2 years, 4 months ago) by martinsfromb
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +2 -2 lines
File MIME type: text/x-php
- converted files to utf-8 and unix newline format
1 <?php
2 // $Id: og_teampage.install,v 1.7 2007/07/10 12:00:37 martinsfromb Exp $
3
4 function og_teampage_install() {
5 switch ($GLOBALS['db_type']) {
6 case 'mysqli':
7 case 'mysql':
8 $result = db_query("
9 CREATE TABLE {og_teampage_members} (
10 id INT( 11 ) NOT NULL AUTO_INCREMENT ,
11 uid INT( 11 ) NOT NULL ,
12 gid INT( 11 ) NOT NULL ,
13 hidden SMALLINT( 1 ) DEFAULT '0' NOT NULL ,
14 name VARCHAR( 50 ) ,
15 description TEXT NULL DEFAULT NULL,
16 picture1 VARCHAR( 255 ) ,
17 weight SMALLINT( 3 ) DEFAULT '0' NOT NULL,
18 PRIMARY KEY ( id ) ,
19 INDEX ( uid , gid ))"
20 );
21 if ($result)
22 {
23 $result = db_query("
24 CREATE TABLE {og_teampage} (
25 gid INT( 11 ) NOT NULL ,
26 show_in_mission SMALLINT( 1 ) DEFAULT '0' NOT NULL ,
27 use_user_images SMALLINT( 1 ) DEFAULT '0' NOT NULL ,
28 PRIMARY KEY ( gid ))"
29 );
30 }
31 break;
32 case 'pgsql':
33 $result = db_query("
34 CREATE TABLE {og_teampage_members} (
35 id numeric( 11 ) NOT NULL AUTO_INCREMENT ,
36 uid numeric( 11 ) NOT NULL ,
37 gid numeric( 11 ) NOT NULL ,
38 hidden numeric( 1 ) DEFAULT '0' NOT NULL ,
39 name varchar( 50 ) ,
40 description varchar(255) NULL DEFAULT NULL,
41 picture1 varchar( 255 ) NULL,
42 weight numeric( 3 ) DEFAULT '0' NOT NULL,
43 PRIMARY KEY ( id ) ,
44 INDEX ( uid , gid ))"
45 );
46 if ($result)
47 {
48 $result = db_query("
49 CREATE TABLE {og_teampage} (
50 gid numeric( 11 ) NOT NULL ,
51 show_in_mission numeric( 1 ) DEFAULT '0' NOT NULL ,
52 use_user_images numeric( 1 ) DEFAULT '0' NOT NULL ,
53 PRIMARY KEY ( gid ))"
54 );
55 }
56 break;
57 default:
58 break;
59 }
60
61 if ($result) {
62 drupal_set_message(t('Teampage module database tables installed successfully.'));
63 }
64 else {
65 drupal_set_message(t('Teampage module database table creation was unsuccessful.'), 'error');
66 }
67 }
68
69 function og_teampage_update_1() {
70 og_teampage_install();
71 og_teampage_update_2();
72 }
73
74 //store old teammembers data from users table in own table
75 //using 0 as gid for default description
76 function og_teampage_update_2() {
77 $result = db_query("SELECT uid, data FROM {users}");
78 $i=0;
79 $users = array();
80 while ($auser = db_fetch_object($result)) {
81 $users[$i][uid] = $auser->uid;
82 $users[$i][data] = unserialize($auser->data);
83 $i++;
84 }
85 foreach($users as $auser)
86 {
87 if (($auser[data]['og_teampage_position'] != '') || ($auser[data]['og_teampage_picture1'] != '') || ($auser[data]['realname'] != '')) {
88 $result = db_query("INSERT INTO {og_teampage_members} SET uid='".$auser[uid]."', gid='0', name='".$auser[data]['realname']."', position='".$auser[data]['og_teampage_position']."',picture1='".$auser[data]['og_teampage_picture1']."' ");
89 }
90 }
91 }
92
93 function og_teampage_update_3() {
94 $items = array();
95 $items[] = update_sql("
96 ALTER TABLE {og_teampage_members} CHANGE position description TEXT NULL DEFAULT NULL;
97 ");
98 return $items;
99 }
100
101 function og_teampage_update_4() {
102 $items = array();
103 $items[] = update_sql("
104 ALTER TABLE {og_teampage_members} ADD weight SMALLINT( 3 ) DEFAULT '0' NOT NULL;
105 ");
106 return $items;
107 }
108
109 function og_teampage_update_5() {
110 $items = array();
111 $items[] = update_sql("
112 UPDATE {node} SET type='og' WHERE type='teampage';
113 ");
114 $items[] = update_sql("
115 DELETE from {node_type} WHERE type='teampage';
116 ");
117 $items[] = update_sql("
118 DELETE from {og_ancestry} WHERE nid=group_nid;
119 ");
120 return $items;
121 }
122
123 function og_teampage_update_6() {
124 $items = array();
125 switch ($GLOBALS['db_type']) {
126 case 'mysqli':
127 case 'mysql':
128 $items[] = update_sql("
129 CREATE TABLE {og_teampage} (
130 gid INT( 11 ) NOT NULL ,
131 show_in_mission SMALLINT( 1 ) DEFAULT '0' NOT NULL ,
132 use_user_images SMALLINT( 1 ) DEFAULT '0' NOT NULL ,
133 PRIMARY KEY ( gid ))"
134 );
135 break;
136 case 'pgsql':
137 $items[] = update_sql("
138 CREATE TABLE {og_teampage} (
139 gid numeric( 11 ) NOT NULL ,
140 show_in_mission numeric( 1 ) DEFAULT '0' NOT NULL ,
141 use_user_images numeric( 1 ) DEFAULT '0' NOT NULL ,
142 PRIMARY KEY ( gid ))"
143 );
144 };
145
146 $res = db_query("SELECT * FROM {og_teampage_members} WHERE uid='0' AND gid <> '0'");
147 while ($entry = db_fetch_object($res)) {
148 $show_in_mission = 0;
149 if ($entry->hidden == 3) $show_in_mission = 1;
150 $items[] = db_query("INSERT INTO {og_teampage} SET gid='".$entry->gid."', show_in_mission='".$show_in_mission."', use_user_images='".$entry->weight."'");
151 }
152
153 $items[] = update_sql("
154 DELETE FROM {og_teampage_members} WHERE uid='0' OR gid = '0';
155 ");
156 return $items;
157 }
158
159 ?>

  ViewVC Help
Powered by ViewVC 1.1.2