Przeglądaj źródła

Ticket #5019 - Contexts: Improve invite/join. Core changes.

AntonLV 1 rok temu
rodzic
commit
22c8c7406e

+ 22 - 4
inc/classes/BxDolTemplate.php

@@ -2100,7 +2100,7 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
      * @param string $sLink URL to image source 
      * @param array $aAttrs an array of key => value pairs
      */
-    function parseImage($sLink, $aAttrs = array())
+    function parseImage($sLink, $aAttrs = [])
     {
         $sAttrs = '';
         foreach($aAttrs as $sKey => $sValue)
@@ -2108,6 +2108,15 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
 
         return '<img src="' . $sLink . '"' . $sAttrs . ' />';
     }
+    
+    function parseImageInline($sName, $aAttrs = [])
+    {
+        $sAttrs = '';
+        foreach($aAttrs as $sKey => $sValue)
+            $sAttrs .= ' ' . $sKey . '="' . bx_html_attribute($sValue) . '"';
+
+        return '<img src="' . $this->_getInlineData('image', $sName, BX_DOL_TEMPLATE_CHECK_IN_BOTH, true) . '"' . $sAttrs . ' />';
+    }
 
     /**
      * Parse font based icon in <I> tag
@@ -2115,7 +2124,7 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
      * @param string $sName font icon name
      * @param array $aAttrs an array of key => value pairs
      */
-    function parseIcon($sName, $aAttrs = array())
+    function parseIcon($sName, $aAttrs = [])
     {
         $aIcons = BxTemplFunctions::getInstance()->getIcon($sName, $aAttrs);
         if($aIcons[0] != '')
@@ -2123,6 +2132,15 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
 
         return implode($aIcons);
     }
+    
+    function parseIconInline($sName, $aAttrs = [])
+    {
+        $sAttrs = '';
+        foreach($aAttrs as $sKey => $sValue)
+            $sAttrs .= ' ' . $sKey . '="' . bx_html_attribute($sValue) . '"';
+
+        return '<img src="' . $this->_getInlineData('icon', $sName, BX_DOL_TEMPLATE_CHECK_IN_BOTH, true) . '"' . $sAttrs . ' />';
+    }
 
     function getCacheFilePrefix($sType)
     {
@@ -3426,7 +3444,7 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
      * @param  string  $sCheckIn where the content would be searched(base, template, both)
      * @return unknown
      */
-    function _getInlineData($sType, $sName, $sCheckIn)
+    function _getInlineData($sType, $sName, $sCheckIn, $bForceInline = false)
     {
         switch($sType) {
             case 'image':
@@ -3439,7 +3457,7 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
         $sPath = $this->_getAbsoluteLocation('path', $sFolder, $sName, $sCheckIn);
 
         $iFileSize = 0;
-        if($this->_bImagesInline && ($iFileSize = filesize($sPath)) !== false && $iFileSize < $this->_iImagesMaxSize) {
+        if(($this->_bImagesInline && ($iFileSize = filesize($sPath)) !== false && $iFileSize < $this->_iImagesMaxSize) || $bForceInline) {
             $aFileInfo = pathinfo($sPath);
             return $this->getImageMimeType($aFileInfo['extension']) . ";base64," . base64_encode(file_get_contents($sPath));
         }

+ 22 - 41
modules/base/groups/classes/BxBaseModGroupsAlertsResponse.php

@@ -47,20 +47,22 @@ class BxBaseModGroupsAlertsResponse extends BxBaseModProfileAlertsResponse
             return;
 
         // join group events
-        switch ($oAlert->sAction) {
-            case 'join_invitation':
-                $this->sendMailInvitation($oAlert, $oAlert->aExtras['profile'], bx_get_logged_profile_id());
-                break;
-
-            case 'join_request':
-                if($this->_bUseIn)
-                    $this->sendMailJoinRequest($oAlert, $oAlert->aExtras['profile'], bx_get_logged_profile_id());
-                break;
-
-            case 'join_request_accepted':
-                if($this->_bUseIn)
-                    $this->sendMailJoinRequestAccepted($oAlert, $oAlert->aExtras['profile'], bx_get_logged_profile_id());
-                break;
+        if($this->_bUseIn) {
+            $iInviter = bx_get_logged_profile_id();
+
+            switch ($oAlert->sAction) {
+                case 'join_invitation':
+                    $this->sendMailInvitation($oAlert, $oAlert->aExtras['profile'], $iInviter);
+                    break;
+
+                case 'join_request':
+                    $this->sendMailJoinRequest($oAlert, $oAlert->aExtras['profile'], $iInviter);
+                    break;
+
+                case 'join_request_accepted':
+                    $this->sendMailJoinRequestAccepted($oAlert, $oAlert->aExtras['profile'], $iInviter);
+                    break;
+            }
         }
     }
 
@@ -68,35 +70,14 @@ class BxBaseModGroupsAlertsResponse extends BxBaseModProfileAlertsResponse
     {
         $CNF = &$this->_oModule->_oConfig->CNF;
 
-        $bTrackInvites = isset($CNF["TABLE_INVITES"]) && isset($CNF['OBJECT_CONNECTIONS']);
-        if(!$this->_bUseIn && !$bTrackInvites)
-            return;
-
-        $sEntryUrl = $oAlert->aExtras['entry_url'];
-        if($bTrackInvites) {
-            if(!($oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS'])))
-                return;
-
-            if($iInviter != $oAlert->iSender && !$oConnection->isConnected($iInviter, $oAlert->iSender))
-                return;
-
-            if($this->_oModule->_oDb->isInviteByInvited($iInvited, $oAlert->iSender))
-                return;
+        $oInviter = BxDolProfile::getInstanceMagic($iInviter);
 
-            $sKey = BxDolKey::getInstance()->getNewKey(false, $CNF["INVITES_KEYS_LIFETIME"]);
-            $this->_oModule->_oDb->insertInvite($sKey, $oAlert->iSender, $iInviter, $iInvited);
-            $sEntryUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'], [
-                'id' => $oAlert->iObject,
-                'key' => $sKey
-            ]));
-        }
-
-        sendMailTemplate($this->_oModule->_oConfig->CNF['EMAIL_INVITATION'], 0, $iInvited, array(
-            'InviterUrl' => BxDolProfile::getInstance($iInviter)->getUrl(),
-            'InviterDisplayName' => BxDolProfile::getInstance($iInviter)->getDisplayName(),
-            'EntryUrl' => $sEntryUrl,
+        sendMailTemplate($CNF['EMAIL_INVITATION'], 0, $iInvited, [
+            'InviterUrl' => $oInviter->getUrl(),
+            'InviterDisplayName' => $oInviter->getDisplayName(),
+            'EntryUrl' => $oAlert->aExtras['entry_url'],
             'EntryTitle' => $oAlert->aExtras['entry_title'],
-        ), BX_EMAIL_NOTIFY);
+        ], BX_EMAIL_NOTIFY);
     }
 
     protected function sendMailJoinRequest ($oAlert, $iProfileId, $iSender = 0)

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

@@ -482,15 +482,33 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
         if (!($aContentInfo = $this->_oDb->getContentInfoById((int)BxDolProfile::getInstance($iGroupProfileId)->getContentId())))
             return false;
 
+        $oConnection = false;
         if (!isset($CNF['OBJECT_CONNECTIONS']) || !($oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS'])))
             return false;
 
+        $oPermalinks = BxDolPermalinks::getInstance();
+
         $sEntryTitle = $aContentInfo[$CNF['FIELD_NAME']];
-        $sEntryUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]));
+        $sEntryUrl = bx_absolute_url($oPermalinks->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]));
 
         // send invitation to the group 
         $sModule = $this->getName();
