Пример #1
0
<?php

$tpl = erLhcoreClassTemplate::getInstance('lhxmp/xmp.tpl.php');
$xmpData = erLhcoreClassModelChatConfig::fetch('xmp_data');
$data = (array) $xmpData->data;
if (isset($_POST['StoreXMPGTalkSendeMessage'])) {
    try {
        $definition = array('test_recipients_gtalk' => new ezcInputFormDefinitionElement(ezcInputFormDefinitionElement::OPTIONAL, 'validate_email'));
        $form = new ezcInputForm(INPUT_POST, $definition);
        if ($form->hasValidData('test_recipients_gtalk')) {
            erLhcoreClassXMP::sendTestXMPGTalk($form->test_recipients_gtalk);
            $tpl->set('message_send', 'done');
            $tpl->set('test_gmail_email', $form->test_recipients_gtalk);
        } else {
            $tpl->set('errors', array(erTranslationClassLhTranslation::getInstance()->getTranslation('system/xmpp', 'Invalid test e-mail address')));
        }
    } catch (Exception $e) {
        $tpl->set('errors', array($e->getMessage()));
    }
}
if (isset($_POST['StoreXMPGTalkRevokeToken'])) {
    try {
        erLhcoreClassXMP::revokeAccessToken();
        $tpl->set('token_revoked', 'done');
    } catch (Exception $e) {
        $tpl->set('errors', array($e->getMessage()));
    }
}
if ($Params['user_parameters_unordered']['gtalkoauth'] == 'true') {
    require_once 'lib/core/lhxmp/google/Google_Client.php';
    require_once 'lib/core/lhxmp/google/contrib/Google_Oauth2Service.php';
Пример #2
0
<?php

$tpl = erLhcoreClassTemplate::getInstance('lhxmp/xmp.tpl.php');
$xmpData = erLhcoreClassModelChatConfig::fetch('xmp_data');
$data = (array) $xmpData->data;
if (isset($_POST['StoreXMPGTalkSendeMessage'])) {
    try {
        erLhcoreClassXMP::sendTestXMPGTalk($currentUser->getUserData());
        $tpl->set('message_send', 'done');
    } catch (Exception $e) {
        $tpl->set('errors', array($e->getMessage()));
    }
}
if (isset($_POST['StoreXMPGTalkRevokeToken'])) {
    try {
        erLhcoreClassXMP::revokeAccessToken();
        $tpl->set('token_revoked', 'done');
    } catch (Exception $e) {
        $tpl->set('errors', array($e->getMessage()));
    }
}
if ($Params['user_parameters_unordered']['gtalkoauth'] == 'true') {
    require_once 'lib/core/lhxmp/google/Google_Client.php';
    require_once 'lib/core/lhxmp/google/contrib/Google_Oauth2Service.php';
    $client = new Google_Client();
    $oauth2 = new Google_Oauth2Service($client);
    $client->setApplicationName('Live Helper Chat');
    $client->setScopes(array("https://www.googleapis.com/auth/googletalk", "https://www.googleapis.com/auth/userinfo.email"));
    $client->setClientId($data['gtalk_client_id']);
    $client->setClientSecret($data['gtalk_client_secret']);
    $client->setApprovalPrompt('force');