Procházet zdrojové kódy

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

AntonLV před 2 roky
rodič
revize
3cb99f69ab

+ 2 - 2
inc/classes/BxDolGrid.php

@@ -271,7 +271,7 @@ class BxDolGrid extends BxDolFactory implements iBxDolFactoryObject, iBxDolRepla
 
         $sBrowseParams = bx_get('bp');
         if(!empty($sBrowseParams)) {
-        	$aBrowseParams = bx_process_input(unserialize(urldecode($sBrowseParams)));
+        	$aBrowseParams = bx_process_input(json_decode(urldecode($sBrowseParams), true));
         	if(!empty($aBrowseParams) && is_array($aBrowseParams))
             	$this->setBrowseParams($aBrowseParams);
         }
@@ -327,7 +327,7 @@ class BxDolGrid extends BxDolFactory implements iBxDolFactoryObject, iBxDolRepla
     public function setBrowseParams($aBrowseParams)
     {
     	$this->_aBrowseParams = $aBrowseParams;
-    	$this->_aQueryAppend['bp'] = urlencode(serialize($this->_aBrowseParams));
+    	$this->_aQueryAppend['bp'] = urlencode(json_encode($this->_aBrowseParams));
     }
 
     /**

+ 1 - 1
inc/classes/BxDolProfileAnonymous.php

@@ -46,7 +46,7 @@ class BxDolProfileAnonymous extends BxDolProfileUndefined
      */
     public static function getInstance($mixedProfileId = false, $bClearCache = false)
     {
-        $oProfile = BxDolProfile::getInstance(abs($mixedProfileId));
+        $oProfile = $mixedProfileId ? BxDolProfile::getInstance(abs($mixedProfileId)) : null;
         if (!$oProfile)
             return BxDolProfileUndefined::getInstance();
 

+ 6 - 1
inc/classes/BxDolPush.php

@@ -88,6 +88,10 @@ class BxDolPush extends BxDolFactory implements iBxDolSingleton
      */
     public static function getNotificationsCount($iProfileId = 0, &$aBubbles = null)
     {    
+        if ('' != trim(getParam('sys_api_url_root_push'))) {
+             return bx_srv('bx_notifications', 'get_unread_notifications_num', [$iProfileId]);
+        }   
+        
         $iMemberIdCookie = null;
         $bLoggedMemberGlobals = null;
         if ($iProfileId && $iProfileId != bx_get_logged_profile_id()) {
@@ -183,7 +187,8 @@ class BxDolPush extends BxDolFactory implements iBxDolSingleton
         curl_setopt($oChannel, CURLOPT_HEADER, false);
         curl_setopt($oChannel, CURLOPT_POST, true);
         curl_setopt($oChannel, CURLOPT_POSTFIELDS, json_encode($aFields));
-        curl_setopt($oChannel, CURLOPT_SSL_VERIFYPEER, false);
+        if (getParam('sys_curl_ssl_allow_untrusted') == 'on')
+            curl_setopt($oChannel, CURLOPT_SSL_VERIFYPEER, false);
 
         $sResult = curl_exec($oChannel);
         curl_close($oChannel);

+ 44 - 2
modules/boonex/okta_connect/classes/BxOktaConCustom.php

@@ -19,12 +19,14 @@ class BxOktaConCustom
     {
     }
 
-    function onRegister ($aRemoteProfileInfo)
+    function onRegister ($iProfileId, $aRemoteProfileInfo)
     {
         bx_log('bx_oktacon', $aRemoteProfileInfo);
         
         if (!empty($aRemoteProfileInfo['communities']))
-           $this->syncCommunities(bx_get_logged_profile_id(), explode(',', $aRemoteProfileInfo['communities']));
+           $this->syncCommunities($iProfileId, explode(',', $aRemoteProfileInfo['communities']));
+
+        $this->syncLocation($iProfileId, $aRemoteProfileInfo);
     }
 
     function onLogin ($oProfile, $aRemoteProfileInfo)
@@ -33,11 +35,51 @@ class BxOktaConCustom
 
         if (!empty($aRemoteProfileInfo['communities']))
            $this->syncCommunities($oProfile ? $oProfile->id() : bx_get_logged_profile_id(), explode(',', $aRemoteProfileInfo['communities']));
+
+        $this->syncLocation($oProfile->id(), $aRemoteProfileInfo);
     }
 
     function onConvertRemoteFields($aProfileInfo, &$aProfileFields)
     {
+        if (empty($aProfileInfo['grade']))
+            return;
+
+        $a = explode(',', $aProfileInfo['grade']);
+
+        $v = 0;
+        foreach ($a as $i) {
+            $v += pow(2, (int)$i - 1);
+        }
+
+        $aProfileFields['grades'] = $v;
+    }
+
+    function syncLocation($iProfileId, $aRemoteProfileInfo)
+    {
+        if (empty($aRemoteProfileInfo['state']) || empty($aRemoteProfileInfo['city']))
+            return;
+
+        $oProfile = BxDolProfile::getInstance($iProfileId);
+        if (!$oProfile)
+            return;
+
+        $oMetatags = BxDolMetatags::getObjectInstance('bx_persons');
+        if (!$oMetatags || !$oMetatags->locationsIsEnabled())
+            return;
 
+        $sEndpoint = bx_append_url_params('https://nominatim.openstreetmap.org', [
+            'format' => 'json',
+            'limit' => 1,
+            'country' => empty($aRemoteProfileInfo['country']) ? 'US' : $aRemoteProfileInfo['country'], 
+            'state' => $aRemoteProfileInfo['state'], 
+            'city' => $aRemoteProfileInfo['city'],
+        ]);
+        $sResults = bx_file_get_contents($sEndpoint);        
+        if (!($a = @json_decode($sResults, true)))
+            return;
+        $a = array_shift($a);
+    
+        $oMetatags->locationsAdd($oProfile->getContentId(), $a['lat'], $a['lon'], 'US', $aRemoteProfileInfo['state'], $aRemoteProfileInfo['city']);
     }
 
     function syncCommunities($iProfileId, $aCommunities, $sModule = 'bx_groups', $sObjConn = 'bx_groups_fans')

+ 15 - 4
modules/boonex/okta_connect/classes/BxOktaConModule.php

@@ -117,21 +117,20 @@ class BxOktaConModule extends BxBaseModConnectModule
 */
         if ($aRemoteProfileInfo) {
 
-            bx_import('Custom', $this->_aModule);
-            $oCustom = new BxOktaConCustom($this->_aModule);
-
             // check if user logged in before
             $iLocalProfileId = $this->_oDb->getProfileId($aRemoteProfileInfo['id']);
             
             if ($iLocalProfileId && $oProfile = BxDolProfile::getInstance($iLocalProfileId)) {
                 // user already exists
                 $this->setLogged($oProfile->id(), '', true, getParam('bx_oktacon_remember_session')); // remember user
+                bx_import('Custom', $this->_aModule);
+                $oCustom = new BxOktaConCustom($this->_aModule);
                 $oCustom->onLogin($oProfile, $aRemoteProfileInfo);
             }             
             else {  
                 // register new user
                 $this->_createProfile($aRemoteProfileInfo);
-                $oCustom->onRegister($aRemoteProfileInfo);
+                
             }
         } 
         else {
@@ -139,6 +138,18 @@ class BxOktaConModule extends BxBaseModConnectModule
         }
     }
 
+    function _createProfileRaw($aProfileInfo, $sAlternativeName = '', $isAutoFriends = true, $isSetLoggedIn = true) 
+    {
+        $mixed = parent::_createProfileRaw($aProfileInfo, $sAlternativeName, $isAutoFriends, $isSetLoggedIn);
+        if (is_array($mixed) && isset($mixed['profile_id']) && (!isset($mixed['join_page_redirect']) || !$mixed['join_page_redirect'])) {
+            bx_import('Custom', $this->_aModule);
+            $oCustom = new BxOktaConCustom($this->_aModule);
+            $oCustom->onRegister($mixed['profile_id'], $aProfileInfo);
+        }
+
+        return $mixed;
+    }
+
     /**
      * @param $aProfileInfo - remote profile info
      * @param $sAlternativeName - suffix to add to NickName to make it unique

+ 1 - 1
modules/boonex/payment/classes/BxPaymentProviderStripe.php

@@ -435,7 +435,7 @@ class BxPaymentProviderStripe extends BxPaymentProviderStripeBasic implements iB
 
         try {
             if(empty($oSubscription))
-                $oSubscription = $this->_oCustomer->subscriptions->create($aSubscription);
+                $oSubscription = \Stripe\Subscription::create(['customer' => $this->_oCustomer->id, 'items' => [['price' => $aItem['name']]], 'metadata' => $aSubscription['metadata']]);				
         }
         catch (Exception $oException) {
             return $this->_processException('Create Subscription Error: ', $oException);

+ 1 - 1
modules/boonex/payment/classes/BxPaymentProviderStripeBasic.php

@@ -430,7 +430,7 @@ class BxPaymentProviderStripeBasic extends BxBaseModPaymentProvider
     {
         try {
             $oCustomer = $this->_retrieveCustomer(BX_PAYMENT_TYPE_RECURRING, $sCustomerId);
-            $oSubscription = $oCustomer->subscriptions->retrieve($sSubscriptionId);
+            $oSubscription = \Stripe\Subscription::retrieve($sSubscriptionId);
         }
         catch (Exception $oException) {
             return $this->_processException('Retrieve Subscription Error: ', $oException);

+ 2 - 2
template/scripts/BxBaseAuditGrid.php

@@ -67,7 +67,7 @@ class BxBaseAuditGrid extends BxDolAuditGrid
             $sLinkExtras = $this->_oTemplate->parseLink('javascript:void(0)',' <i class="sys-icon info-circle"></i>' , array(
                 'title' => '',
                 'bx_grid_action_single' => 'show_stat',
-                'bx_grid_action_data' => $aRow['extras']
+                'bx_grid_action_data' => json_encode($aExtras)
             ));
         }
         
@@ -225,7 +225,7 @@ class BxBaseAuditGrid extends BxDolAuditGrid
     {
 		$aTmp2 = bx_get('ids');
 		$sData = $aTmp2[0];
-        $aData = unserialize($sData);
+        $aData = json_decode($sData, true);
         $sContentInfo = '';
         if (isset($aData['display_info'])){
             foreach($aData['display_info'] as $sKey => $sValue)