Ejemplo n.º 1
0
 static function getLoginInfo($application, $includeInactive = false)
 {
     global $current_user;
     $eapmBean = new EAPM();
     if (isset($_SESSION['EAPM'][$application]) && !$includeInactive) {
         if (is_array($_SESSION['EAPM'][$application])) {
             $eapmBean->fromArray($_SESSION['EAPM'][$application]);
         } else {
             return null;
         }
     } else {
         $queryArray = array('assigned_user_id' => $current_user->id, 'application' => $application, 'deleted' => 0);
         if (!$includeInactive) {
             $queryArray['validated'] = 1;
         }
         $eapmBean = $eapmBean->retrieve_by_string_fields($queryArray);
         // Don't cache the include inactive results
         if (!$includeInactive) {
             if ($eapmBean != null) {
                 $_SESSION['EAPM'][$application] = $eapmBean->toArray();
             } else {
                 $_SESSION['EAPM'][$application] = '';
                 return null;
             }
         }
     }
     if (isset($eapmBean->password)) {
         require_once "include/utils/encryption_utils.php";
         $eapmBean->password = blowfishDecode(blowfishGetKey('encrypt_field'), $eapmBean->password);
     }
     return $eapmBean;
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 function init_tilkee_access_eapm()
 {
     $eapmBean = EAPM::getLoginInfo('tilkee', true);
     $this->loadEAPM($eapmBean);
     if (isset($this->account_name) && $this->account_name != '' && isset($this->account_password) && $this->account_password != '') {
         $result = $this->get_token_password($this->account_name, $this->account_password);
         return $result;
     } else {
         // ERROR : Connection Information not set
         return -1;
     }
 }
Ejemplo n.º 4
0
 public function revokeToken()
 {
     $client = $this->getClient();
     try {
         $client->revokeToken();
     } catch (Google_Auth_Exception $e) {
         return false;
     }
     $eapm = EAPM::getLoginInfo('Google');
     if ($eapm) {
         $eapm->mark_deleted($eapm->id);
     }
     return true;
 }
 /**
  * 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.");
     }
 }
Ejemplo n.º 6
0
 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'] . '">&nbsp;';
         $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();
     }
 }
 function displayOptions()
 {
     global $app_strings;
     global $app_list_strings;
     $ss = new Sugar_Smarty();
     $ss->assign('titleLBL', translate('LBL_TITLE', 'SugarFeed'));
     $ss->assign('categoriesLBL', translate('LBL_CATEGORIES', 'SugarFeed'));
     $ss->assign('autenticationPendingLBL', translate('LBL_AUTHENTICATION_PENDING', 'SugarFeed'));
     $ss->assign('rowsLBL', translate('LBL_ROWS', 'SugarFeed'));
     $ss->assign('saveLBL', $app_strings['LBL_SAVE_BUTTON_LABEL']);
     $ss->assign('clearLBL', $app_strings['LBL_CLEAR_BUTTON_LABEL']);
     $ss->assign('title', $this->title);
     $ss->assign('categories', $this->categories);
     if (empty($this->selectedCategories)) {
         $this->selectedCategories['ALL'] = 'ALL';
     }
     $ss->assign('selectedCategories', $this->selectedCategories);
     $ss->assign('rows', $this->displayRows);
     $externalApis = array();
     foreach ($this->externalAPIList as $apiObj => $apiName) {
         //only show external APis that the user has not created
         if (!EAPM::getLoginInfo($apiName)) {
             $externalApis[] = $apiObj;
         }
     }
     $ss->assign('externalApiList', JSON::encode($externalApis));
     $ss->assign('authenticateLBL', translate('LBL_AUTHENTICATE', 'SugarFeed'));
     $ss->assign('id', $this->id);
     if ($this->isAutoRefreshable()) {
         $ss->assign('isRefreshable', true);
         $ss->assign('autoRefresh', $GLOBALS['app_strings']['LBL_DASHLET_CONFIGURE_AUTOREFRESH']);
         $ss->assign('autoRefreshOptions', $this->getAutoRefreshOptions());
         $ss->assign('autoRefreshSelect', $this->autoRefresh);
     }
     return $ss->fetch('modules/SugarFeed/Dashlets/SugarFeedDashlet/Options.tpl');
 }
Ejemplo n.º 8
0
 /**
  * gets EAPM bean for connector per current user
  * @param array $connector
  * @return null|object|SugarBean
  */
 public function getEAPMForConnector($connector)
 {
     if (isset($connector['name'])) {
         return EAPM::getLoginInfo($connector['name']);
     } else {
         return null;
     }
 }
Ejemplo n.º 9
0
 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'] . '">&nbsp;';
             $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>';
     }
 }
Ejemplo n.º 10
0
 /**
  * Lists the available API's for a module or all modules, and possibly ignoring if the user has auth information for that API even if it is required
  * @param string $module Which module name you are searching for, leave blank to find all API's
  * @param bool $ignoreAuth Ignore API's demands for authentication (used to get a complete list of modules
  * @return API class
  */
 public static function listAPI($module = '', $ignoreAuth = false)
 {
     $apiList = self::loadFullAPIList();
     if ($module == '' && $ignoreAuth == true) {
         // Simplest case, return everything.
         return $apiList;
     }
     $apiFinalList = array();
     // Not such an easy case, we need to limit to specific modules and see if we have authentication (or not)
     foreach ($apiList as $apiName => $apiOpts) {
         if ($module == '' || in_array($module, $apiOpts['supportedModules'])) {
             // This matches the module criteria
             if ($ignoreAuth || !$apiOpts['useAuth'] || !$apiOpts['requireAuth']) {
                 // Don't need to worry about authentication
                 $apiFinalList[$apiName] = $apiOpts;
             } else {
                 // We need to worry about authentication
                 $eapmBean = EAPM::getLoginInfo($apiName);
                 if (isset($eapmBean->application)) {
                     // We have authentication
                     $apiFinalList[$apiName] = $apiOpts;
                 }
             }
         }
     }
     return $apiFinalList;
 }
