AntonLV 8 лет назад
Родитель
Сommit
e4be709f19

+ 28 - 24
modules/boonex/market/classes/BxMarketConfig.php

@@ -45,38 +45,39 @@ class BxMarketConfig extends BxBaseModTextConfig
             'FIELD_AUTHOR' => 'author',
             'FIELD_ADDED' => 'added',
             'FIELD_CHANGED' => 'changed',
-        	'FIELD_NAME' => 'name',
+            'FIELD_NAME' => 'name',
             'FIELD_TITLE' => 'title',
             'FIELD_TEXT' => 'text',
             'FIELD_TEXT_ID' => 'product-text',
-        	'FIELD_CATEGORY' => 'cat',
-        	'FIELD_HEADER_BEG_SINGLE' => 'header_beg_single',
-        	'FIELD_WARNING_SINGLE' => 'warning_single',
-        	'FIELD_PRICE_SINGLE' => 'price_single',
-        	'FIELD_HEADER_END_SINGLE' => 'header_end_single',
-        	'FIELD_HEADER_BEG_RECURRING' => 'header_beg_recurring',
-        	'FIELD_WARNING_RECURRING' => 'warning_recurring',
-        	'FIELD_PRICE_RECURRING' => 'price_recurring',
-        	'FIELD_DURATION_RECURRING' => 'duration_recurring',
-        	'FIELD_TRIAL_RECURRING' => 'trial_recurring',
-        	'FIELD_HEADER_END_RECURRING' => 'header_end_recurring',
+            'FIELD_CATEGORY' => 'cat',
+            'FIELD_HEADER_BEG_SINGLE' => 'header_beg_single',
+            'FIELD_WARNING_SINGLE' => 'warning_single',
+            'FIELD_PRICE_SINGLE' => 'price_single',
+            'FIELD_HEADER_END_SINGLE' => 'header_end_single',
+            'FIELD_HEADER_BEG_RECURRING' => 'header_beg_recurring',
+            'FIELD_WARNING_RECURRING' => 'warning_recurring',
+            'FIELD_PRICE_RECURRING' => 'price_recurring',
+            'FIELD_DURATION_RECURRING' => 'duration_recurring',
+            'FIELD_TRIAL_RECURRING' => 'trial_recurring',
+            'FIELD_HEADER_END_RECURRING' => 'header_end_recurring',
             'FIELD_ALLOW_VIEW_TO' => 'allow_view_to',
-			'FIELD_ALLOW_PURCHASE_TO' => 'allow_purchase_to',
-			'FIELD_ALLOW_COMMENT_TO' => 'allow_comment_to',
-			'FIELD_ALLOW_VOTE_TO' => 'allow_vote_to',
+            'FIELD_ALLOW_PURCHASE_TO' => 'allow_purchase_to',
+            'FIELD_ALLOW_COMMENT_TO' => 'allow_comment_to',
+            'FIELD_ALLOW_VOTE_TO' => 'allow_vote_to',
             'FIELD_SUBENTRIES' => 'subentries',
             'FIELD_PHOTO' => 'pictures',
             'FIELD_THUMB' => 'thumb',
-        	'FIELD_COVER' => 'cover',
-        	'FIELD_FILE' => 'files',
-        	'FIELD_PACKAGE' => 'package',
-        	'FIELD_VIEWS' => 'views',
+            'FIELD_COVER' => 'cover',
+            'FIELD_FILE' => 'files',
+            'FIELD_PACKAGE' => 'package',
+            'FIELD_NOTES_PURCHASED' => 'notes_purchased',
+            'FIELD_VIEWS' => 'views',
             'FIELD_COMMENTS' => 'comments',
-        	'FIELD_FEATURED' => 'featured',
-        	'FIELD_STATUS' => 'status',
-        	'FIELD_STATUS_ADMIN' => 'status_admin',
+            'FIELD_FEATURED' => 'featured',
+            'FIELD_STATUS' => 'status',
+            'FIELD_STATUS_ADMIN' => 'status_admin',
             'FIELD_LOCATION_PREFIX' => 'location',
-        	'FIELDS_QUICK_SEARCH' => array('title'),
+            'FIELDS_QUICK_SEARCH' => array('title'),
             'FIELDS_WITH_KEYWORDS' => 'auto', // can be 'auto', array of fields or comma separated string of field names, works only when OBJECT_METATAGS is specified
 
             // page URIs
