Explorar o código

#4084 Multisite: notifications URLs

Alex Trofimov %!s(int64=4) %!d(string=hai) anos
pai
achega
1d8b1a71c2

+ 2 - 2
inc/utils.inc.php

@@ -2288,10 +2288,10 @@ function is_private_ip ($sIp)
     return filter_var($sIp, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== $sIp;
 }
 
-function bx_absolute_url($sUrl)
+function bx_absolute_url($sUrl, $sPrefix = BX_DOL_URL_ROOT)
 {
     if (!preg_match('/^https?:\/\//', $sUrl))
-        $sUrl = BX_DOL_URL_ROOT . $sUrl;
+        $sUrl = $sPrefix . $sUrl;
     return $sUrl;
 }
 

+ 8 - 8
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -1867,7 +1867,7 @@ class BxBaseModGeneralModule extends BxDolModule
         if(empty($aContentInfo) || !is_array($aContentInfo))
             return array();
 
-        $sEntryUrl = '{bx_url_root}' . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
+        $sEntryUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]), '{bx_url_root}');
         $sEntryCaption = isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...');
 
         return array(
@@ -1940,7 +1940,7 @@ class BxBaseModGeneralModule extends BxDolModule
         if(!$oComment || !$oComment->isEnabled())
             return array();
 
-        $sEntryUrl = '{bx_url_root}' . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
+        $sEntryUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]), '{bx_url_root}');
         $sEntryCaption = isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...');
 
         return array(
@@ -1949,7 +1949,7 @@ class BxBaseModGeneralModule extends BxDolModule
             'entry_caption' => $sEntryCaption,
             'entry_author' => $aContentInfo[$CNF['FIELD_AUTHOR']],
             'subentry_sample' => $CNF['T']['txt_sample_comment_single'],
-            'subentry_url' => '{bx_url_root}' . $oComment->getViewUrl((int)$aEvent['subobject_id'], false),
+            'subentry_url' => bx_absolute_url($oComment->getViewUrl((int)$aEvent['subobject_id'], false), '{bx_url_root}'),
             'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
         );
     }
@@ -1976,11 +1976,11 @@ class BxBaseModGeneralModule extends BxDolModule
         return array(
             'object_id' => $iObjectId,
             'entry_sample' => '_cmt_txt_sample_comment_single',
-            'entry_url' => '{bx_url_root}' . $oComment->getViewUrl($iParentId, false),
+            'entry_url' => bx_absolute_url($oComment->getViewUrl($iParentId, false), '{bx_url_root}'),
             'entry_caption' => strmaxtextlen($aParentInfo['cmt_text'], 20, '...'),
             'entry_author' => (int)$aParentInfo['cmt_author_id'],
             'subentry_sample' => '_cmt_txt_sample_reply_to',
-            'subentry_url' => '{bx_url_root}' . $oComment->getViewUrl((int)$aEvent['subobject_id'], false),
+            'subentry_url' => bx_absolute_url($oComment->getViewUrl((int)$aEvent['subobject_id'], false), '{bx_url_root}'),
             'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
         );
     }
@@ -2001,7 +2001,7 @@ class BxBaseModGeneralModule extends BxDolModule
         if(!$oVote || !$oVote->isEnabled())
             return array();
 
