Просмотр исходного кода

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

AntonLV 6 лет назад
Родитель
Сommit
ca4a37ea2c

+ 22 - 14
modules/base/groups/classes/BxBaseModGroupsPageEntry.php

@@ -49,23 +49,31 @@ class BxBaseModGroupsPageEntry extends BxBaseModProfilePageEntry
         $sRv = '';
         if (bx_get('key')){
             $sKey = bx_get('key');
-            $this->_oTemplate->addJs(array('invite_popup.js'));
             $sId = $this->_oModule->getName() . '_popup_invite';
             
-            $sContent = $this->_oModule->_oTemplate->parseHtmlByName('popup_invite.html', array(
-                'PopupId' => $sId
-            ));
-            
-            $sRv = $this->_oModule->_oTemplate->getJsCode('invite_popup', array(
-                'sPopupId' => $sId,
-                'sKey' => $sKey,
-                'sAcceptUrl' =>  BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $this->_aProfileInfo['content_id']),
-                'sDeclineUrl' => BX_DOL_URL_ROOT,
-                'iGroupProfileId' => $this->_oProfile->id(),
-            )) . BxTemplFunctions::getInstance()->popupBox($sId, _t($CNF['T']['txt_invitation_popup_title']), $sContent, true);
+            $aData = $this->_oModule->_oDb->getInviteByKey($sKey,  $this->_oProfile->id());
+            if (!isset($aData['invited_profile_id'])){
+                $sRv = _t('_bx_groups_txt_invite_popup_error_invitation_absent');
+            }
+            else{
+                if ($aData['invited_profile_id'] != bx_get_logged_profile_id()){
+                    $sRv = _t('_bx_groups_txt_invite_popup_error_invitation_wrong_user');
+                }
+                else{
+                    $sRv = $this->_oModule->_oTemplate->parseHtmlByName('popup_invite.html', array(
+                        'PopupId' => $sId
+                    ));
+                }
+            }
         }
-        
-        return $sRv . parent::getCode();
+        $this->_oTemplate->addJs(array('invite_popup.js'));
+        return ($sRv != '' ? $this->_oModule->_oTemplate->getJsCode('invite_popup', array(
+            'sPopupId' => $sId,
+            'sKey' => $sKey,
+            'sAcceptUrl' =>  BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $this->_aProfileInfo['content_id']),
+            'sDeclineUrl' => BX_DOL_URL_ROOT,
+            'iGroupProfileId' => $this->_oProfile->id(),
+        )) .  BxTemplFunctions::getInstance()->popupBox($sId, _t($CNF['T']['txt_invitation_popup_title']), $sRv, true) : '').parent::getCode();
     }
 }
 

+ 3 - 1
modules/boonex/groups/install/langs/en.xml

@@ -281,8 +281,10 @@
     <string name="_bx_groups_txt_invite_popup_title"><![CDATA[Invitation to a group]]></string>
     <string name="_bx_groups_txt_invite_popup_button_accept"><![CDATA[Accept]]></string>
     <string name="_bx_groups_txt_invite_popup_button_decline"><![CDATA[Decline]]></string>
+    <string name="_bx_groups_txt_invite_popup_error_invitation_absent"><![CDATA[Sorry, an error has occurred. You can not join this group. The invitation is expired or deleted.]]></string>
+    <string name="_bx_groups_txt_invite_popup_error_invitation_wrong_user"><![CDATA[Sorry, an error has occurred. You can not join this group. This invitation cannot be used by you.]]></string>
 
-	<string name="_bx_groups_alert_action_fan_added"><![CDATA[member joined]]></string>
+	  <string name="_bx_groups_alert_action_fan_added"><![CDATA[member joined]]></string>
     <string name="_bx_groups_txt_ntfs_fan_added"><![CDATA[Group <b class="bx-ntfs-content-profile">{owner_name}</b> has got a member <b class="bx-ntfs-content-entry">{subentry_sample}</b>]]></string>
     <string name="_bx_groups_alert_action_join_request"><![CDATA[join request]]></string>
     <string name="_bx_groups_txt_ntfs_join_request"><![CDATA[Group <b class="bx-ntfs-content-profile">{owner_name}</b> has a join request from <b class="bx-ntfs-content-entry">{subentry_sample}</b>]]></string>