[ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 /********************************************************************************* 3 ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 * 10 ********************************************************************************/ 11 12 require_once ("config.php"); 13 require_once ('include/logging.php'); 14 require_once ('include/nusoap/nusoap.php'); 15 require_once ('include/database/PearDatabase.php'); 16 17 $log = &LoggerManager::getLogger('firefoxlog'); 18 19 $NAMESPACE = 'http://www.vtiger.com/products/crm'; 20 $server = new soap_server; 21 $accessDenied = "You are not authorized for performing this action"; 22 $server->configureWSDL('vtigersoap'); 23 24 $server->register( 25 'get_version', 26 array('user_name'=>'xsd:string','password'=>'xsd:string'), 27 array('return'=>'xsd:string'), 28 $NAMESPACE); 29 30 $server->register( 31 'create_lead_from_webform', 32 array('username'=>'xsd:string', 33 'lastname'=>'xsd:string', 34 'email'=>'xsd:string', 35 'phone'=>'xsd:string', 36 'company'=>'xsd:string', 37 'country'=>'xsd:string', 38 'description'=>'xsd:string'), 39 array('return'=>'xsd:string'), 40 $NAMESPACE); 41 42 43 44 45 $server->register( 46 'create_site_from_webform', 47 array('username'=>'xsd:string', 48 'portalname'=>'xsd:string', 49 'portalurl'=>'xsd:string'), 50 array('return'=>'xsd:string'), 51 $NAMESPACE); 52 53 54 55 $server->register( 56 'create_rss_from_webform', 57 array('username'=>'xsd:string', 58 'rssurl'=>'xsd:string'), 59 array('return'=>'xsd:string'), 60 $NAMESPACE); 61 62 63 64 65 66 $server->register( 67 'create_contacts', 68 array('user_name'=>'xsd:string','lastname'=>'xsd:string','phone'=>'xsd:string','mobile'=>'xsd:string','email'=>'xsd:string','street'=>'xsd:string','city'=>'xsd:string','state'=>'xsd:string','country'=>'xsd:string','zipcode'=>'xsd:string'), 69 array('return'=>'xsd:string'), 70 $NAMESPACE); 71 72 73 74 $server->register( 75 'create_account', 76 array('username'=>'xsd:string', 'accountname'=>'xsd:string', 'email'=>'xsd:string', 'phone'=>'xsd:string','$primary_address_street'=>'xsd:string','$primary_address_city'=>'xsd:string','$primary_address_state'=>'xsd:string','$primary_address_postalcode'=>'xsd:string','$primary_address_country'=>'xsd:string'), 77 array('return'=>'xsd:string'), 78 $NAMESPACE); 79 80 81 $server->register( 82 'create_ticket_from_toolbar', 83 array('username'=>'xsd:string', 'title'=>'xsd:string','description'=>'xsd:string','priority'=>'xsd:string','severity'=>'xsd:string','category'=>'xsd:string','user_name'=>'xsd:string','parent_id'=>'xsd:string','product_id'=>'xsd:string'), 84 array('return'=>'xsd:string'), 85 $NAMESPACE); 86 87 88 $server->register( 89 'create_vendor_from_webform', 90 array('username'=>'xsd:string', 'vendorname'=>'xsd:string', 91 'email'=>'xsd:string', 92 'phone'=>'xsd:string', 93 'website'=>'xsd:string'), 94 array('return'=>'xsd:string'), 95 $NAMESPACE); 96 97 98 $server->register( 99 'create_product_from_webform', 100 array('username'=>'xsd:string', 'productname'=>'xsd:string', 101 'productcode'=>'xsd:string', 102 'website'=>'xsd:string'), 103 array('return'=>'xsd:string'), 104 $NAMESPACE); 105 106 107 $server->register( 108 'create_note_from_webform', 109 array('username'=>'xsd:string', 'title'=>'xsd:string', 110 'notecontent'=>'xsd:string'), 111 array('return'=>'xsd:string'), 112 $NAMESPACE); 113 114 $server->register( 115 'LogintoVtigerCRM', 116 array('user_name'=>'xsd:string','password'=>'xsd:string'), 117 array('return'=>'xsd:string'), 118 $NAMESPACE); 119 120 $server->register( 121 'CheckLeadPermission', 122 array('username'=>'xsd:string'), 123 array('return'=>'xsd:string'), 124 $NAMESPACE); 125 126 $server->register( 127 'CheckContactPermission', 128 array('username'=>'xsd:string'), 129 array('return'=>'xsd:string'), 130 $NAMESPACE); 131 132 $server->register( 133 'CheckAccountPermission', 134 array('username'=>'xsd:string'), 135 array('return'=>'xsd:string'), 136 $NAMESPACE); 137 138 $server->register( 139 'CheckTicketPermission', 140 array('username'=>'xsd:string'), 141 array('return'=>'xsd:string'), 142 $NAMESPACE); 143 144 $server->register( 145 'CheckVendorPermission', 146 array('username'=>'xsd:string'), 147 array('return'=>'xsd:string'), 148 $NAMESPACE); 149 150 $server->register( 151 'CheckProductPermission', 152 array('username'=>'xsd:string'), 153 array('return'=>'xsd:string'), 154 $NAMESPACE); 155 156 $server->register( 157 'CheckNotePermission', 158 array('username'=>'xsd:string'), 159 array('return'=>'xsd:string'), 160 $NAMESPACE); 161 162 $server->register( 163 'CheckSitePermission', 164 array('username'=>'xsd:string'), 165 array('return'=>'xsd:string'), 166 $NAMESPACE); 167 168 $server->register( 169 'CheckRssPermission', 170 array('username'=>'xsd:string'), 171 array('return'=>'xsd:string'), 172 $NAMESPACE); 173 174 175 function CheckLeadPermission($username) 176 { 177 global $current_user; 178 require_once ("modules/Users/Users.php"); 179 $seed_user=new Users(); 180 $user_id=$seed_user->retrieve_user_id($username); 181 $current_user=$seed_user; 182 $current_user->retrieve_entity_info($user_id, 'Users'); 183 184 if(isPermitted("Leads","EditView") == "yes") 185 { 186 return "allowed"; 187 }else 188 { 189 return "denied"; 190 } 191 } 192 193 function CheckContactPermission($username) 194 { 195 global $current_user; 196 require_once ("modules/Users/Users.php"); 197 $seed_user=new Users(); 198 $user_id=$seed_user->retrieve_user_id($username); 199 $current_user=$seed_user; 200 $current_user->retrieve_entity_info($user_id, 'Users'); 201 202 if(isPermitted("Contacts","EditView") == "yes") 203 { 204 return "allowed"; 205 }else 206 { 207 return "denied"; 208 } 209 } 210 211 function CheckAccountPermission($username) 212 { 213 global $current_user; 214 require_once ("modules/Users/Users.php"); 215 $seed_user=new Users(); 216 $user_id=$seed_user->retrieve_user_id($username); 217 $current_user=$seed_user; 218 $current_user->retrieve_entity_info($user_id, 'Users'); 219 220 if(isPermitted("Accounts","EditView") == "yes") 221 { 222 return "allowed"; 223 }else 224 { 225 return "denied"; 226 } 227 } 228 229 function CheckTicketPermission($username) 230 { 231 global $current_user; 232 require_once ("modules/Users/Users.php"); 233 $seed_user=new Users(); 234 $user_id=$seed_user->retrieve_user_id($username); 235 $current_user=$seed_user; 236 $current_user->retrieve_entity_info($user_id, 'Users'); 237 238 if(isPermitted("HelpDesk","EditView") == "yes") 239 { 240 return "allowed"; 241 }else 242 { 243 return "denied"; 244 } 245 } 246 247 function CheckVendorPermission($username) 248 { 249 global $current_user; 250 require_once ("modules/Users/Users.php"); 251 $seed_user=new Users(); 252 $user_id=$seed_user->retrieve_user_id($username); 253 $current_user=$seed_user; 254 $current_user->retrieve_entity_info($user_id, 'Users'); 255 256 if(isPermitted("Vendors","EditView") == "yes") 257 { 258 return "allowed"; 259 }else 260 { 261 return "denied"; 262 } 263 } 264 265 function CheckProductPermission($username) 266 { 267 global $current_user; 268 require_once ("modules/Users/Users.php"); 269 $seed_user=new Users(); 270 $user_id=$seed_user->retrieve_user_id($username); 271 $current_user=$seed_user; 272 $current_user->retrieve_entity_info($user_id, 'Users'); 273 274 if(isPermitted("Products","EditView") == "yes") 275 { 276 return "allowed"; 277 }else 278 { 279 return "denied"; 280 } 281 } 282 283 function CheckNotePermission($username) 284 { 285 global $current_user; 286 require_once ("modules/Users/Users.php"); 287 $seed_user=new Users(); 288 $user_id=$seed_user->retrieve_user_id($username); 289 $current_user=$seed_user; 290 $current_user->retrieve_entity_info($user_id, 'Users'); 291 292 if(isPermitted("Notes","EditView") == "yes") 293 { 294 return "allowed"; 295 }else 296 { 297 return "denied"; 298 } 299 } 300 301 function CheckSitePermission($username) 302 { 303 global $current_user; 304 require_once ("modules/Users/Users.php"); 305 $seed_user=new Users(); 306 $user_id=$seed_user->retrieve_user_id($username); 307 $current_user=$seed_user; 308 $current_user->retrieve_entity_info($user_id, 'Users'); 309 310 if(isPermitted("Portal","EditView") == "yes") 311 { 312 return "allowed"; 313 }else 314 { 315 return "denied"; 316 } 317 } 318 319 function CheckRssPermission($username) 320 { 321 global $current_user; 322 require_once ("modules/Users/Users.php"); 323 $seed_user=new Users(); 324 $user_id=$seed_user->retrieve_user_id($username); 325 $current_user=$seed_user; 326 $current_user->retrieve_entity_info($user_id, 'Users'); 327 328 if(isPermitted("Rss","EditView") == "yes") 329 { 330 return "allowed"; 331 }else 332 { 333 return "denied"; 334 } 335 } 336 337 338 function create_site_from_webform($username,$portalname,$portalurl) 339 { 340 global $log; 341 global $adb; 342 global $current_user; 343 require_once ("modules/Users/Users.php"); 344 $seed_user=new Users(); 345 $user_id=$seed_user->retrieve_user_id($username); 346 $current_user=$seed_user; 347 $current_user->retrieve_entity_info($user_id, 'Users'); 348 require_once ("modules/Portal/Portal.php"); 349 if(isPermitted("Portals","EditView") == "yes") 350 { 351 $result = SavePortal($portalname,$portalurl); 352 353 $adb->println("Create New Portal from Web Form - Ends"); 354 355 if($result != '') 356 return 'Portal added sucessfully'; 357 else 358 return "Portal creation failed. Try again"; 359 } 360 else 361 { 362 return $accessDenied; 363 } 364 } 365 function LogintoVtigerCRM($user_name,$password) 366 { 367 global $log; 368 require_once ('modules/Users/Users.php'); 369 370 $return_access = "FALSE"; 371 372 $objuser = new Users(); 373 374 if($password != "") 375 { 376 $objuser->column_fields['user_name'] = $user_name; 377 $objuser->load_user($password); 378 if($objuser->is_authenticated()) 379 { 380 $return_access = "TRUE"; 381 }else 382 { 383 $return_access = "FALSE"; 384 } 385 }else 386 { 387 //$server->setError("Invalid username and/or password"); 388 $return_access = "FALSE"; 389 } 390 $objuser = $objuser; 391 return $return_access; 392 } 393 394 function create_rss_from_webform($username,$url) 395 { 396 397 global $log; 398 global $adb; 399 global $current_user; 400 require_once ("modules/Users/Users.php"); 401 $seed_user=new Users(); 402 $user_id=$seed_user->retrieve_user_id($username); 403 $current_user=$seed_user; 404 $current_user->retrieve_entity_info($user_id, 'Users'); 405 require_once ("modules/Rss/Rss.php"); 406 407 $oRss = new vtigerRSS(); 408 if(isPermitted("RSS","EditView") == "yes") 409 { 410 if($oRss->setRSSUrl($url)) 411 { 412 if($oRss->saveRSSUrl($url) == false) 413 { 414 return "RSS feed addition failed. Try again"; 415 } 416 else 417 { 418 return 'RSS feed added sucessfully.'; 419 } 420 421 }else 422 { 423 return "Not a valid RSS Feed or your Proxy Settings is not correct. Try again"; 424 } 425 } 426 else 427 { 428 return $accessDenied; 429 } 430 431 } 432 433 434 function create_note_from_webform($username,$subject,$desc) 435 { 436 global $log; 437 global $adb; 438 global $current_user; 439 require_once ("modules/Users/Users.php"); 440 $seed_user=new Users(); 441 $user_id=$seed_user->retrieve_user_id($username); 442 $current_user=$seed_user; 443 $current_user->retrieve_entity_info($user_id, 'Users'); 444 $adb->println("Create New Note from Web Form - Starts"); 445 require_once ("modules/Notes/Notes.php"); 446 447 $focus = new Notes(); 448 if(isPermitted("Notes","EditView") == "yes") 449 { 450 $focus->column_fields['notes_title'] = $subject; 451 $focus->column_fields['notecontent'] = $desc; 452 453 $focus->save("Notes"); 454 455 $focus->retrieve_entity_info($focus->id,"Notes"); 456 457 $adb->println("Create New Note from Web Form - Ends"); 458 459 if($focus->id != '') 460 return 'Note added sucessfully.'; 461 else 462 return "Note creation failed. Try again"; 463 } 464 else 465 { 466 return $accessDenied; 467 } 468 469 } 470 471 function create_product_from_webform($username,$productname,$code,$website) 472 { 473 global $log; 474 global $adb; 475 global $current_user; 476 require_once ("modules/Users/Users.php"); 477 $seed_user=new Users(); 478 $user_id=$seed_user->retrieve_user_id($username); 479 $current_user=$seed_user; 480 $current_user->retrieve_entity_info($user_id, 'Users'); 481 $adb->println("Create New Product from Web Form - Starts"); 482 483 require_once ("modules/Products/Products.php"); 484 if(isPermitted("Products","EditView") == "yes") 485 { 486 $focus = new Products(); 487 $focus->column_fields['productname'] = $productname; 488 $focus->column_fields['productcode'] = $code; 489 $focus->column_fields['website'] = $website; 490 $focus->save("Products"); 491 $adb->println("Create New Product from Web Form - Ends"); 492 493 if($focus->id != '') 494 return 'Product added sucessfully.'; 495 else 496 return "Product creation failed. Try again"; 497 } 498 else 499 { 500 return $accessDenied; 501 } 502 503 504 } 505 506 function create_vendor_from_webform($username,$vendorname,$email,$phone,$website) 507 { 508 global $log; 509 global $adb; 510 global $current_user; 511 require_once ("modules/Users/Users.php"); 512 $seed_user=new Users(); 513 $user_id=$seed_user->retrieve_user_id($username); 514 $current_user=$seed_user; 515 $current_user->retrieve_entity_info($user_id, 'Users'); 516 $adb->println("Create New Vendor from Web Form - Starts"); 517 require_once ("modules/Vendors/Vendors.php"); 518 if(isPermitted("Vendors","EditView" ) == "yes") 519 { 520 $focus = new Vendors(); 521 $focus->column_fields['vendorname'] = $vendorname; 522 $focus->column_fields['email'] = $email; 523 $focus->column_fields['phone'] = $phone; 524 $focus->column_fields['website'] = $website; 525 526 $focus->save("Vendors"); 527 528 $focus->retrieve_entity_info($focus->id,"Vendors"); 529 530 $adb->println("Create New Vendor from Web Form - Ends"); 531 532 if($focus->id != '') 533 return 'Vendor added sucessfully'; 534 else 535 return "Vendor creation failed. Try again"; 536 } 537 else 538 { 539 return $accessDenied; 540 } 541 542 543 } 544 545 function create_ticket_from_toolbar($username,$title,$description,$priority,$severity,$category,$user_name,$parent_id,$product_id) 546 { 547 global $log; 548 global $adb; 549 global $current_user; 550 require_once ("modules/Users/Users.php"); 551 $seed_user=new Users(); 552 $user_id=$seed_user->retrieve_user_id($username); 553 $current_user=$seed_user; 554 $current_user->retrieve_entity_info($user_id, 'Users'); 555 556 if(isPermitted("HelpDesk","EditView") == "yes") 557 { 558 559 $seed_ticket = new HelpDesk(); 560 $output_list = Array(); 561 562 require_once ('modules/HelpDesk/HelpDesk.php'); 563 $ticket = new HelpDesk(); 564 565 $ticket->column_fields[ticket_title] = $title; 566 $ticket->column_fields[description]=$description; 567 $ticket->column_fields[ticketpriorities]=$priority; 568 $ticket->column_fields[ticketseverities]=$severity; 569 $ticket->column_fields[ticketcategories]=$category; 570 $ticket->column_fields[ticketstatus]='Open'; 571 572 $ticket->column_fields[parent_id]=$parent_id; 573 $ticket->column_fields[product_id]=$product_id; 574 $ticket->column_fields[assigned_user_id]=$user_id; 575 //$ticket->saveentity("HelpDesk"); 576 $ticket->save("HelpDesk"); 577 578 if($ticket->id != '') 579 return "Ticket Created Sucessfully"; 580 else 581 return "Error while creating Ticket.Try again"; 582 } 583 else 584 { 585 return $accessDenied; 586 } 587 588 589 } 590 591 function create_account($username,$accountname,$email,$phone,$primary_address_street,$primary_address_city,$primary_address_state,$primary_address_postalcode,$primary_address_country) 592 { 593 global $current_user; 594 require_once ("modules/Users/Users.php"); 595 $seed_user=new Users(); 596 $user_id=$seed_user->retrieve_user_id($username); 597 $current_user=$seed_user; 598 $current_user->retrieve_entity_info($user_id,'Users'); 599 require_once ("modules/Accounts/Accounts.php"); 600 if(isPermitted("Accounts","EditView") == "yes") 601 { 602 $account=new Accounts(); 603 $account->column_fields['accountname']=$accountname; 604 $account->column_fields['email1']=$email; 605 $account->column_fields['phone']=$phone; 606 $account->column_fields['bill_street']=$primary_address_street; 607 $account->column_fields['bill_city']=$primary_address_city; 608 $account->column_fields['bill_state']=$primary_address_state; 609 $account->column_fields['bill_code']=$primary_address_postalcode; 610 $account->column_fields['bill_country']=$primary_address_country; 611 $account->column_fields['ship_street']=$primary_address_street; 612 $account->column_fields['ship_city']=$primary_address_city; 613 $account->column_fields['ship_state']=$primary_address_state; 614 $account->column_fields['ship_code']=$primary_address_postalcode; 615 $account->column_fields['ship_country']=$primary_address_country; 616 $account->column_fields['assigned_user_id']=$user_id; 617 $account->save('Accounts'); 618 if($account->id != '') 619 return "Account added Sucessfully"; 620 else 621 return "Error while adding Account.Try again"; 622 } 623 else 624 { 625 return $accessDenied; 626 } 627 628 } 629 630 631 632 function get_version($user_name, $password) 633 { 634 return "5.0.0"; 635 } 636 637 638 639 function create_lead_from_webform($username,$lastname,$email,$phone,$company,$country,$description) 640 { 641 642 global $log; 643 global $adb; 644 global $current_user; 645 require_once ("modules/Users/Users.php"); 646 $seed_user=new Users(); 647 $user_id=$seed_user->retrieve_user_id($username); 648 $current_user=$seed_user; 649 $current_user->retrieve_entity_info($user_id, 'Users'); 650 $adb->println("Create New Lead from Web Form - Starts"); 651 require_once ("modules/Leads/Leads.php"); 652 653 $focus = new Leads(); 654 if(isPermitted("Leads","EditView") == "yes") 655 { 656 $focus->column_fields['lastname'] = $lastname; 657 $focus->column_fields['email'] = $email; 658 $focus->column_fields['phone'] = $phone; 659 $focus->column_fields['company'] = $company; 660 $focus->column_fields['country'] = $country; 661 $focus->column_fields['description'] = $description; 662 $focus->column_fields['assigned_user_id'] = $user_id; 663 $focus->save("Leads"); 664 $adb->println("Create New Lead from Web Form - Ends"); 665 if($focus->id != '') 666 return 'Thank you for your interest. Information has been successfully added as Lead.'; 667 else 668 return "Lead creation failed. Try again"; 669 } 670 else 671 { 672 return $accessDenied; 673 } 674 675 676 } 677 678 function create_contacts($user_name,$lastname,$phone,$mobile,$email,$street,$city,$state,$country,$zipcode) 679 { 680 global $log; 681 $log->debug($user_name); 682 $birthdate = "0000-00-00"; 683 684 return create_contact1($user_name, "", $lastname, $email,"", "","", $mobile, "",$street,$city,$state,$zipcode,$country,$city,$street,$state,$zipcode,$country,$phone,"","","","",$birthdate,"",""); 685 686 } 687 688 function create_contact1($user_name, $first_name, $last_name, $email_address ,$account_name , $salutation , $title, $phone_mobile, $reports_to,$primary_address_street,$primary_address_city,$primary_address_state,$primary_address_postalcode,$primary_address_country,$alt_address_city,$alt_address_street,$alt_address_state,$alt_address_postalcode,$alt_address_country,$office_phone,$home_phone,$other_phone,$fax,$department,$birthdate,$assistant_name,$assistant_phone,$description='') 689 { 690 global $adb,$log; 691 global $current_user; 692 require_once ('modules/Users/Users.php'); 693 $seed_user = new Users(); 694 $user_id = $seed_user->retrieve_user_id($user_name); 695 $current_user = $seed_user; 696 $current_user->retrieve_entity_info($user_id,'Users'); 697 698 require_once ('modules/Contacts/Contacts.php'); 699 if(isPermitted("Contacts","EditView") == "yes") 700 { 701 $contact = new Contacts(); 702 $contact->column_fields[firstname]= $first_name; 703 $contact->column_fields[lastname]= $last_name; 704 //$contact->column_fields[account_id]=retrieve_account_id($account_name,$user_id);// NULL value is not supported NEED TO FIX 705 $contact->column_fields[salutation]=$salutation; 706 // EMAIL IS NOT ADDED 707 $contact->column_fields[title]=$title; 708 $contact->column_fields[email]=$email_address; 709 $contact->column_fields[mobile]=$phone_mobile; 710 //$contact->column_fields[reports_to_id] =retrievereportsto($reports_to,$user_id,$account_id);// NOT FIXED IN SAVEENTITY.PHP 711 $contact->column_fields[mailingstreet]=$primary_address_street; 712 $contact->column_fields[mailingcity]=$primary_address_city; 713 $contact->column_fields[mailingcountry]=$primary_address_country; 714 $contact->column_fields[mailingstate]=$primary_address_state; 715 $contact->column_fields[mailingzip]=$primary_address_postalcode; 716 $contact->column_fields[otherstreet]=$alt_address_street; 717 $contact->column_fields[othercity]=$alt_address_city; 718 $contact->column_fields[othercountry]=$alt_address_country; 719 $contact->column_fields[otherstate]=$alt_address_state; 720 $contact->column_fields[otherzip]=$alt_address_postalcode; 721 $contact->column_fields[assigned_user_id]=$user_id; 722 // new Fields 723 $contact->column_fields[phone]= $office_phone; 724 $contact->column_fields[homephone]= $home_phone; 725 $contact->column_fields[otherphone]= $other_phone; 726 $contact->column_fields[fax]= $fax; 727 $contact->column_fields[department]=$department; 728 $contact->column_fields[birthday]= getDisplayDate($birthdate); 729 $contact->column_fields[assistant]= $assistant_name; 730 $contact->column_fields[assistantphone]= $assistant_phone; 731 $contact->column_fields[description]= $description; 732 $contact->save("Contacts"); 733 if($contact->id != '') 734 return 'Contact added Sucessfully'; 735 else 736 return "Contact creation failed. Try again"; 737 } 738 else 739 { 740 return $accessDenied; 741 } 742 743 } 744 745 $server->service($HTTP_RAW_POST_DATA); 746 exit(); 747 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |