</td> </tr> <?php $arTemplates = CPostingTemplate::GetList(); if (count($arTemplates) > 0) { ?> <tr class="adm-detail-required-field"> <td class="adm-detail-valign-top"><?php echo GetMessage("rub_templates"); ?> </td> <td><table> <?php $i = 0; foreach ($arTemplates as $strTemplate) { $arTemplate = CPostingTemplate::GetByID($strTemplate); ?> <tr> <td class="adm-detail-valign-top"><input type="radio" id="TEMPLATE<?php echo $i; ?> " name="TEMPLATE" value="<?php echo $arTemplate["PATH"]; ?> "<?php if ($str_TEMPLATE == $arTemplate["PATH"]) { echo "checked"; } ?> ></td> <td>
function AddPosting($arRubric) { global $DB, $USER, $MESS; if (!is_object($USER)) { $USER = new CUser(); } //Include language file for template.php $rsSite = CSite::GetByID($arRubric["SITE_ID"]); $arSite = $rsSite->Fetch(); $rsLang = CLanguage::GetByID($arSite["LANGUAGE_ID"]); $arLang = $rsLang->Fetch(); $arFields = false; if (CPostingTemplate::IsExists($arRubric["TEMPLATE"])) { $strFileName = $_SERVER["DOCUMENT_ROOT"] . "/" . $arRubric["TEMPLATE"] . "/lang/" . $arSite["LANGUAGE_ID"] . "/template.php"; if (file_exists($strFileName)) { include $strFileName; } //Execute template $strFileName = $_SERVER["DOCUMENT_ROOT"] . "/" . $arRubric["TEMPLATE"] . "/template.php"; if (file_exists($strFileName)) { ob_start(); $arFields = @(include $strFileName); $strBody = ob_get_contents(); ob_end_clean(); } } $ID = false; //If there was an array returned then add posting if (is_array($arFields)) { $arFields["BODY"] = $strBody; $cPosting = new CPosting(); $arFields["AUTO_SEND_TIME"] = $arRubric["END_TIME"]; $arFields["RUB_ID"] = array($arRubric["ID"]); $arFields["MSG_CHARSET"] = $arLang["CHARSET"]; $ID = $cPosting->Add($arFields); if ($ID) { if (array_key_exists("FILES", $arFields)) { foreach ($arFields["FILES"] as $arFile) { $cPosting->SaveFile($ID, $arFile); } } if (!array_key_exists("DO_NOT_SEND", $arFields) || $arFields["DO_NOT_SEND"] != "Y") { $cPosting->ChangeStatus($ID, "P"); if (COption::GetOptionString("subscribe", "subscribe_auto_method") !== "cron") { CAgent::AddAgent("CPosting::AutoSend(" . $ID . ",true,\"" . $arRubric["LID"] . "\");", "subscribe", "N", 0, $arRubric["END_TIME"], "Y", $arRubric["END_TIME"]); } } } } //Update last execution time mark $strSql = "UPDATE b_list_rubric SET LAST_EXECUTED=" . $DB->CharToDateFunction($arRubric["END_TIME"]) . " WHERE ID=" . intval($arRubric["ID"]); $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); return $ID; }
function CheckFields($arFields) { global $DB; $this->LAST_ERROR = ""; $aMsg = array(); if (strlen($arFields["NAME"]) == 0) { $aMsg[] = array("id" => "NAME", "text" => GetMessage("class_rub_err_name")); } if (strlen($arFields["LID"]) > 0) { $r = CLang::GetByID($arFields["LID"]); if (!$r->Fetch()) { $aMsg[] = array("id" => "LID", "text" => GetMessage("class_rub_err_lang")); } } else { $aMsg[] = array("id" => "LID", "text" => GetMessage("class_rub_err_lang2")); } if (strlen($arFields["DAYS_OF_MONTH"]) > 0) { $arDoM = explode(",", $arFields["DAYS_OF_MONTH"]); $arFound = array(); foreach ($arDoM as $strDoM) { if (preg_match("/^(\\d{1,2})\$/", trim($strDoM), $arFound)) { if (intval($arFound[1]) < 1 || intval($arFound[1]) > 31) { $aMsg[] = array("id" => "DAYS_OF_MONTH", "text" => GetMessage("class_rub_err_dom")); break; } } elseif (preg_match("/^(\\d{1,2})-(\\d{1,2})\$/", trim($strDoM), $arFound)) { if (intval($arFound[1]) < 1 || intval($arFound[1]) > 31 || intval($arFound[2]) < 1 || intval($arFound[2]) > 31 || intval($arFound[1]) >= intval($arFound[2])) { $aMsg[] = array("id" => "DAYS_OF_MONTH", "text" => GetMessage("class_rub_err_dom")); break; } } else { $aMsg[] = array("id" => "DAYS_OF_MONTH", "text" => GetMessage("class_rub_err_dom2")); break; } } } if (strlen($arFields["DAYS_OF_WEEK"]) > 0) { $arDoW = explode(",", $arFields["DAYS_OF_WEEK"]); $arFound = array(); foreach ($arDoW as $strDoW) { if (preg_match("/^(\\d)\$/", trim($strDoW), $arFound)) { if (intval($arFound[1]) < 1 || intval($arFound[1]) > 7) { $aMsg[] = array("id" => "DAYS_OF_WEEK", "text" => GetMessage("class_rub_err_dow")); break; } } else { $aMsg[] = array("id" => "DAYS_OF_WEEK", "text" => GetMessage("class_rub_err_dow2")); break; } } } if (strlen($arFields["TIMES_OF_DAY"]) > 0) { $arToD = explode(",", $arFields["TIMES_OF_DAY"]); $arFound = array(); foreach ($arToD as $strToD) { if (preg_match("/^(\\d{1,2}):(\\d{1,2})\$/", trim($strToD), $arFound)) { if (intval($arFound[1]) > 23 || intval($arFound[2]) > 59) { $aMsg[] = array("id" => "TIMES_OF_DAY", "text" => GetMessage("class_rub_err_tod")); break; } } else { $aMsg[] = array("id" => "TIMES_OF_DAY", "text" => GetMessage("class_rub_err_tod2")); break; } } } if (strlen($arFields["TEMPLATE"]) > 0 && !CPostingTemplate::IsExists($arFields["TEMPLATE"])) { $aMsg[] = array("id" => "TEMPLATE", "text" => GetMessage("class_rub_err_wrong_templ")); } if ($arFields["AUTO"] == "Y") { if (strlen($arFields["FROM_FIELD"]) < 3 || !check_email($arFields["FROM_FIELD"])) { $aMsg[] = array("id" => "FROM_FIELD", "text" => GetMessage("class_rub_err_email")); } if (strlen($arFields["DAYS_OF_MONTH"]) + strlen($arFields["DAYS_OF_WEEK"]) <= 0) { $aMsg[] = array("id" => "DAYS_OF_MONTH", "text" => GetMessage("class_rub_err_days_missing")); } if (strlen($arFields["TIMES_OF_DAY"]) <= 0) { $aMsg[] = array("id" => "TIMES_OF_DAY", "text" => GetMessage("class_rub_err_times_missing")); } if (strlen($arFields["TEMPLATE"]) <= 0) { $aMsg[] = array("id" => "TEMPLATE", "text" => GetMessage("class_rub_err_templ_missing")); } if (is_set($arFields, "FROM_FIELD") && strlen($arFields["FROM_FIELD"]) <= 0) { $aMsg[] = array("id" => "FROM_FIELD", "text" => GetMessage("class_rub_err_from")); } if (strlen($arFields["LAST_EXECUTED"]) <= 0) { $aMsg[] = array("id" => "LAST_EXECUTED", "text" => GetMessage("class_rub_err_le_missing")); } elseif (is_set($arFields, "LAST_EXECUTED") && $arFields["LAST_EXECUTED"] !== false && $DB->IsDate($arFields["LAST_EXECUTED"], false, false, "FULL") !== true) { $aMsg[] = array("id" => "LAST_EXECUTED", "text" => GetMessage("class_rub_err_le_wrong")); } } if (!empty($aMsg)) { $e = new CAdminException($aMsg); $GLOBALS["APPLICATION"]->ThrowException($e); $this->LAST_ERROR = $e->GetString(); return false; } return true; }
?> <tr> <td><?php echo GetMessage("rub_name"); ?> </td> <td><input type="hidden" name="ID" value="<?php echo $ID; ?> "><?php echo htmlspecialcharsbx($arRubric["NAME"]); ?> </td> </tr> <?php $arTemplate = CPostingTemplate::GetByID($arRubric["TEMPLATE"]); if ($arTemplate) { ?> <tr> <td><?php echo GetMessage("rub_tmpl_name"); ?> </td> <td><?php echo htmlspecialcharsbx($arTemplate["NAME"]); ?> </td> </tr> <tr> <td><?php echo GetMessage("rub_tmpl_desc");