use Bitrix\Main\Localization\Loc; use Bitrix\Seo\Engine; use Bitrix\Seo\Adv; use Bitrix\Main\Type\Date; 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;
public function getCurrentUser() { if (Service::isAuthorized($this->getCode())) { $currentAuth = Service::getAuth($this->getCode()); return $currentAuth['user']; } else { return false; } }
$authAction = ""; $request = Context::getCurrent()->getRequest(); echo BeginNote(); if (!Service::isRegistered()) { $authAction = "registerClient();"; ?> <input type=button onclick="<?php echo $authAction; ?> " value="<?php echo Loc::getMessage('SEO_YANDEX_REGISTER'); ?> " 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());