-        $sEntryUrl = '{bx_url_root}' . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
+        $sEntryUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]), '{bx_url_root}');
         $sEntryCaption = isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...');
 
         return array(
@@ -2041,7 +2041,7 @@ class BxBaseModGeneralModule extends BxDolModule
         else
             $aSubentrySampleParams[] = '_undefined';
 
-        $sEntryUrl = '{bx_url_root}' . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
+        $sEntryUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]), '{bx_url_root}');
         $sEntryCaption = isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...');
 
         return array(
@@ -2084,7 +2084,7 @@ class BxBaseModGeneralModule extends BxDolModule
         if(!$oScore || !$oScore->isEnabled())
             return array();
 
-        $sEntryUrl = '{bx_url_root}' . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]);
+        $sEntryUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]), '{bx_url_root}');
         $sEntryCaption = isset($aContentInfo[$CNF['FIELD_TITLE']]) ? $aContentInfo[$CNF['FIELD_TITLE']] : strmaxtextlen($aContentInfo[$CNF['FIELD_TEXT']], 20, '...');
 
         return array(

+ 2 - 2
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -1117,7 +1117,7 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
          * should be linked to Group Profile (Group Profile -> Members tab) 
          * instead of Personal Profile of invited member.
          */
-        $sEntryUrl = str_replace(BX_DOL_URL_ROOT, '{bx_url_root}', $oGroupProfile->getUrl());
+        $sEntryUrl = bx_absolute_url(str_replace(BX_DOL_URL_ROOT, '', $oGroupProfile->getUrl()), '{bx_url_root}');
 
         return array(
             'entry_sample' => $CNF['T']['txt_sample_single'],
@@ -1169,7 +1169,7 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
          * instead of Personal Profile of a member, who performed an action.
          */
         if(empty($CNF['URL_ENTRY_FANS']))
-            $sEntryUrl = str_replace(BX_DOL_URL_ROOT, '{bx_url_root}', $oGroupProfile->getUrl());
+            $sEntryUrl = bx_absolute_url(str_replace(BX_DOL_URL_ROOT, '', $oGroupProfile->getUrl()), '{bx_url_root}');
         else
             $sEntryUrl = BxDolPermalinks::getInstance()->permalink($CNF['URL_ENTRY_FANS'], [
                 'profile_id' => $oGroupProfile->id()

+ 2 - 2
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -1212,14 +1212,14 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         if(empty($aSubcontentInfo) || !is_array($aSubcontentInfo))
             return array();
 
-        $sSubentryUrl = str_replace(BX_DOL_URL_ROOT, '{bx_url_root}', BxDolService::call('bx_timeline', 'get_link', array((int)$aEvent['subobject_id'])));
+        $sSubentryUrl = bx_absolute_url(str_replace(BX_DOL_URL_ROOT, '', BxDolService::call('bx_timeline', 'get_link', array((int)$aEvent['subobject_id']))), '{bx_url_root}');
         $sSubentrySample = $aSubcontentInfo['title'];
         if(empty($sSubentrySample))
             $sSubentrySample = strmaxtextlen($aSubcontentInfo['description'], 20, '...');
 
         return array(
             'entry_sample' => $CNF['T']['txt_sample_single'],
-            'entry_url' => str_replace(BX_DOL_URL_ROOT, '{bx_url_root}', $oGroupProfile->getUrl()),
+            'entry_url' => bx_absolute_url(str_replace(BX_DOL_URL_ROOT, '', $oGroupProfile->getUrl()), '{bx_url_root}'),
             'entry_caption' => $oGroupProfile->getDisplayName(),
             'entry_author' => $oGroupProfile->id(),
             'subentry_sample' => $sSubentrySample,

+ 3 - 3
modules/boonex/ads/classes/BxAdsModule.php

@@ -676,7 +676,7 @@ class BxAdsModule extends BxBaseModTextModule
         if(empty($aInterestedInfo) || !is_array($aInterestedInfo))
             return array();
 
-        $sEntryUrl = '{bx_url_root}' . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId);
+        $sEntryUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId), '{bx_url_root}');
 
         return array(
             'entry_sample' => $CNF['T']['txt_sample_single'],
@@ -742,7 +742,7 @@ class BxAdsModule extends BxBaseModTextModule
         if(empty($aContentInfo) || !is_array($aContentInfo))
             return array();
 
-        $sEntryUrl = '{bx_url_root}' . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId);
+        $sEntryUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId), '{bx_url_root}');
 
         return array(
             'entry_sample' => $CNF['T']['txt_sample_single'],
@@ -769,7 +769,7 @@ class BxAdsModule extends BxBaseModTextModule
         if(empty($aContentInfo) || !is_array($aContentInfo))
             return array();
 
-        $sEntryUrl = '{bx_url_root}' . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId);
+        $sEntryUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId), '{bx_url_root}');
 
         return array(
             'object_id' => $iContentId,

+ 6 - 6
modules/boonex/albums/classes/BxAlbumsModule.php

@@ -625,8 +625,8 @@ class BxAlbumsModule extends BxBaseModTextModule
             return array();
 
         $oPermalinks = BxDolPermalinks::getInstance();
-        $sEntryUrl = '{bx_url_root}' . $oPermalinks->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId);
-        $sSubentryUrl = '{bx_url_root}' . $oPermalinks->permalink('page.php?i=' . $CNF['URI_VIEW_MEDIA'] . '&id=' . $iMediaId);
+        $sEntryUrl = bx_absolute_url($oPermalinks->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $iContentId), '{bx_url_root}');
+        $sSubentryUrl = bx_absolute_url($oPermalinks->permalink('page.php?i=' . $CNF['URI_VIEW_MEDIA'] . '&id=' . $iMediaId), '{bx_url_root}');
         $sEntryCaption = isset($aMediaInfo['title']) ? $aMediaInfo['title'] : _t('_bx_albums_media');
 
         return array(
@@ -653,7 +653,7 @@ class BxAlbumsModule extends BxBaseModTextModule
         if(!$oComment || !$oComment->isEnabled())
             return array();
 
-        $sEntryUrl = '{bx_url_root}' . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_MEDIA'] . '&id=' . $aMediaInfo['id']);
+        $sEntryUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_MEDIA'] . '&id=' . $aMediaInfo['id']), '{bx_url_root}');
         $sEntryCaption = isset($aMediaInfo['title']) ? $aMediaInfo['title'] : _t('_bx_albums_media');
 
         return array(
@@ -662,7 +662,7 @@ class BxAlbumsModule extends BxBaseModTextModule
             'entry_caption' => $sEntryCaption,
             'entry_author' => $aMediaInfo['author'],
             'subentry_sample' => $CNF['T']['txt_media_comment_single'],
-            'subentry_url' => '{bx_url_root}' . $oComment->getViewUrl((int)$aEvent['subobject_id'], false),
+            'subentry_url' => bx_absolute_url($oComment->getViewUrl((int)$aEvent['subobject_id'], false), '{bx_url_root}'),
             'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
         );
     }
