/** * gets twitter EAPM * @return array|bool|ExternalAPIBase */ public function getEAPM() { // ignore auth and load to just check if connector configured $twitterEAPM = ExternalAPIFactory::loadAPI('Twitter', true); if (!$twitterEAPM) { $source = SourceFactory::getSource('ext_rest_twitter'); if ($source && $source->hasTestingEnabled()) { try { if (!$source->test()) { return array('error' => 'ERROR_NEED_OAUTH'); } } catch (Exception $e) { return array('error' => 'ERROR_NEED_OAUTH'); } } return array('error' => 'ERROR_NEED_OAUTH'); } $twitterEAPM->getConnector(); $eapmBean = EAPM::getLoginInfo('Twitter'); if (empty($eapmBean->id)) { return array('error' => 'ERROR_NEED_AUTHORIZE'); } //return a fully authed EAPM $twitterEAPM = ExternalAPIFactory::loadAPI('Twitter'); return $twitterEAPM; }
/** * gets dnb EAPM * @return array|bool|ExternalAPIBase */ public function getEAPM() { $dnbEAPM = ExternalAPIFactory::loadAPI('Dnb', true); $dnbEAPM->getConnector(); if (!$dnbEAPM->getConnectorParam('dnb_username') || !$dnbEAPM->getConnectorParam('dnb_password') || !$dnbEAPM->getConnectorParam('dnb_env')) { return array('error' => 'ERROR_DNB_CONFIG'); } return $dnbEAPM; }
function getDocumentsExternalApiDropDown($focus = null, $name = null, $value = null, $view = null) { require_once 'include/externalAPI/ExternalAPIFactory.php'; $apiList = ExternalAPIFactory::getModuleDropDown('Documents'); $apiList = array_merge(array('Sugar' => $GLOBALS['app_list_strings']['eapm_list']['Sugar']), $apiList); if (!empty($value) && empty($apiList[$value])) { $apiList[$value] = $value; } return $apiList; }
/** * Return a feed of google contacts using the EAPM and Connectors farmework. * * @throws Exception * @param $maxResults * @return array */ public function loadDataSet($maxResults = 0) { if (!($eapmBean = EAPM::getLoginInfo($this->_eapmName, true))) { throw new Exception('Authentication error with Google Contacts EAPM.'); } $api = ExternalAPIFactory::loadAPI($this->_eapmName); $api->loadEAPM($eapmBean); $conn = $api->getConnector(); $feed = $conn->getList(array('maxResults' => $maxResults, 'startIndex' => $this->_offset)); if ($feed !== FALSE) { $this->_totalRecordCount = $feed['totalResults']; $this->_recordSet = $feed['records']; } else { throw new Exception("Unable to retrieve {$this->_eapmName} feed."); } }
function listViewProcess() { if (!($eapmBean = EAPM::getLoginInfo('LotusLive', true))) { $smarty = new Sugar_Smarty(); echo $smarty->fetch('include/externalAPI/LotusLive/LotusLiveSignup.' . $GLOBALS['current_language'] . '.tpl'); return; } $apiName = 'LotusLive'; $api = ExternalAPIFactory::loadAPI($apiName, true); $api->loadEAPM($eapmBean); $quickCheck = $api->quickCheckLogin(); if (!$quickCheck['success']) { $errorMessage = string_format(translate('LBL_ERR_FAILED_QUICKCHECK', 'EAPM'), array('LotusLive')); $errorMessage .= '<form method="POST" target="_EAPM_CHECK" action="index.php">'; $errorMessage .= '<input type="hidden" name="module" value="EAPM">'; $errorMessage .= '<input type="hidden" name="action" value="Save">'; $errorMessage .= '<input type="hidden" name="record" value="' . $eapmBean->id . '">'; $errorMessage .= '<input type="hidden" name="active" value="1">'; $errorMessage .= '<input type="hidden" name="closeWhenDone" value="1">'; $errorMessage .= '<input type="hidden" name="refreshParentWindow" value="1">'; $errorMessage .= '<br><input type="submit" value="' . $GLOBALS['app_strings']['LBL_EMAIL_OK'] . '"> '; $errorMessage .= '<input type="button" onclick="lastLoadedMenu=undefined;DCMenu.closeOverlay();return false;" value="' . $GLOBALS['app_strings']['LBL_CANCEL_BUTTON_LABEL'] . '">'; $errorMessage .= '</form>'; echo $errorMessage; return; } $this->processSearchForm(); $this->params['orderBy'] = 'meetings.date_start'; $this->params['overrideOrder'] = true; $this->lv->searchColumns = $this->searchForm->searchColumns; $this->lv->show_action_dropdown = false; $this->lv->multiSelect = false; unset($this->searchForm->searchdefs['layout']['advanced_search']); if (!$this->headers) { return; } if (empty($_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false) { $this->lv->ss->assign("SEARCH", false); if (!isset($_REQUEST['name_basic'])) { $_REQUEST['name_basic'] = ''; } $this->lv->ss->assign('DCSEARCH', $_REQUEST['name_basic']); $this->lv->setup($this->seed, 'include/ListView/ListViewDCMenu.tpl', $this->where, $this->params); $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : ' - ' . $_REQUEST['saved_search_select_name']; echo $this->lv->display(); } }
/** * test * This method is called from the administration interface to run a test of the service * It is up to subclasses to implement a test and set _has_testing_enabled to true so that * a test button is rendered in the administration interface * * @return result boolean result of the test function */ public function test() { require_once 'vendor/Zend/Oauth/Consumer.php'; $api = ExternalAPIFactory::loadAPI('Twitter', true); if ($api) { $properties = $this->getProperties(); $config = array('callbackUrl' => 'http://www.sugarcrm.com', 'siteUrl' => $api->getOauthRequestURL(), 'consumerKey' => $properties['oauth_consumer_key'], 'consumerSecret' => $properties['oauth_consumer_secret']); try { $consumer = new Zend_Oauth_Consumer($config); $consumer->getRequestToken(); return true; } catch (Exception $e) { $GLOBALS['log']->error("Error getting request token for twitter:" . $e->getMessage()); return false; } } return false; }
public function display() { global $mod_strings; if (isset($_REQUEST['name_basic'])) { $file_search = trim($_REQUEST['name_basic']); } else { $file_search = ''; } if (!isset($_REQUEST['apiName'])) { $apiName = 'IBMSmartCloud'; } else { $tmpApi = ExternalAPIFactory::loadAPI($_REQUEST['apiName'], true); if ($tmpApi === false) { Log::error(string_format($mod_strings['ERR_INVALID_EXTERNAL_API_ACCESS'], [$_REQUEST['apiName']])); return; } $apiName = $_REQUEST['apiName']; } // See if we are running as a popup window if (isset($_REQUEST['isPopup']) && $_REQUEST['isPopup'] == 1 && !empty($_REQUEST['elemBaseName'])) { $isPopup = true; } else { $isPopup = false; } // bug50952 - must actually make sure we can log in, not just that we've got a EAPM record // getLoginInfo only checks to see if user has logged in correctly ONCE to ExternalAPI // Need to manually attempt to fetch the EAPM record, we don't want to give them the signup screen when they just have a deactivated account. $eapmBean = EAPM::getLoginInfo($apiName, true); $api = ExternalAPIFactory::loadAPI($apiName, true); $validSession = true; if (!empty($eapmBean)) { try { $api->loadEAPM($eapmBean); // $api->checkLogin() does the same thing as quickCheckLogin plus actually makes sure the user CAN log in to the API currently $loginCheck = $api->checkLogin($eapmBean); if (isset($loginCheck['success']) && !$loginCheck['success']) { $validSession = false; } } catch (Exception $ex) { $validSession = false; Log::error(string_format($mod_strings['ERR_INVALID_EXTERNAL_API_LOGIN'], [$apiName])); } } if (!$validSession || empty($eapmBean)) { // Bug #49987 : Documents view.extdoc.php doesn't allow custom override $tpl_file = get_custom_file_if_exists('include/externalAPI/' . $apiName . '/' . $apiName . 'Signup.' . $GLOBALS['current_language'] . '.tpl'); if (file_exists($tpl_file)) { $smarty = new Sugar_Smarty(); echo $smarty->fetch($tpl_file); } else { $output = string_format(translate('LBL_ERR_FAILED_QUICKCHECK', 'EAPM'), [$apiName]); $output .= '<form method="POST" target="_EAPM_CHECK" action="index.php">'; $output .= '<input type="hidden" name="module" value="EAPM">'; $output .= '<input type="hidden" name="action" value="Save">'; $output .= '<input type="hidden" name="record" value="' . $eapmBean->id . '">'; $output .= '<input type="hidden" name="active" value="1">'; $output .= '<input type="hidden" name="closeWhenDone" value="1">'; $output .= '<input type="hidden" name="refreshParentWindow" value="1">'; $output .= '<br><input type="submit" value="' . $GLOBALS['app_strings']['LBL_EMAIL_OK'] . '"> '; $output .= '<input type="button" onclick="lastLoadedMenu=undefined;DCMenu.closeOverlay();return false;" value="' . $GLOBALS['app_strings']['LBL_CANCEL_BUTTON_LABEL'] . '">'; $output .= '</form>'; echo $output; } return; } $searchDataLower = $api->searchDoc($file_search, true); // In order to emulate the list views for the SugarFields, I need to uppercase all of the key names. $searchData = []; if (is_array($searchDataLower)) { foreach ($searchDataLower as $row) { $newRow = []; foreach ($row as $key => $value) { $newRow[strtoupper($key)] = $value; } if ($isPopup) { // We are running as a popup window, we need to replace the direct url with some javascript $newRow['DOC_URL'] = "javascript:window.opener.SUGAR.field.file.populateFromPopup('" . addslashes($_REQUEST['elemBaseName']) . "','" . addslashes($newRow['ID']) . "','" . addslashes($newRow['NAME']) . "','" . addslashes($newRow['URL']) . "','" . addslashes($newRow['URL']) . "'); window.close();"; } else { $newRow['DOC_URL'] = $newRow['URL']; } $searchData[] = $newRow; } } $displayColumns = ['NAME' => ['label' => 'LBL_LIST_EXT_DOCUMENT_NAME', 'type' => 'varchar', 'link' => true], 'DATE_MODIFIED' => ['label' => 'LBL_DATE', 'type' => 'date']]; $ss = new Sugar_Smarty(); $ss->assign('searchFieldLabel', translate('LBL_SEARCH_EXTERNAL_DOCUMENT', 'Documents')); $ss->assign('displayedNote', translate('LBL_EXTERNAL_DOCUMENT_NOTE', 'Documents')); $ss->assign('APP', $GLOBALS['app_strings']); $ss->assign('MOD', $GLOBALS['mod_strings']); $ss->assign('data', $searchData); $ss->assign('displayColumns', $displayColumns); $ss->assign('imgPath', SugarThemeRegistry::current()->getImageURL($apiName . '_image_inline.png')); if ($isPopup) { $ss->assign('linkTarget', ''); $ss->assign('isPopup', 1); $ss->assign('elemBaseName', $_REQUEST['elemBaseName']); } else { $ss->assign('linkTarget', '_new'); $ss->assign('isPopup', 0); $ss->assign('elemBaseName', ''); } $ss->assign('apiName', $apiName); $ss->assign('DCSEARCH', $file_search); if ($isPopup) { // Need the popup header... I feel so dirty. ob_start(); echo '<div class="dccontent">'; insert_popup_header($GLOBALS['theme'], false); $output_html = ob_get_contents(); ob_end_clean(); $output_html .= get_form_header(translate('LBL_SEARCH_FORM_TITLE', 'Documents'), '', false); echo $output_html; } $ss->display('modules/Documents/tpls/view.extdoc.tpl'); if ($isPopup) { // Close the dccontent div echo '</div>'; } }
private function getAuthenticatedImportableExternalEAPMs() { return ExternalAPIFactory::getModuleDropDown('Import', FALSE, FALSE); }
require_once 'include/externalAPI/ExternalAPIFactory.php'; global $app_strings; $checkList = ExternalAPIFactory::listAPI('', true); if (!empty($_REQUEST['api'])) { // Check just one login type $newCheckList = array(); if (isset($checkList[$_REQUEST['api']])) { $newCheckList[$_REQUEST['api']] = $checkList[$_REQUEST['api']]; } $checkList = $newCheckList; } $failList = array(); if (is_array($checkList)) { foreach ($checkList as $apiName => $apiOpts) { if ($apiOpts['authMethod'] == 'oauth') { $api = ExternalAPIFactory::loadAPI($apiName); if (is_object($api)) { $loginCheck = $api->quickCheckLogin(); } else { $loginCheck['success'] = false; } if (!$loginCheck['success']) { $thisFail = array(); $thisFail['checkURL'] = 'index.php?module=EAPM&closeWhenDone=1&action=QuickSave&application=' . $apiName; $translateKey = 'LBL_EXTAPI_' . strtoupper($apiName); if (!empty($app_strings[$translateKey])) { $apiLabel = $app_strings[$translateKey]; } else { $apiLabel = $apiName; } $thisFail['label'] = str_replace('{0}', $apiLabel, translate('LBL_ERR_FAILED_QUICKCHECK', 'EAPM'));
function save($check_notify = FALSE) { global $timedate; global $current_user; global $disable_date_format; if (isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) { if (isset($this->date_start) && isset($this->duration_hours) && isset($this->duration_minutes)) { $td = $timedate->fromDb($this->date_start); if (!$td) { $this->date_start = $timedate->to_db($this->date_start); $td = $timedate->fromDb($this->date_start); } if ($td) { $this->date_end = $td->modify("+{$this->duration_hours} hours {$this->duration_minutes} mins")->asDb(); } } } $check_notify = !empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1' ? true : false; if (empty($_REQUEST['send_invites'])) { if (!empty($this->id)) { $old_record = new Meeting(); $old_record->retrieve($this->id); $old_assigned_user_id = $old_record->assigned_user_id; } if (empty($this->id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $GLOBALS['current_user']->id != $_REQUEST['assigned_user_id'] || isset($old_assigned_user_id) && !empty($old_assigned_user_id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $old_assigned_user_id != $_REQUEST['assigned_user_id']) { $this->special_notification = true; $check_notify = true; if (isset($_REQUEST['assigned_user_name'])) { $this->new_assigned_user_name = $_REQUEST['assigned_user_name']; } } } /*nsingh 7/3/08 commenting out as bug #20814 is invalid if($current_user->getPreference('reminder_time')!= -1 && isset($_POST['reminder_checked']) && isset($_POST['reminder_time']) && $_POST['reminder_checked']==0 && $_POST['reminder_time']==-1){ $this->reminder_checked = '1'; $this->reminder_time = $current_user->getPreference('reminder_time'); }*/ // prevent a mass mailing for recurring meetings created in Calendar module if (empty($this->id) && !empty($_REQUEST['module']) && $_REQUEST['module'] == "Calendar" && !empty($_REQUEST['repeat_type']) && !empty($this->repeat_parent_id)) { $check_notify = false; } if (empty($this->status)) { $this->status = $this->getDefaultStatus(); } // Do any external API saving // Clear out the old external API stuff if we have changed types if (isset($this->fetched_row) && $this->fetched_row['type'] != $this->type) { $this->join_url = ''; $this->host_url = ''; $this->external_id = ''; $this->creator = ''; } if (!empty($this->type) && $this->type != 'Sugar') { require_once 'include/externalAPI/ExternalAPIFactory.php'; $api = ExternalAPIFactory::loadAPI($this->type); } if (empty($this->type)) { $this->type = 'Sugar'; } if (isset($api) && is_a($api, 'WebMeeting') && empty($this->in_relationship_update)) { // Make sure the API initialized and it supports Web Meetings // Also make suer we have an ID, the external site needs something to reference if (!isset($this->id) || empty($this->id)) { $this->id = create_guid(); $this->new_with_id = true; } $response = $api->scheduleMeeting($this); if ($response['success'] == TRUE) { // Need to send out notifications if ($api->canInvite) { $notifyList = $this->get_notification_recipients(); foreach ($notifyList as $person) { $api->inviteAttendee($this, $person, $check_notify); } } } else { SugarApplication::appendErrorMessage($GLOBALS['app_strings']['ERR_EXTERNAL_API_SAVE_FAIL']); return $this->id; } $api->logoff(); } $return_id = parent::save($check_notify); if ($this->update_vcal) { vCal::cache_sugar_vcal($current_user); } return $return_id; }
/** * Upload document to external service * @param SugarBean $bean Related bean * @param string $bean_id * @param string $doc_type * @param string $file_name * @param string $mime_type */ function upload_doc($bean, $bean_id, $doc_type, $file_name, $mime_type) { if (!empty($doc_type) && $doc_type != 'Sugar') { global $sugar_config; $destination = $this->get_upload_path($bean_id); sugar_rename($destination, str_replace($bean_id, $bean_id . '_' . $file_name, $destination)); $new_destination = $this->get_upload_path($bean_id . '_' . $file_name); try { $this->api = ExternalAPIFactory::loadAPI($doc_type); if (isset($this->api) && $this->api !== false) { $result = $this->api->uploadDoc($bean, $new_destination, $file_name, $mime_type); } else { $result['success'] = FALSE; // FIXME: Translate $GLOBALS['log']->error("Could not load the requested API (" . $doc_type . ")"); $result['errorMessage'] = 'Could not find a proper API'; } } catch (Exception $e) { $result['success'] = FALSE; $result['errorMessage'] = $e->getMessage(); $GLOBALS['log']->error("Caught exception: (" . $e->getMessage() . ") "); } if (!$result['success']) { sugar_rename($new_destination, str_replace($bean_id . '_' . $file_name, $bean_id, $new_destination)); $bean->doc_type = 'Sugar'; // FIXME: Translate if (!is_array($_SESSION['user_error_message'])) { $_SESSION['user_error_message'] = array(); } $error_message = isset($result['errorMessage']) ? $result['errorMessage'] : $GLOBALS['app_strings']['ERR_EXTERNAL_API_SAVE_FAIL']; $_SESSION['user_error_message'][] = $error_message; } else { unlink($new_destination); } } }
function externalApi($data) { require_once 'include/externalAPI/ExternalAPIFactory.php'; $api = ExternalAPIFactory::loadAPI($data['api']); $json = getJSONobj(); $listArray['fields'] = $api->searchDoc($_REQUEST['query']); $listArray['totalCount'] = count($listArray['fields']); $listJson = $json->encodeReal($listArray); return $listJson; }
public function test() { $api = ExternalAPIFactory::loadAPI('Plivo', true); return $api->getAccountDetails(); }
public function clearExternalAPICache() { global $mod_strings, $sugar_config; if ($this->show_output) { echo "<h3>{$mod_strings['LBL_QR_CLEAR_EXT_API']}</h3>"; } require_once 'include/externalAPI/ExternalAPIFactory.php'; ExternalAPIFactory::clearCache(); }
/** * Returns search results from external API * * @param array $args * @return array */ public function externalApi($args) { require_once 'include/externalAPI/ExternalAPIFactory.php'; $data = array(); try { $api = ExternalAPIFactory::loadAPI($args['api']); $data['fields'] = $api->searchDoc($_REQUEST['query']); $data['totalCount'] = count($data['fields']); } catch (Exception $ex) { $GLOBALS['log']->error($ex->getMessage()); } return $this->getJsonEncodedData($data); }
public function display() { if (isset($_REQUEST['name_basic'])) { $file_search = trim($_REQUEST['name_basic']); } else { $file_search = ''; } if (!isset($_REQUEST['apiName'])) { $apiName = 'LotusLive'; } else { $tmpApi = ExternalAPIFactory::loadAPI($_REQUEST['apiName'], true); if ($tmpApi === false) { $GLOBALS['log']->error('The user attempted to access an invalid external API (' . $_REQUEST['apiName'] . ')'); return; } $apiName = $_REQUEST['apiName']; } // See if we are running as a popup window if (isset($_REQUEST['isPopup']) && $_REQUEST['isPopup'] == 1 && !empty($_REQUEST['elemBaseName'])) { $isPopup = true; } else { $isPopup = false; } // Need to manually attempt to fetch the EAPM record, we don't want to give them the signup screen when they just have a deactivated account. if (!($eapmBean = EAPM::getLoginInfo($apiName, true))) { $smarty = new Sugar_Smarty(); echo $smarty->fetch('include/externalAPI/' . $apiName . '/' . $apiName . 'Signup.' . $GLOBALS['current_language'] . '.tpl'); return; } $api = ExternalAPIFactory::loadAPI($apiName, true); $api->loadEAPM($eapmBean); $quickCheck = $api->quickCheckLogin(); if (!$quickCheck['success']) { $errorMessage = string_format(translate('LBL_ERR_FAILED_QUICKCHECK', 'EAPM'), array($apiName)); $errorMessage .= '<form method="POST" target="_EAPM_CHECK" action="index.php">'; $errorMessage .= '<input type="hidden" name="module" value="EAPM">'; $errorMessage .= '<input type="hidden" name="action" value="Save">'; $errorMessage .= '<input type="hidden" name="record" value="' . $eapmBean->id . '">'; $errorMessage .= '<input type="hidden" name="active" value="1">'; $errorMessage .= '<input type="hidden" name="closeWhenDone" value="1">'; $errorMessage .= '<input type="hidden" name="refreshParentWindow" value="1">'; $errorMessage .= '<br><input type="submit" value="' . $GLOBALS['app_strings']['LBL_EMAIL_OK'] . '"> '; $errorMessage .= '<input type="button" onclick="lastLoadedMenu=undefined;DCMenu.closeOverlay();return false;" value="' . $GLOBALS['app_strings']['LBL_CANCEL_BUTTON_LABEL'] . '">'; $errorMessage .= '</form>'; echo $errorMessage; return; } $searchDataLower = $api->searchDoc($file_search, true); // In order to emulate the list views for the SugarFields, I need to uppercase all of the key names. $searchData = array(); if (is_array($searchDataLower)) { foreach ($searchDataLower as $row) { $newRow = array(); foreach ($row as $key => $value) { $newRow[strtoupper($key)] = $value; } if ($isPopup) { // We are running as a popup window, we need to replace the direct url with some javascript $newRow['DOC_URL'] = "javascript:window.opener.SUGAR.field.file.populateFromPopup('" . addslashes($_REQUEST['elemBaseName']) . "','" . addslashes($newRow['ID']) . "','" . addslashes($newRow['NAME']) . "','" . addslashes($newRow['URL']) . "','" . addslashes($newRow['URL']) . "'); window.close();"; } else { $newRow['DOC_URL'] = $newRow['URL']; } $searchData[] = $newRow; } } $displayColumns = array('NAME' => array('label' => 'LBL_LIST_EXT_DOCUMENT_NAME', 'type' => 'varchar', 'link' => true), 'DATE_MODIFIED' => array('label' => 'LBL_DATE', 'type' => 'date')); $ss = new Sugar_Smarty(); $ss->assign('searchFieldLabel', translate('LBL_SEARCH_EXTERNAL_DOCUMENT', 'Documents')); $ss->assign('displayedNote', translate('LBL_EXTERNAL_DOCUMENT_NOTE', 'Documents')); $ss->assign('APP', $GLOBALS['app_strings']); $ss->assign('MOD', $GLOBALS['mod_strings']); $ss->assign('data', $searchData); $ss->assign('displayColumns', $displayColumns); $ss->assign('imgPath', SugarThemeRegistry::current()->getImageURL($apiName . '_image_inline.png')); if ($isPopup) { $ss->assign('linkTarget', ''); $ss->assign('isPopup', 1); $ss->assign('elemBaseName', $_REQUEST['elemBaseName']); } else { $ss->assign('linkTarget', '_new'); $ss->assign('isPopup', 0); $ss->assign('elemBaseName', ''); } $ss->assign('apiName', $apiName); $ss->assign('DCSEARCH', $file_search); if ($isPopup) { // Need the popup header... I feel so dirty. ob_start(); echo '<div class="dccontent">'; insert_popup_header($GLOBALS['theme']); $output_html = ob_get_contents(); ob_end_clean(); $output_html .= get_form_header(translate('LBL_SEARCH_FORM_TITLE', 'Documents'), '', false); echo $output_html; } $ss->display('modules/Documents/tpls/view.extdoc.tpl'); if ($isPopup) { // Close the dccontent div echo '</div>'; } }
protected function action_FlushFileCache() { $api = ExternalAPIFactory::loadAPI($_REQUEST['api']); if ($api == false) { echo 'FAILED'; return; } if (method_exists($api, 'loadDocCache')) { $api->loadDocCache(true); } echo 'SUCCESS'; }
public function test() { $api = ExternalAPIFactory::loadAPI('Dnb', true); return $api->checkTokenValidity(false); }
private function getImportableExternalEAPMs() { require_once 'include/externalAPI/ExternalAPIFactory.php'; return ExternalAPIFactory::getModuleDropDown('Import', FALSE, FALSE, 'eapm_import_list'); }
protected function fillInName() { if (!empty($this->application)) { $apiList = ExternalAPIFactory::loadFullAPIList(false, true); } if (!empty($apiList) && isset($apiList[$this->application]) && $apiList[$this->application]['authMethod'] == "oauth") { $this->name = sprintf(translate('LBL_OAUTH_NAME', $this->module_dir), $this->application); } }
function deleteAttachment($isduplicate = "false") { if ($this->ACLAccess('edit')) { if ($isduplicate == "true") { return true; } $removeFile = "upload://{$this->id}"; } if (!empty($this->doc_type) && !empty($this->doc_id)) { $document = ExternalAPIFactory::loadAPI($this->doc_type); $response = $document->deleteDoc($this); $this->doc_type = ''; $this->doc_id = ''; $this->doc_url = ''; $this->filename = ''; $this->file_mime_type = ''; } if (file_exists($removeFile)) { if (!unlink($removeFile)) { $GLOBALS['log']->error("*** Could not unlink() file: [ {$removeFile} ]"); } else { $this->filename = ''; $this->file_mime_type = ''; $this->file = ''; $this->save(); return true; } } else { $this->filename = ''; $this->file_mime_type = ''; $this->file = ''; $this->doc_id = ''; $this->save(); return true; } return false; }
function save($check_notify = FALSE) { global $timedate; global $current_user; if (isset($this->date_start)) { $td = $timedate->fromDb($this->date_start); if (!$td) { $this->date_start = $timedate->to_db($this->date_start); $td = $timedate->fromDb($this->date_start); } if ($td) { if (isset($this->duration_hours) && $this->duration_hours != '') { $td->modify("+{$this->duration_hours} hours"); } if (isset($this->duration_minutes) && $this->duration_minutes != '') { $td->modify("+{$this->duration_minutes} mins"); } $this->date_end = $td->asDb(); } } $check_notify = $this->send_invites; if ($this->send_invites == false) { $old_assigned_user_id = CalendarEvents::$old_assigned_user_id; if ((empty($GLOBALS['installing']) || $GLOBALS['installing'] != true) && (!empty($this->assigned_user_id) && $this->assigned_user_id != $GLOBALS['current_user']->id && $this->assigned_user_id != $old_assigned_user_id)) { $this->special_notification = true; $check_notify = true; CalendarEvents::$old_assigned_user_id = $this->assigned_user_id; if (isset($_REQUEST['assigned_user_name'])) { $this->new_assigned_user_name = $_REQUEST['assigned_user_name']; } } } /*nsingh 7/3/08 commenting out as bug #20814 is invalid if($current_user->getPreference('reminder_time')!= -1 && isset($_POST['reminder_checked']) && isset($_POST['reminder_time']) && $_POST['reminder_checked']==0 && $_POST['reminder_time']==-1){ $this->reminder_checked = '1'; $this->reminder_time = $current_user->getPreference('reminder_time'); }*/ // prevent a mass mailing for recurring meetings created in Calendar module if (empty($this->id) && !empty($_REQUEST['module']) && $_REQUEST['module'] == "Calendar" && !empty($_REQUEST['repeat_type']) && !empty($this->repeat_parent_id)) { $check_notify = false; } if (empty($this->status)) { $this->status = $this->getDefaultStatus(); } // Do any external API saving // Clear out the old external API stuff if we have changed types if (isset($this->fetched_row) && $this->fetched_row['type'] != $this->type) { $this->join_url = ''; $this->host_url = ''; $this->external_id = ''; $this->creator = ''; } if (!empty($this->type) && $this->type != 'Sugar') { require_once 'include/externalAPI/ExternalAPIFactory.php'; $api = ExternalAPIFactory::loadAPI($this->type); } if (empty($this->type)) { $this->type = 'Sugar'; } if (isset($api) && is_a($api, 'WebMeeting') && empty($this->in_relationship_update)) { // Make sure the API initialized and it supports Web Meetings // Also make sure we have an ID, the external site needs something to reference if (!isset($this->id) || empty($this->id)) { $this->id = create_guid(); $this->new_with_id = true; } // formatting fix required because our schedule meeting APIs expect data in a specific format $this->fixUpFormatting(); $response = $api->scheduleMeeting($this); if ($response['success'] == TRUE) { // Need to send out notifications if ($api->canInvite) { $notifyList = $this->get_notification_recipients(); foreach ($notifyList as $person) { $api->inviteAttendee($this, $person, $check_notify); } } } else { // Generic Message Provides no value to End User - Log the issue with message detail and continue // SugarApplication::appendErrorMessage($GLOBALS['app_strings']['ERR_EXTERNAL_API_SAVE_FAIL']); $GLOBALS['log']->warn('ERR_EXTERNAL_API_SAVE_FAIL' . ": " . $this->type . " - " . $response['errorMessage']); } $api->logoff(); } $return_id = parent::save($check_notify); $this->setUserInvitees($this->users_arr); if ($this->update_vcal) { $assigned_user = BeanFactory::getBean('Users', $this->assigned_user_id); vCal::cache_sugar_vcal($assigned_user); if ($this->assigned_user_id != $GLOBALS['current_user']->id) { vCal::cache_sugar_vcal($current_user); } } // CCL - Comment out call to set $current_user as invitee // set organizer to auto-accept // if there isn't a fetched row its new if ($this->assigned_user_id == $GLOBALS['current_user']->id && empty($this->fetched_row)) { $this->set_accept_status($GLOBALS['current_user'], 'accept'); } return $return_id; }
function process($lvsParams = array()) { global $current_user; $currentSearchFields = array(); $configureView = true; // configure view or regular view $query = false; $whereArray = array(); $lvsParams['massupdate'] = false; // apply filters if (isset($this->filters) || $this->myItemsOnly) { $whereArray = $this->buildWhere(); } $this->lvs->export = false; $this->lvs->multiSelect = false; $this->lvs->quickViewLinks = false; // columns foreach ($this->columns as $name => $val) { if (!empty($val['default']) && $val['default']) { $displayColumns[strtoupper($name)] = $val; $displayColumns[strtoupper($name)]['label'] = trim($displayColumns[strtoupper($name)]['label'], ':'); } } $this->lvs->displayColumns = $displayColumns; $this->lvs->lvd->setVariableName($this->seedBean->object_name, array()); $lvsParams['overrideOrder'] = true; $lvsParams['orderBy'] = 'date_entered'; $lvsParams['sortOrder'] = 'DESC'; $lvsParams['custom_from'] = ''; // Get the real module list if (empty($this->selectedCategories)) { $mod_list = $this->categories; } else { $mod_list = array_flip($this->selectedCategories); //27949, here the key of $this->selectedCategories is not module name, the value is module name, so array_flip it. } $external_modules = array(); $admin_modules = array(); $owner_modules = array(); $regular_modules = array(); foreach ($mod_list as $module => $ignore) { // Handle the UserFeed differently if ($module == 'UserFeed') { $regular_modules[] = 'UserFeed'; continue; } if (in_array($module, $this->externalAPIList)) { $external_modules[] = $module; } if (ACLAction::getUserAccessLevel($current_user->id, $module, 'view') <= ACL_ALLOW_NONE) { // Not enough access to view any records, don't add it to any lists continue; } if (ACLAction::getUserAccessLevel($current_user->id, $module, 'view') == ACL_ALLOW_OWNER) { $owner_modules[] = $module; } else { $regular_modules[] = $module; } } if (!empty($this->displayTpl)) { //MFH BUG #14296 $where = ''; if (!empty($whereArray)) { $where = '(' . implode(') AND (', $whereArray) . ')'; } $additional_where = ''; $module_limiter = " sugarfeed.related_module in ('" . implode("','", $regular_modules) . "')"; if (is_admin($GLOBALS['current_user'])) { $all_modules = array_merge($regular_modules, $owner_modules, $admin_modules); $module_limiter = " sugarfeed.related_module in ('" . implode("','", $all_modules) . "')"; } else { if (count($owner_modules) > 0) { $module_limiter = " ((sugarfeed.related_module IN ('" . implode("','", $regular_modules) . "') " . ") "; if (count($owner_modules) > 0) { $module_limiter .= "OR (sugarfeed.related_module IN('" . implode("','", $owner_modules) . "') AND sugarfeed.assigned_user_id = '" . $current_user->id . "' " . ") "; } $module_limiter .= ")"; } } if (!empty($where)) { $where .= ' AND '; } $where .= $module_limiter; $this->lvs->setup($this->seedBean, $this->displayTpl, $where, $lvsParams, 0, $this->displayRows, array('name', 'description', 'date_entered', 'created_by', 'related_module', 'link_url', 'link_type')); foreach ($this->lvs->data['data'] as $row => $data) { $this->lvs->data['data'][$row]['NAME'] = str_replace("{this.CREATED_BY}", get_assigned_user_name($this->lvs->data['data'][$row]['CREATED_BY']), $data['NAME']); //Translate the SugarFeeds labels if necessary. preg_match('/\\{([^\\^ }]+)\\.([^\\}]+)\\}/', $this->lvs->data['data'][$row]['NAME'], $modStringMatches); if (count($modStringMatches) == 3 && $modStringMatches[1] == 'SugarFeed' && !empty($data['RELATED_MODULE'])) { $modKey = $modStringMatches[2]; $modString = translate($modKey, $modStringMatches[1]); if (strpos($modString, '{0}') === FALSE || !isset($GLOBALS['app_list_strings']['moduleListSingular'][$data['RELATED_MODULE']])) { continue; } $modStringSingular = $GLOBALS['app_list_strings']['moduleListSingular'][$data['RELATED_MODULE']]; $modString = string_format($modString, array($modStringSingular)); $this->lvs->data['data'][$row]['NAME'] = preg_replace('/' . $modStringMatches[0] . '/', strtolower($modString), $this->lvs->data['data'][$row]['NAME']); } } // assign a baseURL w/ the action set as DisplayDashlet foreach ($this->lvs->data['pageData']['urls'] as $type => $url) { // awu Replacing action=DisplayDashlet with action=DynamicAction&DynamicAction=DisplayDashlet if ($type == 'orderBy') { $this->lvs->data['pageData']['urls'][$type] = preg_replace('/(action=.*&)/Ui', 'action=DynamicAction&DynamicAction=displayDashlet&', $url); } else { $this->lvs->data['pageData']['urls'][$type] = preg_replace('/(action=.*&)/Ui', 'action=DynamicAction&DynamicAction=displayDashlet&', $url) . '&sugar_body_only=1&id=' . $this->id; } } $this->lvs->ss->assign('dashletId', $this->id); } $td = $GLOBALS['timedate']; $needResort = false; $resortQueue = array(); $feedErrors = array(); $fetchRecordCount = $this->displayRows + $this->lvs->data['pageData']['offsets']['current']; foreach ($external_modules as $apiName) { $api = ExternalAPIFactory::loadAPI($apiName); if ($api !== FALSE) { // FIXME: Actually calculate the oldest sugar feed we can see, once we get an API that supports this sort of filter. $reply = $api->getLatestUpdates(0, $fetchRecordCount); if ($reply['success'] && count($reply['messages']) > 0) { array_splice($resortQueue, count($resortQueue), 0, $reply['messages']); } else { if (!$reply['success']) { $feedErrors[] = $reply['errorMessage']; } } } } if (count($feedErrors) > 0) { $this->lvs->ss->assign('feedErrors', $feedErrors); } // If we need to resort, get to work! foreach ($this->lvs->data['data'] as $normalMessage) { list($user_date, $user_time) = explode(' ', $normalMessage['DATE_ENTERED']); list($db_date, $db_time) = $td->to_db_date_time($user_date, $user_time); $unix_timestamp = strtotime($db_date . ' ' . $db_time); $normalMessage['sort_key'] = $unix_timestamp; $normalMessage['NAME'] = '</b>' . $normalMessage['NAME']; $resortQueue[] = $normalMessage; } usort($resortQueue, create_function('$a,$b', 'return $a["sort_key"]<$b["sort_key"];')); // Trim it down to the necessary number of records $numRecords = count($resortQueue); $numRecords = $numRecords - $this->lvs->data['pageData']['offsets']['current']; $numRecords = min($this->displayRows, $numRecords); $this->lvs->data['data'] = $resortQueue; }
public function getMessage(ServiceBase $api, array $args) { $this->requireArgs($args, array('record')); $api = ExternalAPIFactory::loadAPI('Plivo', true); return $api->getMessageDetail($args['record']); }