PageRenderTime 26ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/sender/options.php

https://gitlab.com/alexprowars/bitrix
PHP | 164 lines | 154 code | 10 blank | 0 comment | 26 complexity | 36baed42e89ea8a8bb027bd36168e4a3 MD5 | raw file
  1. <?
  2. $module_id = "sender";
  3. $POST_RIGHT = $APPLICATION->GetGroupRight($module_id);
  4. if($POST_RIGHT>="R") :
  5. IncludeModuleLangFile($_SERVER["DOCUMENT_ROOT"].BX_ROOT."/modules/main/options.php");
  6. IncludeModuleLangFile(__FILE__);
  7. $arAllOptions = array(
  8. array("interval", GetMessage("opt_interval"), array("text", 10)),
  9. array("auto_method", GetMessage("opt_method"), array("selectbox", array("agent"=>GetMessage("opt_method_agent"), "cron"=>GetMessage("opt_method_cron")))),
  10. array("max_emails_per_hit", GetMessage("opt_max_per_hit"), array("text", 10)),
  11. array("auto_agent_interval", GetMessage("opt_auto_agent_interval"), array("text", 10)),
  12. array("max_emails_per_cron", GetMessage("opt_max_per_cron"), array("text", 10)),
  13. array("reiterate_method", GetMessage("opt_reiterate_method"), array("selectbox", array("agent"=>GetMessage("opt_method_agent"), "cron"=>GetMessage("opt_method_cron")))),
  14. array("thread_type", GetMessage("opt_threads_type"), array("selectbox", array
  15. ("Single"=>GetMessage("opt_method_single_thread"),"Ten"=>GetMessage("opt_method_ten_threads")))),
  16. array("reiterate_interval", GetMessage("opt_reiterate_interval"), array("text", 10)),
  17. array("link_protocol", GetMessage("opt_link_protocol"), array("selectbox", array(""=>"http", "https"=>"https"))),
  18. array("track_mails", GetMessage("opt_track_mails"), array("checkbox", 35)),
  19. array("unsub_link", GetMessage("opt_unsub_link"), array("text", 35)),
  20. array("sub_link", GetMessage("opt_sub_link"), array("text", 35)),
  21. array("address_from", GetMessage("opt_address_from"), array("text-list", 3, 20)),
  22. array("address_send_to_me", GetMessage("opt_address_send_to_me"), array("text-list", 3, 20)),
  23. array("mail_headers", GetMessage("opt_mail_headers"), array("srlz-list", 3, 20)),
  24. array("mail_consent",GetMessage("mail_need_consent"),array("checkbox")),
  25. array("~mail_max_consent_requests",GetMessage("mail_max_consent_requests"),array("text", 10)),
  26. );
  27. $aTabs = array(
  28. array("DIV" => "edit1", "TAB" => GetMessage("MAIN_TAB_SET"), "ICON" => "sender_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_SET")),
  29. array("DIV" => "edit2", "TAB" => GetMessage("MAIN_TAB_RIGHTS"), "ICON" => "sender_settings", "TITLE" => GetMessage("MAIN_TAB_TITLE_RIGHTS")),
  30. );
  31. $tabControl = new CAdminTabControl("tabControl", $aTabs);
  32. if($REQUEST_METHOD=="POST" && $Update.$Apply.$RestoreDefaults <> '' && $POST_RIGHT=="W" && check_bitrix_sessid())
  33. {
  34. if($RestoreDefaults <> '')
  35. {
  36. COption::RemoveOption("sender");
  37. $z = CGroup::GetList("id", "asc", array("ACTIVE" => "Y", "ADMIN" => "N"));
  38. while($zr = $z->Fetch())
  39. $APPLICATION->DelGroupRight($module_id, array($zr["ID"]));
  40. }
  41. else
  42. {
  43. foreach($arAllOptions as $arOption)
  44. {
  45. $name = $arOption[0];
  46. if($arOption[2][0]=="srlz-list")
  47. {
  48. $val = ${$name};
  49. TrimArr($val);
  50. sort($val);
  51. $val = serialize($val);
  52. }
  53. else if($arOption[2][0]=="text-list")
  54. {
  55. $val = "";
  56. $valCount = count(${$name});
  57. for($j=0; $j<$valCount; $j++)
  58. {
  59. if(trim(${$name}[$j]) <> '')
  60. $val .= ($val <> ""? ",":"").trim(${$name}[$j]);
  61. }
  62. }
  63. else
  64. $val=${$name};
  65. if($arOption[2][0] == "checkbox" && $val <> "Y")
  66. $val="N";
  67. COption::SetOptionString($module_id, $name, $val);
  68. }
  69. }
  70. \Bitrix\Sender\Runtime\Job::actualizeAll();
  71. $Update = $Update.$Apply;
  72. ob_start();
  73. require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/admin/group_rights.php");
  74. ob_end_clean();
  75. if($_REQUEST["back_url_settings"] <> '')
  76. {
  77. if(($Apply <> '') || ($RestoreDefaults <> ''))
  78. LocalRedirect($APPLICATION->GetCurPage()."?mid=".urlencode($module_id)."&lang=".urlencode(LANGUAGE_ID)."&back_url_settings=".urlencode($_REQUEST["back_url_settings"])."&".$tabControl->ActiveTabParam());
  79. else
  80. LocalRedirect($_REQUEST["back_url_settings"]);
  81. }
  82. else
  83. {
  84. LocalRedirect($APPLICATION->GetCurPage()."?mid=".urlencode($module_id)."&lang=".urlencode(LANGUAGE_ID)."&".$tabControl->ActiveTabParam());
  85. }
  86. }
  87. ?>
  88. <form method="post" action="<?echo $APPLICATION->GetCurPage()?>?mid=<?=urlencode($module_id)?>&amp;lang=<?=LANGUAGE_ID?>">
  89. <?
  90. $tabControl->Begin();
  91. $tabControl->BeginNextTab();
  92. foreach($arAllOptions as $Option):
  93. $type = $Option[2];
  94. $val = COption::GetOptionString($module_id, $Option[0]);
  95. ?>
  96. <tr>
  97. <td width="40%" <?if($type[0]=="textarea" || $type[0]=="text-list") echo 'class="adm-detail-valign-top"'?>>
  98. <label for="<?echo htmlspecialcharsbx($Option[0])?>"><?echo $Option[1]?></label>
  99. <td width="60%">
  100. <?
  101. if($type[0]=="checkbox"):
  102. ?><input type="checkbox" name="<?echo htmlspecialcharsbx($Option[0])?>" id="<?echo htmlspecialcharsbx($Option[0])?>" value="Y"<?if($val=="Y")echo" checked";?>><?
  103. elseif($type[0]=="text"):
  104. ?><input type="text" size="<?echo $type[1]?>" maxlength="255" value="<?echo htmlspecialcharsbx($val)?>" name="<?echo htmlspecialcharsbx($Option[0])?>"><?
  105. elseif($type[0]=="textarea"):
  106. ?><textarea rows="<?echo $type[1]?>" cols="<?echo $type[2]?>" name="<?echo htmlspecialcharsbx($Option[0])?>"><?echo htmlspecialcharsbx($val)?></textarea><?
  107. elseif($type[0]=="text-list" || $type[0]=="srlz-list"):
  108. if ($type[0]=="srlz-list")
  109. {
  110. $aVal = !empty($val) ? unserialize($val, ['allowed_classes' => false]) : '';
  111. }
  112. else
  113. {
  114. $aVal = explode(",", $val);
  115. }
  116. $aVal = is_array($aVal) ? $aVal : [];
  117. sort($aVal);
  118. $aValCount = count($aVal);
  119. for($j=0; $j<$aValCount; $j++):
  120. ?><input type="text" size="<?echo $type[2]?>" value="<?echo htmlspecialcharsbx($aVal[$j])?>" name="<?echo htmlspecialcharsbx($Option[0])."[]"?>"><br><?
  121. endfor;
  122. for($j=0; $j<$type[1]; $j++):
  123. ?><input type="text" size="<?echo $type[2]?>" value="" name="<?echo htmlspecialcharsbx($Option[0])."[]"?>"><br><?
  124. endfor;
  125. elseif($type[0]=="selectbox"):
  126. $arr = $type[1];
  127. $arr_keys = array_keys($arr);
  128. $alertWarning = '';
  129. if(in_array($Option[0], array('auto_method', 'reiterate_method')) && !CheckVersion(SM_VERSION, '15.0.9'))
  130. $alertWarning = 'onchange="if(this.value==\'cron\')alert(\''.GetMessage('opt_sender_cron_support').SM_VERSION.'.\');"';
  131. ?><select name="<?echo htmlspecialcharsbx($Option[0])?>" <?=$alertWarning?>><?
  132. $arr_keys_count = count($arr_keys);
  133. for($j=0; $j<$arr_keys_count; $j++):
  134. ?><option value="<?echo $arr_keys[$j]?>"<?if($val==$arr_keys[$j])echo" selected"?>><?echo htmlspecialcharsbx($arr[$arr_keys[$j]])?></option><?
  135. endfor;
  136. ?></select><?
  137. endif;
  138. ?></td>
  139. </tr>
  140. <?endforeach?>
  141. <?$tabControl->BeginNextTab();?>
  142. <?require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/admin/group_rights.php");?>
  143. <?$tabControl->Buttons();?>
  144. <input <?if ($POST_RIGHT<"W") echo "disabled" ?> type="submit" name="Update" value="<?=GetMessage("MAIN_SAVE")?>" title="<?=GetMessage("MAIN_OPT_SAVE_TITLE")?>" class="adm-btn-save">
  145. <input <?if ($POST_RIGHT<"W") echo "disabled" ?> type="submit" name="Apply" value="<?=GetMessage("MAIN_OPT_APPLY")?>" title="<?=GetMessage("MAIN_OPT_APPLY_TITLE")?>">
  146. <?if($_REQUEST["back_url_settings"] <> ''):?>
  147. <input <?if ($POST_RIGHT<"W") echo "disabled" ?> type="button" name="Cancel" value="<?=GetMessage("MAIN_OPT_CANCEL")?>" title="<?=GetMessage("MAIN_OPT_CANCEL_TITLE")?>" onclick="window.location='<?echo htmlspecialcharsbx(CUtil::addslashes($_REQUEST["back_url_settings"]))?>'">
  148. <input type="hidden" name="back_url_settings" value="<?=htmlspecialcharsbx($_REQUEST["back_url_settings"])?>">
  149. <?endif?>
  150. <input <?if ($POST_RIGHT<"W") echo "disabled" ?> type="submit" name="RestoreDefaults" title="<?echo GetMessage("MAIN_HINT_RESTORE_DEFAULTS")?>" OnClick="return confirm('<?echo AddSlashes(GetMessage("MAIN_HINT_RESTORE_DEFAULTS_WARNING"))?>')" value="<?echo GetMessage("MAIN_RESTORE_DEFAULTS")?>">
  151. <?=bitrix_sessid_post();?>
  152. <?$tabControl->End();?>
  153. </form>
  154. <?endif;?>