Ejemplo n.º 11
0
    $result = $focus->db->query($query);
    while (($row = $focus->db->fetchByAssoc($result)) != null) {
        $del_query = " update email_marketing_prospect_lists set email_marketing_prospect_lists.deleted=1, email_marketing_prospect_lists.date_modified=" . $focus->db->convert("'" . TimeDate::getInstance()->nowDb() . "'", 'datetime');
        $del_query .= " WHERE  email_marketing_prospect_lists.id='{$row['id']}'";
        $focus->db->query($del_query);
    }
    $focus->db->query($query);
}
if ($bean_name == "Meeting") {
    $focus->retrieve($record);
    $user = new User();
    $user->retrieve($linked_id);
    if (!empty($user->id)) {
        //make sure that record exists. we may have a contact on our hands.
        if ($focus->update_vcal) {
            vCal::cache_sugar_vcal($user);
        }
    }
}
if ($bean_name == "User" && $linked_field == 'eapm') {
    $eapm = new EAPM();
    $eapm->mark_deleted($linked_id);
}
if (!empty($_REQUEST['return_url'])) {
    $_REQUEST['return_url'] = urldecode($_REQUEST['return_url']);
}
Log::debug("deleted relationship: bean: {$bean_name}, linked_field: {$linked_field}, linked_id:{$linked_id}");
if (empty($_REQUEST['refresh_page'])) {
    handleRedirect();
}
exit;
Ejemplo n.º 12
0
 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'] . '">&nbsp;';
         $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>';
     }
 }
Ejemplo n.º 13
0
 protected function pre_QuickSave()
 {
     if (!empty($_REQUEST['application'])) {
         $eapmBean = EAPM::getLoginInfo($_REQUEST['application'], true);
         if (!$eapmBean) {
             $this->bean->application = $_REQUEST['application'];
             $this->bean->assigned_user_id = $GLOBALS['current_user']->id;
         } else {
             $this->bean = $eapmBean;
         }
         $this->pre_save();
     } else {
         sugar_die("Please pass an application name.");
     }
 }
Ejemplo n.º 14
0
 public function testdelete_user_accounts()
 {
     $eapm = new EAPM();
     //execute the method and test if it works and does not throws an exception.
     try {
         $eapm->delete_user_accounts(1);
         $this->assertTrue(true);
     } catch (Exception $e) {
         $this->fail();
     }
 }
Ejemplo n.º 15
0
 */
$lotusLiveUrl = '';
$llNowButton = '';
if (!isset($dynamicDCActions) || !is_array($dynamicDCActions)) {
    $dynamicDCActions = array();
}
if (isset($_SESSION['current_db_version']) && isset($_SESSION['target_db_version']) && version_compare($_SESSION['current_db_version'], $_SESSION['target_db_version'], '!=')) {
    // check if we are in upgrade. If yes, skip EAPM for now, until the DB is upgraded
    return;
}
require_once 'include/connectors/utils/ConnectorUtils.php';
require_once 'include/connectors/sources/SourceFactory.php';
$connector = SourceFactory::getSource('ext_eapm_ibmsmartcloud', false);
// Check if IBM SmartCloud (was Lotus Live) is configured and enabled
if (!empty($connector) && $connector->propertyExists('oauth_consumer_key') && $connector->propertyExists('oauth_consumer_secret') && ConnectorUtils::eapmEnabled('ext_eapm_ibmsmartcloud')) {
    // All we need is ibm smartcloud url
    require_once 'modules/EAPM/EAPM.php';
    $eapmBean = EAPM::getLoginInfo('IBMSmartCloud');
    if (!empty($eapmBean->api_data)) {
        $api_data = json_decode(base64_decode($eapmBean->api_data), true);
        if (isset($api_data['hostURL'])) {
            $lotusLiveUrl = $api_data['hostURL'];
            $lotusLiveMeetNowLabel = translate('LBL_MEET_NOW_BUTTON', 'EAPM');
            $llNowButton = '<button onclick=\\\'DCMenu.hostMeeting();\\\'>' . $lotusLiveMeetNowLabel . '</button>';
            $dynamicDCActions['LotusLiveMeetings'] = array('module' => 'Meetings', 'label' => translate('LBL_VIEW_LOTUS_LIVE_MEETINGS', 'EAPM'), 'action' => "DCMenu.hostMeetingUrl='" . $lotusLiveUrl . "'; DCMenu.loadView('" . translate('LBL_TITLE_LOTUS_LIVE_MEETINGS', 'EAPM') . "','index.php?module=Meetings&action=listbytype&type=IBMSmartCloud',undefined,undefined,undefined,'" . $llNowButton . "');", 'icon' => 'icon_LotusMeetings_footer_bar.png');
            $dynamicDCActions['LotusLiveDocuments'] = array('module' => 'Documents', 'label' => translate('LBL_VIEW_LOTUS_LIVE_DOCUMENTS', 'EAPM'), 'action' => 'DCMenu.loadView(\'' . translate('LBL_TITLE_LOTUS_LIVE_DOCUMENTS', 'EAPM') . '\',\'index.php?module=Documents&action=extdoc&type=IBMSmartCloud\');', 'icon' => 'icon_LotusDocuments_footer_bar.png');
        }
    }
    // Display alert if not connected
    $_SESSION['display_lotuslive_alert'] = empty($eapmBean);
}