Explorar o código

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

AntonLV %!s(int64=2) %!d(string=hai) anos
pai
achega
a85bfa47d3

+ 14 - 3
modules/boonex/invites/classes/BxInvModule.php

@@ -29,8 +29,9 @@ class BxInvModule extends BxDolModule
     /**
     /**
      * ACTION METHODS
      * ACTION METHODS
      */
      */
-    function actionGetLink()
+    function serviceGetLink()
     {
     {
+        
         $iProfileId = $this->getProfileId();
         $iProfileId = $this->getProfileId();
         $iAccountId = $this->getAccountId($iProfileId);
         $iAccountId = $this->getAccountId($iProfileId);
 
 
@@ -40,12 +41,12 @@ class BxInvModule extends BxDolModule
 
 
         if(!isAdmin($iAccountId)) {
         if(!isAdmin($iAccountId)) {
             if($this->_oConfig->getCountPerUser() <= 0)
             if($this->_oConfig->getCountPerUser() <= 0)
-                return echoJson(array('message' => _t('_bx_invites_err_limit_reached')));
+                return bx_is_api() ? [bx_api_get_msg(_t('_bx_invites_err_limit_reached'))] : echoJson(array('message' => _t('_bx_invites_err_limit_reached')));
         }
         }
 
 
         $oKeys = BxDolKey::getInstance();
         $oKeys = BxDolKey::getInstance();
         if(!$oKeys)
         if(!$oKeys)
-            return  echoJson(array('message' => _t('_bx_invites_err_not_available')));
+            return bx_is_api() ? [bx_api_get_msg(_t('_bx_invites_err_not_available'))] : echoJson(array('message' => _t('_bx_invites_err_not_available')));
 
 
         $sKey = $oKeys->getNewKey(false, $this->_oConfig->getKeyLifetime());       
         $sKey = $oKeys->getNewKey(false, $this->_oConfig->getKeyLifetime());       
 
 
@@ -65,11 +66,20 @@ class BxInvModule extends BxDolModule
         ));
         ));
         $this->onInvite($iProfileId);
         $this->onInvite($iProfileId);
 
 
+        if (bx_is_api()){
+            return ['link' => bx_api_get_relative_url($this->getJoinLink($sKey))];
+        }
+        
         echoJson(array('popup' => $this->_oTemplate->getLinkPopup(
         echoJson(array('popup' => $this->_oTemplate->getLinkPopup(
             $this->getJoinLink($sKey)
             $this->getJoinLink($sKey)
         )));
         )));
     }
     }
     
     
+    function actionGetLink()
+    {
+        $this->serviceGetLink();
+    }
+    
     public function actionSetSeenMark($Code)
     public function actionSetSeenMark($Code)
     {
     {
         header('Content-Type: image/png');
         header('Content-Type: image/png');
@@ -87,6 +97,7 @@ class BxInvModule extends BxDolModule
             'GetBlockInvite' => '',
             'GetBlockInvite' => '',
             'GetBlockFormInvite' => '',
             'GetBlockFormInvite' => '',
             'GetBlockFormRequest' => '',
             'GetBlockFormRequest' => '',
+            'GetLink' => '',
         );
         );
     }
     }
 
 

+ 8 - 1
modules/boonex/invites/classes/BxInvTemplate.php

@@ -65,7 +65,7 @@ class BxInvTemplate extends BxBaseModGeneralTemplate
         $mInvitesRemain = $this->_oConfig->getCountPerUser();
         $mInvitesRemain = $this->_oConfig->getCountPerUser();
         if($mInvitesRemain === true)
         if($mInvitesRemain === true)
             $mInvitesRemain = _t('_bx_invites_txt_unlimited');
             $mInvitesRemain = _t('_bx_invites_txt_unlimited');
-
+        
         $sUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink($this->_oConfig->CNF['URL_INVITE']));
         $sUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink($this->_oConfig->CNF['URL_INVITE']));
 
 
         if($bRedirect) {
         if($bRedirect) {
@@ -73,12 +73,19 @@ class BxInvTemplate extends BxBaseModGeneralTemplate
 
 
             list($sPageLink, $aPageParams) = bx_get_base_url_inline();
             list($sPageLink, $aPageParams) = bx_get_base_url_inline();
             $sRedirectValue = bx_append_url_params($sPageLink, $aPageParams);
             $sRedirectValue = bx_append_url_params($sPageLink, $aPageParams);
+            if(bx_is_api()){
+                $sRedirectValue = $aPageParams['params'][0];
+            }
 
 
             $oSession = BxDolSession::getInstance();
             $oSession = BxDolSession::getInstance();
             if($oSession->isValue($sRedirectCode))
             if($oSession->isValue($sRedirectCode))
                 $oSession->unsetValue($sRedirectCode);
                 $oSession->unsetValue($sRedirectCode);
             $oSession->setValue($sRedirectCode, $sRedirectValue);
             $oSession->setValue($sRedirectCode, $sRedirectValue);
         }
         }
