Przeglądaj źródła

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

AntonLV 4 lat temu
rodzic
commit
3635680c2a

+ 7 - 7
modules/boonex/forum/install/sql/enable.sql

@@ -346,13 +346,13 @@ INSERT INTO `sys_objects_menu`(`object`, `title`, `set_name`, `module`, `templat
 INSERT INTO `sys_menu_sets`(`set_name`, `module`, `title`, `deletable`) VALUES 
 ('bx_forum_snippet_meta_main', 'bx_forum', '_bx_forum_menu_set_title_snippet_meta_main', 0);
 
-INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `editable`, `order`) VALUES 
-('bx_forum_snippet_meta_main', 'bx_forum', 'author', '_sys_menu_item_title_system_sm_author', '_sys_menu_item_title_sm_author', '', '', '', '', '', 2147483647, 1, 0, 1, 1),
-('bx_forum_snippet_meta_main', 'bx_forum', 'date', '_sys_menu_item_title_system_sm_date', '_sys_menu_item_title_sm_date', '', '', '', 'clock', '', 2147483647, 1, 0, 1, 2),
-('bx_forum_snippet_meta_main', 'bx_forum', 'category', '_sys_menu_item_title_system_sm_category', '_sys_menu_item_title_sm_category', '', '', '', '', '', 2147483647, 1, 0, 1, 3),
-('bx_forum_snippet_meta_main', 'bx_forum', 'comments', '_sys_menu_item_title_system_sm_comments', '_sys_menu_item_title_sm_comments', '', '', '', 'comments', '', 2147483647, 1, 0, 1, 4),
-('bx_forum_snippet_meta_main', 'bx_forum', 'status', '_bx_forum_menu_item_title_system_sm_status', '_bx_forum_menu_item_title_sm_status', '', '', '', '', '', 2147483647, 1, 0, 1, 5),
-('bx_forum_snippet_meta_main', 'bx_forum', 'badges', '_bx_forum_menu_item_title_system_sm_badges', '_bx_forum_menu_item_title_sm_badges', '', '', '', '', '', 2147483647, 1, 0, 1, 6);
+INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `submenu_object`, `visible_for_levels`, `active`, `copyable`, `editable`, `order`, `hidden_on_col`) VALUES 
+('bx_forum_snippet_meta_main', 'bx_forum', 'author', '_sys_menu_item_title_system_sm_author', '_sys_menu_item_title_sm_author', '', '', '', '', '', 2147483647, 1, 0, 1, 1, 0),
+('bx_forum_snippet_meta_main', 'bx_forum', 'date', '_sys_menu_item_title_system_sm_date', '_sys_menu_item_title_sm_date', '', '', '', 'clock', '', 2147483647, 1, 0, 1, 2, 0),
+('bx_forum_snippet_meta_main', 'bx_forum', 'category', '_sys_menu_item_title_system_sm_category', '_sys_menu_item_title_sm_category', '', '', '', '', '', 2147483647, 1, 0, 1, 3, 3),
+('bx_forum_snippet_meta_main', 'bx_forum', 'comments', '_sys_menu_item_title_system_sm_comments', '_sys_menu_item_title_sm_comments', '', '', '', 'comments', '', 2147483647, 1, 0, 1, 4, 0),
+('bx_forum_snippet_meta_main', 'bx_forum', 'status', '_bx_forum_menu_item_title_system_sm_status', '_bx_forum_menu_item_title_sm_status', '', '', '', '', '', 2147483647, 1, 0, 1, 5, 3),
+('bx_forum_snippet_meta_main', 'bx_forum', 'badges', '_bx_forum_menu_item_title_system_sm_badges', '_bx_forum_menu_item_title_sm_badges', '', '', '', '', '', 2147483647, 1, 0, 1, 6, 3);
 
 
 -- MENU: custom menu for 'counters' snippet meta info

+ 1 - 1
modules/boonex/massmailer/classes/BxMassMailerDb.php

@@ -71,7 +71,7 @@ class BxMassMailerDb extends BxBaseModGeneralDb
     
     public function getAccountsByTerms($sTerms = "")
     {
-        $sSql = "SELECT `ta`.`email`, `tp`.`id` AS `profile_id` FROM `sys_accounts` AS `ta` " . $sTerms . "  WHERE `ta`.`receive_news` <> 0 AND `ta`.`email_confirmed` = 1";
+        $sSql = "SELECT `ta`.`email`, `tp`.`id` AS `profile_id`, `ta`.`id` as `account_id` FROM `sys_accounts` AS `ta` " . $sTerms . "  WHERE `ta`.`receive_news` <> 0 AND `ta`.`email_confirmed` = 1";
         return $this->getAll($sSql);
     }
     

+ 34 - 21
modules/boonex/massmailer/classes/BxMassMailerModule.php

@@ -483,7 +483,7 @@ class BxMassMailerModule extends BxBaseModGeneralModule
         if (!$aTemplate)
             return false;
         
-        return $this->sendLetter($sEmail, $iCampaignId, $aCustomHeaders, bx_get_logged_profile_id(), $aTemplate, false);
+        return $this->sendLetter($sEmail, $iCampaignId, $aCustomHeaders, getLoggedId(), $aTemplate, false);
     }
           
     public function sendAll($iCampaignId)
@@ -499,7 +499,7 @@ class BxMassMailerModule extends BxBaseModGeneralModule
         $this->_oDb->deleteCampaignData($iCampaignId);
         $aAccounts = $this->getEmailsBySegment($aCampaign['segments'], $aCampaign['is_one_per_account']);
         foreach ($aAccounts as $aAccountInfo){
-            $this->sendLetter($aAccountInfo['email'], $iCampaignId, $aCustomHeaders, $aAccountInfo['profile_id'], $aTemplate, true);
+            $this->sendLetter($aAccountInfo['email'], $iCampaignId, $aCustomHeaders, $aAccountInfo['account_id'], $aTemplate, true);
             $this->_oDb->addEmailToSentListForCampaign($iCampaignId, $aAccountInfo['email']);
         }
               
@@ -507,12 +507,12 @@ class BxMassMailerModule extends BxBaseModGeneralModule
         return true;
     }
     
-    private function sendLetter($sEmail, $iCampaignId, $aCustomHeaders, $iProfileId, $aTemplate, $bAddToQueue)
+    private function sendLetter($sEmail, $iCampaignId, $aCustomHeaders, $iAccountId, $aTemplate, $bAddToQueue)
     {
         $sLetterCode = $this->_oDb->addLetter($iCampaignId, $sEmail);
         
-        $aMarkers = $this->addMarkers($iProfileId, $sLetterCode);
-        bx_alert($this->_aModule['name'], 'user_fields', $iCampaignId, $iProfileId, array('email' => $sEmail, 'markers' => &$aMarkers));
+        $aMarkers = $this->addMarkers($iAccountId, $sLetterCode);
+        bx_alert($this->_aModule['name'], 'user_fields', $iCampaignId, $iAccountId, array('email' => $sEmail, 'markers' => &$aMarkers));
         
         $regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
         $aTemplate['Body'] = preg_replace_callback("/$regexp/siU",
@@ -528,6 +528,17 @@ class BxMassMailerModule extends BxBaseModGeneralModule
             },
             $aTemplate['Body']);
         
+        $aMarkersInLetter = [];
+        preg_match_all("/\{[^\}]*\}/i", $aTemplate['Body'], $aMarkersInLetter);
+        if ($aMarkersInLetter[0]>0){
+            foreach ($aMarkersInLetter[0] as $sMarker){
+                $sMarker = str_replace(['{', '}'], '', $sMarker);
+                if (!array_key_exists($sMarker, $aMarkers)) {
+                    $aMarkers[$sMarker] = '';
+                }
+            }
+        }
+        
         return sendMail($sEmail, $aTemplate['Subject'], $aTemplate['Body'], 0, $aMarkers, BX_EMAIL_MASS, 'html', false, $aCustomHeaders, $bAddToQueue);
     }
 
@@ -620,19 +631,21 @@ class BxMassMailerModule extends BxBaseModGeneralModule
         return array($aTemplate, $aCustomHeaders, $aCampaign);
     }
           
-    private function addMarkers($iProfileId, $sLetterCode)
+    private function addMarkers(iAccountId, $sLetterCode)
     {
         $CNF = &$this->_oConfig->CNF;
         $aMarkers = array();
-        $oProfile = BxDolProfile::getInstance($iProfileId);
-        if ($oProfile){
-            $oAccount = BxDolAccount::getInstance($oProfile->getAccountId());
-            $sAccountEmail = $oAccount->getEmail();
-
-            $aMarkers['email'] = $sAccountEmail;
-            $aMarkers['account_name'] = $oAccount->getDisplayName();
-            $aMarkers['account_id'] = $oProfile->getAccountId();
-
+        
+        $oAccount = BxDolAccount::getInstance($iAccountId);
+        $aAccountInfo = $oAccount->getInfo();
+        $sAccountEmail = $oAccount->getEmail();
+        
+        $aMarkers['email'] = $sAccountEmail;
+        $aMarkers['account_name'] = $oAccount->getDisplayName();
+        $aMarkers['account_id'] = $oAccount->id();
+        
+        if ($aAccountInfo['profile_id'] > 0){
+            $oProfile = BxDolProfile::getInstance($aAccountInfo['profile_id']);
             $sModule = $oProfile->getModule();
             if (BxDolRequest::serviceExists($sModule, 'get_info')) {
                 $aProfileInfo = bx_srv($sModule, 'get_info', array($oProfile->getContentId(), false));
@@ -640,14 +653,14 @@ class BxMassMailerModule extends BxBaseModGeneralModule
                     if(!isset($aMarkers[$sKey]))
                         $aMarkers[$sKey] = $sValue;
             }
+        }    
 
-            $aMarkers['seen_image_url'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'track/seen/' . $sLetterCode . "/";
-            $aMarkers['unsubscribe_url'] = BX_DOL_URL_ROOT . $oAccount->getUnsubscribeLink(BX_EMAIL_MASS) . "&lhash=" . $sLetterCode;
+        $aMarkers['seen_image_url'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'track/seen/' . $sLetterCode . "/";
+        $aMarkers['unsubscribe_url'] = BX_DOL_URL_ROOT . $oAccount->getUnsubscribeLink(BX_EMAIL_MASS) . "&lhash=" . $sLetterCode;
 
-            $aMarkers['reset_password_url'] = '';
-            if(($sResetPasswordUrl = bx_get_reset_password_link($sAccountEmail)) !== false)
-                $aMarkers['reset_password_url'] = $sResetPasswordUrl . "&lhash=" . $sLetterCode;
-        }
+        $aMarkers['reset_password_url'] = '';
+        if(($sResetPasswordUrl = bx_get_reset_password_link($sAccountEmail)) !== false)
+            $aMarkers['reset_password_url'] = $sResetPasswordUrl . "&lhash=" . $sLetterCode;
 
         return $aMarkers;
     }