Ejemplo n.º 1
0
function getSenderItemContainer($id, array $chain = array())
{
    $i = '%SENDER_LETTER_TEMPLATE_BODY_NUM%';
    ob_start();
    ?>
	<div class="sender-trigger-chain-container-letter">
		<div class="sender-trigger-status-mailing-time">
			<?php 
    echo GetMessage("sender_chain_edit_field_time_thr");
    ?>
 <span class="sender_letter_container_time_text">*</span> <?php 
    echo GetMessage("sender_chain_edit_field_time_after");
    ?>
			<span class="sender_letter_container_time_text_first">&nbsp;<?php 
    echo GetMessage("sender_chain_edit_field_time_event");
    ?>
</span>
			<span style="display: none;" class="sender_letter_container_time_text_nonfirst">&nbsp;<?php 
    echo GetMessage("sender_chain_edit_field_time_letter");
    ?>
</span>
			&nbsp;&nbsp;
			<a id="SENDER_TRIGGER_CHAIN_TIME_BNT_<?php 
    echo $i;
    ?>
" href="javascript: void(0);" class="sender_letter_container_time_button sender-link-email"><?php 
    echo GetMessage("sender_chain_edit_field_time_change");
    ?>
</a>
		</div>
		<div class="sender_letter_container" id="SENDER_TRIGGER_CHAIN_<?php 
    echo $i;
    ?>
">
			<input type="hidden" name="CHAIN[<?php 
    echo $i;
    ?>
][ID]" value="<?php 
    echo htmlspecialcharsbx($chain['ID']);
    ?>
">
			<input class="sender_letter_container_sorter" type="hidden" name="CHAIN[<?php 
    echo $i;
    ?>
][ITEM_SORT]" value="<?php 
    echo $i;
    ?>
">
			<input class="sender_letter_container_time" type="hidden" name="CHAIN[<?php 
    echo $i;
    ?>
][TIME_SHIFT]" value="<?php 
    echo intval($chain['TIME_SHIFT']);
    ?>
">

			<div class="sender_letter_container_head">
				<div class="sender_letter_container_move"><div class="sender_letter_container_burger"></div></div>
				<div class="sender_letter_container_sorter_view">
					<span class="sender_letter_container_sorter_icon">
						<span class="sender_letter_container_sorter_text"><?php 
    echo $i;
    ?>
</span>
					</span>
				</div>
				<h3><span class="sender_letter_container_caption"><?php 
    echo htmlspecialcharsbx($chain['SUBJECT']);
    ?>
</span></h3>
				<span class="sender_letter_container-info">
					<?php 
    if (!empty($chain['ID']) && empty($chain['DATE_INSERT'])) {
        ?>
						<span><?php 
        echo GetMessage("sender_chain_edit_field_created_exists_but_not_save");
        ?>
</span>
					<?php 
    } elseif (!empty($chain['ID'])) {
        ?>
						<span class="sender_letter_container-create"><?php 
        echo GetMessage("sender_chain_edit_field_created");
        ?>
</span>
						<span>
							<?php 
        echo GetMessage("sender_chain_edit_field_created_text", array('%DATE_CREATE%' => htmlspecialcharsbx(is_object($chain['DATE_INSERT']) ? \Bitrix\Main\Type\Date::createFromTimestamp($chain['DATE_INSERT']->getTimestamp()) : $chain['DATE_INSERT']), '%AUTHOR%' => '<a class="sender_letter_container-author" href="/bitrix/admin/user_edit.php?ID=' . htmlspecialcharsbx($chain['CREATED_BY']) . '&lang=' . LANGUAGE_ID . '">' . htmlspecialcharsbx($chain['CREATED_BY_NAME']) . ' ' . htmlspecialcharsbx($chain['CREATED_BY_LAST_NAME']) . '</a>'));
        ?>
						</span>
					<?php 
    } else {
        ?>
						<span><?php 
        echo GetMessage("sender_chain_edit_field_created_new");
        ?>
</span>
					<?php 
    }
    ?>
				</span>
				<a class="sender_letter_container_button_delete" href="javascript: void(0);" title="<?php 
    echo GetMessage("sender_chain_edit_field_delete");
    ?>
"></a>
				<?php 
    if (strlen($chain['SUBJECT']) > 0 && strlen($chain['MESSAGE']) > 0) {
        ?>
					<a class="sender_letter_container_button_show" href="javascript: void(0);">
						<?php 
        echo GetMessage('SENDER_MAILING_TRIG_LETTER_MESSAGE_SHOW');
        ?>
					</a>
				<?php 
    } else {
        ?>
					<a class="sender_letter_container_button_show sender_letter_container_button_hide" href="javascript: void(0);">
						<?php 
        echo GetMessage('SENDER_MAILING_TRIG_LETTER_MESSAGE_HIDE');
        ?>
					</a>
				<?php 
    }
    ?>
			</div>
			<div class="sender_letter_container_body" <?php 
    echo strlen($chain['SUBJECT']) > 0 && strlen($chain['MESSAGE']) > 0 ? 'style="display:none;"' : '';
    ?>
