use Bitrix\Seo\Service; Loader::includeModule('seo'); Loader::includeModule('socialservices'); CUtil::JSPostUnescape(); Loc::loadMessages(dirname(__FILE__) . '/../include.php'); Loc::loadMessages(dirname(__FILE__) . '/../admin/seo_adv.php'); $action = isset($_REQUEST['action']) ? $_REQUEST["action"] : null; if ($action !== "register") { $bNeedAuth = !Service::isRegistered(); if (!$bNeedAuth && $action != "authorize") { $engine = new Engine\YandexDirect(); $bNeedAuth = !Service::isAuthorized($engine->getCode()); $currentUser = null; if (!$bNeedAuth) { try { $currentAuth = Service::getAuth($engine->getCode()); if ($currentAuth) { $currentUser = $currentAuth["user"]; $bNeedAuth = false; } } catch (Exception $e) { $bNeedAuth = true; } } } } else { $bNeedAuth = false; } if (isset($action) && !$bNeedAuth) { try { switch ($_REQUEST['action']) {
public function getCurrentUser() { if (Service::isAuthorized($this->getCode())) { $currentAuth = Service::getAuth($this->getCode()); return $currentAuth['user']; } else { return false; } }
id="seo_authorize_btn" /> <?php } elseif (!Service::isAuthorized()) { $authAction = "authorizeClient();"; ?> <input type=button onclick="<?php echo $authAction; ?> " value="<?php echo Loc::getMessage('SEO_AUTH_YANDEX'); ?> " id="seo_authorize_btn" /> <?php } else { $authInfo = Service::getAuth($engine->getCode()); if (!$authInfo) { $authorizeUrl = Service::getAuthorizeLink($engine->getCode()); ?> <input type=button onclick="authorizeUser('<?php echo $authorizeUrl; ?> ')" value="<?php echo Loc::getMessage('SEO_AUTH_YANDEX'); ?> " id="seo_authorize_btn"/> <?php } else { $currentUser = $authInfo['user']; ?> <div id="auth_result" class="seo-auth-result">