RomanL 8 лет назад
Родитель
Сommit
aacdb020ec

+ 10 - 2
modules/boonex/massmailer/classes/BxMassMailerAlertsResponse.php

@@ -20,8 +20,16 @@ class BxMassMailerAlertsResponse extends BxDolAlertsResponse
     {
         if ($oAlert->sUnit == 'account' && $oAlert->sAction == 'change_receive_news'){
             $oModule = BxDolModule::getInstance('bx_massmailer');
-            if ($oAlert->aExtras['account_id'] != '' && $oAlert->aExtras['old_value'] != $oAlert->aExtras['new_value'])
-                $oModule->_oDb->updateUnsubscribe($oAlert->aExtras['account_id'], $oAlert->aExtras['new_value']);
+            if ($oAlert->aExtras['account_id'] != '' && $oAlert->aExtras['old_value'] != $oAlert->aExtras['new_value']){
+                $sHash = bx_get('lhash');
+                $iCampagn_Id = 0; 
+                if ($sHash){
+                    $aLetter = $oModule->_oDb->getLetterByCode($sHash);
+                    if (isset($aLetter['campaign_id']))
+                        $iCampagn_Id = $aLetter['campaign_id'];
+                }    
+                $oModule->_oDb->updateUnsubscribe($oAlert->aExtras['account_id'], $oAlert->aExtras['new_value'], $iCampagn_Id);
+            }
         }
     }
 }

+ 6 - 3
modules/boonex/massmailer/classes/BxMassMailerDb.php

@@ -163,7 +163,9 @@ class BxMassMailerDb extends BxBaseModGeneralDb
         $q = "
         SELECT COUNT(*) AS `count`, 'total' AS `title` FROM `" . $CNF['TABLE_LETTERS'] . "` WHERE `" . $CNF['FIELD_CAMPAIGN_ID'] . "` = :campaign_id UNION
         SELECT COUNT(*), 'seen' FROM `" . $CNF['TABLE_LETTERS'] . "`  WHERE `" . $CNF['FIELD_CAMPAIGN_ID'] . "` = :campaign_id AND `" . $CNF['FIELD_DATE_SEEN'] . "` > 0 UNION
-        SELECT COUNT(*), 'clicked' FROM `" . $CNF['TABLE_LETTERS'] . "` WHERE `" . $CNF['FIELD_CAMPAIGN_ID'] . "` = :campaign_id AND `" . $CNF['FIELD_DATE_CLICK'] . "` > 0";
+        SELECT COUNT(*), 'clicked' FROM `" . $CNF['TABLE_LETTERS'] . "` WHERE `" . $CNF['FIELD_CAMPAIGN_ID'] . "` = :campaign_id AND `" . $CNF['FIELD_DATE_CLICK'] . "` > 0 UNION 
+        SELECT COUNT(*), 'unsubscribed' FROM `" . $CNF['TABLE_UNSUBSCRIBE'] . "` WHERE `" . $CNF['FIELD_CAMPAIGN_ID'] . "` = :campaign_id 
+        ";
         return $this->getPairs($q, 'title', 'count', $aBindings);
     }
     
@@ -206,15 +208,16 @@ class BxMassMailerDb extends BxBaseModGeneralDb
     }
     
     
-    public function updateUnsubscribe($iAccountId, $iValue)
+    public function updateUnsubscribe($iAccountId, $iValue, $iCampaignId)
     {
         $CNF = &$this->_oConfig->CNF;
         if ($iValue != 1){
             $aBindings = array(
                 'account_id' => $iAccountId,
+                'campaign_id' => $iCampaignId,
                 'date_unsubscribed' => time()
             );
-            $this->query("INSERT INTO `" . $CNF['TABLE_UNSUBSCRIBE'] . "` (`" . $CNF['FIELD_DATE_UNSUBSCRIBED'] . "`, `" . $CNF['FIELD_ACCOUNT_ID'] . "`) VALUES (:date_unsubscribed, :account_id)", $aBindings);
+            $this->query("INSERT INTO `" . $CNF['TABLE_UNSUBSCRIBE'] . "` (`" . $CNF['FIELD_DATE_UNSUBSCRIBED'] . "`, `" . $CNF['FIELD_ACCOUNT_ID'] . "`, `" . $CNF['FIELD_CAMPAIGN_ID'] . "`) VALUES (:date_unsubscribed, :account_id, :campaign_id)", $aBindings);
         }
         else{
             $aBindings = array(

+ 10 - 1
modules/boonex/massmailer/classes/BxMassMailerModule.php

@@ -136,6 +136,7 @@ class BxMassMailerModule extends BxBaseModGeneralModule
                 $aValues['values'][1] = array('legend' => _t('_bx_massmailer_txt_opened_total_title', $aDataStat['seen']) , 'data' => array($aDataStat['seen']));
                 $aValues['values'][2] = array('legend' => _t('_bx_massmailer_txt_unopened_total_title', $aDataStat['total'] - $aDataStat['seen']), 'data' => array($aDataStat['total'] - $aDataStat['seen']));
                 $aValues['values'][3] = array('legend' => _t('_bx_massmailer_txt_clicked_total_title', $aDataStat['clicked']), 'data' => array($aDataStat['clicked']));
+                $aValues['values'][4] = array('legend' => _t('_bx_massmailer_txt_unsubscribed_total_title', $aDataStat['unsubscribed']), 'data' => array($aDataStat['unsubscribed']));
                 $iMaxValueY = $aDataStat['total'];
                 break;
         }
@@ -412,6 +413,14 @@ class BxMassMailerModule extends BxBaseModGeneralModule
         }
         return $this->_oTemplate->getAttributes($aAttributesParts);
     }
