/** * {@inheritdoc} * * @param $section * * @return string */ public function getFormNotes($section) { if ($section == 'authorization') { return ['mautic.salesforce.form.oauth_requirements', 'warning']; } return parent::getFormNotes($section); }
/** * {@inheritdoc} * * @return bool */ public function isAuthorized() { if (!isset($this->keys['version'])) { return false; } if ($this->keys['version'] == '6') { $loginParams = array('user_auth' => array('user_name' => $this->keys['username'], 'password' => md5($this->keys['password']), 'version' => '1'), 'application_name' => 'Mautic', 'name_value_list' => array(), 'method' => 'login', 'input_type' => 'JSON', 'response_type' => 'JSON'); $parameters = array('method' => 'login', 'input_type' => 'JSON', 'response_type' => 'JSON', 'rest_data' => json_encode($loginParams)); $settings['auth_type'] = 'rest'; $response = $this->makeRequest($this->getAccessTokenUrl(), $parameters, 'GET', $settings); unset($response['module'], $response['name_value_list']); $error = $this->extractAuthKeys($response, 'id'); $this->authorzationError = $error; return empty($error); } else { if ($this->isConfigured()) { // SugarCRM 7 uses password grant type so login each time to ensure session is valid $this->authCallback(); } return parent::isAuthorized(); } }
/** * {@inheritdoc} * * @param $lead * @param $config * * @return array */ public function populateLeadData($lead, $config = array()) { $mappedData = parent::populateLeadData($lead, $config); $xmlData = '<Leads>'; $xmlData .= '<row no="1">'; foreach ($mappedData as $name => $value) { $xmlData .= sprintf('<FL val="%s"><![CDATA[%s]]></FL>', $name, $value); } $xmlData .= '</row>'; $xmlData .= '</Leads>'; return $xmlData; }