Ver Fonte

Merge branch 'master' of https://github.com/unaio/una

AntonLV há 2 anos atrás
pai
commit
effbc02274

+ 1 - 1
inc/version.inc.php

@@ -7,6 +7,6 @@
  * @{
  */
 
-define('BX_DOL_VERSION', '14.0.0-A1'); ///< system files version, for DB version @see bx_get_ver, DB and files version must match
+define('BX_DOL_VERSION', '14.0.0-DEV2'); ///< system files version, for DB version @see bx_get_ver, DB and files version must match
 
 /** @} */

+ 1 - 1
install/index.php

@@ -10,7 +10,7 @@
 define ('BX_DOL_INSTALL',  true);
 define ('BX_SKIP_INSTALL_CHECK', true);
 
-define ('BX_DOL_VER', '14.0.0-A1');
+define ('BX_DOL_VER', '14.0.0-DEV2');
 
 define ('BX_INSTALL_DEFAULT_LANGUAGE', 'en');
 

+ 2 - 2
modules/boonex/english/data/langs/system/en.xml

@@ -2177,11 +2177,11 @@ If you don't know how to do it by yourself you can submit <a target="_blank" hre
 	<string name="_sys_audit_msg_php_setup_inefficient"><![CDATA[your PHP setup maybe very inefficient, <a href="javascript:void(0)" onclick="bx_sys_adm_audit_phpinfo()">please check it for sure</a> and try to switch to mod_php, apache dso module or FastCGI]]></string>
 	<string name="_sys_audit_msg_serverside_compression"><![CDATA[
 can be checked <a href="#manual_audit">manually</a> or in "Page Speed" tool build-in into browser.<br />
-If it is not enabled then please consider implement this optimization, since it improve perceived site speed and save the bandwidth, refer to <a href="http://www.boonex.com/trac/dolphin/wiki/HostingServerSetupRecommendations#Serversidecontentcompression">this tutorial</a> on how to do this.<br />{0}]]></string>
+If it is not enabled then please consider implement this optimization, since it improve perceived site speed and save the bandwidth.<br />{0}]]></string>
 	<string name="_sys_audit_msg_should_be"><![CDATA[should be {0} {1}]]></string>
 	<string name="_sys_audit_msg_userside_caching"><![CDATA[
 <a href="{0}">click here to check it in Google Page Speed</a><br />
-If it is not enabled then please consider implement this optimization, since it improve perceived site speed and save the bandwidth, refer to <a target="_blank" href="http://www.boonex.com/trac/dolphin/wiki/HostingServerSetupRecommendations#Usersidecachingforstaticcontent">this tutorial</a> on how to do this.<br />{1}]]></string>
+If it is not enabled then please consider implement this optimization, since it improve perceived site speed and save the bandwidth.<br />{1}]]></string>
 	<string name="_sys_audit_msg_value_checking_failed"><![CDATA[value checking failed]]></string>
 	<string name="_sys_audit_msg_version_is_incompatible"><![CDATA[your version is incompatible with UNA, must be at least {0}]]></string>
 	<string name="_sys_audit_msg_version_is_outdated"><![CDATA[your version is outdated, upgrade to the latest {0} maybe required]]></string>

+ 1 - 1
modules/boonex/linkedin_connect/classes/BxLinkedinConfig.php

@@ -21,7 +21,7 @@ class BxLinkedinConfig extends BxBaseModConnectConfig
     public $sPageStart;
     public $sPageHandle;
 