+        
+        if(bx_is_api()){
+            return [bx_api_get_block('invite', ['remain' => $mInvitesRemain, 'request_url' => 'bx_invites/get_link/'])];
+        }
 
 
         $this->getCssJs();
         $this->getCssJs();
         return $this->parseHtmlByName('block_invite.html', [
         return $this->parseHtmlByName('block_invite.html', [

+ 23 - 13
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -1960,6 +1960,8 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             $aEvent['menu_manage'] = $oMenuManage->getCodeAPI();
             $aEvent['menu_manage'] = $oMenuManage->getCodeAPI();
         }
         }
 
 
+        $aEvent['owners'] = $this->_getTmplVarsTimelineOwner($aEvent);
+        
         $aCmts = [];
         $aCmts = [];
         $oCmts = $oModule->getCmtsObject($aEvent['comments']['system'], $aEvent['comments']['object_id']);
         $oCmts = $oModule->getCmtsObject($aEvent['comments']['system'], $aEvent['comments']['object_id']);
         if($oCmts !== false) {
         if($oCmts !== false) {
@@ -2250,24 +2252,32 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
                     'icon' => 'check'
                     'icon' => 'check'
                 );
                 );
             }
             }
-
-            $aTmplVarsOwners[] =  array(
-                'style_prefix' => $sStylePrefix,
-                'owner_type' => _t('_' . $sToType),
-                'owner_url' => $sToUrl,
-                'owner_username' => $sToName,
-                'bx_if:show_timeline_owner_actions' => array(
-                    'condition' => !empty($aTmplVarsActions),
-                    'content' => array(
-                        'style_prefix' => $sStylePrefix,
-                        'bx_repeat:timeline_owner_actions' => $aTmplVarsActions
+            if(bx_is_api()) {
+                $aTmplVarsOwners[] = $oOwner->getUnitAPI(0, ['template' => 'unit_wo_info']);
+            }
+            else{
+                $aTmplVarsOwners[] =  array(
+                    'style_prefix' => $sStylePrefix,
+                    'owner_type' => _t('_' . $sToType),
+                    'owner_url' => $sToUrl,
+                    'owner_username' => $sToName,
+                    'bx_if:show_timeline_owner_actions' => array(
+                        'condition' => !empty($aTmplVarsActions),
+                        'content' => array(
+                            'style_prefix' => $sStylePrefix,
+                            'bx_repeat:timeline_owner_actions' => $aTmplVarsActions
+                        )
                     )
                     )
-                )
-            );
+                );
+            }
         }
         }
 
 
         if(empty($aTmplVarsOwners))
         if(empty($aTmplVarsOwners))
             return array();
             return array();
+        
+        if(bx_is_api()) {
+            return ($aTmplVarsOwners);
+        }
 
 
         return array(
         return array(
             'style_prefix' => $sStylePrefix,
             'style_prefix' => $sStylePrefix,

+ 4 - 3
template/scripts/BxBaseAccountForms.php

@@ -59,15 +59,16 @@ class BxBaseAccountForms extends BxDolProfileForms
         ));
         ));
 
 
         if (!$oForm->isSubmittedAndValid()) {
         if (!$oForm->isSubmittedAndValid()) {
-            if($bIsApi)
-                return $oForm->getCodeAPI();
-
+            
             $sCode = $oForm->getCode();
             $sCode = $oForm->getCode();
 
 
             bx_alert('account', 'add_form', 0, 0, array(
             bx_alert('account', 'add_form', 0, 0, array(
                     'form_object' => &$oForm,
                     'form_object' => &$oForm,
                     'form_code' => &$sCode
                     'form_code' => &$sCode
             ));
             ));
+            
+            if($bIsApi)
+                return $oForm->getCodeAPI();
 
 
             return $sCode;
             return $sCode;
         }
         }

+ 1 - 1
template/scripts/BxBasePage.php

@@ -417,7 +417,7 @@ class BxBasePage extends BxDolPage
         if (isset(bx_get('params')[2]) && bx_get('params')[2] != ''){
         if (isset(bx_get('params')[2]) && bx_get('params')[2] != ''){
             $array = json_decode(bx_get('params')[2], true);
             $array = json_decode(bx_get('params')[2], true);
             $query_string = http_build_query($array);
             $query_string = http_build_query($array);
-
+            parse_str($query_string, $_GET);
         }
         }
         $a = [
         $a = [
             'id' => $this->_aObject['id'],
             'id' => $this->_aObject['id'],

+ 14 - 2
template/scripts/BxBaseServiceAccount.php

@@ -66,11 +66,23 @@ class BxBaseServiceAccount extends BxDol
                         'request' => ['url' => '/api.php?r=system/create_account_form/TemplServiceAccount', 'immutable' => true]
                         'request' => ['url' => '/api.php?r=system/create_account_form/TemplServiceAccount', 'immutable' => true]
                     ]
                     ]
                 ])];
                 ])];
-            else if($mixedResult === true)
+            else if($mixedResult === true){
+                $sRedirectUrl = BxDolForm::getSubmittedValue('relocate','post');
+                if(empty($sRedirectUrl)){
+                    $RedirectUrl = '/';
+                }
+                else{
+                    $parts = parse_url($sRedirectUrl);
+                    parse_str($parts['query'], $query);
+                    unset($query['_q']);
+                    $parts['query'] = http_build_query($query);
+                    $sRedirectUrl = $parts['path'] . (!empty($parts['query']) ? '?' . $parts['query'] : '');
+                }
                 return [
                 return [
-                    bx_api_get_block('redirect', ['uri' => '/']),
+                    bx_api_get_block('redirect', ['uri' => $sRedirectUrl]),
                     bx_api_get_block('login', ['session' => BxDolSession::getInstance()->getId()], ['id' => 2]),
                     bx_api_get_block('login', ['session' => BxDolSession::getInstance()->getId()], ['id' => 2]),
                 ];
                 ];
+            }
             else
             else
                 return bx_api_get_msg($mixedResult);
                 return bx_api_get_msg($mixedResult);
         }
         }