/[drupal]/contributions/sandbox/stevemckenzie/salesforce/salesforce.install
ViewVC logotype

Contents of /contributions/sandbox/stevemckenzie/salesforce/salesforce.install

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


Revision 1.2 - (show annotations) (download) (as text)
Tue Oct 17 09:07:37 2006 UTC (3 years, 1 month ago) by stevemckenzie
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +10 -9 lines
File MIME type: text/x-php
so much closer to v1 completion - damn this datetime format crap it speaks of.. and damn this not wanting to accept my contact object on updating contacts.. like wtf?
1 <?php
2
3 function salesforce_install() {
4 if (!module_exist('profile')) {
5 form_set_error('status_salesforce', t('salesforce.module requires profile.module'));
6 }
7
8 switch ($GLOBALS['db_type']) {
9 case 'mysql':
10 case 'mysqli':
11 $users_table = db_query("CREATE TABLE {salesforce_users} (
12 uid int(11) NOT NULL default '0',
13 lead_id tinytext NOT NULL,
14 contact_id tinytext NOT NULL,
15 opp_id tinytext NOT NULL,
16 account_id tinytext NOT NULL,
17 created timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
18 PRIMARY KEY (uid)
19 ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
20
21
22 if (!db_error()) {
23 drupal_set_message(t('salesforce.module - users table installed successfully'));
24 } else {
25 drupal_set_message(t('salesforce.module - users table did not install'), 'error');
26 }
27
28 $log_table = db_query("CREATE TABLE {salesforce_log} (
29 sid int(11) NOT NULL auto_increment,
30 type varchar(255) NOT NULL default '',
31 type_id int(11) NOT NULL default '0',
32 message tinytext NOT NULL,
33 timestamp timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
34 status int(11) NOT NULL default '0',
35 data text NOT NULL,
36 PRIMARY KEY (sid),
37 KEY type (type,type_id)
38 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
39
40 if (!db_error()) {
41 drupal_set_message(t('salesforce.module - logs table installed successfully'));
42 } else {
43 drupal_set_message(t('salesforce.module - logs table did not install'), 'error');
44 }
45
46 break;
47 }
48
49 // add required fields in profile.module for salesforce api
50 $fields = array();
51
52 $fields[] = array(
53 'title' => 'First Name',
54 'name' => 'first_name',
55 'category' => 'Personal Information',
56 'page' => 'first_name',
57 'type' => 'textfield',
58 'weight' => 0,
59 'required' => 1,
60 'register' => 1,
61 'visibility' => 2,
62 'autocomplete' => 0,
63 );
64
65 $fields[] = array(
66 'title' => 'Last Name',
67 'name' => 'last_name',
68 'category' => 'Personal Information',
69 'page' => 'last_name',
70 'type' => 'textfield',
71 'weight' => 1,
72 'required' => 1,
73 'register' => 1,
74 'visibility' => 2,
75 'autocomplete' => 0,
76 );
77
78 $fields[] = array(
79 'title' => 'Company',
80 'name' => 'company',
81 'category' => 'Personal Information',
82 'page' => 'company',
83 'type' => 'textfield',
84 'weight' => 2,
85 'required' => 1,
86 'register' => 1,
87 'visibility' => 2,
88 'autocomplete' => 0,
89 );
90
91 $fields[] = array(
92 'title' => 'Phone',
93 'name' => 'phone',
94 'category' => 'Personal Information',
95 'type' => 'textfield',
96 'weight' => 3,
97 'required' => 0,
98 'register' => 1,
99 'visibility' => 2,
100 'autocomplete' => 0,
101 );
102
103 $fields[] = array(
104 'title' => 'Fax',
105 'name' => 'fax',
106 'category' => 'Personal Information',
107 'type' => 'textfield',
108 'weight' => 4,
109 'required' => 0,
110 'register' => 1,
111 'visibility' => 2,
112 'autocomplete' => 0,
113 );
114
115 foreach ($fields as $field) {
116 $result = db_result(db_query("SELECT fid FROM {profile_fields} WHERE name = '%s'", $field['name']));
117
118 if ($result > 0) {
119 profile_field_form_submit('salesforce_install', $field);
120 }
121 }
122 }

  ViewVC Help
Powered by ViewVC 1.1.2