-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwordplugin.php
executable file
·439 lines (392 loc) · 15.7 KB
/
wordplugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
<?php
/*********************************************************************************
** The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
*
********************************************************************************/
/**
* URL Verfication - Required to overcome Apache mis-configuration and leading to shared setup mode.
*/
require_once 'config.php';
if (file_exists('config_override.php')) {
include_once 'config_override.php';
}
include_once 'vtlib/Vtiger/Module.php';
include_once 'includes/main/WebUI.php';
require_once('libraries/nusoap/nusoap.php');
$log = &LoggerManager::getLogger('wordplugin');
error_reporting(0);
$NAMESPACE = 'http://www.vtiger.com/products/crm';
$server = new soap_server;
$accessDenied = "You are not permitted to perform this action";
$server->configureWSDL('vtigersoap');
$server->wsdl->addComplexType(
'contact_column_detail',
'complexType',
'array',
'',
array(
'email_address' => array('name'=>'email_address','type'=>'xsd:string'),
'first_name' => array('name'=>'first_name','type'=>'xsd:string'),
'last_name' => array('name'=>'last_name','type'=>'xsd:string'),
'primary_address_city' => array('name'=>'primary_address_city','type'=>'xsd:string'),
'account_name' => array('name'=>'account_name','type'=>'xsd:string'),
'id' => array('name'=>'id','type'=>'xsd:string'),
'salutation' => array('name'=>'salutation','type'=>'xsd:string'),
'title'=> array('name'=>'title','type'=>'xsd:string'),
'phone_mobile'=> array('name'=>'phone_mobile','type'=>'xsd:string'),
'reports_to'=> array('name'=>'reports_to','type'=>'xsd:string'),
'primary_address_city'=> array('name'=>'primary_address_city','type'=>'xsd:string'),
'primary_address_street'=> array('name'=>'primary_address_street','type'=>'xsd:string'),
'primary_address_state'=> array('name'=>'primary_address_state','type'=>'xsd:string'),
'primary_address_postalcode'=> array('name'=>'primary_address_postalcode','type'=>'xsd:string'),
'primary_address_country'=> array('name'=>'primary_address_country','type'=>'xsd:string'),
'alt_address_city'=> array('name'=>'alt_address_city','type'=>'xsd:string'),
'alt_address_street'=> array('name'=>'alt_address_street','type'=>'xsd:string'),
'alt_address_state'=> array('name'=>'alt_address_state','type'=>'xsd:string'),
'alt_address_postalcode'=> array('name'=>'alt_address_postalcode','type'=>'xsd:string'),
'alt_address_country'=> array('name'=>'alt_address_country','type'=>'xsd:string'),
)
);
$server->wsdl->addComplexType(
'account_column_detail',
'complexType',
'array',
'',
array(
'accountid' => array('name'=>'accountid','type'=>'xsd:string'),
'accountname' => array('name'=>'accountname','type'=>'xsd:string'),
'parentid' => array('name'=>'parentid','type'=>'xsd:string'),
'account_type' => array('name'=>'account_type','type'=>'xsd:string'),
'industry' => array('name'=>'industry','type'=>'xsd:string'),
'annualrevenue' => array('name'=>'annualrevenue','type'=>'xsd:string'),
'rating'=> array('name'=>'rating','type'=>'xsd:string'),
'ownership' => array('name'=>'ownership','type'=>'xsd:string'),
'siccode' => array('name'=>'siccode','type'=>'xsd:string'),
'tickersymbol' => array('name'=>'tickersymbol','type'=>'xsd:string'),
'phone' => array('name'=>'phone','type'=>'xsd:string'),
'otherphone' => array('name'=>'otherphone','type'=>'xsd:string'),
'email1' => array('name'=>'email1','type'=>'xsd:string'),
'email2' => array('name'=>'email2','type'=>'xsd:string'),
'website' => array('name'=>'website','type'=>'xsd:string'),
'fax' => array('name'=>'fax','type'=>'xsd:string'),
//'employees' => array('name'=>'employees','type'=>'xsd:string'),
)
);
$server->wsdl->addComplexType(
'lead_column_detail',
'complexType',
'array',
'',
array(
'id' => array('name'=>'id','type'=>'xsd:string'),
'date_entered' => array('name'=>'date_entered','type'=>'xsd:string'),
'date_modified' => array('name'=>'date_modified','type'=>'xsd:string'),
'modified_user_id' => array('name'=>'modified_user_id','type'=>'xsd:string'),
'assigned_user_id' => array('name'=>'assigned_user_id','type'=>'xsd:string'),
'salutation' => array('name'=>'salutation','type'=>'xsd:string'),
'first_name' => array('name'=>'first_name','type'=>'xsd:string'),
'last_name' => array('name'=>'last_name','type'=>'xsd:string'),
'company' => array('name'=>'company','type'=>'xsd:string'),
'designation' => array('name'=>'designation','type'=>'xsd:string'),
'lead_source' => array('name'=>'lead_source','type'=>'xsd:string'),
'industry' => array('name'=>'industry','type'=>'xsd:string'),
'annual_revenue' => array('name'=>'annual_revenue','type'=>'xsd:string'),
'license_key' => array('name'=>'license_key','type'=>'xsd:string'),
'phone' => array('name'=>'phone','type'=>'xsd:string'),
'mobile' => array('name'=>'mobile','type'=>'xsd:string'),
'fax' => array('name'=>'fax','type'=>'xsd:string'),
'email' => array('name'=>'email','type'=>'xsd:string'),
'secondaryemail' => array('name'=>'secondaryemail','type'=>'xsd:string'),
'website' => array('name'=>'website','type'=>'xsd:string'),
'lead_status' => array('name'=>'lead_status','type'=>'xsd:string'),
'rating' => array('name'=>'rating','type'=>'xsd:string'),
'employees' => array('name'=>'employees','type'=>'xsd:string'),
'address_street' => array('name'=>'address_street','type'=>'xsd:string'),
'address_city' => array('name'=>'address_city','type'=>'xsd:string'),
'address_state' => array('name'=>'address_state','type'=>'xsd:string'),
'address_postalcode' => array('name'=>'address_postalcode','type'=>'xsd:string'),
'address_country' => array('name'=>'address_country','type'=>'xsd:string'),
'description' => array('name'=>'description','type'=>'xsd:string'),
'deleted' => array('name'=>'deleted','type'=>'xsd:string'),
'converted' => array('name'=>'converted','type'=>'xsd:string'),
)
);
$server->wsdl->addComplexType(
'user_column_detail',
'complexType',
'array',
'',
array(
'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
'username' => array('name'=>'username','type'=>'xsd:string'),
'secondaryemail' => array('name'=>'secondaryemail','type'=>'xsd:string'),
'title' => array('name'=>'title','type'=>'xsd:string'),
'workphone' => array('name'=>'workphone','type'=>'xsd:string'),
'department' => array('name'=>'department','type'=>'xsd:string'),
'mobilephone' => array('name'=>'mobilephone','type'=>'xsd:string'),
'otherphone'=> array('name'=>'otherphone','type'=>'xsd:string'),
'fax' => array('name'=>'fax','type'=>'xsd:string'),
'email' => array('name'=>'email','type'=>'xsd:string'),
'homephone' => array('name'=>'homephone','type'=>'xsd:string'),
'otheremail' => array('name'=>'otheremail','type'=>'xsd:string'),
'street' => array('name'=>'street','type'=>'xsd:string'),
'city' => array('name'=>'city','type'=>'xsd:string'),
'state' => array('name'=>'state','type'=>'xsd:string'),
'code' => array('name'=>'code','type'=>'xsd:string'),
'country' => array('name'=>'country','type'=>'xsd:string'),
)
);
$server->wsdl->addComplexType(
'tickets_list_array',
'complexType',
'array',
'',
array(
'ticketid' => array('name'=>'ticketid','type'=>'xsd:string'),
'title' => array('name'=>'title','type'=>'xsd:string'),
'groupname' => array('name'=>'groupname','type'=>'xsd:string'),
'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
'parent_id' => array('name'=>'parent_id','type'=>'xsd:string'),
'productid' => array('name'=>'productid','type'=>'xsd:string'),
'productname' => array('name'=>'productname','type'=>'xsd:string'),
'priority' => array('name'=>'priority','type'=>'xsd:string'),
'severity' => array('name'=>'severity','type'=>'xsd:string'),
'status' => array('name'=>'status','type'=>'xsd:string'),
'category' => array('name'=>'category','type'=>'xsd:string'),
'description' => array('name'=>'description','type'=>'xsd:string'),
'solution' => array('name'=>'solution','type'=>'xsd:string'),
'createdtime' => array('name'=>'createdtime','type'=>'xsd:string'),
'modifiedtime' => array('name'=>'modifiedtime','type'=>'xsd:string'),
)
);
$server->register(
'get_contacts_columns',
array('user_name'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'tns:contact_column_detail'),
$NAMESPACE);
$server->register(
'get_accounts_columns',
array('user_name'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'tns:account_column_detail'),
$NAMESPACE);
$server->register(
'get_leads_columns',
array('user_name'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'tns:lead_column_detail'),
$NAMESPACE);
$server->register(
'get_user_columns',
array('user_name'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'tns:user_column_detail'),
$NAMESPACE);
$server->register(
'get_tickets_columns',
array('user_name'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'tns:tickets_list_array'),
$NAMESPACE);
$server->register(
'create_session',
array('user_name'=>'xsd:string','password'=>'xsd:string','version'=>'xsd:string'),
array('return'=>'xsd:string','session'=>'xsd:string'),
$NAMESPACE);
$server->register(
'end_session',
array('user_name'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
function get_tickets_columns($user_name, $session)
{
if(!validateSession($user_name,$session))
return null;
global $current_user,$log;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($user_name);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("HelpDesk","index") == "yes")
{
require_once('modules/HelpDesk/HelpDesk.php');
$helpdesk = new HelpDesk();
$log->debug($helpdesk->getColumnNames_Hd());
return $helpdesk->getColumnNames_Hd();
}
else
{
$return_array = array();
return $return_array;
}
}
function get_contacts_columns($user_name, $session)
{
if(!validateSession($user_name,$session))
return null;
global $current_user,$log;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($user_name);
$current_user = $seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("Contacts","index") == "yes")
{
require_once('modules/Contacts/Contacts.php');
$contact = new Contacts();
$log->debug($contact->getColumnNames());
return $contact->getColumnNames();
}
else
{
$return_array = array();
return $return_array;
}
}
function get_accounts_columns($user_name, $session)
{
if(!validateSession($user_name,$session))
return null;
global $current_user,$log;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($user_name);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("Accounts","index") == "yes")
{
require_once('modules/Accounts/Accounts.php');
$account = new Accounts();
$log->debug($account->getColumnNames_Acnt());
return $account->getColumnNames_Acnt();
}
else
{
$return_array = array();
return $return_array;
}
}
function get_leads_columns($user_name, $session)
{
if(!validateSession($user_name,$session))
return null;
global $current_user,$log;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($user_name);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("Leads","index") == "yes")
{
require_once('modules/Leads/Leads.php');
$lead = new Leads();
$log->debug($lead->getColumnNames_Lead());
return $lead->getColumnNames_Lead();
}
else
{
$return_array = array();
return $return_array;
}
}
function get_user_columns($user_name, $session)
{
if(!validateSession($user_name,$session))
return null;
global $current_user;
require_once('modules/Users/Users.php');
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($user_name);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
$user = new Users();
return $user->getColumnNames_User();
}
function create_session($user_name, $password,$version)
{
global $log,$adb;
require_once('modules/Users/Users.php');
include('vtigerversion.php');
/* Make 5.0.4 plugins compatible with 5.1.0 */
if(version_compare($version,'5.0.4', '>=') === 1) {
return array("VERSION",'00');
}
$return_access = array("FALSES",'00');
$objuser = new Users();
if($password != "")
{
$objuser->column_fields['user_name'] = $user_name;
$objuser->load_user($password);
if($objuser->is_authenticated())
{
$userid = $objuser->retrieve_user_id($user_name);
$sessionid = makeRandomPassword();
unsetServerSessionId($userid);
$sql="insert into vtiger_soapservice values(?,?,?)";
$result = $adb->pquery($sql, array($userid,'Office',$sessionid));
$return_access = array("TRUE",$sessionid);
}else
{
$return_access = array("FALSE",'00');
}
}else
{
//$server->setError("Invalid username and/or password");
$return_access = array("LOGIN",'00');
}
$objuser = $objuser;
return $return_access;
}
function end_session($user_name)
{
return "Success";
}
function unsetServerSessionId($id)
{
global $adb;
$adb->println("Inside the function unsetServerSessionId");
$id = (int) $id;
$adb->query("delete from vtiger_soapservice where type='Office' and id=$id");
return;
}
function validateSession($username, $sessionid)
{
global $adb,$current_user;
$adb->println("Inside function validateSession($username, $sessionid)");
require_once("modules/Users/Users.php");
$seed_user = new Users();
$id = $seed_user->retrieve_user_id($username);
$server_sessionid = getServerSessionId($id);
$adb->println("Checking Server session id and customer input session id ==> $server_sessionid == $sessionid");
if($server_sessionid == $sessionid)
{
$adb->println("Session id match. Authenticated to do the current operation.");
return true;
}
else
{
$adb->println("Session id does not match. Not authenticated to do the current operation.");
return false;
}
}
function getServerSessionId($id)
{
global $adb;
$adb->println("Inside the function getServerSessionId($id)");
//To avoid SQL injection we are type casting as well as bound the id variable. In each and every function we will call this function
$id = (int) $id;
$query = "select * from vtiger_soapservice where type='Office' and id={$id}";
$sessionid = $adb->query_result($adb->query($query),0,'sessionid');
return $sessionid;
}
/* Begin the HTTP listener service and exit. */
if (!isset($HTTP_RAW_POST_DATA)){
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
}
$server->service($HTTP_RAW_POST_DATA);
exit();
?>