-        if ($bSendInviteOnly && !$oConnection->isConnected((int)$iInitiatorId, $oGroupProfile->id()) && !$oConnection->isConnected($oGroupProfile->id(), (int)$iInitiatorId) && bx_get_logged_profile_id() != $iProfileId) {
+        $iPerformerId = bx_get_logged_profile_id();
+        if ($bSendInviteOnly && !$oConnection->isConnected((int)$iInitiatorId, $oGroupProfile->id()) && !$oConnection->isConnected($oGroupProfile->id(), (int)$iInitiatorId) && $iProfileId != $iPerformerId) {
+            /**
+             * Insert invitation.
+             */
+            if(!empty($CNF['TABLE_INVITES']) && !$this->_oDb->isInviteByInvited($iProfileId, $iGroupProfileId)) {
+                $sKey = BxDolKey::getInstance()->getNewKey(false, $CNF['INVITES_KEYS_LIFETIME']);
+
+                $this->_oDb->insertInvite($sKey, $iGroupProfileId, $iPerformerId, $iProfileId);
+
+                $sEntryUrl = bx_absolute_url($oPermalinks->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'], [
+                    'id' => $aContentInfo[$CNF['FIELD_ID']],
+                    'key' => $sKey
+                ]));
+            }
+
             /**
              * @hooks
              * @hookdef hook-bx_base_groups-join_invitation '{module_name}', 'join_invitation' - hook before adding (sending) new join to context invitation

+ 2 - 2
template/scripts/BxBaseGrid.php

@@ -627,7 +627,7 @@ class BxBaseGrid extends BxDolGrid
     {
         $sRow = '';
         if(is_string($mixedRow))
-            $sRow = '<td class="bx-def-padding-sec-topbottom bx-def-font-bold" colspan="' . count($this->_aOptions['fields']) . '">' . $mixedRow . '</td>';
+            $sRow = '<td class="bx-grid-cell bx-gc-string bx-def-padding-sec-topbottom bx-def-font-bold" colspan="' . count($this->_aOptions['fields']) . '">' . $mixedRow . '</td>';
         else
             foreach($this->_aOptions['fields'] as $sKey => $aField)
                 $sRow .= $this->_getCellDesign($sKey, $aField, $mixedRow);
@@ -738,7 +738,7 @@ class BxBaseGrid extends BxDolGrid
 
         $sAttr = $this->_convertAttrs(
             $aField, 'attr_cell',
-            'bx-def-padding-sec-bottom bx-def-padding-sec-top', // add default classes
+            'bx-grid-cell' . (!empty($aField['name']) ? ' bx-gc-' . $aField['name'] : '') . ' bx-def-padding-sec-bottom bx-def-padding-sec-top', // add default classes
             isset($aField['width']) ? 'width:' . $aField['width'] : false // add default styles
         );
         return '<td ' . $sAttr . '>' . $mixedValue . '</td>';