|
|
@@ -86,6 +86,9 @@ class BxUnaConModule extends BxBaseModConnectModule
|
|
|
$sExpiresAt = new \DateTime('+' . $sExpiresIn . ' seconds');
|
|
|
$sRefreshToken = $aResponse['refresh_token'];
|
|
|
|
|
|
+ $oSession = BxDolSession::getInstance();
|
|
|
+ $oSession->setValue($this->getName() . '_access_token', $sAccessToken);
|
|
|
+
|
|
|
// request info about profile
|
|
|
$s = bx_file_get_contents($this->_oConfig->sApiUrl . 'api/me', array(), 'get', array(
|
|
|
'Authorization: Bearer ' . $sAccessToken,
|
|
|
@@ -119,6 +122,46 @@ class BxUnaConModule extends BxBaseModConnectModule
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Make friends
|
|
|
+ *
|
|
|
+ * @param $iProfileId integer
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ protected function _makeFriends($iProfileId)
|
|
|
+ {
|
|
|
+ if (!$this->_oConfig->bAutoFriends)
|
|
|
+ return;
|
|
|
+
|
|
|
+ $oConnFrinds = BxDolConnection::getObjectInstance('sys_profiles_friends');
|
|
|
+ if (!$oConnFrinds)
|
|
|
+ return;
|
|
|
+
|
|
|
+ // request info about profile
|
|
|
+ if (!($iRemoteProfileId = $this->_oDb->getRemoteProfileId($iProfileId)))
|
|
|
+ return;
|
|
|
+ $oSession = BxDolSession::getInstance();
|
|
|
+ if (!($sAccessToken = $oSession->getValue($this->getName() . '_access_token')))
|
|
|
+ return;
|
|
|
+ $s = bx_file_get_contents($this->_oConfig->sApiUrl . 'api/friends?id=' . $iRemoteProfileId, array(), 'get', array(
|
|
|
+ 'Authorization: Bearer ' . $sAccessToken,
|
|
|
+ ));
|
|
|
+
|
|
|
+ // handle error
|
|
|
+ if (!$s || NULL === ($aResponse = json_decode($s, true)) || !$aResponse || isset($aResponse['error']) || !isset($aResponse['friends'])) {
|
|
|
+ $sErrorDescription = isset($aResponse['error_description']) ? $aResponse['error_description'] : _t('_error occured');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // add friends & followers
|
|
|
+ foreach ($aResponse['friends'] as $iRemoteProfileId) {
|
|
|
+ if (!($iLocalProfileId = $this->_oDb->getProfileId($iRemoteProfileId)))
|
|
|
+ continue;
|
|
|
+ $oConnFrinds->actionAdd($iProfileId, $iLocalProfileId);
|
|
|
+ $oConnFrinds->actionAdd($iLocalProfileId, $iProfileId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @param $aProfileInfo - remote profile info
|
|
|
* @param $sAlternativeName - suffix to add to NickName to make it unique
|
|
|
@@ -131,6 +174,7 @@ class BxUnaConModule extends BxBaseModConnectModule
|
|
|
$aProfileFields['name'] = $aProfileInfo['profile_display_name'];
|
|
|
$aProfileFields['fullname'] = $aProfileInfo['profile_display_name'];
|
|
|
$aProfileFields['picture'] = $aProfileInfo['picture'];
|
|
|
+ $aProfileFields['allow_view_to'] = getParam('bx_unacon_privacy');
|
|
|
|
|
|
return $aProfileFields;
|
|
|
}
|