Поддержка серверов

CEventMessage::GetList: метод Битрикс

Постоянная ссылка: http://bxapi.ru/src/?id=173891

//    CEventMessage::GetList()
//    /bitrix/modules/main/classes/general/event.php:595

    public static function GetList(&$by, &$order, $arFilter=Array())
    {
        $arSearch = Array();
        $arSqlSearch = Array();
        $strSqlSearch = "";
        $bIsLang = false;
        if (is_array($arFilter))
        {
            foreach ($arFilter as $key => $val)
            {
                if(is_array($val))
                {
                    if(count($val) <= 0)
                        continue;
                }
                else
                {
                    if( (strlen($val) <= 0) || ($val === "NOT_REF") )
                        continue;
                }
                $match_value_set = array_key_exists($key."_EXACT_MATCH", $arFilter);
                $key = strtoupper($key);
                switch($key)
                {
                    case "ID":
                        $match = ($arFilter[$key."_EXACT_MATCH"]=="N" && $match_value_set) ? "Y" : "N";
                        if($match == 'Y') $val = '%'.$val.'%';
                        $arSearch['%='.$key] = $val;
                        break;
                    case "TYPE":
                        $match = ($arFilter[$key."_EXACT_MATCH"]=="Y" && $match_value_set) ? "N" : "Y";
                        if($match == 'Y') $val = '%'.$val.'%';
                        $arSearch[] = array('LOGIC' => 'OR', 'EVENT_NAME' => $val, 'EVENT_MESSAGE_TYPE.NAME' => $val);
                        break;
                    case "EVENT_NAME":
                    case "TYPE_ID":
                        $match = ($arFilter[$key."_EXACT_MATCH"]=="N" && $match_value_set) ? "Y" : "N";
                        if($match == 'Y') $val = '%'.$val.'%';
                        $arSearch['%=EVENT_NAME'] = $val;
                        break;
                    case "TIMESTAMP_1":
                        $arSqlSearch[] = "M.TIMESTAMP_X>=TO_DATE('".FmtDate($val, "D.M.Y")." 00:00:00','dd.mm.yyyy hh24:mi:ss')";
                        $arSearch['>=TIMESTAMP_X'] = $val." 00:00:00";
                        break;
                    case "TIMESTAMP_2":
                        $arSqlSearch[] = "M.TIMESTAMP_X<=TO_DATE('".FmtDate($val, "D.M.Y")." 23:59:59','dd.mm.yyyy hh24:mi:ss')";
                        $arSearch['<=TIMESTAMP_X'] = $val." 23:59:59";
                        break;
                    case "LID":
                    case "LANG":
                    case "SITE_ID":
                        $bIsLang = true;
                        $arSearch["=SITE_ID"] = $val;
                        break;
                    case "LANGUAGE_ID":
                        $arSearch["=LANGUAGE_ID"] = $val;
                        break;
                    case "ACTIVE":
                        $arSearch['='.$key] = $val;
                        break;
                    case "FROM":
                        $match = ($arFilter[$key."_EXACT_MATCH"]=="Y" && $match_value_set) ? "N" : "Y";
                        if($match == 'Y') $val = '%'.$val.'%';
                        $arSearch['%=EMAIL_FROM'] = $val;
                        break;
                    case "TO":
                        $match = ($arFilter[$key."_EXACT_MATCH"]=="Y" && $match_value_set) ? "N" : "Y";
                        if($match == 'Y') $val = '%'.$val.'%';
                        $arSearch['%=EMAIL_TO'] = $val;
                        break;
                    case "BCC":
                        $match = ($arFilter[$key."_EXACT_MATCH"]=="Y" && $match_value_set) ? "N" : "Y";
                        if($match == 'Y') $val = '%'.$val.'%';
                        $arSearch['%='.$key] = $val;
                        break;
                    case "SUBJECT":
                        $match = ($arFilter[$key."_EXACT_MATCH"]=="Y" && $match_value_set) ? "N" : "Y";
                        if($match == 'Y') $val = '%'.$val.'%';
                        $arSearch['%='.$key] = $val;
                        break;
                    case "BODY_TYPE":
                        $arSearch[$key] = ($val=="text") ? 'text' : 'html';
                        break;
                    case "BODY":
                        $match = ($arFilter[$key."_EXACT_MATCH"]=="Y" && $match_value_set) ? "N" : "Y";
                        if($match == 'Y') $val = '%'.$val.'%';
                        $arSearch['%=MESSAGE'] = $val;
                        break;
                }
            }
        }

        if ($by == "id") $strSqlOrder = "ID";
        elseif ($by == "active") $strSqlOrder = "ACTIVE";
        elseif ($by == "event_name") $strSqlOrder = "EVENT_NAME";
        elseif ($by == "from") $strSqlOrder = "EMAIL_FROM";
        elseif ($by == "to") $strSqlOrder = "EMAIL_TO";
        elseif ($by == "bcc") $strSqlOrder = "BCC";
        elseif ($by == "body_type") $strSqlOrder = "BODY_TYPE";
        elseif ($by == "subject") $strSqlOrder = "SUBJECT";
        elseif ($by == "language_id") $strSqlOrder = "LANGUAGE_ID";
        else
        {
            $strSqlOrder = "ID";
            $by = "id";
        }

        if ($order!="asc")
        {
            $strSqlOrderBy = "DESC";
            $order = "desc";
        }
        else
        {
            $strSqlOrderBy = "ASC";
            $order = "asc";
        }

        $arSelect = array(
            '*',
            'EVENT_MESSAGE_TYPE_ID' => 'EVENT_MESSAGE_TYPE.ID',
            'EVENT_MESSAGE_TYPE_NAME' => 'EVENT_MESSAGE_TYPE.NAME',
            'EVENT_MESSAGE_TYPE_EVENT_NAME' => 'EVENT_MESSAGE_TYPE.EVENT_NAME',
        );

        if($bIsLang)
        {
            $arSelect['SITE_ID'] = 'EVENT_MESSAGE_SITE.SITE_ID';
        }
        else
        {
            $arSelect['SITE_ID'] = 'LID';
        }

        $resultDb = Mail\Internal\EventMessageTable::getList(array(
            'select' => $arSelect,
            'filter' => $arSearch,
            'order' => array($strSqlOrder => $strSqlOrderBy),
            'runtime' => array(
                'EVENT_MESSAGE_TYPE' => array(
                    'data_type' => 'Bitrix\Main\Mail\Internal\EventType',
                    'reference' => array('=this.EVENT_NAME' => 'ref.EVENT_NAME', '=ref.LID' => new \Bitrix\Main\DB\SqlExpression('?', LANGUAGE_ID)),
                ),
            )
        ));
        $resultDb->addFetchDataModifier(array('CEventMessage', 'GetListDataModifier'));
        $res = new CDBResult($resultDb);

        $strSqlSearch = GetFilterSqlSearch($arSqlSearch);
        $res->is_filtered = (IsFiltered($strSqlSearch));

        return $res;
    }

Блог разработчика

9 августа 2016 ResizeImageGet и простой водяной знак налету

Сегодня поговорим о том как проще всего воткнуть водяной знак на картинки в Битрикс. Например, на все изображения каталога.

21 июля 2016 Добавление вкладки в CRM коробки Битрикс24

В этом посте я покажу, как легко и просто добавить вкладку в сущность CRM. И не просто добавить, а вывести там свой контент.

21 июля 2016 Как просто обращаться из коробки Битрикс24 на сайт на базе Битрикс

К примеру вам хочется внутренним скриптом дернуть с сайта-магазина информацию, которая там, в свою очередь, закрыта некоторыми правами. Например, админскими. Можно конечно мутить свой REST, или иной формат общения, но проще всего воспользоваться штатным инструментом:

Текст сообщения*
Загрузить изображение