@@ -164,9 +165,12 @@ class BxMarketConfig extends BxBaseModTextConfig
             ),
 
             // global settings
-			'OPTION_ENABLE_RECURRING' => 'bx_market_enable_recurring',
+            'OPTION_ENABLE_RECURRING' => 'bx_market_enable_recurring',
             'OPTION_RECURRING_RESERVE' => 'bx_market_recurring_reserve',
 
+            // email templates
+            'ETEMPLATE_PURCHASED' => 'bx_market_purchased',
+
             // some language keys
             'T' => array (
                 'txt_sample_single' => '_bx_market_txt_sample_single',

+ 38 - 21
modules/boonex/market/classes/BxMarketModule.php

@@ -713,11 +713,11 @@ class BxMarketModule extends BxBaseModTextModule
     	$CNF = &$this->_oConfig->CNF;
 
         if(!$iItemId)
-			return array();
+            return array();
 
-		$aItem = $this->_oDb->getContentInfoById($iItemId);
+        $aItem = $this->_oDb->getContentInfoById($iItemId);
         if(empty($aItem) || !is_array($aItem))
-			return array();
+            return array();
 
         return array (
             'id' => $aItem[$CNF['FIELD_ID']],
@@ -977,16 +977,20 @@ class BxMarketModule extends BxBaseModTextModule
 
     protected function _serviceRegisterItem($iClientId, $iSellerId, $iItemId, $iItemCount, $sOrder, $sLicense, $sType)
     {
+        $CNF = &$this->_oConfig->CNF;
+
     	$aItem = $this->serviceGetCartItem($iItemId);
         if(empty($aItem) || !is_array($aItem))
             return array();
 
+        $aProduct = $this->_oDb->getContentInfoById($iItemId);
+        if(empty($aProduct) || !is_array($aProduct))
+            return array();
+
         $iTrial = 0;
         $sDuration = '';
         $sAction = 'register';
         if($sType == BX_MARKET_LICENSE_TYPE_RECURRING) {
-            $aProduct = $this->_oDb->getContentInfoById($iItemId);
-
             $iTrial = $aProduct[$this->_oConfig->CNF['FIELD_TRIAL_RECURRING']];
             $sDuration = $aProduct[$this->_oConfig->CNF['FIELD_DURATION_RECURRING']];
             
@@ -1008,6 +1012,19 @@ class BxMarketModule extends BxBaseModTextModule
             'trial' => $iTrial
         ));
 
+        $oClient = BxDolProfile::getInstanceMagic($iClientId);
+        $oSeller = BxDolProfile::getInstanceMagic($iSellerId);
+
+        sendMailTemplate($CNF['ETEMPLATE_PURCHASED'], 0, $iClientId, array(
+            'client_name' => $oClient->getDisplayName(),
+            'product_name' => $aProduct[$CNF['FIELD_TITLE']],
+            'product_url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=view-product&id=' . $aProduct[$CNF['FIELD_ID']]),
+            'vendor_url' => $oSeller->getUrl(),
+            'vendor_name' => $oSeller->getDisplayName(),
+            'license' => $sLicense,
+            'notes' => $aProduct[$CNF['FIELD_NOTES_PURCHASED']],
+        ));
+
         return $aItem;
     }
 
@@ -1015,21 +1032,21 @@ class BxMarketModule extends BxBaseModTextModule
     {
         $aItemNew = $this->serviceGetCartItem($iItemIdNew);
         if(empty($aItemNew) || !is_array($aItemNew))
-			return array();
+            return array();
 
         if(!$this->_oDb->hasLicenseByOrder($iClientId, $iItemIdOld, $sOrder))
             return array();
-        
+
         if(!$this->_oDb->updateLicense(array('product_id' => $iItemIdNew), array('profile_id' => $iClientId, 'product_id' => $iItemIdOld, 'order' => $sOrder)))
             return array();
 
         bx_alert($this->getName(), 'license_reregister', 0, false, array(
-			'product_id_old' => $iItemIdOld,
-        	'product_id_new' => $iItemIdNew,
-			'profile_id' => $iClientId,
-			'order' => $sOrder,
-			'type' => $sType
-		));
+            'product_id_old' => $iItemIdOld,
+            'product_id_new' => $iItemIdNew,
+            'profile_id' => $iClientId,
+            'order' => $sOrder,
+            'type' => $sType
+        ));
 
         return $aItemNew;
     }