+    
+    /**
+     * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden. So make sure to make strict(===) checking.
+     */
+    public function checkAllowedAdd ($isPerformAction = false)
+    {
+        return CHECK_ACTION_RESULT_ALLOWED;
+    }
           
     public function getSegments($sKey = "")
     {
@@ -556,7 +565,7 @@ class BxMassMailerModule extends BxBaseModGeneralModule
             }
             
             $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);
+            $aMarkers['unsubscribe_url'] = BX_DOL_URL_ROOT . $oAccount->getUnsubscribeLink(BX_EMAIL_MASS) . "&lhash=" . $sLetterCode;
             
         }
         return $aMarkers;

+ 1 - 1
modules/boonex/massmailer/install/langs/en.xml

@@ -115,7 +115,7 @@
   <string name="_bx_massmailer_txt_opened_total_title"><![CDATA[Opened - {0}]]></string>
   <string name="_bx_massmailer_txt_unopened_total_title"><![CDATA[Unopened - {0}]]></string>
   <string name="_bx_massmailer_txt_clicked_total_title"><![CDATA[Clicked - {0}]]></string>
-
+  <string name="_bx_massmailer_txt_unsubscribed_total_title"><![CDATA[Unsubscribed - {0}]]></string>
 
   <string name="_bx_massmailer_txt_attribute_global"><![CDATA[Account]]></string>
   <string name="_bx_massmailer_txt_attribute_email"><![CDATA[Email]]></string>

+ 0 - 4
modules/boonex/massmailer/install/sql/disable.sql

