vTiger 根目录文件。

This commit is contained in:
YUCHENG HU
2013-01-30 22:15:41 -05:00
parent ba357ab70a
commit deaa893a8d
11 changed files with 14667 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
# ------------------------------------------
# vtiger CRM . -- http://www.vtiger.com
# Robot Exclusion File -- robots.txt
# Author: vtiger CRM
# Last Updated: 17/11/06
# ------------------------------------------
User-agent: *
Disallow: /
File diff suppressed because it is too large Load Diff
+288
View File
@@ -0,0 +1,288 @@
<?php
////////////////////////////////////////////////////
// PHPMailer - PHP email class
//
// Class for sending email using either
// sendmail, PHP mail(), or SMTP. Methods are
// based upon the standard AspEmail(tm) classes.
//
// Copyright (C) 2001 - 2003 Brent R. Matzelle
//
// License: LGPL, see LICENSE
////////////////////////////////////////////////////
/**
* PHPMailer - PHP email transport class
* @package PHPMailer
* @author Brent R. Matzelle
* @copyright 2001 - 2003 Brent R. Matzelle
*/
//file modified by richie
require_once('include/utils/utils.php');
require("modules/Emails/class.phpmailer.php");
require_once('include/logging.php');
require("config.php");
$current_user = Users::getActiveAdminUser();
// Set the default sender email id
global $HELPDESK_SUPPORT_EMAIL_ID;
$from = $HELPDESK_SUPPORT_EMAIL_ID;
if(empty($from)) {
// default configuration is empty?
$from = "reminders@localserver.com";
}
// Get the list of activity for which reminder needs to be sent
global $adb;
global $log;
$log =& LoggerManager::getLogger('SendReminder');
$log->debug(" invoked SendReminder ");
// retrieve the translated strings.
if(empty($current_language))
$current_language = 'en_us';
$app_strings = return_application_language($current_language);
//modified query for recurring events -Jag
$query="select vtiger_crmentity.crmid,vtiger_seactivityrel.crmid as setype,vtiger_activity.*,vtiger_activity_reminder.reminder_time,vtiger_activity_reminder.reminder_sent,vtiger_activity_reminder.recurringid,vtiger_recurringevents.recurringdate from vtiger_activity inner join vtiger_crmentity on vtiger_crmentity.crmid=vtiger_activity.activityid inner join vtiger_activity_reminder on vtiger_activity.activityid=vtiger_activity_reminder.activity_id left outer join vtiger_recurringevents on vtiger_activity.activityid=vtiger_recurringevents.activityid left outer join vtiger_seactivityrel on vtiger_seactivityrel.activityid = vtiger_activity.activityid where DATE_FORMAT(vtiger_activity.date_start,'%Y-%m-%d, %H:%i:%s') >= '".date('Y-m-d')."' and vtiger_crmentity.crmid != 0 and vtiger_activity.eventstatus = 'Planned' and vtiger_activity_reminder.reminder_sent = 0 group by vtiger_activity.activityid,vtiger_recurringevents.recurringid";
$result = $adb->pquery($query, array());
if($adb->num_rows($result) >= 1)
{
while($result_set = $adb->fetch_array($result))
{
$date_start = $result_set['date_start'];
$time_start = $result_set['time_start'];
$reminder_time = $result_set['reminder_time'];
$date = new DateTimeField( null );
$curr_time = strtotime($date->getDisplayDateTimeValue())/60;
$activity_id = $result_set['activityid'];
$activitymode = ($result_set['activitytype'] == "Task")?"Task":"Events";
$parent_type = $result_set['setype'];
$activity_sub = $result_set['subject'];
$to_addr='';
if($parent_type!='')
$parent_content = getParentInfo($parent_type)."\n";
else
$parent_content = "";
//code included for recurring events by jaguar starts
$recur_id = $result_set['recurringid'];
$current_date=date('Y-m-d');
if($recur_id == 0)
{
$date_start = $result_set['date_start'];
}
else
{
$date_start = $result_set['recurringdate'];
}
//code included for recurring events by jaguar ends
$date = new DateTimeField("$date_start $time_start");
$activity_time = strtotime($date->getDisplayDateTimeValue())/60;
if (($activity_time - $curr_time) > 0 && ($activity_time - $curr_time) <= $reminder_time)
{
$log->debug(" InSide REMINDER");
$query_user="SELECT vtiger_users.email1,vtiger_salesmanactivityrel.smid FROM vtiger_salesmanactivityrel inner join vtiger_users on vtiger_users.id=vtiger_salesmanactivityrel.smid where vtiger_salesmanactivityrel.activityid =? and vtiger_users.deleted=0";
$user_result = $adb->pquery($query_user, array($activity_id));
if($adb->num_rows($user_result)>=1)
{
while($user_result_row = $adb->fetch_array($user_result))
{
if($user_result_row['email1']!='' || $user_result_row['email1'] !=NULL)
{
$to_addr[] = $user_result_row['email1'];
}
}
}
// Retriving the Subject and message from reminder table
$sql = "select active,notificationsubject,notificationbody from vtiger_notificationscheduler where schedulednotificationid=8";
$result_main = $adb->pquery($sql, array());
$subject = $app_strings['Reminder'].$result_set['activitytype']." @ ".
$result_set['date_start']." ".$result_set['time_start']."] (". DateTimeField::getDBTimeZone() .")".
$adb->query_result($result_main,0,'notificationsubject');
//Set the mail body/contents here
$contents = nl2br($adb->query_result($result_main,0,'notificationbody')) ."\n\n ".
$app_strings['Subject']." : ".$activity_sub."\n ". $parent_content ." ".
$app_strings['Date & Time']." : ".$date_start." ".$time_start."(". DateTimeField::getDBTimeZone() .")\n\n ".
$app_strings['Visit_Link']." <a href='".$site_URL."/index.php?action=DetailView&module=Calendar&record=".$activity_id."&activity_mode=".$activitymode."'>".$app_strings['Click here']."</a>";
if(count($to_addr) >=1)
{
send_mail($to_addr,$from,$subject,$contents,$mail_server,$mail_server_username,$mail_server_password);
$upd_query = "UPDATE vtiger_activity_reminder SET reminder_sent=1 where activity_id=?";
$upd_params = array($activity_id);
if($recur_id!=0)
{
$upd_query.=" and recurringid =?";
array_push($upd_params, $recur_id);
}
$adb->pquery($upd_query, $upd_params);
}
}
}
}
/**
This function is used to assign parameters to the mail object and send it.
It takes the following as parameters.
$to as string - to address
$from as string - from address
$subject as string - subject if the mail
$contents as text - content of the mail
$mail_server as string - sendmail server name
$mail_server_username as string - sendmail server username
$mail_server_password as string - sendmail server password
*/
function send_mail($to,$from,$subject,$contents,$mail_server,$mail_server_username,$mail_server_password)
{
global $adb;
global $log;
$log->info("This is send_mail function in SendReminder.php(vtiger home).");
global $root_directory;
$mail = new PHPMailer();
$mail->Subject = $subject;
$mail->Body = nl2br($contents);//"This is the HTML message body <b>in bold!</b>";
$mail->IsSMTP(); // set mailer to use SMTP
$mailserverresult=$adb->pquery("select * from vtiger_systems where server_type='email'", array());
$mail_server = $adb->query_result($mailserverresult,0,'server');
$mail_server_username = $adb->query_result($mailserverresult,0,'server_username');
$mail_server_password = $adb->query_result($mailserverresult,0,'server_password');
$smtp_auth = $adb->query_result($mailserverresult,0,'smtp_auth');
$_REQUEST['server']=$mail_server;
$log->info("Mail Server Details => '".$mail_server."','".$mail_server_username."','".$mail_server_password."'");
$mail->Host = $mail_server; // specify main and backup server
if($smtp_auth == 'true')
$mail->SMTPAuth = true;
else
$mail->SMTPAuth = false;
$mail->Username = $mail_server_username ; // SMTP username
$mail->Password = $mail_server_password ; // SMTP password
$mail->From = $from;
$mail->FromName = $initialfrom;
$log->info("Mail sending process : From Name & email id => '".$initialfrom."','".$from."'");
foreach($to as $pos=>$addr)
{
$mail->AddAddress($addr); // name is optional
$log->info("Mail sending process : To Email id = '".$addr."' (set in the mail object)");
}
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
$flag = MailSend($mail);
$log->info("After executing the mail->Send() function.");
}
/**
This function is used to ensure mail has been sent sucessfully with out error.
It takes the mail object as the input and returns true if sucess else an error messaget.
*/
function MailSend($mail)
{
global $log;
if(!$mail->Send())
{
$log->info("Error in Mail Sending : Error log = '".$mail->ErrorInfo."'");
$msg = $mail->ErrorInfo;
}
else
{
$log->info("Mail has been sent from the vtigerCRM system : Status : '".$mail->ErrorInfo."'");
return true;
}
}
/**
This function is used to get the Parent mail id
It takes the input returnmodule as string and parentid as integer, returns the parent mailid as string.
*/
function getParentMailId($returnmodule,$parentid)
{
global $adb;
if($returnmodule == 'Leads')
{
$tablename = 'vtiger_leaddetails';
$idname = 'leadid';
}
if($returnmodule == 'Contacts' || $returnmodule == 'HelpDesk')
{
if($returnmodule == 'HelpDesk')
$parentid = $_REQUEST['contact_id'];
$tablename = 'vtiger_contactdetails';
$idname = 'contactid';
}
if($parentid != '')
{
$query = 'select * from '.$tablename.' where '.$idname.' = ?';
$res = $adb->pquery($query, array($parentid));
$mailid = $adb->query_result($res,0,'email');
}
if($mailid == '' && $returnmodule =='Contacts')
{
$mailid = $adb->query_result($res,0,'otheremail');
if($mailid == '')
$mailid = $adb->query_result($res,0,'secondaryemail');
}
return $mailid;
}
/**
This function is used to get the Parent type and its Name
It takes the input integer - crmid and returns the parent type and its name as string.
*/
function getParentInfo($value)
{
global $adb;
$parent_module = getSalesEntityType($value);
if($parent_module == "Leads")
{
$sql = "select * from vtiger_leaddetails where leadid=?";
$result = $adb->pquery($sql, array($value));
$first_name = $adb->query_result($result,0,"firstname");
$last_name = $adb->query_result($result,0,"lastname");
$parent_name = $last_name.' '.$first_name;
}
elseif($parent_module == "Accounts")
{
$sql = "select * from vtiger_account where accountid=?";
$result = $adb->pquery($sql, array($value));
$account_name = $adb->query_result($result,0,"accountname");
$parent_name =$account_name;
}
elseif($parent_module == "Potentials")
{
$sql = "select * from vtiger_potential where potentialid=?";
$result = $adb->pquery($sql, array($value));
$potentialname = $adb->query_result($result,0,"potentialname");
$parent_name =$potentialname;
}
return $parent_module ." : ".$parent_name;
}
?>
File diff suppressed because it is too large Load Diff
+917
View File
@@ -0,0 +1,917 @@
<?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('firefoxlog');
$NAMESPACE = 'http://www.vtiger.com/products/crm';
$server = new soap_server;
$accessDenied = "You are not authorized for performing this action";
$server->configureWSDL('vtigersoap');
$server->register(
'create_lead_from_webform',
array('username'=>'xsd:string',
'session'=>'xsd:string',
'lastname'=>'xsd:string',
'firstname'=>'xsd:string',
'email'=>'xsd:string',
'phone'=>'xsd:string',
'company'=>'xsd:string',
'country'=>'xsd:string',
'description'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'create_site_from_webform',
array('username'=>'xsd:string',
'session'=>'xsd:string',
'portalname'=>'xsd:string',
'portalurl'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'create_rss_from_webform',
array('username'=>'xsd:string',
'session'=>'xsd:string',
'rssurl'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'create_contacts',
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'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'create_account',
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'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'create_ticket_from_toolbar',
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'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'create_vendor_from_webform',
array('username'=>'xsd:string',
'session'=>'xsd:string',
'vendorname'=>'xsd:string',
'email'=>'xsd:string',
'phone'=>'xsd:string',
'website'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'create_product_from_webform',
array('username'=>'xsd:string',
'session'=>'xsd:string',
'productname'=>'xsd:string',
'productcode'=>'xsd:string',
'website'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'create_note_from_webform',
array('username'=>'xsd:string',
'session'=>'xsd:string',
'title'=>'xsd:string',
'notecontent'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'LogintoVtigerCRM',
array('user_name'=>'xsd:string','password'=>'xsd:string','version'=>'xsd:string'),
array('return'=>'tns:logindetails'),
$NAMESPACE);
$server->register(
'CheckLeadPermission',
array('username'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'CheckContactPermission',
array('username'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'CheckAccountPermission',
array('username'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'CheckTicketPermission',
array('username'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'CheckVendorPermission',
array('username'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'CheckProductPermission',
array('username'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'CheckNotePermission',
array('username'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'CheckSitePermission',
array('username'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'CheckRssPermission',
array('username'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'GetPicklistValues',
array('username'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'tns:combo_values_array'),
$NAMESPACE);
$server->wsdl->addComplexType(
'combo_values_array',
'complexType',
'array',
'',
array(
'productid' => array('name'=>'productid','type'=>'tns:xsd:string'),
'productname' => array('name'=>'productname','type'=>'tns:xsd:string'),
'ticketpriorities' => array('name'=>'ticketpriorities','type'=>'tns:xsd:string'),
'ticketseverities' => array('name'=>'ticketseverities','type'=>'tns:xsd:string'),
'ticketcategories' => array('name'=>'ticketcategories','type'=>'tns:xsd:string'),
'moduleslist' => array('name'=>'moduleslist','type'=>'tns:xsd:string'),
)
);
$server->wsdl->addComplexType(
'logindetails',
'complexType',
'array',
'',
array(
'return'=>'returnVal','type'=>'tns:xsd:string',
'session'=>'sessionId','type'=>'tns:xsd:string',
)
);
function CheckLeadPermission($username,$sessionid)
{
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("Leads","EditView") == "yes")
{
return "allowed";
}else
{
return "denied";
}
}
function CheckContactPermission($username,$sessionid)
{
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("Contacts","EditView") == "yes")
{
return "allowed";
}else
{
return "denied";
}
}
function CheckAccountPermission($username,$sessionid)
{
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("Accounts","EditView") == "yes")
{
return "allowed";
}else
{
return "denied";
}
}
function CheckTicketPermission($username,$sessionid)
{
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("HelpDesk","EditView") == "yes")
{
return "allowed";
}else
{
return "denied";
}
}
function CheckVendorPermission($username,$sessionid)
{
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("Vendors","EditView") == "yes")
{
return "allowed";
}else
{
return "denied";
}
}
function CheckProductPermission($username,$sessionid)
{
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("Products","EditView") == "yes")
{
return "allowed";
}else
{
return "denied";
}
}
function CheckNotePermission($username,$sessionid)
{
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("Documents","EditView") == "yes")
{
return "allowed";
}else
{
return "denied";
}
}
function CheckSitePermission($username,$sessionid)
{
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("Portal","EditView") == "yes")
{
return "allowed";
}else
{
return "denied";
}
}
function CheckRssPermission($username,$sessionid)
{
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("Rss","EditView") == "yes")
{
return "allowed";
}else
{
return "denied";
}
}
function create_site_from_webform($username,$sessionid,$portalname,$portalurl)
{
global $log;
global $adb;
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
require_once("modules/Portal/Portal.php");
if(isPermitted("Portals","EditView") == "yes")
{
$result = SavePortal($portalname,$portalurl);
$adb->println("Create New Portal from Web Form - Ends");
if($result != '')
return 'URL added successfully';
else
return "Portal creation failed. Try again";
}
else
{
return $accessDenied;
}
}
function LogintoVtigerCRM($user_name,$password,$version)
{
global $log,$adb;
require_once('modules/Users/Users.php');
include('vtigerversion.php');
if($version != $vtiger_current_version)
{
return array("VERSION",'00');
}
$return_access = array("FALSES",'00');
$objuser = new Users();
if($password != "")
{
$objuser->column_fields['user_name'] = $user_name;
$objuser->load_user($password);
if($objuser->is_authenticated())
{
$userid = $objuser->retrieve_user_id($user_name);
$sessionid = makeRandomPassword();
unsetServerSessionId($userid);
$sql="insert into vtiger_soapservice values(?,?,?)";
$result = $adb->pquery($sql, array($userid,'FireFox' ,$sessionid));
$return_access = array("TRUES",$sessionid);
}else
{
$return_access = array("FALSES",'00');
}
}else
{
//$server->setError("Invalid username and/or password");
$return_access = array("FALSES",'00');
}
$objuser = $objuser;
return $return_access;
}
function create_rss_from_webform($username,$sessionid,$url)
{
global $log;
global $adb;
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
require_once("modules/Rss/Rss.php");
$oRss = new vtigerRSS();
if(isPermitted("RSS","EditView") == "yes")
{
if($oRss->setRSSUrl($url))
{
if($oRss->saveRSSUrl($url) == false)
{
return "RSS feed addition failed. Try again";
}
else
{
return 'RSS feed added successfully.';
}
}else
{
return "Not a valid RSS Feed or your Proxy Settings is not correct. Try again";
}
}
else
{
return $accessDenied;
}
}
function create_note_from_webform($username,$sessionid,$subject,$desc)
{
global $log;
global $adb;
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
$adb->println("Create New Document from Web Form - Starts");
require_once("modules/Documents/Documents.php");
$focus = new Documents();
if(isPermitted("Documents","EditView") == "yes")
{
$focus->column_fields['notes_title'] = $subject;
$focus->column_fields['notecontent'] = $desc;
$focus->save("Documents");
$focus->retrieve_entity_info($focus->id,"Documents");
$adb->println("Create New Document from Web Form - Ends");
if($focus->id != '')
return 'Document added successfully.';
else
return "Document creation failed. Try again";
}
else
{
return $accessDenied;
}
}
function create_product_from_webform($username,$sessionid,$productname,$code,$website)
{
global $log;
global $adb;
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
$adb->println("Create New Product from Web Form - Starts");
require_once("modules/Products/Products.php");
if(isPermitted("Products","EditView") == "yes")
{
$focus = new Products();
$focus->column_fields['productname'] = $productname;
$focus->column_fields['productcode'] = $code;
$focus->column_fields['website'] = $website;
$focus->column_fields['assigned_user_id'] = $user_id;
$focus->column_fields['discontinued'] = "1";
$focus->save("Products");
$adb->println("Create New Product from Web Form - Ends");
if($focus->id != '')
return 'Product added successfully.';
else
return "Product creation failed. Try again";
}
else
{
return $accessDenied;
}
}
function create_vendor_from_webform($username,$sessionid,$vendorname,$email,$phone,$website)
{
global $log;
global $adb;
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
$adb->println("Create New Vendor from Web Form - Starts");
require_once("modules/Vendors/Vendors.php");
if(isPermitted("Vendors","EditView" ) == "yes")
{
$focus = new Vendors();
$focus->column_fields['vendorname'] = $vendorname;
$focus->column_fields['email'] = $email;
$focus->column_fields['phone'] = $phone;
$focus->column_fields['website'] = $website;
$focus->save("Vendors");
$focus->retrieve_entity_info($focus->id,"Vendors");
$adb->println("Create New Vendor from Web Form - Ends");
if($focus->id != '')
return 'Vendor added successfully';
else
return "Vendor creation failed. Try again";
}
else
{
return $accessDenied;
}
}
function create_ticket_from_toolbar($username,$sessionid,$title,$description,$priority,$severity,$category,$user_name,$parent_id,$product_id)
{
global $log;
global $adb;
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("HelpDesk","EditView") == "yes")
{
$seed_ticket = new HelpDesk();
$output_list = Array();
require_once('modules/HelpDesk/HelpDesk.php');
$ticket = new HelpDesk();
$ticket->column_fields[ticket_title] = $title;
$ticket->column_fields[description]=$description;
$ticket->column_fields[ticketpriorities]=$priority;
$ticket->column_fields[ticketseverities]=$severity;
$ticket->column_fields[ticketcategories]=$category;
$ticket->column_fields[ticketstatus]='Open';
$ticket->column_fields[parent_id]=$parent_id;
$ticket->column_fields[product_id]=$product_id;
$ticket->column_fields[assigned_user_id]=$user_id;
//$ticket->saveentity("HelpDesk");
$ticket->save("HelpDesk");
if($ticket->id != '')
return "Ticket created successfully";
else
return "Error while creating Ticket.Try again";
}
else
{
return $accessDenied;
}
}
function create_account($username,$sessionid,$accountname,$email,$phone,$primary_address_street,$primary_address_city,$primary_address_state,$primary_address_postalcode,$primary_address_country)
{
if(!validateSession($username,$sessionid))
return null;
global $current_user,$log,$adb;
$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);
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id,'Users');
require_once("modules/Accounts/Accounts.php");
if(isPermitted("Accounts","EditView") == "yes")
{
$query = "SELECT accountname FROM vtiger_account,vtiger_crmentity WHERE accountname =? and vtiger_account.accountid = vtiger_crmentity.crmid and vtiger_crmentity.deleted != 1";
$result = $adb->pquery($query, array($accountname));
if($adb->num_rows($result) > 0)
{
return "Accounts";
die;
}
$account=new Accounts();
$account->column_fields['accountname']=$accountname;
$account->column_fields['email1']=$email;
$account->column_fields['phone']=$phone;
$account->column_fields['bill_street']=$primary_address_street;
$account->column_fields['bill_city']=$primary_address_city;
$account->column_fields['bill_state']=$primary_address_state;
$account->column_fields['bill_code']=$primary_address_postalcode;
$account->column_fields['bill_country']=$primary_address_country;
$account->column_fields['ship_street']=$primary_address_street;
$account->column_fields['ship_city']=$primary_address_city;
$account->column_fields['ship_state']=$primary_address_state;
$account->column_fields['ship_code']=$primary_address_postalcode;
$account->column_fields['ship_country']=$primary_address_country;
$account->column_fields['assigned_user_id']=$user_id;
$account->save('Accounts');
if($account->id != '')
return "Success";
else
return "Error while adding Account.Try again";
}
else
{
return $accessDenied;
}
}
function create_lead_from_webform($username,$sessionid,$lastname,$email,$phone,$company,$country,$description,$firstname)
{
global $log;
global $adb;
global $current_user;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
$adb->println("Create New Lead from Web Form - Starts");
require_once("modules/Leads/Leads.php");
$focus = new Leads();
if(isPermitted("Leads","EditView") == "yes")
{
$focus->column_fields['lastname'] = $lastname;
$focus->column_fields['firstname'] = $firstname;
$focus->column_fields['email'] = $email;
$focus->column_fields['phone'] = $phone;
$focus->column_fields['company'] = $company;
$focus->column_fields['country'] = $country;
$focus->column_fields['description'] = $description;
$focus->column_fields['assigned_user_id'] = $user_id;
$focus->save("Leads");
$adb->println("Create New Lead from Web Form - Ends");
if($focus->id != '')
return "Thank you for your interest. Information has been successfully added as Lead.";
else
return "Lead creation failed. Try again";
}
else
{
return $accessDenied;
}
}
function create_contacts($user_name,$sessionid,$firstname,$lastname,$phone,$mobile,$email,$street,$city,$state,$country,$zipcode)
{
global $log;
$log->DEBUG("Entering into create_contacts");
$birthdate = "";
if(!validateSession($user_name,$sessionid))
return null;
return create_contact1($user_name, $firstname, $lastname, $email,"", "","", $mobile, "",$street,$city,$state,$zipcode,$country,$city,$street,$state,$zipcode,$country,$phone,"","","","",$birthdate,"","");
}
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='')
{
global $adb,$log;
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');
require_once('modules/Contacts/Contacts.php');
if(isPermitted("Contacts","EditView") == "yes")
{
$contact = new Contacts();
$contact->column_fields[firstname]= $first_name;
$contact->column_fields[lastname]= $last_name;
//$contact->column_fields[account_id]=retrieve_account_id($account_name,$user_id);// NULL value is not supported NEED TO FIX
$contact->column_fields[salutation]=$salutation;
// EMAIL IS NOT ADDED
$contact->column_fields[title]=$title;
$contact->column_fields[email]=$email_address;
$contact->column_fields[mobile]=$phone_mobile;
//$contact->column_fields[reports_to_id] =retrievereportsto($reports_to,$user_id,$account_id);// NOT FIXED IN SAVEENTITY.PHP
$contact->column_fields[mailingstreet]=$primary_address_street;
$contact->column_fields[mailingcity]=$primary_address_city;
$contact->column_fields[mailingcountry]=$primary_address_country;
$contact->column_fields[mailingstate]=$primary_address_state;
$contact->column_fields[mailingzip]=$primary_address_postalcode;
$contact->column_fields[otherstreet]=$alt_address_street;
$contact->column_fields[othercity]=$alt_address_city;
$contact->column_fields[othercountry]=$alt_address_country;
$contact->column_fields[otherstate]=$alt_address_state;
$contact->column_fields[otherzip]=$alt_address_postalcode;
$contact->column_fields[assigned_user_id]=$user_id;
// new Fields
$contact->column_fields[phone]= $office_phone;
$contact->column_fields[homephone]= $home_phone;
$contact->column_fields[otherphone]= $other_phone;
$contact->column_fields[fax]= $fax;
$contact->column_fields[department]=$department;
$contact->column_fields[birthday]= DateTimeField::convertToUserFormat($birthdate);
$contact->column_fields[assistant]= $assistant_name;
$contact->column_fields[assistantphone]= $assistant_phone;
$contact->column_fields[description]= $description;
$contact->save("Contacts");
if($contact->id != '')
return 'Contact added successfully';
else
return "Contact creation failed. Try again";
}
else
{
return $accessDenied;
}
}
function GetPicklistValues($username,$sessionid,$tablename)
{
global $current_user,$log,$adb;
if(!validateSession($username,$sessionid))
return null;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($username);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id,'Users');
require_once("include/utils/UserInfoUtil.php");
$roleid = fetchUserRole($user_id);
require('user_privileges/user_privileges_'.$current_user->id.'.php');
if($is_admin == true || $profileGlobalPermission[1] == 0 || $profileGlobalPermission[2] == 0)
{
$query = "select " . $adb->sql_escape_string($tablename) . " from vtiger_". $adb->sql_escape_string($tablename);
$result1 = $adb->query($query);
for($i=0;$i<$adb->num_rows($result1);$i++)
{
$output[$i] = decode_html($adb->query_result($result1,$i,$tablename));
}
}
else if((isPermitted("HelpDesk","EditView") == "yes") && (CheckFieldPermission($tablename,'HelpDesk') == 'true'))
{
$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";
$result1 = $adb->pquery($query, array($roleid));
for($i=0;$i<$adb->num_rows($result1);$i++)
{
$output[$i] = decode_html($adb->query_result($result1,$i,$tablename));
}
}
else
{
$output[] = 'Not Accessible';
}
return $output;
}
function unsetServerSessionId($id)
{
global $adb;
$adb->println("Inside the function unsetServerSessionId");
$id = (int) $id;
$adb->query("delete from vtiger_soapservice where type='FireFox' and id=$id");
return;
}
function validateSession($username, $sessionid)
{
global $adb,$current_user;
$adb->println("Inside function validateSession($username, $sessionid)");
require_once("modules/Users/Users.php");
$seed_user = new Users();
$id = $seed_user->retrieve_user_id($username);
$server_sessionid = getServerSessionId($id);
$adb->println("Checking Server session id and customer input session id ==> $server_sessionid == $sessionid");
if($server_sessionid == $sessionid)
{
$adb->println("Session id match. Authenticated to do the current operation.");
return true;
}
else
{
$adb->println("Session id does not match. Not authenticated to do the current operation.");
return false;
}
}
function getServerSessionId($id)
{
global $adb;
$adb->println("Inside the function getServerSessionId($id)");
//To avoid SQL injection we are type casting as well as bound the id variable. In each and every function we will call this function
$id = (int) $id;
$query = "select * from vtiger_soapservice where type='FireFox' and id={$id}";
$sessionid = $adb->query_result($adb->query($query),0,'sessionid');
return $sessionid;
}
/* Begin the HTTP listener service and exit. */
if (!isset($HTTP_RAW_POST_DATA)){
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
}
$server->service($HTTP_RAW_POST_DATA);
exit();
?>
+664
View File
@@ -0,0 +1,664 @@
<?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','version'=>'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','password'=>'xsd:string','emailaddress'=>'xsd:string'),
array('return'=>'tns:contactdetails'),
$NAMESPACE);
$server->register(
'GetContacts',
array('username'=>'xsd:string','password'=>'xsd:string'),
array('return'=>'tns:contactdetails'),
$NAMESPACE);
$server->register(
'CheckContactPerm',array('user_name'=>'xsd:string','password'=>'xsd:string'),
array('return'=>'xsd:string'),$NAMESPACE);
$server->register(
'CheckContactViewPerm',array('user_name'=>'xsd:string','password'=>'xsd:string'),
array('return'=>'xsd:string'),$NAMESPACE);
$server->register(
'CheckContactEmailPerm',array('user_name'=>'xsd:string','password'=>'xsd:string'),
array('return'=>'xsd:string'),$NAMESPACE);
$server->register(
'CheckLeadViewPerm',array('user_name'=>'xsd:string','password'=>'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',
'password'=>'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',
'password'=>'xsd:string',
'description'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'track_email',
array('user_name'=>'xsd:string','password'=>'xsd:string', 'contact_ids'=>'xsd:string', 'date_sent'=>'xsd:string', '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,$password,$emailaddress)
{
if(authentication($username,$password))
{
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" => decode_html($contact[contactid]),
"firstname" => decode_html($contact[firstname]),
"lastname" => decode_html($contact[lastname]),
"emailaddress" => decode_html($contact[email]),
"accountname" => decode_html($contact[accountname]),
);
}
//to remove an erroneous compiler warning
$seed_contact = $seed_contact;
return $output_list;
}
}
function track_email($user_name,$password,$contact_ids, $date_sent, $email_subject, $email_body)
{
if(authentication($user_name,$password))
{
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 =?";
$result = $adb->pquery($query, array($user_id));
$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 = substr($date_sent,1,10);
$mydate = date('Y-m-d',$datesent);
$mydate = DateTimeField::convertToDBFormat($mydate);
$email->column_fields[subject] = $emailsubject;
$email->column_fields[assigned_user_id] = $user_id;
$email->column_fields[date_start] = $mydate;
$email->column_fields[description] = $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 and vtiger_field.presence in (0,2)";
$result = $adb->pquery($query, array());
$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=?";
$result = $adb->pquery($sql, array($contact_ids));
$camodulerow = $adb->fetch_array($result);
if(isset($camodulerow))
{
$emailid = $camodulerow["email"];
//added to save < as $lt; and > as &gt; in the database so as to retrive the emailID
$user_emailid = str_replace('<','&lt;',$user_emailid);
$user_emailid = str_replace('>','&gt;',$user_emailid);
$query = 'insert into vtiger_emaildetails values (?,?,?,?,?,?,?,?)';
$params = array($email->id, $emailid, $user_emailid, "", "", "", $user_id.'@-1|'.$contact_ids.'@'.$field_id.'|',"THUNDERBIRD");
$adb->pquery($query, $params);
}
return $email->id;
}
}
function GetContacts($username,$password)
{
if(authentication($username,$password))
{
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"] = "";
}
$output_list[] = Array(
"id" => decode_html($contact["id"]),
"title" => decode_html($contact["salutation"]),
"firstname" => decode_html($contact["firstname"]),
"middlename" => decode_html(trim($middlename)),
"lastname" => decode_html(trim($contact["lastname"])),
"birthdate" => $contact["birthday"],
"emailaddress" => decode_html($contact["email"]),
"jobtitle" => decode_html($contact["title"]),
"department" => decode_html($contact["department"]),
"accountname" => decode_html($contact["accountname"]),
"officephone" => decode_html($contact["phone"]),
"homephone" => decode_html($contact["homephone"]),
"otherphone" => decode_html($contact["otherphone"]),
"fax" => decode_html($contact["fax"]),
"mobile" => decode_html($contact["mobile"]),
"asstname" => decode_html($contact["assistant"]),
"asstphone" => decode_html($contact["assistantphone"]),
"reportsto" => decode_html($contact["reports_to_name"]),
"mailingstreet" => decode_html($contact["mailingstreet"]),
"mailingcity" => decode_html($contact["mailingcity"]),
"mailingstate" => decode_html($contact["mailingstate"]),
"mailingzip" => decode_html($contact["mailingzip"]),
"mailingcountry" => decode_html($contact["mailingcountry"]),
"otherstreet" => decode_html($contact["otherstreet"]),
"othercity" => decode_html($contact["othercity"]),
"otherstate" => decode_html($contact["otherstate"]),
"otherzip" => decode_html($contact["otherzip"]),
"othercountry" => decode_html($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;
}
$db = PearDatabase::getInstance();
$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=?";
$result= $db->pquery($query, array($account_name)) 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="",$password,$description="")
{
if(authentication($user_name,$password))
{
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 and vtiger_field.presence in (0,2)";
$params1 = array();
} 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_field.presence in (0,2)";
$params1 = array();
if (count($profileList) > 0) {
$sql1 .= " and vtiger_profile2field.profileid in (". generateQuestionMarks($profileList) .")";
array_push($params1, $profileList);
}
}
$result1 = $adb->pquery($sql1, $params1);
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[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="",$password,$description="")
{
if(authentication($user_name,$password))
{
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 and vtiger_field.presence in (0,2)";
$params1 = array();
} 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_field.presence in (0,2)";
$params1 = array();
if (count($profileList) > 0) {
$sql1 .= " and vtiger_profile2field.profileid in (". generateQuestionMarks($profileList) .")";
array_push($params1, $profileList);
}
}
$result1 = $adb->pquery($sql1, $params1);
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[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[lane]=in_array('lane',$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,$version)
{
global $adb,$log;
$return_access = 'FALSES';
include('vtigerversion.php');
/* Make 5.0.4 plugins compatible with 5.1.0 */
if(version_compare($version,'5.0.4', '>=') === 1) {
return array("VERSION",'00');
}
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=? and user_password=?";
$result = $adb->pquery($query, array($user_name, $encrypted_password));
if($adb->num_rows($result) > 0)
{
$return_access = 'TRUES';
$log->debug("Logged in sucessfully from thunderbirdplugin");
}else
{
$return_access = 'FALSES';
$log->debug("Logged in failure from thunderbirdplugin");
}
}
else
{
$return_access = 'LOGIN';
$log->debug("Logged in failure from thunderbirdplugin");
}
}else
{
$return_access = 'FALSES';
$log->debug("Logged in failure from thunderbirdplugin");
}
return $return_access;
}
function authentication($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=? and user_password=?";
$log->DEBUG("Running Query is ".$query);
$result = $adb->pquery($query, array($user_name, $encrypted_password));
if($adb->num_rows($result) > 0)
{
return true;
}else
{
return false;
}
}
else
{
return false;
}
}else
{
return false;
}
return false;
}
function end_session($user_name)
{
return "Success";
}
function CheckContactPerm($user_name,$password)
{
if(authentication($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");
if(isPermitted("Contacts","EditView") == "yes")
{
return "allowed";
}else
{
return "denied";
}
}
}
function CheckContactEmailPerm($user_name,$password)
{
if(authentication($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") && (isPermitted("Emails","index") == "yes"))
{
return "allowed";
}else
{
return "notallowed";
}
}
}
function CheckContactViewPerm($user_name,$password)
{
if(authentication($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")
{
return "allowed";
}else
{
return "contact";
}
}
}
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";
}
}
/* Begin the HTTP listener service and exit. */
if (!isset($HTTP_RAW_POST_DATA)){
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
}
$server->service($HTTP_RAW_POST_DATA);
exit();
?>
File diff suppressed because it is too large Load Diff
+199
View File
@@ -0,0 +1,199 @@
<?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/HelpDesk/HelpDesk.php');
$log = &LoggerManager::getLogger('webforms');
//$serializer = new XML_Serializer();
$NAMESPACE = 'http://www.vtiger.com/vtigercrm/';
$server = new soap_server;
$server->configureWSDL('vtigersoap');
$server->register(
'create_lead_from_webform',
array(
'lastname'=>'xsd:string',
'email'=>'xsd:string',
'phone'=>'xsd:string',
'company'=>'xsd:string',
'country'=>'xsd:string',
'description'=>'xsd:string',
'assigned_user_id'=>'xsd:string'
),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'create_contact_from_webform',
array(
'first_name'=>'xsd:string',
'last_name'=>'xsd:string',
'email_address'=>'xsd:string',
'home_phone'=>'xsd:string',
'department'=>'xsd:string',
'description'=>'xsd:string',
'assigned_user_id'=>'xsd:string'
),
array('return'=>'xsd:string'),
$NAMESPACE);
$server->register(
'unsubscribe_email',
array(
'email_address'=>'xsd:string'
),
array('return'=>'xsd:string'),
$NAMESPACE);
/** function used to create lead from webform from the passed details
* @param string $lastname - last name of the lead
* @param string $email - email of the lead
* @param string $phone - phone number of the lead
* @param string $company - company name of the lead
* @param string $country - country name of the lead
* @param string $description - description to create a lead
* @param int $assigned_user_id - assigned to user for the lead
* return message success or failure about the lead creation
*/
function create_lead_from_webform($lastname, $email, $phone, $company, $country, $description, $assigned_user_id)
{
global $adb;
$adb->println("Create New Lead from Web Form - Starts");
if($assigned_user_id == '')
{
//if the user id is empty then assign it to the admin user
$assigned_user_id = $adb->query_result($adb->pquery("select id from vtiger_users where user_name=?", array('admin')),0,'id');
}
require_once("modules/Leads/Leads.php");
$focus = new Leads();
$focus->column_fields['lastname'] = $lastname;
$focus->column_fields['email'] = trim($email);
$focus->column_fields['phone'] = $phone;
$focus->column_fields['company'] = $company;
$focus->column_fields['country'] = $country;
$focus->column_fields['description'] = $description;
$focus->column_fields['assigned_user_id'] = $assigned_user_id;
$focus->save("Leads");
//$focus->retrieve_entity_info($focus->id,"Leads");
$adb->println("Create New Lead from Web Form - Ends");
if($focus->id != '')
$msg = 'Thank you for your interest. Information has been successfully added as Lead in vtigerCRM.';
else
$msg = "Lead creation failed. Please try again";
return $msg;
}
/** function used to create contact from webform from the passed details
* @param string $first_name - first name to create contact
* @param string $last_name - last name to create contact
* @param string $email_address - email address to create contact
* @param string $home_phone - phone number of home to create contact
* @param string $department - department to create contact
* @param string $description - description to create contact
* @param int $assigned_user_id - assigned to user for the contact
* return message success or failure about the contact creation
*/
function create_contact_from_webform($first_name, $last_name, $email_address, $home_phone, $department,$description, $assigned_user_id)
{
global $adb;
$adb->println("Create New Contact from Web Form - Starts");
if($assigned_user_id == '')
{
//if the user id is empty then assign it to the admin user
$assigned_user_id = $adb->query_result($adb->pquery("select id from vtiger_users where user_name=?", array('admin')),0,'id');
}
require_once('modules/Contacts/Contacts.php');
$focus = new Contacts();
$focus->column_fields['firstname'] = $first_name;
$focus->column_fields['lastname'] = $last_name;
$focus->column_fields['email'] = trim($email_address);
$focus->column_fields['homephone'] = $home_phone;
$focus->column_fields['department'] = $department;
$focus->column_fields['description'] = $description;
$focus->column_fields['assigned_user_id'] = $assigned_user_id;
$focus->save("Contacts");
//$focus->retrieve_entity_info($focus->id,"Contacts");
$adb->println("Create New Contact from Web Form - Ends");
if($focus->id != '')
$msg = 'Thank you for your interest. Information has been successfully added as Contact in vtigerCRM.';
else
$msg = "Contact creation failed. Please try again";
return $msg;
}
/** function used to unsubscribe the mail
* @param string $emailid - email address to unsubscribe
* return message about the success or failure status about the unsubscribe
*/
function unsubscribe_email($emailid)
{
global $adb;
$adb->println("Enter into the function unsubscribe_email($emailid)");
$emailid = trim($emailid);
$contact_res = $adb->pquery("select emailoptout from vtiger_contactdetails where email=?", array($emailid));
$contact_noofrows = $adb->num_rows($contact_res);
$emailoptout = $adb->query_result($contact_res,0,'emailoptout');
if($contact_noofrows > 0)
{
if($emailoptout != 1)
{
$adb->pquery("update vtiger_contactdetails set emailoptout=1 where email=?", array($emailid));
$msg = "You have been unsubscribed.";
}
else
{
$msg = "You are already unsubscribed.";
}
}
else
{
$msg = "There are no record available for this mail address.";
}
$adb->println("Exit from the function unsubscribe_email($emailid)");
return $msg;
}
//$log->fatal("In soap.php");
/* Begin the HTTP listener service and exit. */
$server->service($HTTP_RAW_POST_DATA);
exit();
?>
+431
View File
@@ -0,0 +1,431 @@
<?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'),
'secondaryemail' => array('name'=>'secondaryemail','type'=>'xsd:string'),
'website' => array('name'=>'website','type'=>'xsd:string'),
'lead_status' => array('name'=>'lead_status','type'=>'xsd:string'),
'rating' => array('name'=>'rating','type'=>'xsd:string'),
'employees' => array('name'=>'employees','type'=>'xsd:string'),
'address_street' => array('name'=>'address_street','type'=>'xsd:string'),
'address_city' => array('name'=>'address_city','type'=>'xsd:string'),
'address_state' => array('name'=>'address_state','type'=>'xsd:string'),
'address_postalcode' => array('name'=>'address_postalcode','type'=>'xsd:string'),
'address_country' => array('name'=>'address_country','type'=>'xsd:string'),
'description' => array('name'=>'description','type'=>'xsd:string'),
'deleted' => array('name'=>'deleted','type'=>'xsd:string'),
'converted' => array('name'=>'converted','type'=>'xsd:string'),
)
);
$server->wsdl->addComplexType(
'user_column_detail',
'complexType',
'array',
'',
array(
'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
'username' => array('name'=>'username','type'=>'xsd:string'),
'secondaryemail' => array('name'=>'secondaryemail','type'=>'xsd:string'),
'title' => array('name'=>'title','type'=>'xsd:string'),
'workphone' => array('name'=>'workphone','type'=>'xsd:string'),
'department' => array('name'=>'department','type'=>'xsd:string'),
'mobilephone' => array('name'=>'mobilephone','type'=>'xsd:string'),
'otherphone'=> array('name'=>'otherphone','type'=>'xsd:string'),
'fax' => array('name'=>'fax','type'=>'xsd:string'),
'email' => array('name'=>'email','type'=>'xsd:string'),
'homephone' => array('name'=>'homephone','type'=>'xsd:string'),
'otheremail' => array('name'=>'otheremail','type'=>'xsd:string'),
'street' => array('name'=>'street','type'=>'xsd:string'),
'city' => array('name'=>'city','type'=>'xsd:string'),
'state' => array('name'=>'state','type'=>'xsd:string'),
'code' => array('name'=>'code','type'=>'xsd:string'),
'country' => array('name'=>'country','type'=>'xsd:string'),
)
);
$server->wsdl->addComplexType(
'tickets_list_array',
'complexType',
'array',
'',
array(
'ticketid' => array('name'=>'ticketid','type'=>'xsd:string'),
'title' => array('name'=>'title','type'=>'xsd:string'),
'groupname' => array('name'=>'groupname','type'=>'xsd:string'),
'firstname' => array('name'=>'firstname','type'=>'xsd:string'),
'lastname' => array('name'=>'lastname','type'=>'xsd:string'),
'parent_id' => array('name'=>'parent_id','type'=>'xsd:string'),
'productid' => array('name'=>'productid','type'=>'xsd:string'),
'productname' => array('name'=>'productname','type'=>'xsd:string'),
'priority' => array('name'=>'priority','type'=>'xsd:string'),
'severity' => array('name'=>'severity','type'=>'xsd:string'),
'status' => array('name'=>'status','type'=>'xsd:string'),
'category' => array('name'=>'category','type'=>'xsd:string'),
'description' => array('name'=>'description','type'=>'xsd:string'),
'solution' => array('name'=>'solution','type'=>'xsd:string'),
'createdtime' => array('name'=>'createdtime','type'=>'xsd:string'),
'modifiedtime' => array('name'=>'modifiedtime','type'=>'xsd:string'),
)
);
$server->register(
'get_contacts_columns',
array('user_name'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'tns:contact_column_detail'),
$NAMESPACE);
$server->register(
'get_accounts_columns',
array('user_name'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'tns:account_column_detail'),
$NAMESPACE);
$server->register(
'get_leads_columns',
array('user_name'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'tns:lead_column_detail'),
$NAMESPACE);
$server->register(
'get_user_columns',
array('user_name'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'tns:user_column_detail'),
$NAMESPACE);
$server->register(
'get_tickets_columns',
array('user_name'=>'xsd:string','session'=>'xsd:string'),
array('return'=>'tns:tickets_list_array'),
$NAMESPACE);
$server->register(
'create_session',
array('user_name'=>'xsd:string','password'=>'xsd:string','version'=>'xsd:string'),
array('return'=>'xsd:string','session'=>'xsd:string'),
$NAMESPACE);
$server->register(
'end_session',
array('user_name'=>'xsd:string'),
array('return'=>'xsd:string'),
$NAMESPACE);
function get_tickets_columns($user_name, $session)
{
if(!validateSession($user_name,$session))
return null;
global $current_user,$log;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($user_name);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("HelpDesk","index") == "yes")
{
require_once('modules/HelpDesk/HelpDesk.php');
$helpdesk = new HelpDesk();
$log->debug($helpdesk->getColumnNames_Hd());
return $helpdesk->getColumnNames_Hd();
}
else
{
$return_array = array();
return $return_array;
}
}
function get_contacts_columns($user_name, $session)
{
if(!validateSession($user_name,$session))
return null;
global $current_user,$log;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($user_name);
$current_user = $seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("Contacts","index") == "yes")
{
require_once('modules/Contacts/Contacts.php');
$contact = new Contacts();
$log->debug($contact->getColumnNames());
return $contact->getColumnNames();
}
else
{
$return_array = array();
return $return_array;
}
}
function get_accounts_columns($user_name, $session)
{
if(!validateSession($user_name,$session))
return null;
global $current_user,$log;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($user_name);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("Accounts","index") == "yes")
{
require_once('modules/Accounts/Accounts.php');
$account = new Accounts();
$log->debug($account->getColumnNames_Acnt());
return $account->getColumnNames_Acnt();
}
else
{
$return_array = array();
return $return_array;
}
}
function get_leads_columns($user_name, $session)
{
if(!validateSession($user_name,$session))
return null;
global $current_user,$log;
require_once("modules/Users/Users.php");
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($user_name);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
if(isPermitted("Leads","index") == "yes")
{
require_once('modules/Leads/Leads.php');
$lead = new Leads();
$log->debug($lead->getColumnNames_Lead());
return $lead->getColumnNames_Lead();
}
else
{
$return_array = array();
return $return_array;
}
}
function get_user_columns($user_name, $session)
{
if(!validateSession($user_name,$session))
return null;
global $current_user;
require_once('modules/Users/Users.php');
$seed_user=new Users();
$user_id=$seed_user->retrieve_user_id($user_name);
$current_user=$seed_user;
$current_user->retrieve_entity_info($user_id, 'Users');
$user = new Users();
return $user->getColumnNames_User();
}
function create_session($user_name, $password,$version)
{
global $log,$adb;
require_once('modules/Users/Users.php');
include('vtigerversion.php');
/* Make 5.0.4 plugins compatible with 5.1.0 */
if(version_compare($version,'5.0.4', '>=') === 1) {
return array("VERSION",'00');
}
$return_access = array("FALSES",'00');
$objuser = new Users();
if($password != "")
{
$objuser->column_fields['user_name'] = $user_name;
$objuser->load_user($password);
if($objuser->is_authenticated())
{
$userid = $objuser->retrieve_user_id($user_name);
$sessionid = makeRandomPassword();
unsetServerSessionId($userid);
$sql="insert into vtiger_soapservice values(?,?,?)";
$result = $adb->pquery($sql, array($userid,'Office',$sessionid));
$return_access = array("TRUE",$sessionid);
}else
{
$return_access = array("FALSE",'00');
}
}else
{
//$server->setError("Invalid username and/or password");
$return_access = array("LOGIN",'00');
}
$objuser = $objuser;
return $return_access;
}
function end_session($user_name)
{
return "Success";
}
function unsetServerSessionId($id)
{
global $adb;
$adb->println("Inside the function unsetServerSessionId");
$id = (int) $id;
$adb->query("delete from vtiger_soapservice where type='Office' and id=$id");
return;
}
function validateSession($username, $sessionid)
{
global $adb,$current_user;
$adb->println("Inside function validateSession($username, $sessionid)");
require_once("modules/Users/Users.php");
$seed_user = new Users();
$id = $seed_user->retrieve_user_id($username);
$server_sessionid = getServerSessionId($id);
$adb->println("Checking Server session id and customer input session id ==> $server_sessionid == $sessionid");
if($server_sessionid == $sessionid)
{
$adb->println("Session id match. Authenticated to do the current operation.");
return true;
}
else
{
$adb->println("Session id does not match. Not authenticated to do the current operation.");
return false;
}
}
function getServerSessionId($id)
{
global $adb;
$adb->println("Inside the function getServerSessionId($id)");
//To avoid SQL injection we are type casting as well as bound the id variable. In each and every function we will call this function
$id = (int) $id;
$query = "select * from vtiger_soapservice where type='Office' and id={$id}";
$sessionid = $adb->query_result($adb->query($query),0,'sessionid');
return $sessionid;
}
/* Begin the HTTP listener service and exit. */
if (!isset($HTTP_RAW_POST_DATA)){
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
}
$server->service($HTTP_RAW_POST_DATA);
exit();
?>
+1
View File
@@ -0,0 +1 @@
uploads
+15
View File
@@ -0,0 +1,15 @@
<?php
//This file contains the commonly used variables
$tab_info_array=array('Dashboard'=>1,'Potentials'=>2,'Home'=>3,'Contacts'=>4,'Accounts'=>6,'Leads'=>7,'Documents'=>8,'Calendar'=>9,'Emails'=>10,'HelpDesk'=>13,'Products'=>14,'Faq'=>15,'Events'=>16,'Vendors'=>18,'PriceBooks'=>19,'Quotes'=>20,'PurchaseOrder'=>21,'SalesOrder'=>22,'Invoice'=>23,'Rss'=>24,'Reports'=>25,'Campaigns'=>26,'Portal'=>27,'Webmails'=>28,'Users'=>29,'ConfigEditor'=>30,'Import'=>31,'Integration'=>32,'MailManager'=>33,'Mobile'=>34,'ModTracker'=>35,'PBXManager'=>36,'ServiceContracts'=>37,'Services'=>38,'VtigerBackup'=>39,'WSAPP'=>40,'Assets'=>41,'CronTasks'=>42,'CustomerPortal'=>43,'FieldFormulas'=>44,'ModComments'=>45,'ProjectMilestone'=>46,'ProjectTask'=>47,'Project'=>48,'RecycleBin'=>49,'SMSNotifier'=>50,'Tooltip'=>51,'Webforms'=>52,);
$tab_seq_array=array('1'=>0,'2'=>0,'3'=>0,'4'=>0,'6'=>0,'7'=>0,'8'=>0,'9'=>0,'10'=>0,'13'=>0,'14'=>0,'15'=>0,'16'=>2,'18'=>0,'19'=>0,'20'=>0,'21'=>0,'22'=>0,'23'=>0,'24'=>0,'25'=>0,'26'=>0,'27'=>0,'28'=>0,'29'=>0,'30'=>0,'31'=>0,'32'=>0,'33'=>0,'34'=>0,'35'=>0,'36'=>0,'37'=>0,'38'=>0,'39'=>0,'40'=>0,'41'=>0,'42'=>0,'43'=>0,'44'=>0,'45'=>0,'46'=>0,'47'=>0,'48'=>0,'49'=>0,'50'=>0,'51'=>0,'52'=>0,);
$tab_ownedby_array=array('1'=>1,'2'=>0,'3'=>1,'4'=>0,'6'=>0,'7'=>0,'8'=>0,'9'=>0,'10'=>1,'13'=>0,'14'=>0,'15'=>1,'16'=>0,'18'=>1,'19'=>1,'20'=>0,'21'=>0,'22'=>0,'23'=>0,'24'=>1,'25'=>1,'26'=>0,'27'=>1,'28'=>1,'29'=>1,'30'=>0,'31'=>0,'32'=>0,'33'=>0,'34'=>0,'35'=>0,'36'=>0,'37'=>0,'38'=>0,'39'=>0,'40'=>0,'41'=>0,'42'=>0,'43'=>0,'44'=>0,'45'=>0,'46'=>0,'47'=>0,'48'=>0,'49'=>0,'50'=>0,'51'=>0,'52'=>0,);
$action_id_array=array('Save'=>0,'SavePriceBook'=>0,'SaveVendor'=>0,'DetailViewAjax'=>1,'EditView'=>1,'PriceBookEditView'=>1,'QuickCreate'=>1,'VendorEditView'=>1,'Delete'=>2,'DeletePriceBook'=>2,'DeleteVendor'=>2,'index'=>3,'Popup'=>3,'DetailView'=>4,'PriceBookDetailView'=>4,'TagCloud'=>4,'VendorDetailView'=>4,'Import'=>5,'Export'=>6,'Merge'=>8,'ConvertLead'=>9,'DuplicatesHandling'=>10);
$action_name_array=array(0=>'Save',1=>'EditView',2=>'Delete',3=>'index',4=>'DetailView',5=>'Import',6=>'Export',8=>'Merge',9=>'ConvertLead',10=>'DuplicatesHandling');
?>