>
				<div class="sender_letter_container_body_tmpl" id="CHAIN_TEMPLATE_NUM_<?php 
    echo $i;
    ?>
" <?php 
    echo strlen($chain['MESSAGE']) > 0 ? 'style="display:none;"' : '';
    ?>
>
					<?php 
    echo \Bitrix\Sender\Preset\Template::getTemplateListHtml('SENDER_TRIGGER_CHAIN_' . $i);
    ?>
				</div>
				<div class="sender_letter_container_body_fields" <?php 
    echo strlen($chain['MESSAGE']) > 0 ? '' : 'style="display:none;"';
    ?>
>
					<table class="trigger_chain_item">
						<tr>
							<td><?php 
    echo GetMessage("sender_chain_edit_field_sel_templ");
    ?>
</td>
							<td>
								<span class="sender-template-message-caption-container"></span>
								&nbsp;
								<a href="javascript:void(0);" class="sender-template-message-caption-container-btn sender-link-email">
									<?php 
    echo GetMessage("sender_chain_edit_field_sel_templ_another");
    ?>
								</a>
							</td>
						</tr>
						<tr>
							<td><?php 
    echo GetMessage("sender_chain_edit_field_subject");
    ?>
</td>
							<td>
								<input class="sender_letter_container_subject" type="text" id="CHAIN_<?php 
    echo $i;
    ?>
_SUBJECT" name="CHAIN[<?php 
    echo $i;
    ?>
][SUBJECT]" value="<?php 
    echo htmlspecialcharsbx($chain['SUBJECT']);
    ?>
">
							</td>
						</tr>
						<tr>
							<td>&nbsp;</td>
							<td>
								<?php 
    $arPersonalizeList = \Bitrix\Sender\PostingRecipientTable::getPersonalizeList();
    ?>
								<?php 
    echo GetMessage("sender_chain_edit_field_subject_personalize");
    ?>
								<?php 
    foreach ($arPersonalizeList as $arPersonalize) {
        ?>
								<a class="sender-link-email" onclick="SetAddressToControl('CHAIN_<?php 
        echo $i;
        ?>
_SUBJECT', ' #<?php 
        echo htmlspecialcharsbx($arPersonalize['CODE']);
        ?>
#', true)" title="#<?php 
        echo htmlspecialcharsbx($arPersonalize['CODE']);
        ?>
# - <?php 
        echo htmlspecialcharsbx($arPersonalize['DESC']);
        ?>
">
									<?php 
        echo htmlspecialcharsbx($arPersonalize['NAME']);
        ?>
									</a><?php 
        echo end($arPersonalizeList) === $arPersonalize ? '' : ',';
        ?>
								<?php 
    }
    ?>
								<span style="cursor: pointer;" class="hidden-when-show-template-list-info" onclick="ShowPersonalizeDescDialog(this);">&nbsp;</span>
							</td>
						</tr>
						<tr>
							<td colspan="2">
								<b><?php 
    echo GetMessage("sender_chain_edit_field_message");
    ?>
