[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/soap/ -> firefoxtoolbar.php (source)

   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  /**
  13   * URL Verfication - Required to overcome Apache mis-configuration and leading to shared setup mode.
  14   */
  15  require_once  'config.php';
  16  if (file_exists('config_override.php')) {
  17                      include_once 'config_override.php';
  18  }
  19  
  20  include_once  'vtlib/Vtiger/Module.php';
  21  include_once  'includes/main/WebUI.php';
  22  
  23  require_once ('libraries/nusoap/nusoap.php');
  24  
  25  $log = &LoggerManager::getLogger('firefoxlog');
  26  
  27  $NAMESPACE = 'http://www.vtiger.com/products/crm';
  28  $server = new soap_server;
  29  $accessDenied = "You are not authorized for performing this action";
  30  $server->configureWSDL('vtigersoap');
  31  
  32  $server->register(
  33      'create_lead_from_webform',
  34      array('username'=>'xsd:string',
  35                 'session'=>'xsd:string',    
  36          'lastname'=>'xsd:string',
  37          'firstname'=>'xsd:string',
  38          'email'=>'xsd:string', 
  39          'phone'=>'xsd:string', 
  40          'company'=>'xsd:string', 
  41          'country'=>'xsd:string', 
  42          'description'=>'xsd:string'),
  43      array('return'=>'xsd:string'),
  44      $NAMESPACE);
  45  
  46  
  47  
  48  
  49  $server->register(
  50      'create_site_from_webform',
  51      array('username'=>'xsd:string', 
  52                 'session'=>'xsd:string',    
  53          'portalname'=>'xsd:string',
  54          'portalurl'=>'xsd:string'), 
  55      array('return'=>'xsd:string'),
  56      $NAMESPACE);
  57  
  58  
  59  
  60  $server->register(
  61      'create_rss_from_webform',
  62      array('username'=>'xsd:string', 
  63                 'session'=>'xsd:string',    
  64          'rssurl'=>'xsd:string'),
  65      array('return'=>'xsd:string'),
  66      $NAMESPACE);
  67  
  68  
  69  
  70  
  71      
  72  $server->register(
  73     'create_contacts',
  74      array('user_name'=>'xsd:string','session'=>'xsd:string','firstname'=>'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'),
  75      array('return'=>'xsd:string'),
  76      $NAMESPACE);
  77  
  78  
  79  
  80  $server->register(
  81      'create_account',
  82      array('username'=>'xsd:string','session'=>'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'),
  83      array('return'=>'xsd:string'),
  84      $NAMESPACE);
  85  
  86      
  87      $server->register(
  88      'create_ticket_from_toolbar',
  89      array('username'=>'xsd:string','session'=>'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'),
  90      array('return'=>'xsd:string'),
  91      $NAMESPACE);
  92   
  93  
  94  $server->register(
  95      'create_vendor_from_webform',
  96      array('username'=>'xsd:string',
  97          'session'=>'xsd:string',
  98                 'vendorname'=>'xsd:string',
  99          'email'=>'xsd:string', 
 100          'phone'=>'xsd:string', 
 101          'website'=>'xsd:string'), 
 102      array('return'=>'xsd:string'),
 103      $NAMESPACE);
 104  
 105  
 106  $server->register(
 107      'create_product_from_webform',
 108      array('username'=>'xsd:string', 
 109          'session'=>'xsd:string',
 110          'productname'=>'xsd:string',
 111          'productcode'=>'xsd:string', 
 112          'website'=>'xsd:string'), 
 113      array('return'=>'xsd:string'),
 114      $NAMESPACE);
 115  
 116  
 117  $server->register(
 118      'create_note_from_webform',
 119      array('username'=>'xsd:string', 
 120          'session'=>'xsd:string',
 121          'title'=>'xsd:string',
 122          'notecontent'=>'xsd:string'), 
 123      array('return'=>'xsd:string'),
 124      $NAMESPACE);
 125  
 126  $server->register(
 127      'LogintoVtigerCRM',
 128      array('user_name'=>'xsd:string','password'=>'xsd:string','version'=>'xsd:string'),
 129      array('return'=>'tns:logindetails'),
 130      $NAMESPACE);
 131      
 132  $server->register(
 133      'CheckLeadPermission',
 134      array('username'=>'xsd:string','session'=>'xsd:string'),
 135      array('return'=>'xsd:string'),
 136      $NAMESPACE);
 137  
 138  $server->register(
 139      'CheckContactPermission',
 140      array('username'=>'xsd:string','session'=>'xsd:string'),
 141      array('return'=>'xsd:string'),
 142      $NAMESPACE);
 143      
 144  $server->register(
 145      'CheckAccountPermission',
 146      array('username'=>'xsd:string','session'=>'xsd:string'),
 147      array('return'=>'xsd:string'),
 148      $NAMESPACE);
 149  
 150  $server->register(
 151      'CheckTicketPermission',
 152      array('username'=>'xsd:string','session'=>'xsd:string'),
 153      array('return'=>'xsd:string'),
 154      $NAMESPACE);
 155  
 156  $server->register(
 157      'CheckVendorPermission',
 158      array('username'=>'xsd:string','session'=>'xsd:string'),
 159      array('return'=>'xsd:string'),
 160      $NAMESPACE);
 161  
 162  $server->register(
 163      'CheckProductPermission',
 164      array('username'=>'xsd:string','session'=>'xsd:string'),
 165      array('return'=>'xsd:string'),
 166      $NAMESPACE); 
 167  
 168  $server->register(
 169      'CheckNotePermission',
 170      array('username'=>'xsd:string','session'=>'xsd:string'),
 171      array('return'=>'xsd:string'),
 172      $NAMESPACE);
 173  
 174  $server->register(
 175      'CheckSitePermission',
 176      array('username'=>'xsd:string','session'=>'xsd:string'),
 177      array('return'=>'xsd:string'),
 178      $NAMESPACE);
 179  
 180  $server->register(
 181      'CheckRssPermission',
 182      array('username'=>'xsd:string','session'=>'xsd:string'),
 183      array('return'=>'xsd:string'),
 184      $NAMESPACE);
 185  
 186  $server->register(
 187      'GetPicklistValues',
 188      array('username'=>'xsd:string','session'=>'xsd:string'),
 189      array('return'=>'tns:combo_values_array'),
 190      $NAMESPACE);
 191      
 192  $server->wsdl->addComplexType(
 193          'combo_values_array',
 194          'complexType',
 195          'array',
 196          '',
 197          array(
 198                  'productid' => array('name'=>'productid','type'=>'tns:xsd:string'),
 199                  'productname' => array('name'=>'productname','type'=>'tns:xsd:string'),
 200                  'ticketpriorities' => array('name'=>'ticketpriorities','type'=>'tns:xsd:string'),
 201                  'ticketseverities' => array('name'=>'ticketseverities','type'=>'tns:xsd:string'),
 202                  'ticketcategories' => array('name'=>'ticketcategories','type'=>'tns:xsd:string'),
 203                  'moduleslist' => array('name'=>'moduleslist','type'=>'tns:xsd:string'),
 204               )
 205       );
 206  $server->wsdl->addComplexType(
 207        'logindetails',
 208        'complexType',
 209        'array',
 210        '',
 211        array(
 212                  'return'=>'returnVal','type'=>'tns:xsd:string',
 213          'session'=>'sessionId','type'=>'tns:xsd:string',
 214      )
 215  );
 216  function CheckLeadPermission($username,$sessionid)
 217  {
 218      global $current_user;
 219      if(!validateSession($username,$sessionid))
 220      return null;
 221      require_once ("modules/Users/Users.php");
 222      $seed_user=new Users();
 223      $user_id=$seed_user->retrieve_user_id($username);
 224      $current_user=$seed_user;
 225      $current_user->retrieve_entity_info($user_id, 'Users');
 226  
 227      if(isPermitted("Leads","EditView") == "yes")
 228      {
 229          return "allowed";
 230      }else
 231      {
 232          return "denied";
 233      }
 234  }
 235  
 236  function CheckContactPermission($username,$sessionid)
 237  {
 238      global $current_user;
 239      if(!validateSession($username,$sessionid))
 240      return null;
 241      require_once ("modules/Users/Users.php");
 242      $seed_user=new Users();
 243      $user_id=$seed_user->retrieve_user_id($username);
 244      $current_user=$seed_user;
 245      $current_user->retrieve_entity_info($user_id, 'Users');
 246  
 247      if(isPermitted("Contacts","EditView") == "yes")
 248      {
 249          return "allowed";
 250      }else
 251      {
 252          return "denied";
 253      }
 254  }
 255  
 256  function CheckAccountPermission($username,$sessionid)
 257  {
 258      global $current_user;
 259      if(!validateSession($username,$sessionid))
 260      return null;
 261      require_once ("modules/Users/Users.php");
 262      $seed_user=new Users();
 263      $user_id=$seed_user->retrieve_user_id($username);
 264      $current_user=$seed_user;
 265      $current_user->retrieve_entity_info($user_id, 'Users');
 266  
 267      if(isPermitted("Accounts","EditView") == "yes")
 268      {
 269          return "allowed";
 270      }else
 271      {
 272          return "denied";
 273      }
 274  }
 275  
 276  function CheckTicketPermission($username,$sessionid)
 277  {
 278      global $current_user;
 279      if(!validateSession($username,$sessionid))
 280      return null;
 281      require_once ("modules/Users/Users.php");
 282      $seed_user=new Users();
 283      $user_id=$seed_user->retrieve_user_id($username);
 284      $current_user=$seed_user;
 285      $current_user->retrieve_entity_info($user_id, 'Users');
 286  
 287      if(isPermitted("HelpDesk","EditView") == "yes")
 288      {
 289          return "allowed";
 290      }else
 291      {
 292          return "denied";
 293      }
 294  }
 295  
 296  function CheckVendorPermission($username,$sessionid)
 297  {
 298      global $current_user;
 299      if(!validateSession($username,$sessionid))
 300      return null;
 301      require_once ("modules/Users/Users.php");
 302      $seed_user=new Users();
 303      $user_id=$seed_user->retrieve_user_id($username);
 304      $current_user=$seed_user;
 305      $current_user->retrieve_entity_info($user_id, 'Users');
 306  
 307      if(isPermitted("Vendors","EditView") == "yes")
 308      {
 309          return "allowed";
 310      }else
 311      {
 312          return "denied";
 313      }
 314  }
 315  
 316  function CheckProductPermission($username,$sessionid)
 317  {
 318      global $current_user;
 319      if(!validateSession($username,$sessionid))
 320      return null;
 321      require_once ("modules/Users/Users.php");
 322      $seed_user=new Users();
 323      $user_id=$seed_user->retrieve_user_id($username);
 324      $current_user=$seed_user;
 325      $current_user->retrieve_entity_info($user_id, 'Users');
 326  
 327      if(isPermitted("Products","EditView") == "yes")
 328      {
 329          return "allowed";
 330      }else
 331      {
 332          return "denied";
 333      }
 334  }
 335  
 336  function CheckNotePermission($username,$sessionid)
 337  {
 338      global $current_user;
 339      if(!validateSession($username,$sessionid))
 340      return null;
 341      require_once ("modules/Users/Users.php");
 342      $seed_user=new Users();
 343      $user_id=$seed_user->retrieve_user_id($username);
 344      $current_user=$seed_user;
 345      $current_user->retrieve_entity_info($user_id, 'Users');
 346  
 347      if(isPermitted("Documents","EditView") == "yes")
 348      {
 349          return "allowed";
 350      }else
 351      {
 352          return "denied";
 353      }
 354  }
 355  
 356  function CheckSitePermission($username,$sessionid)
 357  {
 358      global $current_user;
 359      if(!validateSession($username,$sessionid))
 360      return null;
 361      require_once ("modules/Users/Users.php");
 362      $seed_user=new Users();
 363      $user_id=$seed_user->retrieve_user_id($username);
 364      $current_user=$seed_user;
 365      $current_user->retrieve_entity_info($user_id, 'Users');
 366  
 367      if(isPermitted("Portal","EditView") == "yes")
 368      {
 369          return "allowed";
 370      }else
 371      {
 372          return "denied";
 373      }
 374  }
 375  
 376  function CheckRssPermission($username,$sessionid)
 377  {
 378      global $current_user;
 379      if(!validateSession($username,$sessionid))
 380      return null;
 381      require_once ("modules/Users/Users.php");
 382      $seed_user=new Users();
 383      $user_id=$seed_user->retrieve_user_id($username);
 384      $current_user=$seed_user;
 385      $current_user->retrieve_entity_info($user_id, 'Users');
 386  
 387      if(isPermitted("Rss","EditView") == "yes")
 388      {
 389          return "allowed";
 390      }else
 391      {
 392          return "denied";
 393      }
 394  }
 395  
 396      
 397  function create_site_from_webform($username,$sessionid,$portalname,$portalurl)
 398  {
 399      global $log;
 400      global $adb;
 401      global $current_user;
 402      if(!validateSession($username,$sessionid))
 403      return null;
 404      require_once ("modules/Users/Users.php");
 405      $seed_user=new Users();
 406      $user_id=$seed_user->retrieve_user_id($username);
 407      $current_user=$seed_user;
 408      $current_user->retrieve_entity_info($user_id, 'Users');
 409      require_once("modules/Portal/Portal.php");
 410      if(isPermitted("Portals","EditView") == "yes")
 411      {
 412          $result = SavePortal($portalname,$portalurl);
 413  
 414          $adb->println("Create New Portal from Web Form - Ends");
 415  
 416          if($result != '')
 417            return 'URL added successfully';
 418          else
 419            return "Portal creation failed. Try again";
 420      }
 421      else
 422      {
 423          return $accessDenied;
 424      }
 425  }
 426  function LogintoVtigerCRM($user_name,$password,$version)
 427  {
 428      global $log,$adb;
 429      require_once ('modules/Users/Users.php');
 430      include ('vtigerversion.php');
 431      if($version != $vtiger_current_version)
 432      {
 433          return array("VERSION",'00');
 434      }
 435      $return_access = array("FALSES",'00');
 436      
 437      $objuser = new Users();
 438      
 439      if($password != "")
 440      {
 441          $objuser->column_fields['user_name'] = $user_name;
 442          $objuser->load_user($password);
 443          if($objuser->is_authenticated())
 444          {
 445              $userid =  $objuser->retrieve_user_id($user_name);
 446              $sessionid = makeRandomPassword();
 447              unsetServerSessionId($userid);
 448              $sql="insert into vtiger_soapservice values(?,?,?)";
 449              $result = $adb->pquery($sql, array($userid,'FireFox' ,$sessionid));
 450              $return_access = array("TRUES",$sessionid);
 451          }else
 452          {
 453              $return_access = array("FALSES",'00');
 454          }
 455      }else
 456      {
 457              //$server->setError("Invalid username and/or password");
 458              $return_access = array("FALSES",'00');
 459      }
 460      $objuser = $objuser;
 461      return $return_access;
 462  }
 463  
 464  function create_rss_from_webform($username,$sessionid,$url)
 465  {
 466  
 467      global $log;
 468      global $adb;
 469      global $current_user;
 470      if(!validateSession($username,$sessionid))
 471      return null;
 472      require_once ("modules/Users/Users.php");
 473      $seed_user=new Users();
 474      $user_id=$seed_user->retrieve_user_id($username);
 475      $current_user=$seed_user;
 476      $current_user->retrieve_entity_info($user_id, 'Users');
 477      require_once("modules/Rss/Rss.php");
 478  
 479      $oRss = new vtigerRSS();
 480      if(isPermitted("RSS","EditView") == "yes")
 481      {
 482          if($oRss->setRSSUrl($url))
 483          {
 484              if($oRss->saveRSSUrl($url) == false)
 485              {
 486                  return "RSS feed addition failed. Try again";
 487              }
 488              else
 489              {
 490                      return 'RSS feed added successfully.';
 491              }
 492  
 493        }else
 494        {
 495           return "Not a valid RSS Feed or your Proxy Settings is not correct. Try again";
 496      }
 497      }
 498      else
 499      {
 500          return $accessDenied;
 501      }
 502  
 503  }
 504  
 505  
 506  function create_note_from_webform($username,$sessionid,$subject,$desc)
 507  {
 508      global $log;
 509      global $adb;
 510      global $current_user;
 511      if(!validateSession($username,$sessionid))
 512      return null;
 513      require_once ("modules/Users/Users.php");
 514      $seed_user=new Users();
 515      $user_id=$seed_user->retrieve_user_id($username);
 516      $current_user=$seed_user;
 517      $current_user->retrieve_entity_info($user_id, 'Users');
 518      $adb->println("Create New Document from Web Form - Starts");
 519      require_once ("modules/Documents/Documents.php");
 520  
 521      $focus = new Documents();
 522      if(isPermitted("Documents","EditView") == "yes")
 523      {
 524          $focus->column_fields['notes_title'] = $subject;
 525          $focus->column_fields['notecontent'] = $desc;
 526  
 527          $focus->save("Documents");
 528  
 529          $focus->retrieve_entity_info($focus->id,"Documents");
 530  
 531          $adb->println("Create New Document from Web Form - Ends");
 532  
 533          if($focus->id != '')
 534          return 'Document added successfully.';
 535          else
 536          return "Document creation failed. Try again";
 537      }
 538      else
 539      {
 540          return $accessDenied;
 541      }
 542  
 543  }
 544  
 545  function create_product_from_webform($username,$sessionid,$productname,$code,$website)
 546  {
 547      global $log;
 548      global $adb;
 549      global $current_user;
 550      if(!validateSession($username,$sessionid))
 551      return null;
 552      require_once ("modules/Users/Users.php");
 553      $seed_user=new Users();
 554      $user_id=$seed_user->retrieve_user_id($username);
 555      $current_user=$seed_user;
 556      $current_user->retrieve_entity_info($user_id, 'Users');
 557      $adb->println("Create New Product from Web Form - Starts");
 558      
 559    require_once ("modules/Products/Products.php");
 560      if(isPermitted("Products","EditView") == "yes")
 561      {
 562          $focus = new Products();
 563          $focus->column_fields['productname'] = $productname;
 564          $focus->column_fields['productcode'] = $code;
 565          $focus->column_fields['website'] = $website;
 566          $focus->column_fields['assigned_user_id'] = $user_id;
 567          $focus->column_fields['discontinued'] = "1";
 568  
 569          $focus->save("Products");
 570          $adb->println("Create New Product from Web Form - Ends");
 571  
 572          if($focus->id != '')
 573            return 'Product added successfully.';
 574          else
 575            return "Product creation failed. Try again";
 576      }
 577      else
 578      {
 579          return $accessDenied;
 580      }
 581  
 582      
 583  }
 584  
 585  function create_vendor_from_webform($username,$sessionid,$vendorname,$email,$phone,$website)
 586  {
 587      global $log;
 588      global $adb;
 589      global $current_user;
 590      if(!validateSession($username,$sessionid))
 591      return null;
 592      require_once ("modules/Users/Users.php");
 593      $seed_user=new Users();
 594      $user_id=$seed_user->retrieve_user_id($username);
 595      $current_user=$seed_user;
 596      $current_user->retrieve_entity_info($user_id, 'Users');
 597      $adb->println("Create New Vendor from Web Form - Starts");
 598      require_once ("modules/Vendors/Vendors.php");
 599      if(isPermitted("Vendors","EditView" ) == "yes")
 600      {
 601          $focus = new Vendors();
 602          $focus->column_fields['vendorname'] = $vendorname;
 603          $focus->column_fields['email'] = $email;
 604          $focus->column_fields['phone'] = $phone;
 605          $focus->column_fields['website'] = $website;
 606  
 607          $focus->save("Vendors");
 608  
 609          $focus->retrieve_entity_info($focus->id,"Vendors");
 610  
 611          $adb->println("Create New Vendor from Web Form - Ends");
 612  
 613          if($focus->id != '')
 614          return 'Vendor added successfully';
 615          else
 616          return "Vendor creation failed. Try again";
 617    }        
 618    else
 619      {
 620          return $accessDenied;
 621      }
 622  
 623      
 624  }
 625  
 626  function create_ticket_from_toolbar($username,$sessionid,$title,$description,$priority,$severity,$category,$user_name,$parent_id,$product_id)
 627  {
 628      global $log;
 629      global $adb;
 630      global $current_user;
 631      if(!validateSession($username,$sessionid))
 632      return null;
 633      require_once ("modules/Users/Users.php");
 634      $seed_user=new Users();
 635      $user_id=$seed_user->retrieve_user_id($username);
 636      $current_user=$seed_user;
 637      $current_user->retrieve_entity_info($user_id, 'Users');
 638  
 639      if(isPermitted("HelpDesk","EditView") == "yes")
 640      {
 641  
 642          $seed_ticket = new HelpDesk();
 643          $output_list = Array();
 644  
 645          require_once ('modules/HelpDesk/HelpDesk.php');
 646          $ticket = new HelpDesk();
 647  
 648          $ticket->column_fields[ticket_title] = $title;
 649          $ticket->column_fields[description]=$description;
 650          $ticket->column_fields[ticketpriorities]=$priority;
 651          $ticket->column_fields[ticketseverities]=$severity;
 652          $ticket->column_fields[ticketcategories]=$category;
 653          $ticket->column_fields[ticketstatus]='Open';
 654  
 655          $ticket->column_fields[parent_id]=$parent_id;
 656          $ticket->column_fields[product_id]=$product_id;
 657          $ticket->column_fields[assigned_user_id]=$user_id;
 658          //$ticket->saveentity("HelpDesk");
 659          $ticket->save("HelpDesk");
 660  
 661          if($ticket->id != '')
 662        return "Ticket created successfully";
 663      else
 664        return "Error while creating Ticket.Try again";  
 665      }
 666      else
 667      {
 668          return $accessDenied;
 669      }
 670  
 671  
 672  }
 673  
 674  function create_account($username,$sessionid,$accountname,$email,$phone,$primary_address_street,$primary_address_city,$primary_address_state,$primary_address_postalcode,$primary_address_country)
 675  {
 676      if(!validateSession($username,$sessionid))
 677      return null;
 678      global $current_user,$log,$adb;
 679      $log->DEBUG("Entering with data ".$username.$accountname.$email.$phone."<br>".$primary_address_street.$primary_address_city.$primary_address_state.$primary_address_postalcode.$primary_address_country);
 680      require_once ("modules/Users/Users.php");
 681      $seed_user=new Users();
 682      $user_id=$seed_user->retrieve_user_id($username);
 683      $current_user=$seed_user;
 684      $current_user->retrieve_entity_info($user_id,'Users');
 685      require_once ("modules/Accounts/Accounts.php");
 686      if(isPermitted("Accounts","EditView") == "yes")
 687      {
 688          $query = "SELECT accountname FROM vtiger_account,vtiger_crmentity WHERE accountname =? and vtiger_account.accountid = vtiger_crmentity.crmid and vtiger_crmentity.deleted != 1";
 689          $result = $adb->pquery($query, array($accountname));
 690              if($adb->num_rows($result) > 0)
 691          {
 692              return "Accounts";
 693              die;
 694          }
 695          $account=new Accounts();
 696          $account->column_fields['accountname']=$accountname;
 697          $account->column_fields['email1']=$email;
 698          $account->column_fields['phone']=$phone;
 699          $account->column_fields['bill_street']=$primary_address_street;
 700          $account->column_fields['bill_city']=$primary_address_city;
 701          $account->column_fields['bill_state']=$primary_address_state;
 702          $account->column_fields['bill_code']=$primary_address_postalcode;
 703          $account->column_fields['bill_country']=$primary_address_country;
 704          $account->column_fields['ship_street']=$primary_address_street;
 705          $account->column_fields['ship_city']=$primary_address_city;
 706          $account->column_fields['ship_state']=$primary_address_state;
 707          $account->column_fields['ship_code']=$primary_address_postalcode;
 708          $account->column_fields['ship_country']=$primary_address_country;
 709          $account->column_fields['assigned_user_id']=$user_id;
 710          $account->save('Accounts');
 711          if($account->id != '')
 712        return "Success";
 713      else
 714        return "Error while adding Account.Try again";  
 715      }
 716      else
 717      {
 718          return $accessDenied;
 719      }
 720  
 721  }
 722  
 723  function create_lead_from_webform($username,$sessionid,$lastname,$email,$phone,$company,$country,$description,$firstname)
 724  {
 725  
 726      global $log;
 727      global $adb;
 728      global $current_user;
 729      if(!validateSession($username,$sessionid))
 730      return null;
 731      require_once ("modules/Users/Users.php");
 732      $seed_user=new Users();
 733      $user_id=$seed_user->retrieve_user_id($username);
 734      $current_user=$seed_user;
 735      $current_user->retrieve_entity_info($user_id, 'Users');
 736      $adb->println("Create New Lead from Web Form - Starts");
 737      require_once ("modules/Leads/Leads.php");
 738  
 739      $focus = new Leads();
 740      if(isPermitted("Leads","EditView") == "yes")
 741      {
 742          $focus->column_fields['lastname'] = $lastname;
 743          $focus->column_fields['firstname'] = $firstname;
 744          $focus->column_fields['email'] = $email;
 745          $focus->column_fields['phone'] = $phone;
 746          $focus->column_fields['company'] = $company;
 747          $focus->column_fields['country'] = $country;
 748          $focus->column_fields['description'] = $description;
 749          $focus->column_fields['assigned_user_id'] = $user_id;
 750          $focus->save("Leads");
 751          $adb->println("Create New Lead from Web Form - Ends");
 752          if($focus->id != '')
 753            return "Thank you for your interest. Information has been successfully added as Lead.";
 754          else
 755            return "Lead creation failed. Try again";
 756    }
 757      else
 758      {
 759          return $accessDenied;
 760      }
 761  
 762  
 763  }
 764  
 765  function create_contacts($user_name,$sessionid,$firstname,$lastname,$phone,$mobile,$email,$street,$city,$state,$country,$zipcode)
 766  {
 767      global $log;
 768      $log->DEBUG("Entering into create_contacts");
 769      $birthdate = "";
 770      if(!validateSession($user_name,$sessionid))
 771      return null;
 772  
 773      return create_contact1($user_name, $firstname, $lastname, $email,"", "","", $mobile, "",$street,$city,$state,$zipcode,$country,$city,$street,$state,$zipcode,$country,$phone,"","","","",$birthdate,"","");
 774      
 775  }
 776  
 777  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='')
 778  {
 779      global $adb,$log;
 780      global $current_user;
 781      require_once ('modules/Users/Users.php');
 782      $seed_user = new Users();
 783      $user_id = $seed_user->retrieve_user_id($user_name);
 784      $current_user = $seed_user;
 785      $current_user->retrieve_entity_info($user_id,'Users');
 786  
 787      require_once ('modules/Contacts/Contacts.php');
 788    if(isPermitted("Contacts","EditView") == "yes")
 789    {
 790     $contact = new Contacts();
 791     $contact->column_fields[firstname]= $first_name;
 792     $contact->column_fields[lastname]= $last_name;
 793     //$contact->column_fields[account_id]=retrieve_account_id($account_name,$user_id);// NULL value is not supported NEED TO FIX
 794     $contact->column_fields[salutation]=$salutation;
 795     // EMAIL IS NOT ADDED
 796     $contact->column_fields[title]=$title;
 797     $contact->column_fields[email]=$email_address;
 798     $contact->column_fields[mobile]=$phone_mobile;
 799     //$contact->column_fields[reports_to_id] =retrievereportsto($reports_to,$user_id,$account_id);// NOT FIXED IN SAVEENTITY.PHP
 800     $contact->column_fields[mailingstreet]=$primary_address_street;
 801     $contact->column_fields[mailingcity]=$primary_address_city;
 802     $contact->column_fields[mailingcountry]=$primary_address_country;
 803     $contact->column_fields[mailingstate]=$primary_address_state;
 804     $contact->column_fields[mailingzip]=$primary_address_postalcode;
 805     $contact->column_fields[otherstreet]=$alt_address_street;
 806     $contact->column_fields[othercity]=$alt_address_city;
 807     $contact->column_fields[othercountry]=$alt_address_country;
 808     $contact->column_fields[otherstate]=$alt_address_state;
 809     $contact->column_fields[otherzip]=$alt_address_postalcode;
 810     $contact->column_fields[assigned_user_id]=$user_id;
 811     // new Fields
 812     $contact->column_fields[phone]= $office_phone;
 813     $contact->column_fields[homephone]= $home_phone;
 814     $contact->column_fields[otherphone]= $other_phone;
 815     $contact->column_fields[fax]= $fax;
 816     $contact->column_fields[department]=$department;
 817     $contact->column_fields[birthday]= DateTimeField::convertToUserFormat($birthdate);
 818     $contact->column_fields[assistant]= $assistant_name;
 819     $contact->column_fields[assistantphone]= $assistant_phone;
 820     $contact->column_fields[description]= $description;
 821     $contact->save("Contacts");
 822     if($contact->id != '')
 823        return 'Contact added successfully';
 824     else
 825        return "Contact creation failed. Try again";
 826    }
 827      else
 828      {
 829          return $accessDenied;
 830      }
 831  
 832  }
 833  function GetPicklistValues($username,$sessionid,$tablename)
 834  {
 835      global $current_user,$log,$adb;
 836      if(!validateSession($username,$sessionid))
 837      return null;
 838  
 839      require_once ("modules/Users/Users.php");
 840      $seed_user=new Users();
 841      $user_id=$seed_user->retrieve_user_id($username);
 842      $current_user=$seed_user;
 843      $current_user->retrieve_entity_info($user_id,'Users');
 844      require_once ("include/utils/UserInfoUtil.php");
 845      $roleid = fetchUserRole($user_id);
 846      checkFileAccessForInclusion('user_privileges/user_privileges_'.$current_user->id.'.php');
 847      require('user_privileges/user_privileges_'.$current_user->id.'.php');
 848      if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
 849      {
 850          $query = "select " . $adb->sql_escape_string($tablename) . " from vtiger_". $adb->sql_escape_string($tablename);        
 851              $result1 = $adb->pquery($query, array());
 852          for($i=0;$i<$adb->num_rows($result1);$i++)
 853          {
 854              $output[$i] = decode_html($adb->query_result($result1,$i,$tablename));
 855          }            
 856      }
 857      else if((isPermitted("HelpDesk","EditView") == "yes") && (CheckFieldPermission($tablename,'HelpDesk') == 'true'))
 858      {
 859          $query = "select " .$adb->sql_escape_string($tablename) . " from vtiger_". $adb->sql_escape_string($tablename) ." inner join vtiger_role2picklist on vtiger_role2picklist.picklistvalueid = vtiger_". $adb->sql_escape_string($tablename) .".picklist_valueid where roleid=? and picklistid in (select picklistid from vtiger_". $adb->sql_escape_string($tablename)." ) order by sortid";    
 860          $result1 = $adb->pquery($query, array($roleid));
 861          for($i=0;$i<$adb->num_rows($result1);$i++)
 862          {
 863              $output[$i] = decode_html($adb->query_result($result1,$i,$tablename));
 864          }            
 865      }
 866      else
 867      {
 868          $output[] = 'Not Accessible';
 869      }
 870          
 871      return $output;
 872  }
 873  function unsetServerSessionId($id)
 874  {
 875      global $adb;
 876      $adb->println("Inside the function unsetServerSessionId");
 877  
 878      $id = (int) $id;
 879  
 880      $adb->query("delete from vtiger_soapservice where type='FireFox' and id=$id");
 881  
 882      return;
 883  }
 884  function validateSession($username, $sessionid)
 885  {
 886      global $adb,$current_user;
 887      $adb->println("Inside function validateSession($username, $sessionid)");
 888      require_once ("modules/Users/Users.php");
 889      $seed_user = new Users();
 890      $id = $seed_user->retrieve_user_id($username);
 891  
 892      $server_sessionid = getServerSessionId($id);
 893  
 894      $adb->println("Checking Server session id and customer input session id ==> $server_sessionid == $sessionid");
 895  
 896      if($server_sessionid == $sessionid)
 897      {
 898          $adb->println("Session id match. Authenticated to do the current operation.");
 899          return true;
 900      }
 901      else
 902      {
 903          $adb->println("Session id does not match. Not authenticated to do the current operation.");
 904          return false;
 905      }
 906  }
 907  function getServerSessionId($id)
 908  {
 909      global $adb;
 910      $adb->println("Inside the function getServerSessionId($id)");
 911  
 912      //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
 913      $id = (int) $id;
 914  
 915      $query = "select * from vtiger_soapservice where type='FireFox' and id={$id}";
 916      $sessionid = $adb->query_result($adb->query($query),0,'sessionid');
 917  
 918      return $sessionid;
 919  }
 920  /* Begin the HTTP listener service and exit. */ 
 921  if (!isset($HTTP_RAW_POST_DATA)){
 922      $HTTP_RAW_POST_DATA = file_get_contents('php://input');
 923  }
 924  $server->service($HTTP_RAW_POST_DATA); 
 925  exit(); 
 926  ?>


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1