[Vtigercrm-commits] [vtiger-commits] r10253 - in /vtigercrm/branches/5.0.3/soap: thunderbirdplugin.php wordplugin.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Tue Feb 27 08:00:12 EST 2007


Author: saraj
Date: Tue Feb 27 06:00:05 2007
New Revision: 10253

Log:
authentication for inactive user

Modified:
    vtigercrm/branches/5.0.3/soap/thunderbirdplugin.php
    vtigercrm/branches/5.0.3/soap/wordplugin.php

Modified: vtigercrm/branches/5.0.3/soap/thunderbirdplugin.php
==============================================================================
--- vtigercrm/branches/5.0.3/soap/thunderbirdplugin.php (original)
+++ vtigercrm/branches/5.0.3/soap/thunderbirdplugin.php Tue Feb 27 06:00:05 2007
@@ -1,580 +1,576 @@
-<?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.
-*
- ********************************************************************************/
-
-require_once("config.php");
-require_once('include/logging.php');
-require_once('include/nusoap/nusoap.php');
-require_once('include/database/PearDatabase.php');
-require_once('modules/Contacts/Contacts.php');
-
-$log = &LoggerManager::getLogger('thunderbirdplugin');
-
-$accessDenied = "You are not authorized for performing this action";
-$NAMESPACE = 'http://www.vtiger.com/products/crm';
-$server = new soap_server;
-
-$server->configureWSDL('vtigersoap');
-
-$server->register(
- 	    'create_session',
- 	    array('user_name'=>'xsd:string','password'=>'xsd:string'),
- 	    array('return'=>'xsd:string'),
- 	    $NAMESPACE);
-
-$server->register(
- 	    'end_session',
- 	    array('user_name'=>'xsd:string'),
- 	    array('return'=>'xsd:string'),
- 	    $NAMESPACE);
-
-$server->register(
-    'SearchContactsByEmail',
-    array('username'=>'xsd:string','emailaddress'=>'xsd:string'),
-    array('return'=>'tns:contactdetails'),
-    $NAMESPACE);
-
-$server->register(
-		'GetContacts',
-    array('username'=>'xsd:string'),
-    array('return'=>'tns:contactdetails'),
-    $NAMESPACE);
-
-$server->register(
-    'CheckContactPerm',array('user_name'=>'xsd:string'),array('return'=>'xsd:string'),$NAMESPACE);
-
-$server->register(
-    'CheckContactViewPerm',array('user_name'=>'xsd:string'),array('return'=>'xsd:string'),$NAMESPACE);
-
-$server->register(
-	'CheckLeadViewPerm',array('user_name'=>'xsd:string'),array('return'=>'xsd:string'),$NAMESPACE);
-
-$server->register(
-	  'AddContact',
-    array('user_name'=>'xsd:string',
-          'first_name'=>'xsd:string',
-          'last_name'=>'xsd:string',
-          'email_address'=>'xsd:string',
-          'account_name'=>'xsd:string',
-          'salutation'=>'xsd:string',
-          'title'=>'xsd:string',
-          'phone_mobile'=>'xsd:string',
-          'reports_to'=>'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',
-          'alt_address_city'=>'xsd:string',
-          'alt_address_street'=>'xsd:string',
-          'alt_address_state'=>'xsd:string',
-          'alt_address_postalcode'=>'xsd:string',
-          'alt_address_country'=>'xsd:string',
-          'office_phone'=>'xsd:string',
-          'home_phone'=>'xsd:string',
-          'fax'=>'xsd:string',
-          'department'=>'xsd:string',
-          'description'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-$server->register(
-	  'AddLead',
-    array('user_name'=>'xsd:string',
-          'first_name'=>'xsd:string',
-          'last_name'=>'xsd:string',
-          'email_address'=>'xsd:string',
-          'account_name'=>'xsd:string',
-          'salutation'=>'xsd:string',
-          'title'=>'xsd:string',
-          'phone_mobile'=>'xsd:string',
-          'reports_to'=>'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',
-          'alt_address_city'=>'xsd:string',
-          'alt_address_street'=>'xsd:string',
-          'alt_address_state'=>'xsd:string',
-          'alt_address_postalcode'=>'xsd:string',
-          'alt_address_country'=>'xsd:string',
-          'office_phone'=>'xsd:string',
-          'home_phone'=>'xsd:string',
-          'fax'=>'xsd:string',
-          'department'=>'xsd:string',
-	  'description'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-$server->register(
-	'track_email',
-    array('user_name'=>'xsd:string', 'contact_ids'=>'xsd:string', 'date_sent'=>'xsd:date', 'email_subject'=>'xsd:string', 'email_body'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-$server->wsdl->addComplexType(
-    'contactdetail',
-    'complexType',
-    'struct',
-    'all',
-    '',
-    array(
-	      'id' => array('name'=>'id','type'=>'xsd:string'),
-        'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
-        'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
-        'emailaddress' => array('name'=>'emailaddress','type'=>'xsd:string'),
-        'accountname' => array('name'=>'accountname','type'=>'xsd:string'),
-        'middlename' => array('name'=>'middlename','type'=>'xsd:string'),
-        'birthdate'=> array('name'=>'birthdate','type'=>'xsd:string'),
-        'jobtitle'=> array('name'=>'jobtitle','type'=>'xsd:string'),
-        'department'=> array('name'=>'department','type'=>'xsd:string'),
-        'title' => array('name'=>'title','type'=>'xsd:string'),
-        'officephone'=> array('name'=>'officephone','type'=>'xsd:string'),
-        'homephone'=> array('name'=>'homephone','type'=>'xsd:string'),
-        'otherphone'=> array('name'=>'otherphone','type'=>'xsd:string'),
-        'fax'=> array('name'=>'fax','type'=>'xsd:string'),
-        'mobile'=> array('name'=>'mobile','type'=>'xsd:string'),
-        'asstname'=> array('name'=>'asstname','type'=>'xsd:string'),
-        'asstphone'=> array('name'=>'asstphone','type'=>'xsd:string'),
-        'reportsto'=> array('name'=>'reportsto','type'=>'xsd:string'),
-        'mailingstreet'=> array('name'=>'mailingstreet','type'=>'xsd:string'),
-        'mailingcity'=> array('name'=>'mailingcity','type'=>'xsd:string'),
-        'mailingstate'=> array('name'=>'mailingstate','type'=>'xsd:string'),
-        'mailingzip'=> array('name'=>'mailingzip','type'=>'xsd:string'),
-        'mailingcountry'=> array('name'=>'mailingcountry','type'=>'xsd:string'),
-        'otherstreet'=> array('name'=>'otherstreet','type'=>'xsd:string'),
-        'othercity'=> array('name'=>'othercity','type'=>'xsd:string'),
-        'otherstate'=> array('name'=>'otherstate','type'=>'xsd:string'),
-        'otherzip'=> array('name'=>'otherzip','type'=>'xsd:string'),
-        'othercountry'=> array('name'=>'othercountry','type'=>'xsd:string'),
-        'description'=> array('name'=>'description','type'=>'xsd:string'),
-        'category'=> array('name'=>'category','type'=>'xsd:string'),
-    )
-);
-
-$server->wsdl->addComplexType(
-    'contactdetails',
-    'complexType',
-    'array',
-    '',
-    'SOAP-ENC:Array',
-    array(),
-    array(
-        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:contactdetail[]')
-    ),
-    'tns:contactdetail'
-);
-
-
-function SearchContactsByEmail($username,$emailaddress)
-{
-     require_once('modules/Contacts/Contacts.php');
-
-     $seed_contact = new Contacts();
-     $output_list = Array();
-
-     $response = $seed_contact->get_searchbyemailid($username,$emailaddress);
-     $contactList = $response['list'];
-
-     // create a return array of names and email addresses.
-     foreach($contactList as $contact)
-     {
-          $output_list[] = Array(
-               "id" => $contact[contactid],
-               "firstname" => $contact[firstname],
-               "lastname" => $contact[lastname],
-               "emailaddress" => $contact[email],
-               "accountname" => $contact[accountname],
-          );
-     }
-
-     //to remove an erroneous compiler warning
-     $seed_contact = $seed_contact;
-     return $output_list;
-}
-
-function track_email($user_name, $contact_ids, $date_sent, $email_subject, $email_body)
-{
-	global $current_user;
-	global $adb;
-	global $log;
-	require_once('modules/Users/Users.php');
-	require_once('modules/Emails/Emails.php');
-
-	$current_user = new Users();
-	$user_id = $current_user->retrieve_user_id($user_name);
-	$query = "select email1 from vtiger_users where id =".$user_id;
-	$result = $adb->query($query);
-	$user_emailid = $adb->query_result($result,0,"email1");
-	$current_user = $current_user->retrieveCurrentUserInfoFromFile($user_id);
-	$email = new Emails();
-	//$log->debug($msgdtls['contactid']);
-	$emailbody = str_replace("'", "''", $email_body);
-	$emailsubject = str_replace("'", "''",$email_subject);
-	$datesent = getDisplayDate($date_sent);
-
-	$email->column_fields[subject] = $emailsubject;
-	$email->column_fields[assigned_user_id] = $user_id;
-	$email->column_fields[date_start] = $datesent;
-	$email->column_fields[description]  = htmlentities($emailbody);
-	$email->column_fields[activitytype] = 'Emails';
-	$email->plugin_save = true;
-	$email->save("Emails");
-	$query = "select fieldid from vtiger_field where fieldname = 'email' and tabid = 4";
-	$result = $adb->query($query);
-	$field_id = $adb->query_result($result,0,"fieldid");
-	$email->set_emails_contact_invitee_relationship($email->id,$contact_ids);
-	$email->set_emails_se_invitee_relationship($email->id,$contact_ids);
-	$email->set_emails_user_invitee_relationship($email->id,$user_id);
-	$sql = "select email from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted =0 and vtiger_contactdetails.contactid='".$contact_ids."'";
-	$result = $adb->query($sql);
-	$camodulerow = $adb->fetch_array($result);
-	if(isset($camodulerow))
-	{
-		$emailid = $camodulerow["email"];
-		$query = 'insert into vtiger_emaildetails values ('.$email->id.',"'.$emailid.'","'.$user_emailid.'","","","","'.$user_id.'@-1|'.$contact_ids.'@'.$field_id.'|","THUNDERBIRD")';
-		$adb->query($query);
-	}
-	return $email->id;
-}
-
-
-function GetContacts($username)
-{
-	global $adb;
-	global $log;
-	require_once('modules/Contacts/Contacts.php');
-
-	$seed_contact = new Contacts();
-	$output_list = Array();
-
-	$query = $seed_contact->get_contactsforol($username);
-	$result = $adb->query($query);
-
-	while($contact = $adb->fetch_array($result))
-	{
-		if($contact["birthdate"] == "0000-00-00")
-		{
-			$contact["birthdate"] = "";
-		}
-		if($contact["salutation"] == "--None--")
-		{
-			$contact["salutation"] = "";
-		}
-
-		$namelist = explode(" ", $contact["lastname"]);
-		if(isset($namelist))
-		{
-			if(count($namelist) >= 2)
-			{
-				$contact["lastname"] = $namelist[count($namelist)-1];
-				for($i=0; $i<count($namelist)-2; $i++)
-				{
-					$middlename[] = $namelist[$i];
-				}
-				if(isset($middlename))
-				{
-					$middlename = implode(" ",$middlename);
-				}
-			}
-		}
-
-		$output_list[] = Array(
-				"id" => $contact["id"],
-				"title" => $contact["salutation"],
-				"firstname" => $contact["firstname"],
-				"middlename" => trim($middlename),
-				"lastname" => trim($contact["lastname"]),
-				"birthdate" => $contact["birthday"],
-				"emailaddress" => $contact["email"],
-				"jobtitle" => $contact["title"],
-				"department" => $contact["department"],
-				"accountname" => $contact["accountname"],
-				"officephone" => $contact["phone"],
-				"homephone" => $contact["homephone"],
-				"otherphone" => $contact["otherphone"],
-				"fax" => $contact["fax"],
-				"mobile" => $contact["mobile"],
-				"asstname" => $contact["assistant"],
-				"asstphone" => $contact["assistantphone"],
-				"reportsto" => $contact["reports_to_name"],
-				"mailingstreet" => $contact["mailingstreet"],
-				"mailingcity" => $contact["mailingcity"],
-				"mailingstate" => $contact["mailingstate"],
-				"mailingzip" => $contact["mailingzip"],
-				"mailingcountry" => $contact["mailingcountry"],
-				"otherstreet" => $contact["otherstreet"],
-				"othercity" => $contact["othercity"],
-				"otherstate" => $contact["otherstate"],
-				"otherzip" => $contact["otherzip"],
-				"othercountry" => $contact["othercountry"],
-				"description" => "",
-				"category" => "",
-			  );
-	}
-	//to remove an erroneous compiler warning
-	$seed_contact = $seed_contact;
-	return $output_list;
-}
-
-function retrieve_account_id($account_name,$user_id)
-{
-
-	if($account_name=="")
-	{
-		return null;
-	}
-
-	$query = "select vtiger_account.accountname accountname,vtiger_account.accountid accountid from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid where vtiger_crmentity.deleted=0 and vtiger_account.accountname='" .$account_name."'";
-
-
-	$db = new PearDatabase();
-	$result=  $db->query($query) or die ("Not able to execute insert");
-
-	$rows_count =  $db->getRowCount($result);
-	if($rows_count==0)
-	{
-		require_once('modules/Accounts/Accounts.php');
-		$account = new Accounts();
-		$account->column_fields[accountname] = $account_name;
-		$account->column_fields[assigned_user_id]=$user_id;
-		//$account->saveentity("Accounts");
-		$account->save("Accounts");
-		//mysql_close();
-		return $account->id;
-	}
-	else if ($rows_count==1)
-	{
-		$row = $db->fetchByAssoc($result, 0);
-		//mysql_close();
-		return $row["accountid"];
-	}
-	else
-	{
-		$row = $db->fetchByAssoc($result, 0);
-		//mysql_close();
-		return $row["accountid"];
-	}
-
-}
-
-function AddContact($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="",$fax="",$department="",$description="")
-{
-	global $adb;
-	global $current_user;
-	require_once('modules/Users/Users.php');
-	require_once('modules/Contacts/Contacts.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");
-	require('user_privileges/user_privileges_'.$current_user->id.'.php');
-	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
-
-	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
-  {
-    $sql1 = "select fieldname,columnname from vtiger_field where tabid=4 and block <> 75 and block <> 6 and block <> 5";
-  }else
-  {
-    $profileList = getCurrentUserProfileList();
-    $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 75 and vtiger_field.block <> 6 and vtiger_field.block <> 5 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
-  }
-  $result1 = $adb->query($sql1);
-  for($i=0;$i < $adb->num_rows($result1);$i++)
-  {
-      $permitted_lists[] = $adb->query_result($result1,$i,'fieldname');
-  }
-
-	$contact = new Contacts();
-	$contact->column_fields[firstname]=in_array('firstname',$permitted_lists) ? $first_name : "";
-	$contact->column_fields[lastname]=in_array('lastname',$permitted_lists) ? $last_name : "";
-	$contact->column_fields[birthday]=in_array('birthday',$permitted_lists) ? getDisplayDate("0000-00-00") : "";
-	$contact->column_fields[email]=in_array('email',$permitted_lists) ? $email_address : "";
-	$contact->column_fields[title]=in_array('title',$permitted_lists) ? $title : "";
-	$contact->column_fields[department]=in_array('department',$permitted_lists) ? $department : "";
-	$contact->column_fields[account_id]=in_array('account_id',$permitted_lists) ? retrieve_account_id($account_name,$user_id) : "";
-	$contact->column_fields[phone]=in_array('phone',$permitted_lists) ? $office_phone : "";
-	$contact->column_fields[homephone]=in_array('homephone',$permitted_lists) ? $home_phone : "";
-	$contact->column_fields[fax]=in_array('fax',$permitted_lists) ? $fax : "";
-	$contact->column_fields[mobile]=in_array('mobile',$permitted_lists) ? $phone_mobile : "";
-	$contact->column_fields[mailingstreet]=in_array('mailingstreet',$permitted_lists) ? $primary_address_street : "";
-	$contact->column_fields[mailingcity]=in_array('mailingcity',$permitted_lists) ? $primary_address_city : "";
-	$contact->column_fields[mailingstate]=in_array('mailingstate',$permitted_lists) ? $primary_address_state : "";
-	$contact->column_fields[mailingzip]=in_array('mailingzip',$permitted_lists) ? $primary_address_postalcode : "";
-	$contact->column_fields[mailingcountry]=in_array('mailingcountry',$permitted_lists) ? $primary_address_country : "";
-	$contact->column_fields[otherstreet]=in_array('otherstreet',$permitted_lists) ? $alt_address_street : "";
-	$contact->column_fields[othercity]=in_array('othercity',$permitted_lists) ? $alt_address_city : "";
-	$contact->column_fields[otherstate]=in_array('otherstate',$permitted_lists) ? $alt_address_state : "";
-	$contact->column_fields[otherzip]=in_array('otherzip',$permitted_lists) ? $alt_address_postalcode : "";
-	$contact->column_fields[othercountry]=in_array('othercountry',$permitted_lists) ? $alt_address_country : "";
-	$contact->column_fields[assigned_user_id]=in_array('assigned_user_id',$permitted_lists) ? $user_id : "";
-	$contact->column_fields[description]= "";
-	$contact->save("Contacts");
-
-  $contact = $contact;
-	return $contact->id;
-}
-
-function AddLead($user_name, $first_name, $last_name, $email_address ,$account_name , $salutation , $title, $phone_mobile, $reports_to ,$primary_address_street , $website ,$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="",$fax="",$department="",$description="")
-{
-	global $adb;
-	global $current_user;
-	require_once('modules/Users/Users.php');
-	require_once('modules/Leads/Leads.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");
-	require('user_privileges/user_privileges_'.$current_user->id.'.php');
-	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
-
-	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
-  {
-    $sql1 = "select fieldname,columnname from vtiger_field where tabid=7 and block <> 14";
-  }else
-  {
-    $profileList = getCurrentUserProfileList();
-    $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=7 and vtiger_field.block <> 14 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
-  }
-  $result1 = $adb->query($sql1);
-  for($i=0;$i < $adb->num_rows($result1);$i++)
-  {
-      $permitted_lists[] = $adb->query_result($result1,$i,'fieldname');
-  }
-
-	$Lead = new Leads();
-	$Lead->column_fields[firstname]=in_array('firstname',$permitted_lists) ? $first_name : "";
-	$Lead->column_fields[lastname]=in_array('lastname',$permitted_lists) ? $last_name : "";
-	$Lead->column_fields[birthday]=in_array('birthday',$permitted_lists) ? getDisplayDate("0000-00-00") : "";
-	$Lead->column_fields[company]=in_array('company',$permitted_lists) ? $account_name : "";
-	$Lead->column_fields[email]=in_array('email',$permitted_lists) ? $email_address : "";
-	$Lead->column_fields[title]=in_array('title',$permitted_lists) ? $title : "";
-	$Lead->column_fields[designation]=in_array('designation',$permitted_lists) ? $department : "";
-	$Lead->column_fields[phone]=in_array('phone',$permitted_lists) ? $office_phone : "";
-	$Lead->column_fields[homephone]=in_array('homephone',$permitted_lists) ? $home_phone : "";
-	$Lead->column_fields[website]=in_array('website',$permitted_lists) ? $website : "";
-	$Lead->column_fields[fax]=in_array('fax',$permitted_lists) ? $fax : "";
-	$Lead->column_fields[mobile]=in_array('mobile',$permitted_lists) ? $phone_mobile : "";
-	$Lead->column_fields[mailingstreet]=in_array('mailingstreet',$permitted_lists) ? $primary_address_street : "";
-	$Lead->column_fields[mailingcity]=in_array('mailingcity',$permitted_lists) ? $primary_address_city : "";
-	$Lead->column_fields[mailingstate]=in_array('mailingstate',$permitted_lists) ? $primary_address_state : "";
-	$Lead->column_fields[mailingzip]=in_array('mailingzip',$permitted_lists) ? $primary_address_postalcode : "";
-	$Lead->column_fields[workCountry]=in_array('mailingcountry',$permitted_lists) ? $workCountry : "";
-	$Lead->column_fields[street]=in_array('street',$permitted_lists) ? $alt_address_street : "";
-	$Lead->column_fields[city]=in_array('city',$permitted_lists) ? $alt_address_city : "";
-	$Lead->column_fields[state]=in_array('state',$permitted_lists) ? $alt_address_state : "";
-	$Lead->column_fields[code]=in_array('code',$permitted_lists) ? $alt_address_postalcode : "";
-	$Lead->column_fields[country]=in_array('country',$permitted_lists) ? $alt_address_country : "";
-	$Lead->column_fields[assigned_user_id]=in_array('assigned_user_id',$permitted_lists) ? $user_id : "";
-	$Lead->column_fields[description]= "";
-//	$log->fatal($Lead->column_fields);
-	$Lead->save("Leads");
-
-  	$Lead = $Lead;
-	return $Lead->id;
-}
-
-function create_session($user_name, $password)
-{
-  global $adb,$log;
-  $return_access = 'failure';
-  require_once('modules/Users/Users.php');
-	$objuser = new Users();
-	if($password != "" && $user_name != '')
-	{
-		if($objuser->is_authenticated())
-		{
-			$objuser->column_fields['user_name'] = $user_name;
-			$encrypted_password = $objuser->encrypt_password($password);
-			$query = "select id from vtiger_users where user_name='$user_name' and user_password='$encrypted_password'";
-			$result = $adb->query($query);
-			if($adb->num_rows($result) > 0)
-			{
-				$return_access = 'success';
-				$log->debug("Logged in sucessfully from thunderbirdplugin");
-			}else
-			{
-				$return_access = 'failure';
-				$log->debug("Logged in failure from thunderbirdplugin");
-			}
-		}
-		else
-		{
-			$return_access = 'failure';
-		}
-	}else
-	{
-		$return_access = 'failure';
-		$log->debug("Logged in failure from thunderbirdplugin");
-  }
-	return $return_access;
-}
-
-function end_session($user_name)
-{
-        return "Success";
-}
-
-function CheckContactPerm($user_name)
-{
-  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");
-	if(isPermitted("Contacts","EditView") == "yes")
-	{
-		return "allowed";
-	}else
-	{
-		return "denied";
-	}
-}
-
-function CheckContactViewPerm($user_name)
-{
-  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")
-	{
-		return "allowed";
-	}else
-	{
-		return "denied";
-	}
-}
-
-function CheckLeadViewPerm($user_name)
-{
-  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","EditView") == "yes")
-	{
-		return "allowed";
-	}else
-	{
-		return "denied";
-	}
-}
-$server->service($HTTP_RAW_POST_DATA);
-exit();
-?>
+<?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.
+*
+ ********************************************************************************/
+
+require_once("config.php");
+require_once('include/logging.php');
+require_once('include/nusoap/nusoap.php');
+require_once('include/database/PearDatabase.php');
+require_once('modules/Contacts/Contacts.php');
+
+$log = &LoggerManager::getLogger('thunderbirdplugin');
+
+$accessDenied = "You are not authorized for performing this action";
+$NAMESPACE = 'http://www.vtiger.com/products/crm';
+$server = new soap_server;
+
+$server->configureWSDL('vtigersoap');
+
+$server->register(
+ 	    'create_session',
+ 	    array('user_name'=>'xsd:string','password'=>'xsd:string'),
+ 	    array('return'=>'xsd:string'),
+ 	    $NAMESPACE);
+
+$server->register(
+ 	    'end_session',
+ 	    array('user_name'=>'xsd:string'),
+ 	    array('return'=>'xsd:string'),
+ 	    $NAMESPACE);
+
+$server->register(
+    'SearchContactsByEmail',
+    array('username'=>'xsd:string','emailaddress'=>'xsd:string'),
+    array('return'=>'tns:contactdetails'),
+    $NAMESPACE);
+
+$server->register(
+		'GetContacts',
+    array('username'=>'xsd:string'),
+    array('return'=>'tns:contactdetails'),
+    $NAMESPACE);
+
+$server->register(
+    'CheckContactPerm',array('user_name'=>'xsd:string'),array('return'=>'xsd:string'),$NAMESPACE);
+
+$server->register(
+    'CheckContactViewPerm',array('user_name'=>'xsd:string'),array('return'=>'xsd:string'),$NAMESPACE);
+
+$server->register(
+	'CheckLeadViewPerm',array('user_name'=>'xsd:string'),array('return'=>'xsd:string'),$NAMESPACE);
+
+$server->register(
+	  'AddContact',
+    array('user_name'=>'xsd:string',
+          'first_name'=>'xsd:string',
+          'last_name'=>'xsd:string',
+          'email_address'=>'xsd:string',
+          'account_name'=>'xsd:string',
+          'salutation'=>'xsd:string',
+          'title'=>'xsd:string',
+          'phone_mobile'=>'xsd:string',
+          'reports_to'=>'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',
+          'alt_address_city'=>'xsd:string',
+          'alt_address_street'=>'xsd:string',
+          'alt_address_state'=>'xsd:string',
+          'alt_address_postalcode'=>'xsd:string',
+          'alt_address_country'=>'xsd:string',
+          'office_phone'=>'xsd:string',
+          'home_phone'=>'xsd:string',
+          'fax'=>'xsd:string',
+          'department'=>'xsd:string',
+          'description'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+$server->register(
+	  'AddLead',
+    array('user_name'=>'xsd:string',
+          'first_name'=>'xsd:string',
+          'last_name'=>'xsd:string',
+          'email_address'=>'xsd:string',
+          'account_name'=>'xsd:string',
+          'salutation'=>'xsd:string',
+          'title'=>'xsd:string',
+          'phone_mobile'=>'xsd:string',
+          'reports_to'=>'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',
+          'alt_address_city'=>'xsd:string',
+          'alt_address_street'=>'xsd:string',
+          'alt_address_state'=>'xsd:string',
+          'alt_address_postalcode'=>'xsd:string',
+          'alt_address_country'=>'xsd:string',
+          'office_phone'=>'xsd:string',
+          'home_phone'=>'xsd:string',
+          'fax'=>'xsd:string',
+          'department'=>'xsd:string',
+	  'description'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+$server->register(
+	'track_email',
+    array('user_name'=>'xsd:string', 'contact_ids'=>'xsd:string', 'date_sent'=>'xsd:date', 'email_subject'=>'xsd:string', 'email_body'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+$server->wsdl->addComplexType(
+    'contactdetail',
+    'complexType',
+    'struct',
+    'all',
+    '',
+    array(
+	      'id' => array('name'=>'id','type'=>'xsd:string'),
+        'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
+        'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
+        'emailaddress' => array('name'=>'emailaddress','type'=>'xsd:string'),
+        'accountname' => array('name'=>'accountname','type'=>'xsd:string'),
+        'middlename' => array('name'=>'middlename','type'=>'xsd:string'),
+        'birthdate'=> array('name'=>'birthdate','type'=>'xsd:string'),
+        'jobtitle'=> array('name'=>'jobtitle','type'=>'xsd:string'),
+        'department'=> array('name'=>'department','type'=>'xsd:string'),
+        'title' => array('name'=>'title','type'=>'xsd:string'),
+        'officephone'=> array('name'=>'officephone','type'=>'xsd:string'),
+        'homephone'=> array('name'=>'homephone','type'=>'xsd:string'),
+        'otherphone'=> array('name'=>'otherphone','type'=>'xsd:string'),
+        'fax'=> array('name'=>'fax','type'=>'xsd:string'),
+        'mobile'=> array('name'=>'mobile','type'=>'xsd:string'),
+        'asstname'=> array('name'=>'asstname','type'=>'xsd:string'),
+        'asstphone'=> array('name'=>'asstphone','type'=>'xsd:string'),
+        'reportsto'=> array('name'=>'reportsto','type'=>'xsd:string'),
+        'mailingstreet'=> array('name'=>'mailingstreet','type'=>'xsd:string'),
+        'mailingcity'=> array('name'=>'mailingcity','type'=>'xsd:string'),
+        'mailingstate'=> array('name'=>'mailingstate','type'=>'xsd:string'),
+        'mailingzip'=> array('name'=>'mailingzip','type'=>'xsd:string'),
+        'mailingcountry'=> array('name'=>'mailingcountry','type'=>'xsd:string'),
+        'otherstreet'=> array('name'=>'otherstreet','type'=>'xsd:string'),
+        'othercity'=> array('name'=>'othercity','type'=>'xsd:string'),
+        'otherstate'=> array('name'=>'otherstate','type'=>'xsd:string'),
+        'otherzip'=> array('name'=>'otherzip','type'=>'xsd:string'),
+        'othercountry'=> array('name'=>'othercountry','type'=>'xsd:string'),
+        'description'=> array('name'=>'description','type'=>'xsd:string'),
+        'category'=> array('name'=>'category','type'=>'xsd:string'),
+    )
+);
+
+$server->wsdl->addComplexType(
+    'contactdetails',
+    'complexType',
+    'array',
+    '',
+    'SOAP-ENC:Array',
+    array(),
+    array(
+        array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:contactdetail[]')
+    ),
+    'tns:contactdetail'
+);
+
+
+function SearchContactsByEmail($username,$emailaddress)
+{
+     require_once('modules/Contacts/Contacts.php');
+
+     $seed_contact = new Contacts();
+     $output_list = Array();
+
+     $response = $seed_contact->get_searchbyemailid($username,$emailaddress);
+     $contactList = $response['list'];
+
+     // create a return array of names and email addresses.
+     foreach($contactList as $contact)
+     {
+          $output_list[] = Array(
+               "id" => $contact[contactid],
+               "firstname" => $contact[firstname],
+               "lastname" => $contact[lastname],
+               "emailaddress" => $contact[email],
+               "accountname" => $contact[accountname],
+          );
+     }
+
+     //to remove an erroneous compiler warning
+     $seed_contact = $seed_contact;
+     return $output_list;
+}
+
+function track_email($user_name, $contact_ids, $date_sent, $email_subject, $email_body)
+{
+	global $current_user;
+	global $adb;
+	global $log;
+	require_once('modules/Users/Users.php');
+	require_once('modules/Emails/Emails.php');
+
+	$current_user = new Users();
+	$user_id = $current_user->retrieve_user_id($user_name);
+	$query = "select email1 from vtiger_users where id =".$user_id;
+	$result = $adb->query($query);
+	$user_emailid = $adb->query_result($result,0,"email1");
+	$current_user = $current_user->retrieveCurrentUserInfoFromFile($user_id);
+	$email = new Emails();
+	//$log->debug($msgdtls['contactid']);
+	$emailbody = str_replace("'", "''", $email_body);
+	$emailsubject = str_replace("'", "''",$email_subject);
+	$datesent = getDisplayDate($date_sent);
+
+	$email->column_fields[subject] = $emailsubject;
+	$email->column_fields[assigned_user_id] = $user_id;
+	$email->column_fields[date_start] = $datesent;
+	$email->column_fields[description]  = htmlentities($emailbody);
+	$email->column_fields[activitytype] = 'Emails';
+	$email->plugin_save = true;
+	$email->save("Emails");
+	$query = "select fieldid from vtiger_field where fieldname = 'email' and tabid = 4";
+	$result = $adb->query($query);
+	$field_id = $adb->query_result($result,0,"fieldid");
+	$email->set_emails_contact_invitee_relationship($email->id,$contact_ids);
+	$email->set_emails_se_invitee_relationship($email->id,$contact_ids);
+	$email->set_emails_user_invitee_relationship($email->id,$user_id);
+	$sql = "select email from vtiger_contactdetails inner join vtiger_crmentity on vtiger_crmentity.crmid = vtiger_contactdetails.contactid where vtiger_crmentity.deleted =0 and vtiger_contactdetails.contactid='".$contact_ids."'";
+	$result = $adb->query($sql);
+	$camodulerow = $adb->fetch_array($result);
+	if(isset($camodulerow))
+	{
+		$emailid = $camodulerow["email"];
+		$query = 'insert into vtiger_emaildetails values ('.$email->id.',"'.$emailid.'","'.$user_emailid.'","","","","'.$user_id.'@-1|'.$contact_ids.'@'.$field_id.'|","THUNDERBIRD")';
+		$adb->query($query);
+	}
+	return $email->id;
+}
+
+
+function GetContacts($username)
+{
+	global $adb;
+	global $log;
+	require_once('modules/Contacts/Contacts.php');
+
+	$seed_contact = new Contacts();
+	$output_list = Array();
+
+	$query = $seed_contact->get_contactsforol($username);
+	$result = $adb->query($query);
+
+	while($contact = $adb->fetch_array($result))
+	{
+		if($contact["birthdate"] == "0000-00-00")
+		{
+			$contact["birthdate"] = "";
+		}
+		if($contact["salutation"] == "--None--")
+		{
+			$contact["salutation"] = "";
+		}
+
+		$namelist = explode(" ", $contact["lastname"]);
+		if(isset($namelist))
+		{
+			if(count($namelist) >= 2)
+			{
+				$contact["lastname"] = $namelist[count($namelist)-1];
+				for($i=0; $i<count($namelist)-2; $i++)
+				{
+					$middlename[] = $namelist[$i];
+				}
+				if(isset($middlename))
+				{
+					$middlename = implode(" ",$middlename);
+				}
+			}
+		}
+
+		$output_list[] = Array(
+				"id" => $contact["id"],
+				"title" => $contact["salutation"],
+				"firstname" => $contact["firstname"],
+				"middlename" => trim($middlename),
+				"lastname" => trim($contact["lastname"]),
+				"birthdate" => $contact["birthday"],
+				"emailaddress" => $contact["email"],
+				"jobtitle" => $contact["title"],
+				"department" => $contact["department"],
+				"accountname" => $contact["accountname"],
+				"officephone" => $contact["phone"],
+				"homephone" => $contact["homephone"],
+				"otherphone" => $contact["otherphone"],
+				"fax" => $contact["fax"],
+				"mobile" => $contact["mobile"],
+				"asstname" => $contact["assistant"],
+				"asstphone" => $contact["assistantphone"],
+				"reportsto" => $contact["reports_to_name"],
+				"mailingstreet" => $contact["mailingstreet"],
+				"mailingcity" => $contact["mailingcity"],
+				"mailingstate" => $contact["mailingstate"],
+				"mailingzip" => $contact["mailingzip"],
+				"mailingcountry" => $contact["mailingcountry"],
+				"otherstreet" => $contact["otherstreet"],
+				"othercity" => $contact["othercity"],
+				"otherstate" => $contact["otherstate"],
+				"otherzip" => $contact["otherzip"],
+				"othercountry" => $contact["othercountry"],
+				"description" => "",
+				"category" => "",
+			  );
+	}
+	//to remove an erroneous compiler warning
+	$seed_contact = $seed_contact;
+	return $output_list;
+}
+
+function retrieve_account_id($account_name,$user_id)
+{
+
+	if($account_name=="")
+	{
+		return null;
+	}
+
+	$query = "select vtiger_account.accountname accountname,vtiger_account.accountid accountid from vtiger_account inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_account.accountid where vtiger_crmentity.deleted=0 and vtiger_account.accountname='" .$account_name."'";
+
+
+	$db = new PearDatabase();
+	$result=  $db->query($query) or die ("Not able to execute insert");
+
+	$rows_count =  $db->getRowCount($result);
+	if($rows_count==0)
+	{
+		require_once('modules/Accounts/Accounts.php');
+		$account = new Accounts();
+		$account->column_fields[accountname] = $account_name;
+		$account->column_fields[assigned_user_id]=$user_id;
+		//$account->saveentity("Accounts");
+		$account->save("Accounts");
+		//mysql_close();
+		return $account->id;
+	}
+	else if ($rows_count==1)
+	{
+		$row = $db->fetchByAssoc($result, 0);
+		//mysql_close();
+		return $row["accountid"];
+	}
+	else
+	{
+		$row = $db->fetchByAssoc($result, 0);
+		//mysql_close();
+		return $row["accountid"];
+	}
+
+}
+
+function AddContact($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="",$fax="",$department="",$description="")
+{
+	global $adb;
+	global $current_user;
+	require_once('modules/Users/Users.php');
+	require_once('modules/Contacts/Contacts.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");
+	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+
+	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+  {
+    $sql1 = "select fieldname,columnname from vtiger_field where tabid=4 and block <> 75 and block <> 6 and block <> 5";
+  }else
+  {
+    $profileList = getCurrentUserProfileList();
+    $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=4 and vtiger_field.block <> 75 and vtiger_field.block <> 6 and vtiger_field.block <> 5 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+  }
+  $result1 = $adb->query($sql1);
+  for($i=0;$i < $adb->num_rows($result1);$i++)
+  {
+      $permitted_lists[] = $adb->query_result($result1,$i,'fieldname');
+  }
+
+	$contact = new Contacts();
+	$contact->column_fields[firstname]=in_array('firstname',$permitted_lists) ? $first_name : "";
+	$contact->column_fields[lastname]=in_array('lastname',$permitted_lists) ? $last_name : "";
+	$contact->column_fields[birthday]=in_array('birthday',$permitted_lists) ? getDisplayDate("0000-00-00") : "";
+	$contact->column_fields[email]=in_array('email',$permitted_lists) ? $email_address : "";
+	$contact->column_fields[title]=in_array('title',$permitted_lists) ? $title : "";
+	$contact->column_fields[department]=in_array('department',$permitted_lists) ? $department : "";
+	$contact->column_fields[account_id]=in_array('account_id',$permitted_lists) ? retrieve_account_id($account_name,$user_id) : "";
+	$contact->column_fields[phone]=in_array('phone',$permitted_lists) ? $office_phone : "";
+	$contact->column_fields[homephone]=in_array('homephone',$permitted_lists) ? $home_phone : "";
+	$contact->column_fields[fax]=in_array('fax',$permitted_lists) ? $fax : "";
+	$contact->column_fields[mobile]=in_array('mobile',$permitted_lists) ? $phone_mobile : "";
+	$contact->column_fields[mailingstreet]=in_array('mailingstreet',$permitted_lists) ? $primary_address_street : "";
+	$contact->column_fields[mailingcity]=in_array('mailingcity',$permitted_lists) ? $primary_address_city : "";
+	$contact->column_fields[mailingstate]=in_array('mailingstate',$permitted_lists) ? $primary_address_state : "";
+	$contact->column_fields[mailingzip]=in_array('mailingzip',$permitted_lists) ? $primary_address_postalcode : "";
+	$contact->column_fields[mailingcountry]=in_array('mailingcountry',$permitted_lists) ? $primary_address_country : "";
+	$contact->column_fields[otherstreet]=in_array('otherstreet',$permitted_lists) ? $alt_address_street : "";
+	$contact->column_fields[othercity]=in_array('othercity',$permitted_lists) ? $alt_address_city : "";
+	$contact->column_fields[otherstate]=in_array('otherstate',$permitted_lists) ? $alt_address_state : "";
+	$contact->column_fields[otherzip]=in_array('otherzip',$permitted_lists) ? $alt_address_postalcode : "";
+	$contact->column_fields[othercountry]=in_array('othercountry',$permitted_lists) ? $alt_address_country : "";
+	$contact->column_fields[assigned_user_id]=in_array('assigned_user_id',$permitted_lists) ? $user_id : "";
+	$contact->column_fields[description]= "";
+	$contact->save("Contacts");
+
+  $contact = $contact;
+	return $contact->id;
+}
+
+function AddLead($user_name, $first_name, $last_name, $email_address ,$account_name , $salutation , $title, $phone_mobile, $reports_to ,$primary_address_street , $website ,$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="",$fax="",$department="",$description="")
+{
+	global $adb;
+	global $current_user;
+	require_once('modules/Users/Users.php');
+	require_once('modules/Leads/Leads.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");
+	require('user_privileges/user_privileges_'.$current_user->id.'.php');
+	require('user_privileges/sharing_privileges_'.$current_user->id.'.php');
+
+	if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
+  {
+    $sql1 = "select fieldname,columnname from vtiger_field where tabid=7 and block <> 14";
+  }else
+  {
+    $profileList = getCurrentUserProfileList();
+    $sql1 = "select fieldname,columnname from vtiger_field inner join vtiger_profile2field on vtiger_profile2field.fieldid=vtiger_field.fieldid inner join vtiger_def_org_field on vtiger_def_org_field.fieldid=vtiger_field.fieldid where vtiger_field.tabid=7 and vtiger_field.block <> 14 and vtiger_field.displaytype in (1,2,4) and vtiger_profile2field.visible=0 and vtiger_def_org_field.visible=0 and vtiger_profile2field.profileid in ".$profileList;
+  }
+  $result1 = $adb->query($sql1);
+  for($i=0;$i < $adb->num_rows($result1);$i++)
+  {
+      $permitted_lists[] = $adb->query_result($result1,$i,'fieldname');
+  }
+
+	$Lead = new Leads();
+	$Lead->column_fields[firstname]=in_array('firstname',$permitted_lists) ? $first_name : "";
+	$Lead->column_fields[lastname]=in_array('lastname',$permitted_lists) ? $last_name : "";
+	$Lead->column_fields[birthday]=in_array('birthday',$permitted_lists) ? getDisplayDate("0000-00-00") : "";
+	$Lead->column_fields[company]=in_array('company',$permitted_lists) ? $account_name : "";
+	$Lead->column_fields[email]=in_array('email',$permitted_lists) ? $email_address : "";
+	$Lead->column_fields[title]=in_array('title',$permitted_lists) ? $title : "";
+	$Lead->column_fields[designation]=in_array('designation',$permitted_lists) ? $department : "";
+	$Lead->column_fields[phone]=in_array('phone',$permitted_lists) ? $office_phone : "";
+	$Lead->column_fields[homephone]=in_array('homephone',$permitted_lists) ? $home_phone : "";
+	$Lead->column_fields[website]=in_array('website',$permitted_lists) ? $website : "";
+	$Lead->column_fields[fax]=in_array('fax',$permitted_lists) ? $fax : "";
+	$Lead->column_fields[mobile]=in_array('mobile',$permitted_lists) ? $phone_mobile : "";
+	$Lead->column_fields[mailingstreet]=in_array('mailingstreet',$permitted_lists) ? $primary_address_street : "";
+	$Lead->column_fields[mailingcity]=in_array('mailingcity',$permitted_lists) ? $primary_address_city : "";
+	$Lead->column_fields[mailingstate]=in_array('mailingstate',$permitted_lists) ? $primary_address_state : "";
+	$Lead->column_fields[mailingzip]=in_array('mailingzip',$permitted_lists) ? $primary_address_postalcode : "";
+	$Lead->column_fields[workCountry]=in_array('mailingcountry',$permitted_lists) ? $workCountry : "";
+	$Lead->column_fields[street]=in_array('street',$permitted_lists) ? $alt_address_street : "";
+	$Lead->column_fields[city]=in_array('city',$permitted_lists) ? $alt_address_city : "";
+	$Lead->column_fields[state]=in_array('state',$permitted_lists) ? $alt_address_state : "";
+	$Lead->column_fields[code]=in_array('code',$permitted_lists) ? $alt_address_postalcode : "";
+	$Lead->column_fields[country]=in_array('country',$permitted_lists) ? $alt_address_country : "";
+	$Lead->column_fields[assigned_user_id]=in_array('assigned_user_id',$permitted_lists) ? $user_id : "";
+	$Lead->column_fields[description]= "";
+//	$log->fatal($Lead->column_fields);
+	$Lead->save("Leads");
+
+  	$Lead = $Lead;
+	return $Lead->id;
+}
+
+function create_session($user_name, $password)
+{
+  global $adb,$log;
+  $return_access = 'failure';
+  require_once('modules/Users/Users.php');
+	$objuser = new Users();
+	if($password != "" && $user_name != '')
+	{
+		$objuser->column_fields['user_name'] = $user_name;
+		$encrypted_password = $objuser->encrypt_password($password);
+		if($objuser->load_user($password) && $objuser->is_authenticated())
+		{
+			$query = "select id from vtiger_users where user_name='$user_name' and user_password='$encrypted_password'";
+			$result = $adb->query($query);
+			if($adb->num_rows($result) > 0)
+			{
+				$return_access = 'success';
+				$log->debug("Logged in sucessfully from thunderbirdplugin");
+			}else
+			{
+				$return_access = 'failure';
+				$log->debug("Logged in failure from thunderbirdplugin");
+			}
+		}
+	}else
+	{
+		$return_access = 'failure';
+		$log->debug("Logged in failure from thunderbirdplugin");
+	}
+	return $return_access;
+}
+
+function end_session($user_name)
+{
+        return "Success";
+}
+
+function CheckContactPerm($user_name)
+{
+  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");
+	if(isPermitted("Contacts","EditView") == "yes")
+	{
+		return "allowed";
+	}else
+	{
+		return "denied";
+	}
+}
+
+function CheckContactViewPerm($user_name)
+{
+  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")
+	{
+		return "allowed";
+	}else
+	{
+		return "denied";
+	}
+}
+
+function CheckLeadViewPerm($user_name)
+{
+  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","EditView") == "yes")
+	{
+		return "allowed";
+	}else
+	{
+		return "denied";
+	}
+}
+$server->service($HTTP_RAW_POST_DATA);
+exit();
+?>

Modified: vtigercrm/branches/5.0.3/soap/wordplugin.php
==============================================================================
--- vtigercrm/branches/5.0.3/soap/wordplugin.php (original)
+++ vtigercrm/branches/5.0.3/soap/wordplugin.php Tue Feb 27 06:00:05 2007
@@ -1,370 +1,365 @@
-<?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.
-*
- ********************************************************************************/
-
-require_once("config.php");
-require_once('include/logging.php');
-require_once('include/nusoap/nusoap.php');
-require_once('include/database/PearDatabase.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'),
-        'yahoo_id' => array('name'=>'yahoo_id','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'),
-        'yahooid' => array('name'=>'yahooid','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','password'=>'xsd:string'),
-    array('return'=>'tns:contact_column_detail'),
-    $NAMESPACE);
-
-$server->register(
-    'get_accounts_columns',
-    array('user_name'=>'xsd:string','password'=>'xsd:string'),
-    array('return'=>'tns:account_column_detail'),
-    $NAMESPACE);
-
-$server->register(
-    'get_leads_columns',
-    array('user_name'=>'xsd:string','password'=>'xsd:string'),
-    array('return'=>'tns:lead_column_detail'),
-    $NAMESPACE);
-
-$server->register(
-    'get_user_columns',
-    array('user_name'=>'xsd:string','password'=>'xsd:string'),
-    array('return'=>'tns:user_column_detail'),
-    $NAMESPACE);
-
-$server->register(
-    'get_tickets_columns',
-    array('user_name'=>'xsd:string','password'=>'xsd:string'),
-    array('return'=>'tns:tickets_list_array'),
-    $NAMESPACE);
-
-$server->register(
-    'create_session',
-    array('user_name'=>'xsd:string','password'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-$server->register(
-    'end_session',
-    array('user_name'=>'xsd:string'),
-    array('return'=>'xsd:string'),
-    $NAMESPACE);
-
-	        
-function get_tickets_columns($user_name, $password)
-{
-	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, $password)
-{
-	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, $password)
-{
-	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, $password)
-{	
-	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, $password)
-{
-	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)
-{ 
-  	global $adb,$log;
-	require_once('modules/Users/Users.php');
-	$objuser = new Users();
-	if($password != "" && $user_name != '')
-	{
-		if($objuser->is_authenticated())
-		{
-			$objuser->column_fields['user_name'] = $user_name;
-			$encrypted_password = $objuser->encrypt_password($password);
-			$query = "select id from vtiger_users where user_name='$user_name' and user_password='$encrypted_password'";
-			$result = $adb->query($query);
-			if($adb->num_rows($result) > 0)
-			{
-				$return_access = "TempSessionID";
-				$log->debug("Logged in sucessfully from wordplugin");
-			}else
-			{
-				$return_access = "false";
-				$log->debug("Logged in failure from wordplugin");
-			}
-		}
-		else
-		{
-			$return_access = "false";
-			$log->debug("Logged in failure from wordplugin when the user is not authenticated");
-		}
-	}else
-	{
-		$return_access = "false";
-		$log->debug("Logged in failure from wordplugin");
-     }
-   return $return_access;
-		
-}
-
-function end_session($user_name)
-{
-	return "Success";	
-}
- 
-
-
-
-$server->service(utf8_encode($HTTP_RAW_POST_DATA)); 
-exit(); 
-?>
+<?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.
+*
+ ********************************************************************************/
+
+require_once("config.php");
+require_once('include/logging.php');
+require_once('include/nusoap/nusoap.php');
+require_once('include/database/PearDatabase.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'),
+        'yahoo_id' => array('name'=>'yahoo_id','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'),
+        'yahooid' => array('name'=>'yahooid','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','password'=>'xsd:string'),
+    array('return'=>'tns:contact_column_detail'),
+    $NAMESPACE);
+
+$server->register(
+    'get_accounts_columns',
+    array('user_name'=>'xsd:string','password'=>'xsd:string'),
+    array('return'=>'tns:account_column_detail'),
+    $NAMESPACE);
+
+$server->register(
+    'get_leads_columns',
+    array('user_name'=>'xsd:string','password'=>'xsd:string'),
+    array('return'=>'tns:lead_column_detail'),
+    $NAMESPACE);
+
+$server->register(
+    'get_user_columns',
+    array('user_name'=>'xsd:string','password'=>'xsd:string'),
+    array('return'=>'tns:user_column_detail'),
+    $NAMESPACE);
+
+$server->register(
+    'get_tickets_columns',
+    array('user_name'=>'xsd:string','password'=>'xsd:string'),
+    array('return'=>'tns:tickets_list_array'),
+    $NAMESPACE);
+
+$server->register(
+    'create_session',
+    array('user_name'=>'xsd:string','password'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+$server->register(
+    'end_session',
+    array('user_name'=>'xsd:string'),
+    array('return'=>'xsd:string'),
+    $NAMESPACE);
+
+	        
+function get_tickets_columns($user_name, $password)
+{
+	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, $password)
+{
+	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, $password)
+{
+	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, $password)
+{	
+	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, $password)
+{
+	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)
+{ 
+  	global $adb,$log;
+	require_once('modules/Users/Users.php');
+	$objuser = new Users();
+	if($password != "" && $user_name != '')
+	{
+			$objuser->column_fields['user_name'] = $user_name;
+			$encrypted_password = $objuser->encrypt_password($password);
+			if($objuser->load_user($password) && $objuser->is_authenticated())
+			{
+				$query = "select id from vtiger_users where user_name='$user_name' and user_password='$encrypted_password'";
+				$result = $adb->query($query);
+				if($adb->num_rows($result) > 0)
+				{
+					$return_access = "TempSessionID";
+					$log->debug("Logged in sucessfully from wordplugin");
+				}else
+				{
+					$return_access = "false";
+					$log->debug("Logged in failure from wordplugin");
+				}
+			}
+	}else
+	{
+		$return_access = "false";
+		$log->debug("Logged in failure from wordplugin");
+     }
+   return $return_access;
+		
+}
+
+function end_session($user_name)
+{
+	return "Success";	
+}
+ 
+
+
+
+$server->service(utf8_encode($HTTP_RAW_POST_DATA)); 
+exit(); 
+?>





More information about the vtigercrm-commits mailing list