@@ -680,7 +680,7 @@ class BxAlbumsModule extends BxBaseModTextModule
         if(!$oVote || !$oVote->isEnabled())
             return array();
 
-        $sEntryUrl = '{bx_url_root}' . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_MEDIA'] . '&id=' . $aMediaInfo['id']);
+        $sEntryUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_MEDIA'] . '&id=' . $aMediaInfo['id']), '{bx_url_root}');
         $sEntryCaption = isset($aMediaInfo['title']) ? $aMediaInfo['title'] : _t('_bx_albums_media');
 
         return array(
@@ -717,7 +717,7 @@ class BxAlbumsModule extends BxBaseModTextModule
         if(!$oVote || !$oVote->isEnabled())
             return array();
 
-        $sEntryUrl = '{bx_url_root}' . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_MEDIA'] . '&id=' . $aMediaInfo['id']);
+        $sEntryUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_MEDIA'] . '&id=' . $aMediaInfo['id']), '{bx_url_root}');
         $sEntryCaption = isset($aMediaInfo['title']) ? $aMediaInfo['title'] : _t('_bx_albums_media');
 
         return array(

+ 1 - 1
modules/boonex/channels/classes/BxCnlModule.php

@@ -405,7 +405,7 @@ class BxCnlModule extends BxBaseModGroupsModule
             if(method_exists($oModule, 'serviceActAsProfile') && $oModule->serviceActAsProfile())
                 $aRv['lang_key'] = '_bx_channels_ntfs_txt_subobject_added_profile';
 
-            $aRv['entry_url'] = str_replace(BX_DOL_URL_ROOT, '{bx_url_root}', $this->serviceGetLink($aContentEvent['cnl_id']));
+            $aRv['entry_url'] = bx_absolute_url(str_replace(BX_DOL_URL_ROOT, '', $this->serviceGetLink($aContentEvent['cnl_id'])), '{bx_url_root}');
             return $aRv;
         }
 

+ 1 - 1
modules/boonex/events/classes/BxEventsModule.php

@@ -442,7 +442,7 @@ class BxEventsModule extends BxBaseModGroupsModule implements iBxDolCalendarServ
 
         return [
             'entry_sample' => $CNF['T']['txt_sample_single'],
-            'entry_url' => str_replace(BX_DOL_URL_ROOT, '{bx_url_root}', $oEventProfile->getUrl()),
+            'entry_url' => bx_absolute_url(str_replace(BX_DOL_URL_ROOT, '', $oEventProfile->getUrl()), '{bx_url_root}'),
             'entry_caption' => $oEventProfile->getDisplayName(),
             'entry_author' => $oEventProfile->id(),
             'lang_key' => '_bx_events_txt_ntfs_reminder_' . $aEvent['content']['reminder']

+ 1 - 1
modules/boonex/invites/classes/BxInvModule.php

@@ -351,7 +351,7 @@ class BxInvModule extends BxDolModule
             return [];
 
         $CNF = &$this->_oConfig->CNF;
-        $sEntryUrl = '{bx_url_root}' . BxDolPermalinks::getInstance()->permalink($CNF['URL_REQUESTS']);
+        $sEntryUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink($CNF['URL_REQUESTS']), '{bx_url_root}');
 
         return [
             'entry_sample' => $aRequest['name'] . '(' . $aRequest['email'] . ')',

+ 1 - 1
modules/boonex/reminders/classes/BxRemindersModule.php

@@ -87,7 +87,7 @@ class BxRemindersModule extends BxBaseModGeneralModule
 
         $aReturn = array(
             'entry_sample' => $CNF['T']['txt_sample_single'],
-            'entry_url' => str_replace(BX_DOL_URL_ROOT, '{bx_url_root}', $this->getEntryUrl($aEntry)),
+            'entry_url' => bx_absolute_url(str_replace(BX_DOL_URL_ROOT, '', $this->getEntryUrl($aEntry)), '{bx_url_root}'),
             'lang_key' => $aEntry[$CNF['FIELD_TEXT']]
         );
 

+ 8 - 8
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -2255,7 +2255,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         return array(
             'entry_sample' => $CNF['T']['txt_sample_single_ext'],
-            'entry_url' => '{bx_url_root}' . $this->_oConfig->getItemViewUrl($aContent, false),
+            'entry_url' => bx_absolute_url($this->_oConfig->getItemViewUrl($aContent, false), '{bx_url_root}'),
             'entry_caption' => $sEntryCaption,
             'entry_author' => $iEntryAuthor,
             'lang_key' => '' //may be empty or not specified. In this case the default one from Notification module will be used.
@@ -2297,11 +2297,11 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         return array(
             'entry_sample' => $CNF['T']['txt_sample_single'],
-            'entry_url' => '{bx_url_root}' . $this->_oConfig->getItemViewUrl($aContent, false),
+            'entry_url' => bx_absolute_url($this->_oConfig->getItemViewUrl($aContent, false), '{bx_url_root}'),
             'entry_caption' => $sEntryCaption,
             'entry_author' => $aContent['owner_id'],
             'subentry_sample' => $CNF['T']['txt_sample_comment_single'],
-            'subentry_url' => '{bx_url_root}' . $oComment->getViewUrl((int)$aEvent['subobject_id'], false),
+            'subentry_url' => bx_absolute_url($oComment->getViewUrl((int)$aEvent['subobject_id'], false), '{bx_url_root}'),
             'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
         );
     }
@@ -2343,11 +2343,11 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         return array(
             'object_id' => $iObjectId,
             'entry_sample' => '_cmt_txt_sample_comment_single',
-            'entry_url' => '{bx_url_root}' . $oComment->getViewUrl($iParentId, false),
+            'entry_url' => bx_absolute_url($oComment->getViewUrl($iParentId, false), '{bx_url_root}'),
             'entry_caption' => strmaxtextlen($aParentInfo['cmt_text'], 20, '...'),
             'entry_author' => (int)$aParentInfo['cmt_author_id'],
             'subentry_sample' => '_cmt_txt_sample_reply_to',
-            'subentry_url' => '{bx_url_root}' . $oComment->getViewUrl((int)$aEvent['subobject_id'], false),
+            'subentry_url' => bx_absolute_url($oComment->getViewUrl((int)$aEvent['subobject_id'], false), '{bx_url_root}'),
             'lang_key' => '', //may be empty or not specified. In this case the default one from Notification module will be used.
         );
     }
@@ -2387,7 +2387,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         return array(
             'entry_sample' => $CNF['T']['txt_sample_single'],
-            'entry_url' => '{bx_url_root}' . $this->_oConfig->getItemViewUrl($aContent, false),
+            'entry_url' => bx_absolute_url($this->_oConfig->getItemViewUrl($aContent, false), '{bx_url_root}'),
             'entry_caption' => $sEntryCaption,
             'entry_author' => $aContent['owner_id'],
             'subentry_sample' => $CNF['T']['txt_sample_vote_single'],
@@ -2426,7 +2426,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         return array(
             'entry_sample' => $CNF['T']['txt_sample_single'],
-            'entry_url' => '{bx_url_root}' . $this->_oConfig->getItemViewUrl($aContent, false),
+            'entry_url' => bx_absolute_url($this->_oConfig->getItemViewUrl($aContent, false), '{bx_url_root}'),
             'entry_caption' => $sEntryCaption,
             'entry_author' => $aContent['owner_id'],
             'subentry_sample' => $CNF['T']['txt_sample_reaction_single'],
@@ -2499,7 +2499,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         return array(
             'entry_sample' => $CNF['T']['txt_sample_single'],
-            'entry_url' => '{bx_url_root}' . $this->_oConfig->getItemViewUrl($aContent, false),
+            'entry_url' => bx_absolute_url($this->_oConfig->getItemViewUrl($aContent, false), '{bx_url_root}'),
             'entry_caption' => $sEntryCaption,
             'entry_author' => $aContent['owner_id'],
             'subentry_sample' => $CNF['T']['txt_sample_score_' . $sType . '_single'],