It definitely is possible. I've done the same thing. I copied the lead capture form in the modules\Leads directory and created a contactCapture.php file in the root sugar directory with the contents:
PHP Code:
<?php
if(!defined('sugarEntry'))define('sugarEntry', true);
require_once('include/entryPoint.php');
require_once('include/utils.php');
require_once('modules/Contacts/ContactFormBase.php');
global $app_strings, $app_list_strings;
$mod_strings = return_module_language($sugar_config['default_language'], 'Contacts');
$app_list_strings['record_type_module'] = array('Contact'=>'Contacts', 'Account'=>'Accounts', 'Opportunity'=>'Opportunities', 'Case'=>'Cases', 'Note'=>'Notes', 'Call'=>'Calls', 'Email'=>'Emails', 'Meeting'=>'Meetings', 'Task'=>'Tasks', 'Contact'=>'Contacts','Bug'=>'Bugs',);
$users = array(
'FORMUSERHEREr' => array('name'=>'FORMUSERHERE', 'pass'=>'USERHASHHERE'),
);
if (!empty($_POST['user']) && !empty($users[$_POST['user']])) {
require_once('modules/Users/User.php');
$current_user = new User();
$current_user->user_name = $users[$_POST['user']]['name'];
if($current_user->authenticate_user($users[$_POST['user']]['pass'])){
$userid = $current_user->retrieve_user_id($users[$_REQUEST['user']]['name']);
$current_user->retrieve($userid);
$contactForm = new ContactFormBase();
$prefix = '';
if(!empty($_POST['prefix'])){
$prefix = $_POST['prefix'];
}
$_POST['record'] ='';
if( isset($_POST['_splitName']) ) {
$name = explode(' ',$_POST['name']);
if(sizeof($name) == 1) {
$_POST['first_name'] = ''; $_POST['last_name'] = $name[0];
}
else {
$_POST['first_name'] = $name[0]; $_POST['last_name'] = $name[1];
}
}
$return_val = $contactForm->handleSave($prefix, false, true);
if(isset($_POST['redirect']) && !empty($_POST['redirect'])){
//header("Location: ".$_POST['redirect']);
echo '<html><head><title>SugarCRM</title></head><body>';
echo '<form name="redirect" action="' .$_POST['redirect']. '" method="POST">';
foreach($_POST as $param => $value) {
if($param != 'redirect' || $param != 'submit') {
echo '<input type="hidden" name="'.$param.'" value="'.$value.'">';
}
}
if( ($return_val == '') || ($return_val == 0) || ($return_val < 0) ) {
echo '<input type="hidden" name="error" value="1">';
}
echo '</form><script language="javascript" type="text/javascript">document.redirect.submit();</script>';
echo '</body></html>';
}
else{
echo "Thank You For Your Submission.";
}
sugar_cleanup();
// die to keep code from running into redirect case below
die();
}
}
echo "We're sorry, the server is currently unavailable, please try again later.";
if (!empty($_POST['redirect'])) {
echo '<html><head><title>SugarCRM</title></head><body>';
echo '<form name="redirect" action="' .$_POST['redirect']. '" method="POST">';
echo '</form><script language="javascript" type="text/javascript">document.redirect.submit();</script>';
echo '</body></html>';
}
?>
And then my action from my external site on the form submits to that page:
action="...../sugar/contactCapture.php"
Bookmarks