@@ -21,10 +21,6 @@ DELETE FROM `sys_objects_grid` WHERE `object` IN ('bx_massmailer_campaigns', 'bx
 DELETE FROM `sys_grid_fields` WHERE `object` IN ('bx_massmailer_campaigns', 'bx_massmailer_letters');
 DELETE FROM `sys_grid_actions` WHERE `object` IN ('bx_massmailer_campaigns', 'bx_massmailer_letters');
 
--- ACL
-DELETE `sys_acl_actions`, `sys_acl_matrix` FROM `sys_acl_actions`, `sys_acl_matrix` WHERE `sys_acl_matrix`.`IDAction` = `sys_acl_actions`.`ID` AND `sys_acl_actions`.`Module` = @sName;
-DELETE FROM `sys_acl_actions` WHERE `Module` = @sName;
-
 -- EMAIL TEMPLATES
 DELETE FROM `sys_email_templates` WHERE `module` = @sName;
 

+ 1 - 39
modules/boonex/massmailer/install/sql/enable.sql

@@ -17,14 +17,13 @@ INSERT INTO `sys_options` (`category_id`, `name`, `caption`, `value`, `type`, `e
 
 -- PAGE: create campaign
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
-('bx_massmailer_create_campaign', '_bx_massmailer_page_title_sys_create_campaign', '_bx_massmailer_page_title_create_campaign', 'bx_massmailer', 7, 128, 1, 'create-campaign', 'page.php?i=create-campaign', '', '', '', 0, 1, 0, 'BxMassMailerPageBrowse', 'modules/boonex/massmailer/classes/BxMassMailerPageBrowse.php');
+('bx_massmailer_create_campaign', '_bx_massmailer_page_title_sys_create_campaign', '_bx_massmailer_page_title_create_campaign', 'bx_massmailer', 7, 128, 1, 'create-campaign', 'page.php?i=create-campaign', '', '', '', 0, 1, 0, 'BxMassMailerPageEntry', 'modules/boonex/massmailer/classes/BxMassMailerPageEntry.php');
 
 INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title`, `designbox_id`, `visible_for_levels`, `type`, `content`, `deletable`, `copyable`, `order`) VALUES
 ('bx_massmailer_create_campaign', 1, @sName, '_bx_massmailer_page_block_title_entry_breadcrumb', 13, 128, 'service', 'a:2:{s:6:"module";s:13:"bx_massmailer";s:6:"method";s:17:"entity_breadcrumb";}', 0, 0, 0),
 ('bx_massmailer_create_campaign', 2, @sName, '_bx_massmailer_page_block_title_create_campaign', 11, 128, 'service', 'a:2:{s:6:"module";s:13:"bx_massmailer";s:6:"method";s:13:"entity_create";}', 0, 1, 1),
 ('bx_massmailer_create_campaign', 3, @sName, '_bx_massmailer_page_block_title_attributes', 11, 128, 'service', 'a:2:{s:6:"module";s:13:"bx_massmailer";s:6:"method";s:10:"attributes";}', 0, 0, 1);
 
-
 -- PAGE: edit campaign
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_massmailer_edit_campaign', '_bx_massmailer_page_title_sys_edit_campaign', '_bx_massmailer_page_title_edit_campaign', 'bx_massmailer', 7, 128, 1, 'edit-campaign', '', '', '', '', 0, 1, 0, 'BxMassMailerPageEntry', 'modules/boonex/massmailer/classes/BxMassMailerPageEntry.php');
@@ -44,7 +43,6 @@ INSERT INTO `sys_pages_blocks` (`object`, `cell_id`, `module`, `title`, `designb
 ('bx_massmailer_view_campaign', 1, @sName, '_bx_massmailer_page_block_title_view_campaign_subscribers', 11, 128, 'service', 'a:2:{s:6:"module";s:13:"bx_massmailer";s:6:"method";s:19:"campagn_subscribers";}', 0, 0, 2),
 ('bx_massmailer_view_campaign', 1, @sName, '_bx_massmailer_page_block_title_view_campaign_links', 11, 128, 'service', 'a:2:{s:6:"module";s:13:"bx_massmailer";s:6:"method";s:13:"campagn_links";}', 0, 0, 3);
 
-
 -- PAGE: campaigns administration
 INSERT INTO `sys_objects_page`(`object`, `title_system`, `title`, `module`, `layout_id`, `visible_for_levels`, `visible_for_levels_editable`, `uri`, `url`, `meta_description`, `meta_keywords`, `meta_robots`, `cache_lifetime`, `cache_editable`, `deletable`, `override_class_name`, `override_class_file`) VALUES 
 ('bx_massmailer_campaigns', '_bx_massmailer_page_title_sys_manage_campaigns', '_bx_massmailer_page_title_manage_campaigns', @sName, 5, 128, 1, 'massmailer-campaigns', 'page.php?i=massmailer-campaigns', '', '', '', 0, 1, 0, 'BxMassMailerPageBrowse', 'modules/boonex/massmailer/classes/BxMassMailerPageBrowse.php');
@@ -97,42 +95,6 @@ INSERT INTO `sys_grid_actions` (`object`, `type`, `name`, `title`, `icon`, `icon
 INSERT INTO `sys_email_templates` (`Module`, `NameSystem`, `Name`, `Subject`, `Body`) VALUES
 (@sName, '_bx_massmailer_email_name', 'bx_massmailer_email', '_bx_massmailer_email_subject', '_bx_massmailer_email_body');
 
--- ACL
-INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`, `Desc`, `Countable`, `DisabledForLevels`) VALUES
-('bx_massmailer', 'create entry', NULL, '_bx_massmailer_acl_action_create_entry', '', 1, 3);
-SET @iIdActionEntryCreate = LAST_INSERT_ID();
-
-INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`, `Desc`, `Countable`, `DisabledForLevels`) VALUES
-('bx_massmailer', 'delete entry', NULL, '_bx_massmailer_acl_action_delete_entry', '', 1, 3);
-SET @iIdActionEntryDelete = LAST_INSERT_ID();
-
-INSERT INTO `sys_acl_actions` (`Module`, `Name`, `AdditionalParamName`, `Title`, `Desc`, `Countable`, `DisabledForLevels`) VALUES
-('bx_massmailer', 'view entry', NULL, '_bx_massmailer_acl_action_view_entry', '', 1, 0);
-SET @iIdActionEntryView = LAST_INSERT_ID();
-
-SET @iUnauthenticated = 1;
-SET @iAccount = 2;
-SET @iStandard = 3;
-SET @iUnconfirmed = 4;
-SET @iPending = 5;
-SET @iSuspended = 6;
-SET @iModerator = 7;
-SET @iAdministrator = 8;
-SET @iPremium = 9;
-
-INSERT INTO `sys_acl_matrix` (`IDLevel`, `IDAction`) VALUES
-
--- entry create
-(@iModerator, @iIdActionEntryCreate),
-(@iAdministrator, @iIdActionEntryCreate),
-
--- entry delete
-(@iModerator, @iIdActionEntryDelete),
-(@iAdministrator, @iIdActionEntryDelete),
-
--- entry view
-(@iModerator, @iIdActionEntryView),
-(@iAdministrator, @iIdActionEntryView);
 
 -- ALERTS
 INSERT INTO `sys_alerts_handlers` (`name`, `class`, `file`, `service_call`) VALUES 

+ 1 - 0
modules/boonex/massmailer/install/sql/install.sql

@@ -50,6 +50,7 @@ CREATE TABLE `bx_massmailer_links` (
 CREATE TABLE `bx_massmailer_unsubscribe` (
   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
   `account_id` int(11) DEFAULT NULL,
+  `campaign_id` int(11) DEFAULT NULL,
   `unsubscribed` int(11) NOT NULL default '0',
   PRIMARY KEY (`id`)
 );