// $PASSWORD - variable that contains your Salesforce.com password $USERNAME = $_SERVER['USERNAME']; $PASSWORD = $_SERVER['PASSWORD']; define('SOAP_CLIENT_BASEDIR', '../vendor/soapclient.repo/soapclient'); require_once SOAP_CLIENT_BASEDIR . '/SforceEnterpriseClient.php'; function guid() { mt_srand((double) microtime() * 10000); // optional for php 4.2.0 and up. $charid = strtoupper(md5(uniqid(rand(), true))); $hyphen = ''; //chr(45); // "-" $uuid = '' . substr($charid, 0, 8) . $hyphen . substr($charid, 8, 4) . $hyphen . substr($charid, 12, 4) . $hyphen . substr($charid, 16, 4) . $hyphen . substr($charid, 20, 12); // "}" return $uuid; } try { $mySforceConnection = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR . '/enterprise.wsdl.xml'); $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD); $query = 'SELECT Id, Name, TimeZoneSidKey from User where UseICalForce__c = true'; $response = $mySforceConnection->query($query); echo "<?php\n\n"; echo "\$ICALFORCEWHITELIST_19b70db3_f172_40eb_910c_f356365166c1 = array(\n"; foreach ($response->records as $user) { echo " '", substr($user->Id, 0, 15), "' => array('pub-token' => '", guid(), "'),\n"; } echo ");\n\n"; } catch (Exception $e) { echo $e; }
echo "Order Insert Statement<br>"; print_r($orderInsert);*/ /**** Look-Up Relation Inserts ****/ /*$Product = array(); $Product[0] = new stdclass(); if(isset($orderInsert[0]) && $orderInsert[0]->success==1){ $Product[0]->OrderId__c = $orderInsert[0]->id; $Product[0]->ProductName__c = 'Product 1'; $Product[0]->PurchaseAmount__c = '2000.00'; $Product[0]->Tax__c = '500.00'; $ProductInsert = $mySforceConnection->create($Product,'OrderDetail__c'); echo "Order Insert<br>"; print_r($ProductInsert); }*/ $query = "SELECT Id, FirstName, LastName, Phone from Contact"; $response = $mySforceConnection->query($query); echo '<pre>'; //print_r( $response ); echo '</pre>'; echo "Turtalbox Testing <br><pre>"; //$qryGetZip = " SELECT ID FROM Zipcode__c"; $qryGetProd = "SELECT Choose_Your_Product__c FROM Product__c WHERE Number_of_Boxes__c = 3"; //Choose_Your_Product__c = 'a05b0000007rm9j'"; //$qryGetProd = 'select id, IsAllDayEvent, Description from Event'; $rsPro = $mySforceConnection->query($qryGetProd); print_r($rsPro->records); $pid = $rsPro->records[0]->Id; // GET Product From Warehouse_Products Table $ProductName = 'Kleiderbox'; $qryGetWarProd = " SELECT ID FROM Warehouse_Product__c WHERE Name = '" . $ProductName . "' "; $rsWarPro = $mySforceConnection->query($qryGetWarProd);
$records = array(); $records[0] = new stdclass(); if (isset($list_v['fields']) && $list_v['fields']) { foreach ($list_v['fields'] as $field_v) { $records[0]->{$field_v['list_field_id']} = getElementValue($field_v['element_id']); } try { $sf_addcontact = true; if ($list_v['preventduplicates'] || $list_v['updateexistingcontact'] && !empty($list_v['filterduplicates'])) { $sf_contact_exists_where = ''; foreach ($list_v['filterduplicates'] as $filterduplicates_v) { $sf_contact_exists_where .= $filterduplicates_v . '=\'' . addcslashes($element_ids_values[$list_v['fields_by_id'][$filterduplicates_v]]['element_value'][0], "'") . '\' AND '; } $sf_contact_exists_where = substr($sf_contact_exists_where, 0, -4); $sf_contact_exists_req = 'SELECT Id from ' . $list_id . ' WHERE ' . $sf_contact_exists_where; $sf_contact_exists_res = $mySforceConnection->query($sf_contact_exists_req); if ($contactform_obj->cfg['debug']) { echo $sf_contact_exists_req . "\r\n"; echo 'Exist_res:' . "\r\n"; print_r($sf_contact_exists_res->records); echo "\r\n"; } if ($list_v['preventduplicates'] && $sf_contact_exists_res->records) { $sf_addcontact = false; } else { if ($contactform_obj->cfg['debug']) { echo 'NO RES CONTACT'; } } } if ($contactform_obj->cfg['debug']) {
function printSfiCalendar($userName, $pass, $ownerId, $baseUrl, $showDetail) { function calguid($str) { $charid = strtoupper(md5($str)); $hyphen = chr(45); // "-" $uuid = "" . substr($charid, 0, 8) . $hyphen . substr($charid, 8, 4) . $hyphen . substr($charid, 12, 4) . $hyphen . substr($charid, 16, 4) . $hyphen . substr($charid, 20, 12); return $uuid; } function get_timezone_offset($remote_tz, $origin_tz = null) { if ($origin_tz === null) { if (!is_string($origin_tz = date_default_timezone_get())) { return false; // A UTC timestamp was returned -- bail out! } } $origin_dtz = new DateTimeZone($origin_tz); $remote_dtz = new DateTimeZone($remote_tz); $origin_dt = new DateTime("now", $origin_dtz); $remote_dt = new DateTime("now", $remote_dtz); $offset = $origin_dtz->getOffset($origin_dt) - $remote_dtz->getOffset($remote_dt); return $offset; } function escapeText($s) { $v = str_replace("\r\n", "\n", $s); $v = str_replace("\r", "\n", $s); $v = str_replace("\t", " ", $v); $v = str_replace("\v", " ", $v); $v = str_replace("\\", "\\\\", $v); $v = str_replace("\n", "\\n", $v); $v = str_replace(";", "\\;", $v); $v = str_replace(",", "\\,", $v); return $v; } try { $calGuid = calguid($userName . $ownerId); $mySforceConnection = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR . '/enterprise.wsdl.xml'); $mylogin = $mySforceConnection->login($userName, $pass); $nowDate = new DateTime(); $startDate = clone $nowDate; $startDate = $startDate->sub(new DateInterval('P366D')); $endDate = clone $nowDate; $endDate = $endDate->add(new DateInterval('P400D')); $query = 'SELECT Id, Name, TimeZoneSidKey from User where Id = \'' . $ownerId . '\''; $users = $mySforceConnection->query($query); if (count($users->records) == 0) { header('HTTP/1.1 403 Forbidden'); echo 'no data'; exit; } $query = ' SELECT Id , Subject , ActivityDateTime , StartDateTime , EndDateTime , Location ' . ($showDetail ? ' , Description ' : '') . ' , IsAllDayEvent , OwnerId from Event where OwnerId = \'' . $ownerId . '\' and StartDateTime >= ' . gmdate('Y-m-d\\TH:i:s\\Z', $startDate->getTimestamp()) . ' and StartDateTime < ' . gmdate('Y-m-d\\TH:i:s\\Z', $endDate->getTimestamp()) . ' order by StartDateTime limit 10000'; $response = $mySforceConnection->query($query); header("Cache-Control: no-cache"); header('Content-type: text/plain; charset=utf-8'); //header('Content-Disposition: attachment; filename="' . $calGuid . '.ics"'); $tzoffset = get_timezone_offset('UTC', $users->records[0]->TimeZoneSidKey); $tzoffset = (int) ($tzoffset / 3600) * 100 + (int) ($tzoffset / 60) % 60; echo "BEGIN:VCALENDAR\r\n", "PRODID:My Cal\r\n", "VERSION:2.0\r\n", "METHOD:PUBLISH\r\n", "CALSCALE:GREGORIAN\r\n", "BEGIN:VTIMEZONE\r\n", "TZID:", $users->records[0]->TimeZoneSidKey, "\r\n", "BEGIN:STANDARD\r\n", "DTSTART:19700101T000000Z\r\n", "TZOFFSETFROM:", sprintf('%1$+05d', $tzoffset), "\r\n", "TZOFFSETTO:", sprintf('%1$+05d', $tzoffset), "\r\n", "END:STANDARD\r\n", "END:VTIMEZONE\r\n", "X-WR-CALNAME:", escapeText($users->records[0]->Name), "'s calendar\r\n", "X-WR-CALDESC:", escapeText($users->records[0]->Name), "'s calendar\r\n", "X-WR-RELCALID:", $calGuid, "\r\n", "X-WR-TIMEZONE:Asia/Tokyo\r\n"; foreach ($response->records as $record) { $dateFmt = 'Ymd\\THis\\Z'; $timeAdd = 0; if ($record->IsAllDayEvent) { $dateFmt = 'Ymd'; $timeAdd = 3600 * 24; } echo "BEGIN:VEVENT\r\n", "UID:mycal/", $calGuid, "/", $record->Id, "\r\n", !$record->IsAllDayEvent ? "DTSTAMP:" . gmdate('Ymd\\THis\\Z', strtotime($record->StartDateTime)) . "\r\n" : '', "DTSTART:", gmdate($dateFmt, strtotime($record->StartDateTime)), "\r\n", "DTEND:", gmdate($dateFmt, strtotime($record->EndDateTime) + $timeAdd), "\r\n", "SUMMARY:", escapeText($record->Subject), "\r\n", "DESCRIPTION:", $baseUrl, "/", $record->Id, $showDetail && isset($record->Description) ? '\\n\\n' . escapeText($record->Description) : '', "\r\n", "LOCATION:", isset($record->Location) ? escapeText($record->Location) : '', "\r\n", "END:VEVENT\r\n"; } echo "END:VCALENDAR\r\n"; } catch (Exception $e) { echo $e; exit; } }
function salesforce_save_choice() { global $avail_id; $IDU = $_POST['idu']; $IDU_Type = $_POST['idu_type']; $chosen_start = $_POST['chosen_start']; $chosen_end = $_POST['chosen_end']; $chosen_offset = $_POST['chosen_offset']; $avail_id = $_POST['avail_id']; $utc_offset = $_POST['utc_offset']; $userPhonenumber = $_POST['userPhonenumber']; $userNotes = $_POST['userNotes']; $id_opp = $_POST['id_opp']; $nonce = $_POST['nonce']; if (check_ajax_referer('save-choice', $nonce, false)) { echo $nonce; die('Security Check:'); } else { //nonce check passed if ($avail_id == '') { echo 'no id'; return; } $server_base = $_SERVER['DOCUMENT_ROOT']; define("SOAP_CLIENT_BASEDIR", "{$server_base}/wp-content/Force.com-Toolkit-for-PHP-master/soapclient"); require_once SOAP_CLIENT_BASEDIR . '/SforceEnterpriseClient.php'; require_once "{$server_base}/wp-content/Force.com-Toolkit-for-PHP-master/samples/userAuth.php"; ini_set("soap.wsdl_cache_enabled", "0"); $mySforceConnection = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR . '/enterprise.wsdl.xml'); $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD); // $ID=$_GET['ID']; $query = "SELECT Id,Json_Times__c From Conference_Call__c WHERE Id='{$avail_id}'"; $response = $mySforceConnection->query($query); foreach ($response->records as $record) { $json_times = $record->Json_Times__c; } $date_start = explode('T', $chosen_start); $date_start = $date_start[0]; $date_start = $date_start . "T"; $temp = explode($date_start, $json_times); $temp = $temp[1]; $offset_hour = intval(substr($temp, 9, 2)) * 60 / -1; $sObject1 = new stdClass(); $sObject1->Time_start__c = $chosen_start; $sObject1->Time_end__c = $chosen_end; if ($IDU_Type == 'Expert') { $sObject1->Timezone_Expert__c = $chosen_offset; $sObject1->Expert_Phone_Call__c = $userPhonenumber; $sObject1->Expert_Call_Note__c = $userNotes; $sObject1->Timezone_Contact__c = $offset_hour; } if ($IDU_Type == 'Attorney') { $sObject1->Timezone_Expert__c = $offset_hour; $sObject1->Timezone_Contact__c = $chosen_offset; $sObject1->Contact_Phone_Call__c = $userPhonenumber; $sObject1->Client_Call_Info__c = $userNotes; } $sObject1->Status__c = 'Confirmed'; $sObject1->Id = $avail_id; $response = $mySforceConnection->update(array($sObject1), 'Conference_Call__c'); $sObject11 = new stdClass(); $sObject11->StageName = 'CC Scheduled'; $sObject11->Id = $id_opp; $response = $mySforceConnection->update(array($sObject11), 'Opportunity'); if ($IDU_Type == 'Expert') { $query = "SELECT Id, Expert__c,E_ID__c, Contact__c,Opportunity__c,Time_start_Contact__c,Start_Contact_Text__c From Conference_Call__c WHERE Id='{$avail_id}' "; $response = $mySforceConnection->query($query); foreach ($response->records as $record) { $utc_offset_client = $record->Timezone_Contact__c; $Time_client_start = $record->Time_start_Contact__c; $eid = $record->E_ID__c; $attorneyID = $record->Contact__c; $client_start = $record->Start_Contact_Text__c; $url = site_url(); $cc_link = "{$url}/scheduler/?ID={$record->Opportunity__c}&IDCC={$avail_id}&IDU={$attorneyID}"; $msg = "Conference Call Scheduled w/ Expert {$eid} for {$client_start}"; $sObject3 = new stdclass(); $sObject3->Expert__c = $record->Expert__c; $sObject3->Message__c = $msg; $sObject3->Opportunity__c = $record->Opportunity__c; $createResponse = $mySforceConnection->create(array($sObject3), 'Opportunity_Messages__c'); $id = $createResponse[0]; } } die; } }
function SF_Account_Upsert($entry, $form) { global $wpdb; $user_email = $entry[4]; ini_set("soap.wsdl_cache_enabled", "0"); $USERNAME = "******"; //- variable that contains your Salesforce.com username (must be in the form of an email) $PASSWORD = "******"; //- variable that contains your Salesforce.com password $TOKEN = "qhO7UhNTUrYp8XU5eF1SRomDp"; //- variable that contains your Salesforce.com password require_once ABSPATH . '/soapclient/SforceEnterpriseClient.php'; require_once ABSPATH . '/soapclient/SforceHeaderOptions.php'; // Salesforce Login information $wsdl = ABSPATH . '/soapclient/eSNenterprise.wsdl.xml'; $mySforceConnectionu = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnectionu->createConnection($wsdl); $mylogin = $mySforceConnectionu->login($USERNAME, $PASSWORD . $TOKEN); //determine site we are on - ecampus, eclassroom, or enews $sitesource = $entry[26]; $entrysubtype = $entry[21]; if ($entrysubtype == 'Print') { $pubsubtype = "Print"; $pubforid = 1; } else { $pubsubtype = "Digital"; $pubforid = 2; } if ($sitesource !== "") { $school = strpos($sitesource, "eschoolnews"); $campus = strpos($sitesource, "ecampusnews"); $classroom = strpos($sitesource, "eclassroomnews"); } else { $school = strpos($_SERVER["SERVER_NAME"], "eschoolnews"); $campus = strpos($_SERVER["SERVER_NAME"], "ecampusnews"); $classroom = strpos($_SERVER["SERVER_NAME"], "eclassroomnews"); } if ($school !== false) { $name = 'eSchoolNews ' . $pubsubtype . ' Subscription'; $linksource = "eschoolnews"; $pubforid = $pubforid . '1'; } elseif ($campus !== false) { $name = 'eCampusNews ' . $pubsubtype . ' Subscription'; $linksource = "ecampusnews"; $pubforid = $pubforid . '2'; } elseif ($classroom !== false) { $newSubReq["Name"] = 'eClassroomNews ' . $pubsubtype . ' Subscription'; $linksource = "eclassroomnews"; $pubforid = $pubforid . '3'; } else { $name = 'Unknown'; $linksource = "Unk"; $pubforid = $pubforid . '4'; } //query sfdc to see if user exists based on email address $sfaccountdataquery = "Select Id, WP_Unique_ID__c from Account where Email_as_ExternalID__c ='" . $user_email . "' and IsPersonAccount=true"; $sfaccountresponse = $mySforceConnectionu->query($sfaccountdataquery); $wp_id = ""; //create array for account to get upserted $newperson = array(); if (count($sfaccountresponse->records) > 0) { $wp_id = $sfaccountresponse->records[0]->WP_Unique_ID__c; } else { //see if user is in WP and get id $wp_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$WPDB->USERS} WHERE USER_EMAIL='" . $user_email . "'")); $newperson['Source__c'] = $_SERVER["SERVER_NAME"]; //only want to populate source when first creating person account } if (is_null($wp_id)) { $wp_id = $user_email; } $newperson['WP_Unique_ID__c'] = $wp_id; //query sfdc subscription request object to see if there is an existing pending subscription request $sfsubreqdataquery = "Select Id, wp_id__c, sub_status__c, Title__c, name from Subscription_Request__c where Email__c = '" . $user_email . "' and Sub_Status__c = 'Pending' and name = '" . $name . "'"; $sfsubreqresponse = $mySforceConnectionu->query($sfsubreqdataquery); if (count($sfsubreqresponse->records) > 0) { $wp_subreq_id = $pubforid . $sfsubreqresponse->records[0]->WP_ID__c; } else { //there is no sub request record, need to create an external id //echo 'No Pending'.PHP_EOL; $sfcountquery = "Select id from Subscription_Request__c where Email__c = '" . $user_email . "'"; $sfcountresponse = $mySforceConnectionu->query($sfcountquery); //echo 'count '.$sfcountresponse->size; $reccount = $sfcountresponse->size + 1; $wp_subreq_id = $pubforid . $user_email; //$wp_subreq_id = $pubforid . $reccount.$user_email; } //create new array for subscription request to be upserted $newSubReq = array(); $newSubReq['Source__c'] = "Web"; $newSubReq['WP_ID__c'] = substr($wp_subreq_id, 0, 20); //need to limit length to 20 characters //echo $newSubReq['WP_ID__c'].PHP_EOL.PHP_EOL; $newSubReq["Sub_Status__c"] = 'Pending'; $newSubReq['Personal_Question__c'] = "What was your high school mascot?"; $newSubReq['Request_URL__c'] = $_SERVER["SERVER_NAME"]; $newSubReq["Name"] = $name; $newSubReq['Request_Date__c'] = date("Y-m-d"); $sfFEIDquery = "Select feid__c, wp_id__c from Subscription_Request__c where Email__c = '" . $user_email . "' and Sub_Status__c = 'Processed' and name = '" . $name . "'"; $sfFEIDresponse = $mySforceConnectionu->query($sfFEIDquery); if (count($sfFEIDresponse->records) > 0) { //echo 'Processed Found'.PHP_EOL; //echo 'wp id = '.$sfFEIDresponse->records[0]->WP_ID__C.PHP_EOL; $newSubReq['FEID__c'] = $sfFEIDresponse->records[0]->FEID__c; } if (!empty($entry[4])) { //if (strpos($entry[4], 'esmnoemailsupplied') !== false) { $newperson['PersonEmail'] = $entry[4]; $newSubReq['Email__c'] = $entry[4]; $newperson['Email_as_ExternalID__c'] = $entry[4]; //12-20-2011 //} } if (!empty($entry[1])) { $newperson['FirstName'] = $entry[1]; $newSubReq['First_Name__c'] = $entry[1]; } if (!empty($entry[2])) { $newperson['LastName'] = $entry[2]; $newSubReq['Last_Name__c'] = $entry[2]; } if (!empty($entry[3])) { $newperson['Organization__c'] = $entry[3]; $newSubReq['Organization__c'] = $entry[3]; } if (!empty($entry[5])) { $newperson['PersonTitle'] = $entry[5]; $newSubReq['Title__c'] = $entry[5]; } if (!empty($entry[6])) { $newperson['Company_Type__c'] = $entry[6]; $newSubReq['Organization_Type__c'] = $entry[6]; } if (!empty($entry[7])) { $newperson['PersonMailingStreet'] = $entry[7]; $newSubReq['Address1__c'] = $entry[7]; } if (!empty($entry[8])) { $newperson['Mailing_Address_2__c'] = $entry[8]; $newSubReq['Address2__c'] = $entry[8]; } if (!empty($entry[9])) { $newperson['PersonMailingCity'] = $entry[9]; $newSubReq['city__c'] = $entry[9]; } if (!empty($entry[10])) { $newperson['PersonMailingState'] = $entry[10]; $newSubReq['State__c'] = $entry[10]; } if (!empty($entry[12])) { $newperson['PersonMailingPostalCode'] = $entry[12]; $newSubReq['Zip__c'] = $entry[12]; } if (!empty($entry[13])) { $newperson['PersonMailingCountry'] = $entry[13]; $newSubReq['Country__c'] = $entry[13]; } if (!empty($entry[22])) { $newperson['Phone'] = $entry[22]; $newSubReq['Phone__c'] = $entry[22]; } if (!empty($entry[23])) { $newperson['Grade_Level__c'] = $entry[23]; } if (!empty($entry[24])) { $newperson['Subject_Taught__c'] = $entry[24]; } if (!empty($entry[25])) { $newperson['Industry__c'] = $entry[25]; } if (!empty($entry[14])) { $newSubReq['Personal_Answer__c'] = $entry[14]; } if (!empty($entry[29])) { $newSubReq['Promo_Code__c'] = $entry[29]; } $upsertResponse = $mySforceConnectionu->upsert('Email_as_ExternalID__c', array($newperson), 'Account'); //echo '<pre> 189<br>'; //echo print_r($upsertResponse); //echo '</pre>'; if ($upsertResponse->success == 1) { update_user_meta($user_id, "sfid", $upsertResponse->id); $sfaccountdataquery = "Select Id, PersonContactId from Account where PersonEmail ='" . $entry[4] . "'"; $sfaccountresponse = $mySforceConnectionu->query($sfaccountdataquery); $sfAccountid = $sfaccountresponse->records[0]->Id; // echo '<pre> 195<br>'; //echo print_r($sfaccountresponse); //mail('*****@*****.**','SF Subscription upserted account', print_r($sfaccountresponse).print_r($sfAccountid)); //echo '</pre>'; //since upserted account successfully, now upsert sub request //get the person account id just created to use in the subscription request record $newSubReq['Person_Account__c'] = $sfAccountid; //need to set renewal link $isrenewal = strpos($entry[source_url], 'sfid'); if ($isrenewal !== false) { $renewalurl = substr($entry[source_url], 0, $isrenewal) . 'sfid=' . $sfAccountid . '&source=' . $linksource; } else { if (strpos($entry[source_url], '?' !== false)) { $renewalurl = $entry[source_url] . '&sfid=' . $sfAccountid . '&source=' . $linksource; } else { $renewalurl = $entry[source_url] . '?sfid=' . $sfAccountid . '&source=' . $linksource; } } $newSubReq['Renewal_Link__c'] = substr($renewalurl, 0, 254); $upsertResponse2 = $mySforceConnectionu->upsert('WP_ID__c', array($newSubReq), 'Subscription_Request__c'); //echo '<pre> 220<br>' . $Subscription_Request__c; //print_r($newSubReq); //print_r($sfaccountresponse); //echo '</pre>'; if ($upsertResponse2->success == 1) { print_r($sfaccountresponse); //mail('*****@*****.**','SF Subscription request upload success','we are ok'); } else { //mail('*****@*****.**','SF Subscription Request UPload FAILED', print_r($newSubReq).print_r($upsertResponse2)); } } else { //mail('*****@*****.**','SF Subscription form UPload FAILED',print_r($sfaccountresponse)); //mail('*****@*****.**','an SF Subscription account upload FAILED ','Email address that failed is '.$user_email); //echo '<pre> 236<br>'; //print_r($newSubReq); //print_r($sfaccountresponse); //echo '</pre>'; } }
<?php $id = $_GET['ID']; $IDU_Type = $_GET['IDU_Type']; define("SOAP_CLIENT_BASEDIR", "../../Force.com-Toolkit-for-PHP-master/soapclient"); require_once SOAP_CLIENT_BASEDIR . '/SforceEnterpriseClient.php'; require_once '../../Force.com-Toolkit-for-PHP-master/samples/userAuth.php'; ini_set("soap.wsdl_cache_enabled", "0"); $mySforceConnection = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR . '/enterprise.wsdl.xml'); $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD); $query1 = "SELECT Id,Name,E_ID__c,Opportunity_Name__c,Opportunity_Name_Expert__c,Time_end__c,Time_start__c from Conference_Call__c WHERE Id='{$id}'"; $response1 = $mySforceConnection->query($query1); foreach ($response1->records as $cc) { $start = str_replace('-', '', $cc->Time_start__c); $start = str_replace('.000', '', $start); $start = str_replace(':', '', $start); $start2 = str_replace('Z', '', $start); $end = str_replace('-', '', $cc->Time_end__c); $end = str_replace('.000', '', $end); $end = str_replace(':', '', $end); $end = str_replace('Z', '', $end); if ($IDU_Type == 'Attorney') { $cc_subject = "Expert {$cc->E_ID__c}"; } else { $cc_subject = 'Attorney'; } if ($IDU_Type == "Expert") { $file = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//www.theexpertinstitute.com//Conference Call Scheduling//EN\nX-WR-CALNAME:Conference Call\nCALSCALE:GREGORIAN\nBEGIN:VEVENT\nDTSTAMP:{$start}\nUID:{$cc->Name}\nDTSTART;TZID=\"Etc/UTC\":{$start2}\nDTEND;TZID=\"Etc/UTC\":{$end}\nSUMMARY:Conference call with {$cc_subject}\nDESCRIPTION:{$cc->Opportunity_Name_Expert__c} - Conference call with {$cc_subject}\nEND:VEVENT\nEND:VCALENDAR"; } else { $file = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//www.theexpertinstitute.com//Conference Call Scheduling//EN\nX-WR-CALNAME:Conference Call\nCALSCALE:GREGORIAN\nBEGIN:VEVENT\nDTSTAMP:{$start}\nUID:{$cc->Name}\nDTSTART;TZID=\"Etc/UTC\":{$start2}\nDTEND;TZID=\"Etc/UTC\":{$end}\nSUMMARY:Conference call with {$cc_subject}\nDESCRIPTION:{$cc->Opportunity_Name__c} - Conference call with {$cc_subject}\nEND:VEVENT\nEND:VCALENDAR";
function myplugin_registration_save($user_id) { $user_info = get_userdata($user_id); $email = "{$user_info->user_email}"; #$test=implode(" ",$user_info); $role = $user_info->roles[0]; $test = get_user_meta($user_id, 'role'); $test = implode(" ", $test); $server_base = $_SERVER['DOCUMENT_ROOT']; define("SOAP_CLIENT_BASEDIR", "{$server_base}/wp-content/Force.com-Toolkit-for-PHP-master/soapclient"); require_once SOAP_CLIENT_BASEDIR . '/SforceEnterpriseClient.php'; require_once "{$server_base}/wp-content/Force.com-Toolkit-for-PHP-master/samples/userAuth.php"; ini_set("soap.wsdl_cache_enabled", "0"); $mySforceConnection = new SforceEnterpriseClient(); $mySoapClient = $mySforceConnection->createConnection(SOAP_CLIENT_BASEDIR . '/enterprise.wsdl.xml'); $mylogin = $mySforceConnection->login($USERNAME, $PASSWORD); $found = 0; if ($role == 'Client' || $role == 'Expert') { $query = "SELECT Id,C_ID__c,AccountId,Account_Name__c,Email,Phone,LastName,FirstName,IsDeleted,MailingCity,MailingState,MailingCountry,MailingPostalCode from Contact WHERE Email='{$email}' AND IsDeleted=False LIMIT 1"; $response = $mySforceConnection->query($query); foreach ($response->records as $record) { $found = 1; update_user_meta($user_id, 'first_name', $record->FirstName); update_user_meta($user_id, 'last_name', $record->LastName); update_user_meta($user_id, 'account_name', $record->Account_Name__c); update_user_meta($user_id, 'id_sf_account', $record->AccountId); update_user_meta($user_id, 'id_sf_contact', $record->Id); update_user_meta($user_id, 'cid', $record->C_ID__c); wp_update_user(array('ID' => $user_id, 'role' => 'Client')); $sObject1 = new stdClass(); $sObject1->Id = $record->Id; $sObject1->WP_Login_ID__c = $user_id; $response = $mySforceConnection->update(array($sObject1), 'Contact'); } if ($found == 0) { $query = "SELECT Id,Firstname__c,Lastname__c,Ms_Mr_Dr_Nurse__c,E_ID__c from Expert__c WHERE Email__c='{$email}' LIMIT 1"; $response = $mySforceConnection->query($query); foreach ($response->records as $record) { $found = 1; update_user_meta($user_id, 'id_sf_expert', $record->Id); update_user_meta($user_id, 'eid', $record->E_ID__c); update_user_meta($user_id, 'first_name', $record->Firstname__c); update_user_meta($user_id, 'last_name', $record->Lastname__c); update_user_meta($user_id, 'title', $record->Ms_Mr_Dr_Nurse__c); update_user_meta($user_id, 'role_check', "Expert"); $update = wp_update_user(array('ID' => $user_id, 'role' => "Expert")); $sObject1 = new stdClass(); $sObject1->Id = $record->Id; $sObject1->WP_Login_ID__c = $user_id; $response = $mySforceConnection->update(array($sObject1), 'Expert__c'); } } } }