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

Contents of /contributions/modules/views_argument_api/views_argument_api.install

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


Revision 1.1 - (show annotations) (download) (as text)
Mon Jun 11 20:39:32 2007 UTC (2 years, 5 months ago) by morrissinger
Branch: MAIN
CVS Tags: DRUPAL-5--1-1, DRUPAL-5--1-0, DRUPAL-5--1-2, HEAD
Branch point for: DRUPAL-5
File MIME type: text/x-php
Initial commit of views_argument_api module. This module allows modules to implement and use methods other than the URI to specify arguments in block and embedded views.
1 <?php
2 // $Id$
3
4 /**
5 * Implementation of hook_install().
6 */
7 function views_argument_api_install() {
8 switch ($GLOBALS['db_type']) {
9 case 'mysql':
10 case 'mysqli':
11 $r = db_query("CREATE TABLE {views_argument_api} (
12 view varchar(32) NOT NULL default '0',
13 argid varchar(32) NOT NULL default '0',
14 element varchar(32) NOT NULL default '0'
15 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
16 break;
17 $r2 = db_query("CREATE TABLE {views_argument_api_args} (
18 api_id varchar(32) NOT NULL default '0',
19 api_values longtext
20 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
21 case 'pgsql':
22 $r = db_query("CREATE TABLE {views_argument_api} (
23 view varchar(32) NOT NULL default '0',
24 argid varchar(32) NOT NULL default '0',
25 element varchar(32) NOT NULL default '0'
26 )");
27 $r2 = db_query("CREATE TABLE {views_argument_api_args} (
28 api_id varchar(32) NOT NULL default '0',
29 api_values longtext
30 )");
31 break;
32 }
33
34 $weight = db_result(db_query_range("SELECT s.weight FROM {system} s ORDER BY s.weight ASC", 0, 1));
35 $weight = empty($weight) ? 0 : $weight - 1;
36
37 $r3 = db_query("UPDATE {system} SET weight = %d WHERE name = '%s'", $weight, 'views_argument_api');
38
39 if($r && $r2) {
40 drupal_set_message(t("Views Argument API tables created successfully."));
41 } else {
42 drupal_set_message(t('Views Argument API tables could not be created.'), 'error');
43 }
44
45 if($r3) {
46 drupal_set_message(t("Views Argument API module weight moved to the top"));
47 }
48
49 }
50
51 /**
52 * Update 1
53 */
54 function views_argument_api_update_1() {
55 views_argument_api_install();
56 }
57 /**
58 * Update 2
59 */
60 function views_argument_api_update_2() {
61 switch ($GLOBALS['db_type']) {
62 case 'mysql':
63 case 'mysqli':
64 $r = db_query("CREATE TABLE {views_argument_api_args} (
65 api_id varchar(32) NOT NULL default '0',
66 api_values longtext
67 ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
68 break;
69 case 'pgsql':
70 $r = db_query("CREATE TABLE {views_argument_api_args} (
71 api_id varchar(32) NOT NULL default '0',
72 api_values longtext
73 )");
74 break;
75 }
76 if($r) {
77 drupal_set_message(t("Views Argument API Arguments table created successfully."));
78 } else {
79 drupal_set_message(t('Views Argument API Arguments table created successfully.'), 'error');
80 }
81 }
82
83 /**
84 * Update 3
85 */
86 function views_argument_api_update_3() {
87 db_query("ALTER TABLE {views_argument_api} DROP PRIMARY KEY");
88 }
89
90 /**
91 * Update 4
92 */
93 function views_argument_api_update_4() {
94 $weight = db_result(db_query_range("SELECT s.weight FROM {system} s ORDER BY s.weight ASC", 0, 1));
95 $weight = empty($weight) ? 0 : $weight - 1;
96
97 $r3 = db_query("UPDATE {system} SET weight = %d WHERE name = '%s'", $weight, 'views_argument_api');
98
99 drupal_set_message(t("Views Argument API module weight moved to the top"));
100 }

  ViewVC Help
Powered by ViewVC 1.1.2