本文整理汇总了PHP中CSocServAuthDB::Update方法的典型用法代码示例。如果您正苦于以下问题:PHP CSocServAuthDB::Update方法的具体用法?PHP CSocServAuthDB::Update怎么用?PHP CSocServAuthDB::Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSocServAuthDB
的用法示例。
在下文中一共展示了CSocServAuthDB::Update方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveDataDB
public function saveDataDB()
{
global $USER;
$dbSocUser = CSocServAuthDB::GetList(array(), array('XML_ID' => $this->appID, 'PERSONAL_WWW' => $this->portalURI, 'EXTERNAL_AUTH_ID' => "Bitrix24OAuth"), false, false, array("ID"));
if ($USER->IsAuthorized()) {
$arFields = array('PERSONAL_WWW' => $this->portalURI, 'XML_ID' => $this->appID, 'EXTERNAL_AUTH_ID' => static::SERVICE_ID, 'USER_ID' => $USER->GetID(), 'OATOKEN' => $this->access_token, 'OATOKEN_EXPIRES' => $this->accessTokenExpires, 'OASECRET' => $this->getSignatureKey(), 'LOGIN' => $this->appID);
if ($this->refresh_token != '') {
$arFields['REFRESH_TOKEN'] = $this->refresh_token;
}
if ($arUser = $dbSocUser->Fetch()) {
return CSocServAuthDB::Update($arUser["ID"], $arFields);
} else {
return CSocServAuthDB::Add($arFields);
}
}
return true;
}
示例2: getNewAccessToken
public function getNewAccessToken($refreshToken = false, $userId = 0, $save = false, $scope = array())
{
if ($this->appID == false || $this->appSecret == false) {
return false;
}
if ($refreshToken == false) {
$refreshToken = $this->refresh_token;
}
if ($scope != null) {
$this->addScope($scope);
}
$http = new \Bitrix\Main\Web\HttpClient(array('socketTimeout' => $this->httpTimeout));
$result = $http->get(self::NET_URL . self::TOKEN_URL . '?' . http_build_query(array('client_id' => $this->appID, 'client_secret' => $this->appSecret, 'refresh_token' => $refreshToken, 'scope' => implode(',', $this->getScope()), 'grant_type' => 'refresh_token')));
$arResult = CUtil::JsObjectToPhp($result);
if (isset($arResult["access_token"]) && $arResult["access_token"] != '') {
$this->access_token = $arResult["access_token"];
$this->accessTokenExpires = time() + $arResult["expires_in"];
$this->refresh_token = $arResult["refresh_token"];
if ($save && intval($userId) > 0) {
$dbSocservUser = CSocServAuthDB::GetList(array(), array("USER_ID" => intval($userId), "EXTERNAL_AUTH_ID" => CSocServBitrix24Net::ID), false, false, array("ID"));
$arOauth = $dbSocservUser->Fetch();
if ($arOauth) {
CSocServAuthDB::Update($arOauth["ID"], array("OATOKEN" => $this->access_token, "OATOKEN_EXPIRES" => $this->accessTokenExpires, "REFRESH_TOKEN" => $this->refresh_token));
}
}
return true;
}
return false;
}
示例3: RefreshToken
private function RefreshToken($socServUserId)
{
$result = CHTTP::sPostHeader(self::TOKEN_URL, array("refresh_token" => $this->refresh_token, "client_id" => $this->appID, "client_secret" => $this->appSecret, "grant_type" => "refresh_token"), array(), $this->httpTimeout);
$arResult = CUtil::JsObjectToPhp($result);
if (isset($arResult["access_token"]) && $arResult["access_token"] != '') {
$this->access_token = $arResult["access_token"];
CSocServAuthDB::Update($socServUserId, array("OATOKEN" => $arResult["access_token"]));
return true;
}
return false;
}
示例4: getNewAccessToken
public function getNewAccessToken($refreshToken = false, $userId = 0, $save = false)
{
if ($this->appID == false || $this->appSecret == false) {
return false;
}
if ($refreshToken == false) {
$refreshToken = $this->refresh_token;
}
$result = CHTTP::sPostHeader(static::TOKEN_URL, array("refresh_token" => $refreshToken, "client_id" => $this->appID, "client_secret" => $this->appSecret, "grant_type" => "refresh_token"), array(), $this->httpTimeout);
$this->arResult = CUtil::JsObjectToPhp($result);
if (isset($this->arResult["access_token"]) && $this->arResult["access_token"] != '') {
$this->access_token = $this->arResult["access_token"];
$this->accessTokenExpires = $this->arResult["expires_in"] + time();
if ($save && intval($userId) > 0) {
$dbSocservUser = CSocServAuthDB::GetList(array(), array('USER_ID' => intval($userId), "EXTERNAL_AUTH_ID" => static::SERVICE_ID), false, false, array("ID"));
if ($arOauth = $dbSocservUser->Fetch()) {
CSocServAuthDB::Update($arOauth["ID"], array("OATOKEN" => $this->access_token, "OATOKEN_EXPIRES" => $this->accessTokenExpires));
}
}
return true;
}
return false;
}
示例5: AuthorizeUser
public function AuthorizeUser($arFields)
{
if (!isset($arFields['XML_ID']) || $arFields['XML_ID'] == '') {
return false;
}
if (!isset($arFields['EXTERNAL_AUTH_ID']) || $arFields['EXTERNAL_AUTH_ID'] == '') {
return false;
}
$errorCode = 1;
if ($GLOBALS["USER"]->IsAuthorized() && $GLOBALS["USER"]->GetID()) {
$id = CSocServAuthDB::Add($arFields);
if ($id && $_SESSION["OAUTH_DATA"] && is_array($_SESSION["OAUTH_DATA"])) {
CSocServAuthDB::Update($id, $_SESSION["OAUTH_DATA"]);
unset($_SESSION["OAUTH_DATA"]);
}
} else {
$dbSocUser = CSocServAuthDB::GetList(array(), array('XML_ID' => $arFields['XML_ID'], 'EXTERNAL_AUTH_ID' => $arFields['EXTERNAL_AUTH_ID']), false, false, array("USER_ID", "ACTIVE"));
$dbUsersOld = $GLOBALS["USER"]->GetList($by, $ord, array('XML_ID' => $arFields['XML_ID'], 'EXTERNAL_AUTH_ID' => $arFields['EXTERNAL_AUTH_ID'], 'ACTIVE' => 'Y'), array('NAV_PARAMS' => array("nTopCount" => "1")));
$dbUsersNew = $GLOBALS["USER"]->GetList($by, $ord, array('XML_ID' => $arFields['XML_ID'], 'EXTERNAL_AUTH_ID' => 'socservices', 'ACTIVE' => 'Y'), array('NAV_PARAMS' => array("nTopCount" => "1")));
if ($arUser = $dbSocUser->Fetch()) {
if ($arUser["ACTIVE"] === 'Y') {
$USER_ID = $arUser["USER_ID"];
}
} elseif ($arUser = $dbUsersOld->Fetch()) {
$USER_ID = $arUser["ID"];
} elseif ($arUser = $dbUsersNew->Fetch()) {
$USER_ID = $arUser["ID"];
} elseif (COption::GetOptionString("main", "new_user_registration", "N") == "Y") {
$arFields['PASSWORD'] = randString(30);
//not necessary but...
$arFields['LID'] = SITE_ID;
$def_group = COption::GetOptionString('main', 'new_user_registration_def_group', '');
if ($def_group != '') {
$arFields['GROUP_ID'] = explode(',', $def_group);
}
$arFieldsUser = $arFields;
$arFieldsUser["EXTERNAL_AUTH_ID"] = "socservices";
if (!($USER_ID = $GLOBALS["USER"]->Add($arFieldsUser))) {
return false;
}
$arFields['CAN_DELETE'] = 'N';
$arFields['USER_ID'] = $USER_ID;
$id = CSocServAuthDB::Add($arFields);
if ($id && $_SESSION["OAUTH_DATA"] && is_array($_SESSION["OAUTH_DATA"])) {
CSocServAuth::Update($id, $_SESSION["OAUTH_DATA"]);
unset($_SESSION["OAUTH_DATA"]);
}
unset($arFields['CAN_DELETE']);
} elseif (COption::GetOptionString("main", "new_user_registration", "N") == "N") {
$errorCode = 2;
}
if (isset($USER_ID) && $USER_ID > 0) {
$GLOBALS["USER"]->Authorize($USER_ID);
} else {
return $errorCode;
}
//it can be redirect after authorization, so no spreading. Store cookies in the session for next hit
$GLOBALS['APPLICATION']->StoreCookies();
}
return true;
}
示例6: AuthorizeUser
public function AuthorizeUser($arFields)
{
global $USER, $APPLICATION;
if (!isset($arFields['XML_ID']) || $arFields['XML_ID'] == '') {
return false;
}
if (!isset($arFields['EXTERNAL_AUTH_ID']) || $arFields['EXTERNAL_AUTH_ID'] == '') {
return false;
}
$arOAuthKeys = array();
if (isset($arFields["OATOKEN"])) {
$arOAuthKeys["OATOKEN"] = $arFields["OATOKEN"];
}
if (isset($arFields["REFRESH_TOKEN"]) && $arFields["REFRESH_TOKEN"] !== '') {
$arOAuthKeys["REFRESH_TOKEN"] = $arFields["REFRESH_TOKEN"];
}
if (isset($arFields["OATOKEN_EXPIRES"])) {
$arOAuthKeys["OATOKEN_EXPIRES"] = $arFields["OATOKEN_EXPIRES"];
}
$errorCode = SOCSERV_AUTHORISATION_ERROR;
$dbSocUser = CSocServAuthDB::GetList(array(), array('XML_ID' => $arFields['XML_ID'], 'EXTERNAL_AUTH_ID' => $arFields['EXTERNAL_AUTH_ID']), false, false, array("ID", "USER_ID", "ACTIVE"));
$arUser = $dbSocUser->Fetch();
if ($USER->IsAuthorized()) {
if (!self::isSplitDenied()) {
if (!$arUser) {
$id = CSocServAuthDB::Add($arFields);
} else {
$id = $arUser['ID'];
// socservice link split
if ($arUser['USER_ID'] != $USER->GetID()) {
$dbRes = CSocServAuthDB::GetList(array(), array('USER_ID' => $USER->GetID(), 'EXTERNAL_AUTH_ID' => $arFields['EXTERNAL_AUTH_ID']), false, false, array("ID"));
if ($dbRes->Fetch()) {
return SOCSERV_AUTHORISATION_ERROR;
} else {
$arOAuthKeys['USER_ID'] = $USER->GetID();
$arOAuthKeys['CAN_DELETE'] = 'Y';
}
}
}
if ($_SESSION["OAUTH_DATA"] && is_array($_SESSION["OAUTH_DATA"])) {
$arOAuthKeys = array_merge($arOAuthKeys, $_SESSION['OAUTH_DATA']);
unset($_SESSION["OAUTH_DATA"]);
}
CSocServAuthDB::Update($id, $arOAuthKeys);
} else {
return SOCSERV_REGISTRATION_DENY;
}
} else {
$entryId = 0;
$USER_ID = 0;
if ($arUser) {
$entryId = $arUser['ID'];
if ($arUser["ACTIVE"] === 'Y') {
$USER_ID = $arUser["USER_ID"];
}
} else {
// check for user with old socialservices linking system (socservice ID in user's EXTERNAL_AUTH_ID)
$dbUsersOld = CUser::GetList($by = 'ID', $ord = 'ASC', array('XML_ID' => $arFields['XML_ID'], 'EXTERNAL_AUTH_ID' => $arFields['EXTERNAL_AUTH_ID'], 'ACTIVE' => 'Y'), array('NAV_PARAMS' => array("nTopCount" => "1")));
$arUser = $dbUsersOld->Fetch();
if ($arUser) {
$USER_ID = $arUser["ID"];
} else {
// theoretically possible situation with abandoned external user w/o b_socialservices_user entry
$dbUsersNew = CUser::GetList($by = 'ID', $ord = 'ASC', array('XML_ID' => $arFields['XML_ID'], 'EXTERNAL_AUTH_ID' => 'socservices', 'ACTIVE' => 'Y'), array('NAV_PARAMS' => array("nTopCount" => "1")));
$arUser = $dbUsersNew->Fetch();
if ($arUser) {
$USER_ID = $arUser["ID"];
} elseif (COption::GetOptionString("main", "new_user_registration", "N") == "Y" && COption::GetOptionString("socialservices", "allow_registration", "Y") == "Y") {
$arFields['PASSWORD'] = randString(30);
//not necessary but...
$arFields['LID'] = SITE_ID;
$def_group = COption::GetOptionString('main', 'new_user_registration_def_group', '');
if ($def_group != '') {
$arFields['GROUP_ID'] = explode(',', $def_group);
}
if (!empty($arFields['GROUP_ID']) && self::isAuthDenied($arFields['GROUP_ID'])) {
$errorCode = SOCSERV_REGISTRATION_DENY;
} else {
$arFieldsUser = $arFields;
$arFieldsUser["EXTERNAL_AUTH_ID"] = "socservices";
if (isset($arFieldsUser['PERSONAL_PHOTO']) && is_array($arFieldsUser['PERSONAL_PHOTO'])) {
$res = CFile::CheckImageFile($arFieldsUser["PERSONAL_PHOTO"]);
if ($res != '') {
unset($arFieldsUser['PERSONAL_PHOTO']);
}
}
$USER_ID = $USER->Add($arFieldsUser);
if ($USER_ID <= 0) {
$errorCode = SOCSERV_AUTHORISATION_ERROR;
}
}
} elseif (COption::GetOptionString("main", "new_user_registration", "N") == "N") {
$errorCode = SOCSERV_REGISTRATION_DENY;
}
$arFields['CAN_DELETE'] = 'N';
}
}
if (isset($_SESSION["OAUTH_DATA"]) && is_array($_SESSION["OAUTH_DATA"])) {
foreach ($_SESSION['OAUTH_DATA'] as $key => $value) {
$arFields[$key] = $value;
//.........这里部分代码省略.........
示例7: saveDataDB
private function saveDataDB()
{
$dbSocUser = CSocServAuthDB::GetList(array(), array('XML_ID' => $this->appID, 'PERSONAL_WWW' => $this->portalURI, 'EXTERNAL_AUTH_ID' => "Bitrix24OAuth"), false, false, array("ID"));
if($GLOBALS["USER"]->IsAuthorized() && $GLOBALS["USER"]->GetID())
{
$arFields = array(
'PERSONAL_WWW' => $this->portalURI,
'XML_ID' => $this->appID,
'EXTERNAL_AUTH_ID' => "Bitrix24OAuth",
'USER_ID' => $GLOBALS["USER"]->GetID(),
'OATOKEN' => $this->access_token,
'OATOKEN_EXPIRES' => $this->accessTokenExpires + time(),
'LOGIN' => $this->appID,
);
if($this->refresh_token <> '')
$arFields['REFRESH_TOKEN'] = $this->refresh_token;
if($arUser = $dbSocUser->Fetch())
{
return CSocServAuthDB::Update($arUser["ID"], $arFields);
}
else
{
return CSocServAuthDB::Add($arFields);
}
}
return true;
}
示例8: getNewAccessToken
public function getNewAccessToken($refreshToken = false, $userId = 0, $save = false, $scope = array())
{
if ($this->appID == false || $this->appSecret == false) {
return false;
}
if ($refreshToken == false) {
$refreshToken = $this->refresh_token;
}
$http = new HttpClient(array('socketTimeout' => $this->httpTimeout));
$result = $http->post(static::TOKEN_URL, array('client_id' => $this->appID, 'client_secret' => $this->appSecret, 'refresh_token' => $refreshToken, 'grant_type' => 'refresh_token'));
$arResult = Json::decode($result);
if (isset($arResult["access_token"]) && $arResult["access_token"] != '') {
$this->access_token = $arResult["access_token"];
$this->accessTokenExpires = time() + $arResult["expires_in"];
$this->refresh_token = $arResult["refresh_token"];
if ($save && intval($userId) > 0) {
$dbSocservUser = CSocServAuthDB::GetList(array(), array("USER_ID" => intval($userId), "EXTERNAL_AUTH_ID" => CSocServBoxAuth::ID), false, false, array("ID"));
$arOauth = $dbSocservUser->Fetch();
if ($arOauth) {
CSocServAuthDB::Update($arOauth["ID"], array("OATOKEN" => $this->access_token, "OATOKEN_EXPIRES" => $this->accessTokenExpires, "REFRESH_TOKEN" => $this->refresh_token));
}
}
return true;
}
return false;
}
示例9: getNewAccessToken
public function getNewAccessToken($refreshToken, $userId = 0, $save = false)
{
if ($this->appID == false || $this->appSecret == false) {
return false;
}
$httpClient = new \Bitrix\Main\Web\HttpClient();
$result = $httpClient->post(static::TOKEN_URL, array("refresh_token" => $refreshToken, "client_id" => $this->appID, "client_secret" => $this->appSecret, "grant_type" => "refresh_token"));
$arResult = \Bitrix\Main\Web\Json::decode($result);
if (isset($arResult["access_token"]) && $arResult["access_token"] != '') {
$this->access_token = $arResult["access_token"];
$this->accessTokenExpires = $arResult["expires_in"];
if ($save && intval($userId) > 0) {
$dbSocservUser = CSocServAuthDB::GetList(array(), array('USER_ID' => intval($userId), "EXTERNAL_AUTH_ID" => static::SERVICE_ID), false, false, array("ID"));
if ($arOauth = $dbSocservUser->Fetch()) {
CSocServAuthDB::Update($arOauth["ID"], array("OATOKEN" => $this->access_token, "OATOKEN_EXPIRES" => time() + $this->accessTokenExpires));
}
}
return true;
}
return false;
}