</b>
								<br>
								<br>
								%SENDER_LETTER_TEMPLATE_MESSAGE%
							</td>
						</tr>
					</table>
				</div>
			</div>
		</div>
	</div>
	<?php 
    return ob_get_clean();
}
Ejemplo n.º 2
0
            LocalRedirect('sender_mailing_wizard.php?step=' . $step . '&MAILING_ID=' . $MAILING_ID . "&MAILING_CHAIN_ID=" . $MAILING_CHAIN_ID . "&lang=" . LANGUAGE_ID);
        } else {
            $DB->InitTableVarsForEdit("b_sender_mailing_chain", "", "str_");
        }
    } else {
    }
    $arMailngChainAttachment = array();
    if ($ID > 0) {
        $attachmentFileDb = \Bitrix\Sender\MailingAttachmentTable::getList(array('select' => array('FILE_ID'), 'filter' => array('CHAIN_ID' => $ID)));
        while ($ar = $attachmentFileDb->fetch()) {
            if ($arFileFetch = CFile::GetFileArray($ar['FILE_ID'])) {
                $arMailngChainAttachment[] = $arFileFetch;
            }
        }
    }
    $templateListHtml = \Bitrix\Sender\Preset\Template::getTemplateListHtml();
}
if ($step == 'chain_send_type') {
    $ID = $MAILING_CHAIN_ID;
    IncludeModuleLangFile(dirname(__FILE__) . "/mailing_chain_edit.php");
    $DAYS_OF_WEEK = empty($DAYS_OF_WEEK) ? '' : implode(',', $DAYS_OF_WEEK);
    if ($REQUEST_METHOD == "POST" && !$isPostedFormProcessed && check_bitrix_sessid()) {
        $arFields = array("REITERATE" => "N", "AUTO_SEND_TIME" => "", "DAYS_OF_WEEK" => "", "DAYS_OF_MONTH" => "", "TIMES_OF_DAY" => "");
        switch ($SEND_TYPE) {
            case 'MANUAL':
                break;
            case 'TIME':
                if (empty($AUTO_SEND_TIME)) {
                    $arError[] = GetMessage("sender_chain_edit_error_empty_time");
                }
                if (!\Bitrix\Main\Type\DateTime::isCorrect($AUTO_SEND_TIME)) {
Ejemplo n.º 3
0
    /**
     * @return string
     */
    public static function getTemplateListHtml()
    {
        $arTemplateListByType = \Bitrix\Sender\Preset\Template::getListByType();
        $arTemplateTypeList = \Bitrix\Sender\Preset\Template::getTypeList();
        ob_start();
        ?>
		<script>
			function ChangeTemplateList(type)
			{
				var tmplTypeContList = BX.findChildren(BX('TEMPLATE_CONTAINER'), {'className': 'sender-template-list-type-container'}, true);
				for(var i in tmplTypeContList)
					tmplTypeContList[i].style.display = 'none';

				BX('TEMPLATE_CONTAINER_'+type).style.display = 'table-row';


				var buttonList = BX.findChildren(BX('TEMPLATE_BUTTON_CONTAINER'), {'className': 'sender-template-type-selector-button'}, true);
				for(var j in buttonList)
					BX.removeClass(buttonList[j], 'sender-template-type-selector-button-selected');

				BX.addClass(BX('TEMPLATE_BUTTON_'+type), 'sender-template-type-selector-button-selected');
			}
			function SetTemplateToMessage(type, num)
			{
				BX('TEMPLATE_SELECTED_TITILE').innerHTML = templateListByType[type][num]['NAME'];
				var tmplTypeContList = BX.findChildren(BX('tabControl_layout'), {'className': 'hidden-when-show-template-list'}, true);
				for(i in tmplTypeContList)
					tmplTypeContList[i].style.display = 'table-row';

				tmplTypeContList = BX.findChildren(BX('tabControl_layout'), {'className': 'show-when-show-template-list'}, true);
				for(i in tmplTypeContList)
					tmplTypeContList[i].style.display = 'none';

				PutStringToMessageContainer(templateListByType[type][num]['HTML'], true);
				BX('IS_TEMPLATE_LIST_SHOWN').value = 'N';
			}

			var templateListByType = <?php 
        echo \CUtil::PhpToJSObject($arTemplateListByType);
        ?>
;
		</script>
		<div id="TEMPLATE_CONTAINER">
			<div>
				<table>
					<tr>
					<td style="vertical-align: top;">
						<div class="sender-template-type-selector" id="TEMPLATE_BUTTON_CONTAINER">
							<?php 
        $firstTemplateType = null;
        foreach ($arTemplateTypeList as $templateType => $templateTypeName) {
            if (!$firstTemplateType) {
                $firstTemplateType = $templateType;
            }
            ?>
								<div id="TEMPLATE_BUTTON_<?php 
            echo $templateType;
            ?>
" class="sender-template-type-selector-button" onclick="ChangeTemplateList('<?php 
            echo htmlspecialcharsbx($templateType);
            ?>
');">
									<?php 
            echo $templateTypeName;
            ?>
								</div>
							<?php 
        }
        ?>
						</div>
					</td>
					<td style="vertical-align: top;">
						<div class="sender-template-list-container">
							<?php 
        foreach ($arTemplateTypeList as $templateType => $templateTypeName) {
            ?>
								<div class="sender-template-list-type-container" id="TEMPLATE_CONTAINER_<?php 
            echo $templateType;
            ?>
" style="display: none;">
									<?php 
            if (isset($arTemplateListByType[$templateType])) {
                foreach ($arTemplateListByType[$templateType] as $templateNum => $arTemplate) {
                    ?>
										<div class="sender-template-list-type-block">
											<div class="sender-template-list-type-block-caption">
												<a class="sender-link-email" href="javascript: void(0);"
													onclick="SetTemplateToMessage('<?php 
                    echo htmlspecialcharsbx($arTemplate['TYPE']);
                    ?>
', <?php 
                    echo intval($templateNum);
                    ?>
);"
													>
													<?php 
                    echo htmlspecialcharsbx($arTemplate['NAME']);
                    ?>
												</a>
											</div>
											<div class="sender-template-list-type-block-img" onclick="SetTemplateToMessage('<?php 
                    echo htmlspecialcharsbx($arTemplate['TYPE']);
                    ?>
', <?php 
                    echo intval($templateNum);
                    ?>
);">
												<?php 
                    if (!empty($arTemplate['ICON'])) {
                        ?>
													<img src="<?php 
                        echo $arTemplate['ICON'];
                        ?>
">
												<?php 
                    }
                    ?>
											</div>
										</div>
									<?php 
                }
            }
            ?>
									<?php 
            if (empty($arTemplateListByType[$templateType])) {
                ?>
										<div class="sender-template-list-type-blockempty">
											<?php 
                echo Loc::getMessage('SENDER_PRESET_TEMPLATE_NO_TMPL');
                ?>
										</div>
									<?php 
            }
            ?>
								</div>
							<?php 
        }
        ?>
						</div>
					</td>
					</tr>
				</table>
				<script>
					ChangeTemplateList('BASE');
				</script>
			</div>
		</div>
		<?php 
        return ob_get_clean();
    }
Ejemplo n.º 4
0
        } else {
            $DB->InitTableVarsForEdit("b_sender_mailing_chain", "", "str_");
        }
    } else {
    }
    $arMailngChainAttachment = array();
    if ($ID > 0) {
        $attachmentFileDb = \Bitrix\Sender\MailingAttachmentTable::getList(array('select' => array('FILE_ID'), 'filter' => array('CHAIN_ID' => $ID)));
        while ($ar = $attachmentFileDb->fetch()) {
            if ($arFileFetch = CFile::GetFileArray($ar['FILE_ID'])) {
                $arMailngChainAttachment[] = $arFileFetch;
            }
        }
    }
    \Bitrix\Sender\PostingRecipientTable::setPersonalizeList(\Bitrix\Sender\MailingTable::getPersonalizeList($MAILING_ID));
    $templateListHtml = \Bitrix\Sender\Preset\Template::getTemplateListHtml('tabControl_layout');
}
if ($step == 'chain_send_type') {
    $ID = $MAILING_CHAIN_ID;
    IncludeModuleLangFile(dirname(__FILE__) . "/mailing_chain_edit.php");
    $DAYS_OF_WEEK = empty($DAYS_OF_WEEK) ? '' : implode(',', $DAYS_OF_WEEK);
    if ($REQUEST_METHOD == "POST" && !$isPostedFormProcessed && check_bitrix_sessid()) {
        $arFields = array("REITERATE" => "N", "AUTO_SEND_TIME" => "", "DAYS_OF_WEEK" => "", "DAYS_OF_MONTH" => "", "TIMES_OF_DAY" => "");
        switch ($SEND_TYPE) {
            case 'MANUAL':
                break;
            case 'TIME':
                if (empty($AUTO_SEND_TIME)) {
                    $arError[] = GetMessage("sender_chain_edit_error_empty_time");
                }
                if (!\Bitrix\Main\Type\DateTime::isCorrect($AUTO_SEND_TIME)) {
Ejemplo n.º 5
0
if (!\Bitrix\Main\Loader::includeModule("sender")) {
    ShowError(\Bitrix\Main\Localization\Loc::getMessage("MAIN_MODULE_NOT_INSTALLED"));
}
IncludeModuleLangFile(__FILE__);
$POST_RIGHT = $APPLICATION->GetGroupRight("sender");
if ($POST_RIGHT == "D") {
    $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED"));
}
$request = \Bitrix\Main\Context::getCurrent()->getRequest();
if ($request->get('action') == 'get_template') {
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_js.php";
    $templateType = $request->get('template_type');
    $templateId = $request->get('template_id');
    $templateCharset = $request->get('template_charset');
    \Bitrix\Main\Loader::includeModule('fileman');
    $template = \Bitrix\Sender\Preset\Template::getById($templateType, $templateId);
    if ($template) {
        echo \Bitrix\Fileman\Block\Editor::getHtmlForEditor($template['HTML'], $templateCharset);
    }
    require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin_js.php";
}
$sTableID = "tbl_sender_template";
$ID = intval($_REQUEST["ID"]);
$oSort = new CAdminSorting($sTableID, "ID", "desc");
$lAdmin = new CAdminList($sTableID, $oSort);
function CheckFilter()
{
    global $FilterArr, $lAdmin;
    foreach ($FilterArr as $f) {
        global ${$f};
    }
Ejemplo n.º 6
0
}
if ($message) {
    echo $message->Show();
}
if (!isset($SEND_TYPE)) {
    if ($str_REITERATE == 'Y') {
        $SEND_TYPE = 'REITERATE';
    } elseif (!empty($str_AUTO_SEND_TIME)) {
        $SEND_TYPE = 'TIME';
    } elseif ($ID > 0) {
        $SEND_TYPE = 'MANUAL';
    }
}
$templateListHtml = \Bitrix\Sender\Preset\Template::getTemplateListHtml('tabControl_layout');
$templateName = '';
$template = \Bitrix\Sender\Preset\Template::getById($str_TEMPLATE_TYPE, $str_TEMPLATE_ID);
if ($template) {
    $templateName = $template['NAME'];
}
?>


	<script>
		function SendTestMailing()
		{
			var data = {
				'action': 'send_to_me',
				'send_to_me_addr': BX('EMAIL_TO_ME').value
			};
			var url = '/bitrix/admin/sender_mailing_chain_admin.php?MAILING_ID=<?php 
echo $MAILING_ID;
Ejemplo n.º 7
0
    /**
     * @return string
     */
    public static function getTemplateListHtml($containerId = 'TEMPLATE_CONTAINER')
    {
        static $templateListByType;
        if (!$templateListByType) {
            $templateListByType = \Bitrix\Sender\Preset\Template::getListByType();
        }
        $templateTypeList = \Bitrix\Sender\Preset\Template::getTypeList();
        ob_start();
        ?>
		<script>
			BX.ready(function(){
				letterManager = new SenderLetterManager;
				letterManager.setTemplateListByType(<?php 
        echo \CUtil::PhpToJSObject($templateListByType);
        ?>
);
				if(!letterManager.get('<?php 
        echo $containerId;
        ?>
'))
				{
					letterManager.add('<?php 
        echo $containerId;
        ?>
', {'container': BX('<?php 
        echo $containerId;
        ?>
')});
				}
			});
		</script>
		<div class="sender-template-cont">
			<div>
				<table>
					<tr>
					<td style="vertical-align: top;">
						<div class="sender-template-type-selector">
							<?php 
        $firstTemplateType = null;
        foreach ($templateTypeList as $templateType => $templateTypeName) {
            if (!$firstTemplateType) {
                $firstTemplateType = $templateType;
            }
            ?>
								<div class="sender-template-type-selector-button sender-template-type-selector-button-type-<?php 
            echo $templateType;
            ?>
"
									 bxsendertype="<?php 
            echo htmlspecialcharsbx($templateType);
            ?>
">
									<?php 
            echo $templateTypeName;
            ?>
								</div>
							<?php 
        }
        ?>
						</div>
					</td>
					<td style="vertical-align: top;">
						<div class="sender-template-list-container">
							<?php 
        foreach ($templateTypeList as $templateType => $templateTypeName) {
            ?>
								<div class="sender-template-list-type-container sender-template-list-type-container-<?php 
            echo $templateType;
            ?>
" style="display: none;">
									<?php 
            if (isset($templateListByType[$templateType])) {
                foreach ($templateListByType[$templateType] as $templateNum => $template) {
                    ?>
										<div class="sender-template-list-type-block">
											<div class="sender-template-list-type-block-caption sender-template-list-block-selector">
												<a class="sender-link-email" href="javascript: void(0);" bxsendertype="<?php 
                    echo htmlspecialcharsbx($template['TYPE']);
                    ?>
" bxsendernum="<?php 
                    echo intval($templateNum);
                    ?>
">
													<?php 
                    echo htmlspecialcharsbx($template['NAME']);
                    ?>
												</a>
											</div>
											<div class="sender-template-list-type-block-img sender-template-list-block-selector"
												 bxsendertype="<?php 
                    echo htmlspecialcharsbx($template['TYPE']);
                    ?>
" bxsendernum="<?php 
                    echo intval($templateNum);
                    ?>
">
												<?php 
                    if (!empty($template['ICON'])) {
                        ?>
													<img src="<?php 
                        echo $template['ICON'];
                        ?>
">
												<?php 
                    }
                    ?>
											</div>
										</div>
									<?php 
                }
            }
            ?>
									<?php 
            if (empty($templateListByType[$templateType])) {
                ?>
										<div class="sender-template-list-type-blockempty">
											<?php 
                echo Loc::getMessage('SENDER_PRESET_TEMPLATE_NO_TMPL');
                ?>
										</div>
									<?php 
            }
            ?>
								</div>
							<?php 
        }
        ?>
						</div>
					</td>
					</tr>
				</table>
			</div>
		</div>
		<?php 
        return ob_get_clean();
    }
Ejemplo n.º 8
0
    /**
     * @return string
     */
    public static function getTemplateListHtml($containerId = 'TEMPLATE_CONTAINER')
    {
        static $templateListByType;
        if (!$templateListByType) {
            $templateListByType = \Bitrix\Sender\Preset\Template::getListByType();
        }
        $templateTypeList = \Bitrix\Sender\Preset\Template::getTypeList();
        ob_start();
        ?>
		<script>
			BX.ready(function(){
				letterManager = new SenderLetterManager;
				if(!letterManager.get('<?php 
        echo $containerId;
        ?>
'))
				{
					letterManager.add('<?php 
        echo $containerId;
        ?>
', {'container': BX('<?php 
        echo $containerId;
        ?>
')});
				}
			});
		</script>
		<div class="sender-template-cont">
			<div>
				<table>
					<tr>
					<td style="vertical-align: top;">
						<div class="sender-template-type-selector">
							<?php 
        $firstTemplateType = null;
        foreach ($templateTypeList as $templateType => $templateTypeName) {
            if (!$firstTemplateType) {
                $firstTemplateType = $templateType;
            }
            ?>
								<div class="sender-template-type-selector-button sender-template-type-selector-button-type-<?php 
            echo $templateType;
            ?>
"
										data-bx-sender-tmpl-type="<?php 
            echo htmlspecialcharsbx($templateType);
            ?>
">
									<?php 
            echo $templateTypeName;
            ?>
								</div>
							<?php 
        }
        ?>
						</div>
					</td>
					<td style="vertical-align: top;">
						<div class="sender-template-list-container">
							<?php 
        foreach ($templateTypeList as $templateType => $templateTypeName) {
            ?>
								<div id="sender-template-list-type-container-<?php 
            echo $templateType;
            ?>
" class="sender-template-list-type-container sender-template-list-type-container-<?php 
            echo $templateType;
            ?>
" style="display: none;">
									<?php 
            /*
            if($templateType == 'MARKETPLACE')
            {
            	\Bitrix\Main\Page\Asset::getInstance()->addCss('/bitrix/panel/main/marketplace.css');
            	?>
            	<script>
            		function mp_hl(el, show)
            		{
            			if(show)
            				BX.addClass(el, 'mp-over-over');
            			else
            				BX.removeClass(el, 'mp-over-over');
            
            		}
            		BX.ready(function(){
            			BX.ajax.insertToNode(
            				'/bitrix/admin/update_system_market.php?category=55&lang=ru&mode=list',
            				BX('sender-template-list-type-container-<?=$templateType?>')
            			);
            		});
            	</script>
            	<?
            }
            else
            */
            if (isset($templateListByType[$templateType])) {
                foreach ($templateListByType[$templateType] as $templateNum => $template) {
                    $isContentForBlockEditor = TemplateTable::isContentForBlockEditor($template['HTML']);
                    ?>
										<div class="sender-template-list-type-block">
											<div class="sender-template-list-type-block-caption sender-template-list-block-selector"
											     data-bx-sender-tmpl-version="<?php 
                    echo $isContentForBlockEditor ? 'block' : 'visual';
                    ?>
"
											     data-bx-sender-tmpl-name="<?php 
                    echo htmlspecialcharsbx($template['NAME']);
                    ?>
"
											     data-bx-sender-tmpl-type="<?php 
                    echo htmlspecialcharsbx($template['TYPE']);
                    ?>
"
											     data-bx-sender-tmpl-code="<?php 
                    echo htmlspecialcharsbx($template['ID']);
                    ?>
"
											     data-bx-sender-tmpl-lang="<?php 
                    echo LANGUAGE_ID;
                    ?>
">
												<a class="sender-link-email" href="javascript: void(0);">
													<?php 
                    echo htmlspecialcharsbx($template['NAME']);
                    ?>
												</a>
												<?php 
                    if (!$isContentForBlockEditor) {
                        ?>
													<br>
													<span style="font-size: 10px;"><?php 
                        echo Loc::getMessage('SENDER_PRESET_TEMPLATE_OLD_EDITOR');
                        ?>
</span>
												<?php 
                    }
                    ?>
											</div>
											<div class="sender-template-list-type-block-img sender-template-list-block-selector"
													data-bx-sender-tmpl-version="<?php 
                    echo $isContentForBlockEditor ? 'block' : 'visual';
                    ?>
"
													data-bx-sender-tmpl-name="<?php 
                    echo htmlspecialcharsbx($template['NAME']);
                    ?>
"
													data-bx-sender-tmpl-type="<?php 
                    echo htmlspecialcharsbx($template['TYPE']);
                    ?>
"
													data-bx-sender-tmpl-code="<?php 
                    echo htmlspecialcharsbx($template['ID']);
                    ?>
"
													data-bx-sender-tmpl-lang="<?php 
                    echo LANGUAGE_ID;
                    ?>
">
												<?php 
                    if (!empty($template['ICON'])) {
                        ?>
													<img src="<?php 
                        echo $template['ICON'];
                        ?>
">
												<?php 
                    }
                    ?>
											</div>
											<?php 
                    if (!empty($template['HTML'])) {
                        ?>
												<div class="sender-template-message-preview-btn"
													data-bx-sender-tmpl-name="<?php 
                        echo htmlspecialcharsbx($template['NAME']);
                        ?>
"
													data-bx-sender-tmpl-type="<?php 
                        echo htmlspecialcharsbx($template['TYPE']);
                        ?>
"
													data-bx-sender-tmpl-code="<?php 
                        echo htmlspecialcharsbx($template['ID']);
                        ?>
"
													data-bx-sender-tmpl-lang="<?php 
                        echo LANGUAGE_ID;
                        ?>
">
													<a class="sender-link-email " href="javascript: void(0);"><?php 
                        echo Loc::getMessage('SENDER_PRESET_TEMPLATE_BTN_PREVIEW');
                        ?>
</a>
												</div>
											<?php 
                    }
                    ?>
										</div>
									<?php 
                }
            }
            ?>
									<?php 
            if (empty($templateListByType[$templateType])) {
                ?>
										<div class="sender-template-list-type-blockempty">
											<?php 
                echo Loc::getMessage('SENDER_PRESET_TEMPLATE_NO_TMPL');
                ?>
										</div>
									<?php 
            }
            ?>
								</div>
							<?php 
        }
        ?>
						</div>
					</td>
					<td style="vertical-align: top;">
						<span class="sender-template-btn-close" title="<?php 
        echo Loc::getMessage('SENDER_PRESET_TEMPLATE_BTN_CLOSE');
        ?>
"></span>
					</td>
					</tr>
				</table>
			</div>
		</div>
		<?php 
        return ob_get_clean();
    }
Ejemplo n.º 9
0
 /**
  *
  * @param $mailingChainId
  * @param array $params
  * @return string
  * @throws \Bitrix\Main\ArgumentException
  * @throws \Bitrix\Main\DB\Exception
  */
 protected static function sendInternal($mailingChainId, array $params)
 {
     // event before sending
     $eventSendParams = $params;
     $eventSendParams['MAILING_CHAIN_ID'] = $mailingChainId;
     $event = new Event('sender', 'OnBeforePostingSendRecipient', array($eventSendParams));
     $event->send();
     foreach ($event->getResults() as $eventResult) {
         if ($eventResult->getType() == \Bitrix\Main\EventResult::ERROR) {
             return PostingRecipientTable::SEND_RESULT_ERROR;
         }
         if (is_array($eventResult->getParameters())) {
             $eventSendParams = array_merge($eventSendParams, $eventResult->getParameters());
         }
     }
     unset($eventSendParams['MAILING_CHAIN_ID']);
     $params = $eventSendParams;
     // prepare common params
     if (static::$currentMailingChainFields !== null) {
         if (static::$currentMailingChainFields['ID'] != $mailingChainId) {
             static::$currentMailingChainFields = null;
         }
     }
     if (static::$currentMailingChainFields === null) {
         $mailingChainDb = MailingChainTable::getList(array('select' => array('*', 'SITE_ID' => 'MAILING.SITE_ID'), 'filter' => array('=ID' => $mailingChainId)));
         if (!($mailingChain = $mailingChainDb->fetch())) {
             return PostingRecipientTable::SEND_RESULT_ERROR;
         }
         $charset = false;
         $siteDb = \Bitrix\Main\SiteTable::getList(array('select' => array('SERVER_NAME', 'NAME', 'CULTURE_CHARSET' => 'CULTURE.CHARSET'), 'filter' => array('=LID' => $mailingChain['SITE_ID'])));
         if ($site = $siteDb->fetch()) {
             $charset = $site['CULTURE_CHARSET'];
             $serverName = $site['SERVER_NAME'];
         } else {
             throw new \Bitrix\Main\DB\Exception(Loc::getMessage('SENDER_POSTING_MANAGER_ERR_SITE', array('#SITE_ID#' => $mailingChain['SITE_ID'])));
         }
         if (!$charset) {
             throw new \Bitrix\Main\DB\Exception(Loc::getMessage('SENDER_POSTING_MANAGER_ERR_CHARSET', array('#SITE_ID#' => "[" . $mailingChain['SITE_ID'] . "]" . $site['NAME'])));
         }
         $attachmentList = array();
         $attachmentDb = \Bitrix\Sender\MailingAttachmentTable::getList(array('select' => array('FILE_ID'), 'filter' => array('CHAIN_ID' => $mailingChainId)));
         while ($attachment = $attachmentDb->fetch()) {
             $attachmentList[] = $attachment['FILE_ID'];
         }
         static::$currentMailingChainFields = array();
         static::$currentMailingChainFields['EVENT'] = array('FILE' => $attachmentList);
         static::$currentMailingChainFields['ID'] = $mailingChain['ID'];
         // create final mail-text due to filling template by blocks
         static::$currentMailingChainFields['IS_MESSAGE_WITH_TEMPLATE'] = false;
         if ($mailingChain['TEMPLATE_TYPE'] && $mailingChain['TEMPLATE_ID']) {
             $chainTemplate = \Bitrix\Sender\Preset\Template::getById($mailingChain['TEMPLATE_TYPE'], $mailingChain['TEMPLATE_ID']);
             if ($chainTemplate && $chainTemplate['HTML']) {
                 $document = new \Bitrix\Main\Web\DOM\Document();
                 $document->loadHTML($chainTemplate['HTML']);
                 \Bitrix\Main\Loader::includeModule('fileman');
                 if (\Bitrix\Fileman\Block\Editor::fillDocumentBySliceContent($document, $mailingChain['MESSAGE'])) {
                     \Bitrix\Main\Web\DOM\StyleInliner::inlineDocument($document);
                     $mailingChain['MESSAGE'] = $document->saveHTML();
                     static::$currentMailingChainFields['IS_MESSAGE_WITH_TEMPLATE'] = true;
                 } else {
                     unset($document);
                 }
             }
         }
         static::$currentMailingChainFields['MESSAGE'] = array('BODY_TYPE' => 'html', 'EMAIL_FROM' => $mailingChain['EMAIL_FROM'], 'EMAIL_TO' => '#EMAIL_TO#', 'PRIORITY' => $mailingChain['PRIORITY'], 'SUBJECT' => $mailingChain['SUBJECT'], 'MESSAGE' => $mailingChain['MESSAGE'], 'MESSAGE_PHP' => \Bitrix\Main\Mail\Internal\EventMessageTable::replaceTemplateToPhp($mailingChain['MESSAGE']));
         static::$currentMailingChainFields['SITE'] = array($mailingChain['SITE_ID']);
         static::$currentMailingChainFields['CHARSET'] = $charset;
         static::$currentMailingChainFields['SERVER_NAME'] = $serverName;
         static::$currentMailingChainFields['LINK_PROTOCOL'] = \Bitrix\Main\Config\Option::get("sender", "link_protocol", 'http');
         static::$currentMailingChainFields['LINK_PARAMS'] = $mailingChain['LINK_PARAMS'];
     }
     $trackClick = isset($params['TRACK_CLICK']) ? $params['TRACK_CLICK'] : null;
     if ($trackClick && static::$currentMailingChainFields['LINK_PARAMS']) {
         if (!is_array($trackClick['URL_PARAMS'])) {
             $trackClick['URL_PARAMS'] = array();
         }
         parse_str(static::$currentMailingChainFields['LINK_PARAMS'], $trackClickTmp);
         if (is_array($trackClickTmp)) {
             $trackClick['URL_PARAMS'] = array_merge($trackClick['URL_PARAMS'], $trackClickTmp);
         }
     }
     // prepare params for send email
     $messageParams = array('EVENT' => static::$currentMailingChainFields['EVENT'], 'FIELDS' => $params['FIELDS'], 'MESSAGE' => static::$currentMailingChainFields['MESSAGE'], 'SITE' => static::$currentMailingChainFields['SITE'], 'CHARSET' => static::$currentMailingChainFields['CHARSET']);
     if (!empty($params['FIELDS']['UNSUBSCRIBE_LINK'])) {
         if (substr($params['FIELDS']['UNSUBSCRIBE_LINK'], 0, 4) !== 'http') {
             if (!empty(static::$currentMailingChainFields['SERVER_NAME'])) {
                 $serverName = static::$currentMailingChainFields['SERVER_NAME'];
             } else {
                 $serverName = \Bitrix\Main\Config\Option::get("main", "server_name", $GLOBALS["SERVER_NAME"]);
             }
             $linkProtocol = static::$currentMailingChainFields['LINK_PROTOCOL'];
             $params['FIELDS']['UNSUBSCRIBE_LINK'] = $linkProtocol . '://' . $serverName . $params['FIELDS']['UNSUBSCRIBE_LINK'];
         }
     }
     // event on sending
     $eventMessageParams = $messageParams;
     $eventMessageParams['MAILING_CHAIN_ID'] = $mailingChainId;
     $eventMessageParams['IS_MESSAGE_WITH_TEMPLATE'] = static::$currentMailingChainFields['IS_MESSAGE_WITH_TEMPLATE'];
     $event = new Event('sender', 'OnPostingSendRecipient', array($eventMessageParams));
     $event->send();
     foreach ($event->getResults() as $eventResult) {
         if ($eventResult->getType() == \Bitrix\Main\EventResult::ERROR) {
             return PostingRecipientTable::SEND_RESULT_ERROR;
         }
         if (is_array($eventResult->getParameters())) {
             $eventMessageParams = array_merge($eventMessageParams, $eventResult->getParameters());
         }
     }
     static::$currentMailingChainFields['IS_MESSAGE_WITH_TEMPLATE'] = $eventMessageParams['IS_MESSAGE_WITH_TEMPLATE'];
     unset($eventMessageParams['IS_MESSAGE_WITH_TEMPLATE']);
     unset($eventMessageParams['MAILING_CHAIN_ID']);
     $messageParams = $eventMessageParams;
     $message = Mail\EventMessageCompiler::createInstance($messageParams);
     $message->compile();
     // add unsubscribe info to header
     $mailHeaders = $message->getMailHeaders();
     if (!empty($params['FIELDS']['UNSUBSCRIBE_LINK'])) {
         $unsubUrl = $params['FIELDS']['UNSUBSCRIBE_LINK'];
         $mailHeaders['List-Unsubscribe'] = '<' . $unsubUrl . '>';
     }
     $mailBody = null;
     if (static::$currentMailingChainFields['IS_MESSAGE_WITH_TEMPLATE'] && Option::get('sender', 'use_inliner_for_each_template_mail', 'N') == 'Y') {
         // inline styles
         $mailBody = \Bitrix\Main\Web\DOM\StyleInliner::inlineHtml($message->getMailBody());
     }
     if (!$mailBody) {
         $mailBody = $message->getMailBody();
     }
     // set email params
     $mailParams = array('TO' => $message->getMailTo(), 'SUBJECT' => $message->getMailSubject(), 'BODY' => $mailBody, 'HEADER' => $mailHeaders, 'CHARSET' => $message->getMailCharset(), 'CONTENT_TYPE' => $message->getMailContentType(), 'MESSAGE_ID' => '', 'ATTACHMENT' => $message->getMailAttachment(), 'LINK_PROTOCOL' => static::$currentMailingChainFields['LINK_PROTOCOL'], 'LINK_DOMAIN' => static::$currentMailingChainFields['SERVER_NAME'], 'TRACK_READ' => isset($params['TRACK_READ']) ? $params['TRACK_READ'] : null, 'TRACK_CLICK' => $trackClick);
     // event on sending email
     $eventMailParams = $mailParams;
     $eventMailParams['MAILING_CHAIN_ID'] = $mailingChainId;
     $event = new Event('sender', 'OnPostingSendRecipientEmail', array($eventMailParams));
     $event->send();
     foreach ($event->getResults() as $eventResult) {
         if ($eventResult->getType() == \Bitrix\Main\EventResult::ERROR) {
             return PostingRecipientTable::SEND_RESULT_ERROR;
         }
         if (is_array($eventResult->getParameters())) {
             $eventMailParams = array_merge($eventMailParams, $eventResult->getParameters());
         }
     }
     unset($eventMailParams['MAILING_CHAIN_ID']);
     $mailParams = $eventMailParams;
     // send mail
     $result = Mail\Mail::send($mailParams);
     if ($result) {
         return PostingRecipientTable::SEND_RESULT_SUCCESS;
     } else {
         return PostingRecipientTable::SEND_RESULT_ERROR;
     }
 }