Exemplo n.º 1
0
	function CheckFields($arFields, $ID=false)
	{
		$err_cnt = CMailError::ErrCount();
		$arMsg = Array();

		if(is_set($arFields, "NAME") && strlen($arFields["NAME"])<1)
		{
			CMailError::SetError("B_MAIL_ERR_NAME", GetMessage("MAIL_CL_ERR_NAME")." \"".GetMessage("MAIL_CL_NAME")."\"");
			$arMsg[] = array("id"=>"NAME", "text"=> GetMessage("MAIL_CL_ERR_NAME")." \"".GetMessage("MAIL_CL_NAME")."\"");
		}

		if(is_set($arFields, "PHP_CONDITION") && strlen(trim($arFields["PHP_CONDITION"]))>0)
		{
			if (!CMailFilter::CheckPHP($arFields["PHP_CONDITION"], GetMessage("MAIL_CL_PHP_COND")))
				$arMsg[] = array("id"=>"PHP_CONDITION", "text"=> GetMessage("MAIL_CL_ERR_IN_PHP").GetMessage("MAIL_CL_PHP_COND"));
		}

		if(is_set($arFields, "ACTION_PHP") && strlen(trim($arFields["ACTION_PHP"]))>0)
		{
			if (!CMailFilter::CheckPHP($arFields["ACTION_PHP"], GetMessage("MAIL_CL_PHP_ACT")))
				$arMsg[] = array("id"=>"ACTION_PHP", "text"=> GetMessage("MAIL_CL_ERR_IN_PHP").GetMessage("MAIL_CL_PHP_ACT"));
		}

		if(is_set($arFields, "MAILBOX_ID"))
		{
			$r = CMailBox::GetByID($arFields["MAILBOX_ID"]);
			if(!$r->Fetch())
			{
				CMailError::SetError("B_MAIL_ERR_BAD_MAILBOX", GetMessage("MAIL_CL_ERR_WRONG_MAILBOX"));
				$arMsg[] = array("id"=>"MAILBOX_ID", "text"=> GetMessage("MAIL_CL_ERR_WRONG_MAILBOX"));
			}
		}
		elseif($ID===false)
		{
			CMailError::SetError("B_MAIL_ERR_BAD_MAILBOX_NA", GetMessage("MAIL_CL_ERR_MAILBOX_NA"));
			$arMsg[] = array("id"=>"MAILBOX_ID", "text"=> GetMessage("MAIL_CL_ERR_MAILBOX_NA"));
		}

		if(!empty($arMsg))
		{
			$e = new CAdminException($arMsg);
			$GLOBALS["APPLICATION"]->ThrowException($e);
			return false;
		}
		return true;

		//return ($err_cnt == CMailError::ErrCount());
	}
	</tr>

</table></form>
<?php 
if (check_bitrix_sessid()) {
    $arFilter = array('ACTIVE' => 'Y', 'USER_ID' => 0);
    if ($mailbox_id > 0) {
        $arFilter["ID"] = $mailbox_id;
    }
    $dbr = CMailBox::GetList(array(), $arFilter);
    ClearVars("f_");
    while ($res = $dbr->ExtractFields("f_")) {
        CMailError::ResetErrors();
        $mb = new CMailbox();
        echo '<p><b>' . GetMessage("MAIL_CHECK_TEXT") . '&quot;' . $f_NAME . '&quot;:</b></p>';
        if ($mb->Connect($res["ID"])) {
            CAdminMessage::ShowNote(GetMessage("MAIL_CHECK_CNT") . " " . intval($mb->new_mess_count) . " " . GetMessage("MAIL_CHECK_CNT_NEW"));
            $aContext = array();
            if ($mb->new_mess_count > 0) {
                $aContext[] = array("ICON" => "btn_list", "TEXT" => GetMessage("MAIL_CHECK_VIEW"), "LINK" => "mail_message_admin.php?find_mailbox_id=" . $f_ID . "&lang=" . LANG . "&find_new=Y&set_filter=Y", "TITLE" => GetMessage("MAIL_CHECK_VIEW"));
            }
            $aContext[] = array("TEXT" => GetMessage("MAIL_CHECK_LOG"), "LINK" => "mail_log.php?set_filter=Y&find_mailbox_id=" . $f_ID . "&lang=" . LANG, "TITLE" => GetMessage("MAIL_CHECK_LOG"));
        } else {
            CAdminMessage::ShowMessage(GetMessage("MAIL_CHECK_ERR") . " " . CMailError::GetErrorsText());
            $aContext = array(array("TEXT" => GetMessage("MAIL_CHECK_MBOX_PARAMS"), "LINK" => "mail_mailbox_edit.php?ID=" . $f_ID . "&lang=" . LANG, "TITLE" => GetMessage("MAIL_CHECK_MBOX_PARAMS")), array("TEXT" => GetMessage("MAIL_CHECK_LOG"), "LINK" => "mail_log.php?set_filter=Y&find_mailbox_id=" . $f_ID . "&lang=" . LANG, "TITLE" => GetMessage("MAIL_CHECK_LOG")));
        }
        $context = new CAdminContextMenu($aContext);
        $context->Show();
    }
}
require $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog_admin.php";