@@ -1039,14 +1056,14 @@ class BxMarketModule extends BxBaseModTextModule
     	if(!$this->_oDb->unregisterLicense($iClientId, $iItemId, $sOrder, $sLicense, $sType))
     		return false;
 
-    	bx_alert($this->getName(), 'license_unregister', 0, false, array(
-			'product_id' => $iItemId,
-			'profile_id' => $iClientId,
-			'order' => $sOrder,
-			'license' => $sLicense,
-			'type' => $sType,
-			'count' => $iItemCount
-		));
+        bx_alert($this->getName(), 'license_unregister', 0, false, array(
+            'product_id' => $iItemId,
+            'profile_id' => $iClientId,
+            'order' => $sOrder,
+            'license' => $sLicense,
+            'type' => $sType,
+            'count' => $iItemCount
+        ));
 
     	return true;
     }

+ 13 - 0
modules/boonex/market/install/langs/en.xml

@@ -58,6 +58,10 @@
 	<string name="_bx_market_form_entry_input_text_err"><![CDATA[Text field can't be empty]]></string>
 	<string name="_bx_market_form_entry_input_sys_notes"><![CDATA[Notes]]></string>
 	<string name="_bx_market_form_entry_input_notes"><![CDATA[Notes]]></string>
+        <string name="_bx_market_form_entry_input_notes_inf"><![CDATA[Will be shown on product's info page.]]></string>
+        <string name="_bx_market_form_entry_input_sys_notes_purchased"><![CDATA[After purchase notes]]></string>
+        <string name="_bx_market_form_entry_input_notes_purchased"><![CDATA[After purchase notes]]></string>
+        <string name="_bx_market_form_entry_input_notes_purchased_inf"><![CDATA[Will be attached to email message which is sent to buyer after purchase.]]></string>
 	<string name="_bx_market_form_entry_input_sys_delete_confirm"><![CDATA[Delete confirmation]]></string>
 	<string name="_bx_market_form_entry_input_delete_confirm"><![CDATA[I am sure I want to delete this product]]></string>
 	<string name="_bx_market_form_entry_input_delete_confirm_info"><![CDATA[This action can not be undone]]></string>
@@ -427,4 +431,13 @@
     <string name="_bx_market_txt_per_year"><![CDATA[year]]></string>
     <string name="_bx_market_txt_per_year_short"><![CDATA[year]]></string>
     <string name="_bx_market_txt_get_for_free"><![CDATA[Download for Free]]></string>
+
+    <!-- EMAIL TEMPLATES -->
+    <string name="_bx_market_et_txt_name_purchased"><![CDATA[Product purchased.]]></string>
+    <string name="_bx_market_et_txt_subject_purchased"><![CDATA[You've purchased {product_name} product.]]></string>
+    <string name="_bx_market_et_txt_body_purchased"><![CDATA[{email_header}
+<p>Hello, {client_name}.</p>
+<p>You've purchased <a href="{product_url}">{product_name}</a> product from <a href="{vendor_url}">{vendor_name}</a>.<br />Your license is <b>{license}</b>.</p>
+<p>{notes}</p>
+{email_footer}]]></string>
 </resources>

+ 3 - 0
modules/boonex/market/install/sql/disable.sql

@@ -55,3 +55,6 @@ DELETE FROM `sys_alerts_handlers` WHERE `id` = @iHandler;
 
 -- CRON
 DELETE FROM `sys_cron_jobs` WHERE `name` LIKE 'bx_market%';
+
+-- EMAIL TEMPLATES
+DELETE FROM `sys_email_templates` WHERE `Module` = 'bx_market';

+ 5 - 0
modules/boonex/market/install/sql/enable.sql

@@ -632,3 +632,8 @@ INSERT INTO `sys_alerts` (`unit`, `action`, `handler_id`) VALUES
 -- CRON
 INSERT INTO `sys_cron_jobs` (`name`, `time`, `class`, `file`, `service_call`) VALUES
 ('bx_market_pruning', '0 0 * * *', 'BxMarketCronPruning', 'modules/boonex/market/classes/BxMarketCronPruning.php', '');
+
+
+-- EMAIL TEMPLATES
+INSERT INTO `sys_email_templates` (`Module`, `NameSystem`, `Name`, `Subject`, `Body`) VALUES 
+('bx_market', '_bx_market_et_txt_name_purchased', 'bx_market_purchased', '_bx_market_et_txt_subject_purchased', '_bx_market_et_txt_body_purchased');

+ 11 - 7
modules/boonex/market/install/sql/install.sql

@@ -14,6 +14,7 @@ CREATE TABLE IF NOT EXISTS `bx_market_products` (
   `title` varchar(255) NOT NULL,
   `text` text NOT NULL,
   `notes` text NOT NULL,
+  `notes_purchased` text NOT NULL,
   `cat` int(11) NOT NULL,
   `price_single` float NOT NULL default '0',
   `price_recurring` float NOT NULL default '0',
@@ -339,7 +340,8 @@ INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `ch
 ('bx_market', 'bx_market', 'pictures', 'a:1:{i:0;s:15:"bx_market_html5";}', 'a:2:{s:16:"bx_market_simple";s:26:"_sys_uploader_simple_title";s:15:"bx_market_html5";s:25:"_sys_uploader_html5_title";}', 0, 'files', '_bx_market_form_entry_input_sys_pictures', '_bx_market_form_entry_input_pictures', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_market', 'bx_market', 'files', 'a:1:{i:0;s:15:"bx_market_html5";}', 'a:2:{s:16:"bx_market_simple";s:26:"_sys_uploader_simple_title";s:15:"bx_market_html5";s:25:"_sys_uploader_html5_title";}', 0, 'files', '_bx_market_form_entry_input_sys_files', '_bx_market_form_entry_input_files', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),
 ('bx_market', 'bx_market', 'text', '', '', 0, 'textarea', '_bx_market_form_entry_input_sys_text', '_bx_market_form_entry_input_text', '', 1, 0, 2, '', '', '', 'Avail', '', '_bx_market_form_entry_input_text_err', 'XssHtml', '', 1, 0),
-('bx_market', 'bx_market', 'notes', '', '', 0, 'textarea', '_bx_market_form_entry_input_sys_notes', '_bx_market_form_entry_input_notes', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 1, 0),
+('bx_market', 'bx_market', 'notes', '', '', 0, 'textarea', '_bx_market_form_entry_input_sys_notes', '_bx_market_form_entry_input_notes', '_bx_market_form_entry_input_notes_inf', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 1, 0),
+('bx_market', 'bx_market', 'notes_purchased', '', '', 0, 'textarea', '_bx_market_form_entry_input_sys_notes_purchased', '_bx_market_form_entry_input_notes_purchased', '_bx_market_form_entry_input_notes_purchased_inf', 0, 0, 0, '', '', '', '', '', '', 'XssHtml', '', 1, 0),
 ('bx_market', 'bx_market', 'title', '', '', 0, 'text', '_bx_market_form_entry_input_sys_title', '_bx_market_form_entry_input_title', '', 1, 0, 0, '', '', '', 'Avail', '', '_bx_market_form_entry_input_title_err', 'Xss', '', 1, 0),
 ('bx_market', 'bx_market', 'name', '', '', 0, 'text', '_bx_market_form_entry_input_sys_name', '_bx_market_form_entry_input_name', '', 1, 0, 0, '', '', '', 'Avail', '', '_bx_market_form_entry_input_name_err', 'Xss', '', 1, 0),
 ('bx_market', 'bx_market', 'cat', '', '#!bx_market_cats', 0, 'select', '_bx_market_form_entry_input_sys_cat', '_bx_market_form_entry_input_cat', '', 1, 0, 0, '', '', '', 'avail', '', '_bx_market_form_entry_input_cat_err', 'Xss', '', 1, 0),
@@ -384,9 +386,10 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_market_entry_add', 'allow_vote_to', 2147483647, 1, 21),
 ('bx_market_entry_add', 'header_end_privacy', 2147483647, 1, 22),
 ('bx_market_entry_add', 'notes', 2147483647, 1, 23),
-('bx_market_entry_add', 'location', 2147483647, 1, 24),
-('bx_market_entry_add', 'subentries', 2147483647, 1, 25),
-('bx_market_entry_add', 'do_publish', 2147483647, 1, 26),
+('bx_market_entry_add', 'notes_purchased', 2147483647, 1, 24),
+('bx_market_entry_add', 'location', 2147483647, 1, 25),
+('bx_market_entry_add', 'subentries', 2147483647, 1, 26),
+('bx_market_entry_add', 'do_publish', 2147483647, 1, 27),
 
 ('bx_market_entry_delete', 'delete_confirm', 2147483647, 1, 1),
 ('bx_market_entry_delete', 'do_submit', 2147483647, 1, 2),
@@ -414,9 +417,10 @@ INSERT INTO `sys_form_display_inputs`(`display_name`, `input_name`, `visible_for
 ('bx_market_entry_edit', 'allow_vote_to', 2147483647, 1, 21),
 ('bx_market_entry_edit', 'header_end_privacy', 2147483647, 1, 22),
 ('bx_market_entry_edit', 'notes', 2147483647, 1, 23),
-('bx_market_entry_edit', 'location', 2147483647, 1, 24),
-('bx_market_entry_edit', 'subentries', 2147483647, 1, 25),
-('bx_market_entry_edit', 'do_submit', 2147483647, 1, 26),
+('bx_market_entry_edit', 'notes_purchased', 2147483647, 1, 24),
+('bx_market_entry_edit', 'location', 2147483647, 1, 25),
+('bx_market_entry_edit', 'subentries', 2147483647, 1, 26),
+('bx_market_entry_edit', 'do_submit', 2147483647, 1, 27),
 
 ('bx_market_entry_view', 'cat', 2147483647, 1, 1),
 ('bx_market_entry_view', 'added', 2147483647, 1, 2),

+ 15 - 2
modules/boonex/russian/data/langs/bx_market/ru.xml

@@ -56,8 +56,12 @@
 	<string name="_bx_market_form_entry_input_sys_text"><![CDATA[Текст]]></string>
 	<string name="_bx_market_form_entry_input_text"><![CDATA[Текст]]></string>
 	<string name="_bx_market_form_entry_input_text_err"><![CDATA[Поле Текст не может быть пустым]]></string>
-	<string name="_bx_market_form_entry_input_sys_notes"><![CDATA[Примечания]]></string>
-	<string name="_bx_market_form_entry_input_notes"><![CDATA[Примечания]]></string>
+	<string name="_bx_market_form_entry_input_sys_notes"><![CDATA[Примечание]]></string>
+	<string name="_bx_market_form_entry_input_notes"><![CDATA[Примечание]]></string>
+        <string name="_bx_market_form_entry_input_notes_inf"><![CDATA[Будет отображаться на информационной странице продукта.]]></string>
+        <string name="_bx_market_form_entry_input_sys_notes_purchased"><![CDATA[Примечание к покупке]]></string>
+        <string name="_bx_market_form_entry_input_notes_purchased"><![CDATA[Примечание к покупке]]></string>
+        <string name="_bx_market_form_entry_input_notes_purchased_inf"><![CDATA[Будет прикреплено к сообщению электронной почты, которое отправляется покупателю после покупки.]]></string>
 	<string name="_bx_market_form_entry_input_sys_delete_confirm"><![CDATA[Удалить подтверждение]]></string>
 	<string name="_bx_market_form_entry_input_delete_confirm"><![CDATA[Я уверен(а), что хочу удалить этот продукт]]></string>
 	<string name="_bx_market_form_entry_input_delete_confirm_info"><![CDATA[Это действие не может быть отменено]]></string>
@@ -425,4 +429,13 @@
     <string name="_bx_market_txt_per_year"><![CDATA[год]]></string>
     <string name="_bx_market_txt_per_year_short"><![CDATA[год]]></string>
     <string name="_bx_market_txt_get_for_free"><![CDATA[Скачать бесплатно]]></string>
+
+    <!-- EMAIL TEMPLATES -->
+    <string name="_bx_market_et_txt_name_purchased"><![CDATA[Продукт приобретен.]]></string>
+    <string name="_bx_market_et_txt_subject_purchased"><![CDATA[Вы приобрели {product_name} продукт.]]></string>
+    <string name="_bx_market_et_txt_body_purchased"><![CDATA[{email_header}
+<p>Здравствуйте, {client_name}.</p>
+<p>Вы приобрели <a href="{product_url}">{product_name}</a> продукт у <a href="{vendor_url}">{vendor_name}</a>.<br />Ваша лицензия - <b>{license}</b>.</p>
+<p>{notes}</p>
+{email_footer}]]></string>
 </resources>