-    public $sScope = 'r_liteprofile r_emailaddress';
+    public $sScope = 'openid email profile';
 
     function __construct($aModule)
     {

+ 7 - 59
modules/boonex/linkedin_connect/classes/BxLinkedinModule.php

@@ -86,7 +86,7 @@ class BxLinkedinModule extends BxBaseModConnectModule
         $sExpiresAt = new \DateTime('+' . $sExpiresIn . ' seconds');
 
         // request info about profile
-        $s = bx_file_get_contents($this->_oConfig->sApiUrl . '/me?projection=(' . $this->_oConfig->sFields . ')', array(), 'get', array(
+        $s = bx_file_get_contents($this->_oConfig->sApiUrl . '/userinfo', array(), 'get', array(
             'Authorization: Bearer ' . $sAccessToken,
         ));
 
@@ -97,19 +97,7 @@ class BxLinkedinModule extends BxBaseModConnectModule
             return;
         }
 
-        // request email
-        $s = bx_file_get_contents($this->_oConfig->sApiUrl . '/emailAddress?q=members&projection=(elements*(handle~))', array(), 'get', array(
-            'Authorization: Bearer ' . $sAccessToken,
-        ));
-
-        // handle error
-        if (!$s || NULL === ($aResponseEmail = json_decode($s, true)) || !$aResponseEmail || (isset($aResponseEmail['status']) && ($aResponseEmail['status'] < 200 || $aResponseEmail['status'] > 299))) {
-            $sErrorDescription = isset($aResponseEmail['message']) ? $aResponseEmail['message'] : _t('_error occured'); 
-            $this->_oTemplate->getPage(_t('_Error'), MsgBox($sErrorDescription));
-            return;
-        }
-
-        $aRemoteProfileInfo = array_merge($aResponse, $aResponseEmail);
+        $aRemoteProfileInfo = array_merge($aResponse, ['id' => $aResponse['sub']]);
 
         if ($aRemoteProfileInfo) {
 
@@ -118,7 +106,7 @@ class BxLinkedinModule extends BxBaseModConnectModule
             
             if ($iLocalProfileId && $oProfile = BxDolProfile::getInstance($iLocalProfileId)) {
                 // user already exists
-                $this->setLogged($oProfile ->id());
+                $this->setLogged($oProfile->id());
             }             
             else {  
                 // register new user
@@ -139,55 +127,15 @@ class BxLinkedinModule extends BxBaseModConnectModule
     {
         $aProfileFields = $aProfileInfo;
 
-        $aProfileFields['name'] = $this->_getLocalizedValue($aProfileInfo['firstName']);
-        $aProfileFields['fullname'] = $this->_getLocalizedValue($aProfileInfo['firstName']) . ' ' . (isset($aProfileInfo['lastName']) ? $this->_getLocalizedValue($aProfileInfo['lastName']) : '');
-        $aProfileFields['email'] = isset($aProfileInfo['elements']) ? $this->_getEmail($aProfileInfo['elements']) : '';
-        $aProfileFields['picture'] = isset($aProfileInfo['profilePicture']) ? $this->_getImageUrl($aProfileInfo['profilePicture']) : '';
+        $aProfileFields['name'] = $aProfileInfo['name'];
+        $aProfileFields['fullname'] = $aProfileInfo['name'];
+        $aProfileFields['email'] = $aProfileInfo['email'];
+        $aProfileFields['picture'] = $aProfileInfo['picture'];
         $aProfileFields['allow_view_to'] = getParam('bx_linkedin_privacy');
 
         return $aProfileFields;
     }
 
-    protected function _getLocalizedValue($a) 
-    {
-        $sLocale = isset($a['preferredLocale']) ? $a['preferredLocale']['language'] . '_' . $a['preferredLocale']['country'] : false;
-        if (isset($a['localized']) && isset($a['localized'][$sLocale]))
-            return $a['localized'][$sLocale];
-        return false;
-    }
-
-    protected function _getEmail($a) 
-    {
-        $r = array_pop($a);
-        if (!isset($r['handle~']) || !isset($r['handle~']['emailAddress']))
-            return false;
-        return $r['handle~']['emailAddress'];
-    }
-
-    protected function _getImageUrl($a) 
-    {
-        if (!isset($a['displayImage~']))
-            return false;
-        $aBiggestImage = false;
-        foreach ($a['displayImage~']['elements'] as $r) {
-            if (empty($r['identifiers']) || !isset($r['data']) || !isset($r['data']['com.linkedin.digitalmedia.mediaartifact.StillImage']) || !isset($r['data']['com.linkedin.digitalmedia.mediaartifact.StillImage']['storageSize']))
-                continue;
-            if (!$aBiggestImage || $r['data']['com.linkedin.digitalmedia.mediaartifact.StillImage']['storageSize']['width'] > $aBiggestImage['width']) {
-                foreach ($r['identifiers'] as $rr) {
-                    if ('EXTERNAL_URL' == $rr['identifierType']) {
-                        $aBiggestImage = array(
-                            'width' => $r['data']['com.linkedin.digitalmedia.mediaartifact.StillImage']['storageSize']['width'],
-                            'url' => $rr['identifier'],
-                        );
-                        break;
-                    }
-                }
-            }
-        }
-        if (!$aBiggestImage)
-            return false;
-        return $aBiggestImage['url'];
-    }
 }
 
 /** @} */

+ 7 - 6
modules/boonex/linkedin_connect/install/langs/en.xml

@@ -4,13 +4,14 @@
 	<string name="_bx_linkedin"><![CDATA[LinkedIn Connect]]></string>
 	<string name="_bx_linkedin_settings"><![CDATA[LinkedIn Connect]]></string>
 	<string name="_bx_linkedin_information_block"><![CDATA[
-        <p>This module can be used to login to this site using LinkedIn credentials.</p>
-        <p>To make it work, <a target="_blank" href="https://www.linkedin.com/developer/apps">create LinkedIn app</a> and specify all the details, particularly:
+        <p>This module can be used to login to the site using LinkedIn credentials.</p>
+        <p>To make it work:
             <ul>
-                <li>For "Application Permissions": <strong>r_liteprofile</strong> and <strong>r_emailaddress</strong></li>
-                <li>For the redirect URL: <strong>{0}</strong></li>
-            </ul>
-            Then enter generated Client ID & Secret pair in this module settings.
+                <li><a target="_blank" href="https://www.linkedin.com/developers/apps">Create LinkedIn app</a></li>
+                <li>Add the following <strong>Authorized redirect URLs for your app</strong> in <strong>Auth</strong> section: <strong>{0}</strong></li>
+                <li>Add <strong>Sign In with LinkedIn using OpenID Connect</strong> product in <strong>Products</strong> section</li>
+                <li>Get generated Client ID & Secret pair from <strong>Auth</strong> section then enter these details in this module settings.</li>
+            </ul>            
         </p>]]></string>
 	<string name="_bx_linkedin_profile_error_api_keys"><![CDATA[Please configure the module in admin panel (can't define Client ID and Secret)]]></string>
 	<string name="_bx_linkedin_auth_title"><![CDATA[Login with LinkedIn]]></string>	

+ 7 - 6
modules/boonex/russian/data/langs/bx_linkedin/ru.xml

@@ -5,12 +5,13 @@
 	<string name="_bx_linkedin_settings"><![CDATA[LinkedIn-соединение]]></string>
 	<string name="_bx_linkedin_information_block"><![CDATA[
         <p>Этот модуль может использоваться для входа на сайт используя LinkedIn профиль.</p>
-        <p>Чтобы он заработал, нужно <a target="_blank" href="https://www.linkedin.com/developer/apps">создать LinkedIn приложение</a> и указать всю необходимую информацию, в частности:
+        <p>Чтобы он заработал, нужно:
             <ul>
-                <li>Для "Application Permissions": <strong>r_basicprofile</strong> и <strong>r_emailaddress</strong></li>
-                <li>Для "Redirect URL": <strong>{0}</strong></li>
-            </ul>
-            Затем нужно ввести полученную пару Client ID & Secret в настройках этого модуля.
+                <li><a target="_blank" href="https://www.linkedin.com/developers/apps">Cоздать LinkedIn приложение</a></li>
+                <li>Добавить следуюший адрес для <strong>Authorized redirect URLs for your app</strong> в секции <strong>Auth</strong>: <strong>{0}</strong></li>
+                <li>Добавить продукт <strong>Sign In with LinkedIn using OpenID Connect</strong> в секции <strong>Products</strong></li>
+                <li>Затем нужно ввести полученную пару Client ID & Secret в настройках этого модуля</li>
+            </ul>            
         </p>]]></string>
     
     <string name="_bx_linkedin_profile_error_api_keys"><![CDATA[Нужно настроить модуль - указать LinkedIn Client ID & Secret]]></string>
@@ -26,4 +27,4 @@
 <p>Временный пароль - <b>{password}</b></p>
 <p>Его нужно изменить, после первого захода на сайт.</p>
 {email_footer}]]></string>
-</resources>
+</resources>

+ 2 - 2
modules/boonex/russian/data/langs/system/ru.xml

@@ -2152,11 +2152,11 @@
 	<string name="_sys_audit_msg_php_setup_inefficient"><![CDATA[Ваши PHP-настройки могут быть очень неэффективными, <a href="javascript:void(0)" onclick="bx_sys_adm_audit_phpinfo()">проверьте их</a> и попробуйте переключиться на mod_php, apache dso module или FastCGI]]></string>
 	<string name="_sys_audit_msg_serverside_compression"><![CDATA[
 может быть проверено <a href="#manual_audit">вручную</a> или с помощью интсрумента "Page Speed", встроенного в браузер.<br />
-Если он не задействован, тогда попробуйте применить эту оптимизацию, так как она улучшает скорость сайта и сохраняет трафик, обратитесь к <a href="http://www.boonex.com/trac/dolphin/wiki/HostingServerSetupRecommendations#Serversidecontentcompression">этому руководству</a>, чтобы узнать больше.<br />{0}]]></string>
+Если он не задействован, тогда попробуйте применить эту оптимизацию, так как она улучшает скорость сайта и сохраняет трафик.<br />{0}]]></string>
 	<string name="_sys_audit_msg_should_be"><![CDATA[хорошо бы {0} {1}]]></string>
 	<string name="_sys_audit_msg_userside_caching"><![CDATA[
 <a href="{0}">нажмите здесь для проверки в Google Page Speed</a><br />
-Если он не задействован, тогда попробуйте применить эту оптимизацию, так как она улучшает скорость сайта и сохраняет трафик, обратитесь к <a target="_blank" href="http://www.boonex.com/trac/dolphin/wiki/HostingServerSetupRecommendations#Usersidecachingforstaticcontent">этому руководству</a>, чтобы узнать больше.<br />{1}]]></string>
+Если он не задействован, тогда попробуйте применить эту оптимизацию, так как она улучшает скорость сайта и сохраняет трафик.<br />{1}]]></string>
 	<string name="_sys_audit_msg_value_checking_failed"><![CDATA[проверка значения не удалась]]></string>
 	<string name="_sys_audit_msg_version_is_incompatible"><![CDATA[Ваша версия несовместима с UNA, нужно как минимум {0}]]></string>
 	<string name="_sys_audit_msg_version_is_outdated"><![CDATA[Ваша версия устарела, может потребоваться обновление до последней версии {0}]]></string>