function gotowebinar_civicrm_buildForm($formName, &$form) { if ($formName == 'CRM_Event_Form_ManageEvent_EventInfo' and ($form->getAction() == CRM_Core_Action::ADD or $form->getAction() == CRM_Core_Action::UPDATE)) { $accessToken = CRM_Core_BAO_Setting::getItem(CRM_Gotowebinar_Form_Setting::WEBINAR_SETTING_GROUP, 'access_token', NULL, FALSE); $organizerKey = CRM_Core_BAO_Setting::getItem(CRM_Gotowebinar_Form_Setting::WEBINAR_SETTING_GROUP, 'organizer_key', NULL, FALSE); if ($accessToken && $organizerKey) { $upcomingWebinars = CRM_Gotowebinar_Form_Setting::findUpcomingWebinars(); $form->assign('upcomingWebinars', $upcomingWebinars); } } }
/** * Function to process the form * * @access public * * @return None */ public function postProcess() { // Store the submitted values in an array. $params = $this->controller->exportValues($this->_name); // If gotowebinar was already connected, we introduced button called 'save status' CRM_Core_BAO_Setting::setItem(array_keys($params['participant_status_id']), self::WEBINAR_SETTING_GROUP, 'participant_status'); // Save the API Key & Save the Security Key if (CRM_Utils_Array::value('api_key', $params) && CRM_Utils_Array::value('email_address', $params) && CRM_Utils_Array::value('password', $params)) { CRM_Core_BAO_Setting::setItem(array_keys($params['participant_status_id']), self::WEBINAR_SETTING_GROUP, 'participant_status'); $apiKey = urlencode($params['api_key']); $username = urlencode($params['email_address']); $password = urlencode($params['password']); $redirectUrl = CRM_Utils_System::url('civicrm/gotowebinar/settings', 'reset=1', TRUE, NULL, FALSE, TRUE); $url = "https://api.citrixonline.com/oauth/access_token?grant_type=password&user_id=" . $username . "&password="******"&client_id=" . $apiKey; $clientInfo = $this->requestPost($url); if (isset($clientInfo['int_err_code']) && $clientInfo['int_err_code'] != '') { $session = CRM_Core_Session::singleton(); $session->set("autherror", $clientInfo); CRM_Utils_System::redirect($redirectUrl); } else { if ($clientInfo['access_token'] && $clientInfo['organizer_key']) { CRM_Core_BAO_Setting::setItem($clientInfo['access_token'], self::WEBINAR_SETTING_GROUP, 'access_token'); CRM_Core_BAO_Setting::setItem($clientInfo['organizer_key'], self::WEBINAR_SETTING_GROUP, 'organizer_key'); $session = CRM_Core_Session::singleton(); $session->set("autherror", NULL); CRM_Utils_System::redirect($redirectUrl); $upcomingWebinars = CRM_Gotowebinar_Form_Setting::findUpcomingWebinars(); if (isset($upcomingWebinars['int_err_code']) and $upcomingWebinars['int_err_code'] != '') { $this->assign('error', $upcomingWebinars); } else { $this->assign('responseKey', TRUE); $this->assign('upcomingWebinars', $upcomingWebinars); } } } } }