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

CCrmLiveFeedComponent::__construct: метод Битрикс

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

//    CCrmLiveFeedComponent::__construct()
//    /bitrix/modules/crm/classes/general/livefeed.php:4574

    public function __construct($params)
    {
        if(!is_array($params))
        {
            $params = array();
        }

        $this->fields = isset($params["FIELDS"]) && !empty($params["FIELDS"]) ? $params["FIELDS"] : false;
        $this->eventParams = isset($params["EVENT_PARAMS"]) ? $params["EVENT_PARAMS"] : array();
        $this->params = isset($params["PARAMS"]) ? $params["PARAMS"] : array();

        $this->arSipServiceUrl = array(
            CCrmOwnerType::Lead => SITE_DIR.'bitrix/components/bitrix/crm.lead.show/ajax.php?'.bitrix_sessid_get(),
            CCrmOwnerType::Company => SITE_DIR.'bitrix/components/bitrix/crm.company.show/ajax.php?'.bitrix_sessid_get(),
            CCrmOwnerType::Contact => SITE_DIR.'bitrix/components/bitrix/crm.contact.show/ajax.php?'.bitrix_sessid_get()
        );

        if (!$this->fields)
        {
            throw new Exception("Empty fields");
        }

        $this->entityTypeID = CCrmLiveFeedEntity::ResolveEntityTypeID($this->fields["ENTITY_TYPE"]);

        if ($this->entityTypeID == CCrmOwnerType::Activity)
        {
            $this->activity = isset($params["ACTIVITY"]) ? $params["ACTIVITY"] : array();
            $this->eventMeta = array(
                CCrmActivityType::Meeting => array(
                    "SUBJECT" => array(
                        "CODE" => "COMBI_ACTIVITY_SUBJECT/ACTIVITY_ONCLICK",
                        "FORMAT" => "COMBI_TITLE"
                    ),
                    "LOCATION" => array(
                        "CODE" => "ACTIVITY_LOCATION",
                        "FORMAT" => "TEXT"
                    ),
                    "DATE" => array(
                        "CODE" => "ACTIVITY_START_END_TIME",
                        "FORMAT" => "DATETIME"
                    ),
                    "CLIENT_ID" => array(
                        "CODE" => "ACTIVITY_COMMUNICATIONS",
                        "FORMAT" => "COMMUNICATIONS"
                    ),
                    "RESPONSIBLE" => array(
                        "CODE" => "ACTIVITY_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID"
                    )
                ),
                CCrmActivityType::Call => array(
                    "SUBJECT" => array(
                        "CODE" => "COMBI_ACTIVITY_SUBJECT/ACTIVITY_ONCLICK",
                        "FORMAT" => "COMBI_TITLE"
                    ),
                    "DATE" => array(
                        "CODE" => "ACTIVITY_START_END_TIME",
                        "FORMAT" => "DATETIME"
                    ),
                    "CLIENT_ID" => array(
                        "CODE" => "ACTIVITY_COMMUNICATIONS",
                        "FORMAT" => "COMMUNICATIONS"
                    ),
                    "RESPONSIBLE" => array(
                        "CODE" => "ACTIVITY_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID"
                    )
                ),
                CCrmActivityType::Email => array(
                    "SUBJECT" => array(
                        "CODE" => "COMBI_ACTIVITY_SUBJECT/ACTIVITY_ONCLICK",
                        "FORMAT" => "COMBI_TITLE"
                    ),
                    "DATE" => array(
                        "CODE" => "ACTIVITY_START_END_TIME",
                        "FORMAT" => "DATETIME"
                    ),
                    "CLIENT_ID" => array(
                        "CODE" => "ACTIVITY_COMMUNICATIONS",
                        "FORMAT" => "COMMUNICATIONS"
                    ),
                    "RESPONSIBLE" => array(
                        "CODE" => "ACTIVITY_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID"
                    )
                )
            );
        }
        elseif ($this->entityTypeID == CCrmOwnerType::Invoice)
        {
            $this->invoice = isset($params["INVOICE"]) ? $params["INVOICE"] : array();
            $this->eventMeta = array(
                "crm_invoice_add" => array(
                    "INVOICE_ADD_TITLE" => array(
                        "CODE" => "COMBI_INVOICE_ACCOUNT_NUMBER/INVOICE_ORDER_TOPIC/INVOICE_URL",
                        "FORMAT" => "COMBI_TITLE_ID"
                    ),
                    "PRICE" => array(
                        "CODE" => array(
                            "VALUE" => "INVOICE_PRICE",
                            "CURRENCY" => "INVOICE_CURRENCY"
                        ),
                        "FORMAT" => "SUM"
                    ),
                    "STATUS" => array(
                        "CODE" => "INVOICE_STATUS_ID",
                        "FORMAT" => "INVOICE_PROGRESS",
                    ),
                    "CLIENT_ID" => array(
                        "CODE" => "COMBI_INVOICE_UF_CONTACT_ID/INVOICE_UF_COMPANY_ID",
                        "FORMAT" => "COMBI_CLIENT",
                    ),
                    "DEAL" => array(
                        "CODE" => "INVOICE_UF_DEAL_ID",
                        "FORMAT" => "DEAL_ID",
                    ),                    
                    "RESPONSIBLE" => array(
                        "CODE" => "INVOICE_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID"
                    )
                )
            );
        }
        else
        {
            $this->eventMeta = array(
                "crm_lead_add" => array(
                    "ADD_TITLE" => array(
                        "CODE" => "EVENT_PARAMS_TITLE",
                        "FORMAT" => "TEXT_ADD"
                    ),
                    "STATUS" => array(
                        "CODE" => "EVENT_PARAMS_STATUS_ID",
                        "FORMAT" => "LEAD_PROGRESS",
                    ),
                    "CLIENT_NAME" => array(
                        "CODE" => "COMBI_EVENT_PARAMS_NAME/EVENT_PARAMS_LAST_NAME/EVENT_PARAMS_SECOND_NAME/EVENT_PARAMS_COMPANY_TITLE/EVENT_PARAMS_HONORIFIC",
                        "FORMAT" => "COMBI_CLIENT_NAME",
                    ),
                    "OPPORTUNITY" => array(
                        "CODE" => array(
                            "VALUE" => "EVENT_PARAMS_OPPORTUNITY",
                            "CURRENCY" => "EVENT_PARAMS_CURRENCY_ID"
                        ),
                        "FORMAT" => "SUM"
                    ),
                    "RESPONSIBLE" => array(
                        "CODE" => "EVENT_PARAMS_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID"
                    )
                ),
                "crm_lead_progress" => array(
                    "FINAL_STATUS_ID" => array(
                        "CODE" => "EVENT_PARAMS_FINAL_STATUS_ID",
                        "FORMAT" => "LEAD_PROGRESS",
                    ),
                    "START_STATUS_ID" => array(
                        "CODE" => "EVENT_PARAMS_START_STATUS_ID",
                        "FORMAT" => "LEAD_PROGRESS"
                    )
                ),
                "crm_lead_responsible" => array(
                    "FINAL_RESPONSIBLE_ID" => array(
                        "CODE" => "EVENT_PARAMS_FINAL_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID",
                    ),
                    "START_RESPONSIBLE_ID" => array(
                        "CODE" => "EVENT_PARAMS_START_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID"
                    )
                ),
                "crm_lead_denomination" => array(
                    "FINAL_TITLE" => array(
                        "CODE" => "EVENT_PARAMS_FINAL_TITLE",
                        "FORMAT" => "TEXT",
                    ),
                    "START_TITLE" => array(
                        "CODE" => "EVENT_PARAMS_START_TITLE",
                        "FORMAT" => "TEXT"
                    )
                ),
                "crm_lead_message" => array(
                    "MESSAGE_TITLE" => array(
                        "CODE" => "TITLE",
                        "FORMAT" => "TEXT_FORMATTED_BOLD",
                    ),
                    "MESSAGE" => array(
                        "CODE" => "MESSAGE",
                        "FORMAT" => "TEXT_FORMATTED",
                    ),
                ),
                "crm_contact_add" => array(
                    "ADD_TITLE" => array(
                        "CODE" => "COMBI_EVENT_PARAMS_NAME/EVENT_PARAMS_LAST_NAME/EVENT_PARAMS_SECOND_NAME/EVENT_PARAMS_PHOTO_ID/EVENT_PARAMS_COMPANY_ID/EVENT_PARAMS_HONORIFIC/ENTITY_ID",
                        "FORMAT" => "COMBI_CLIENT",
                    ),
                    "PHONES" => array(
                        "CODE" => "EVENT_PARAMS_PHONES",
                        "FORMAT" => "PHONE",
                    ),
                    "EMAILS" => array(
                        "CODE" => "EVENT_PARAMS_EMAILS",
                        "FORMAT" => "EMAIL",
                    ),
                    "RESPONSIBLE" => array(
                        "CODE" => "EVENT_PARAMS_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID"
                    )
                ),
                "crm_contact_owner" => array(
                    "FINAL_OWNER_COMPANY_ID" => array(
                        "CODE" => "EVENT_PARAMS_FINAL_OWNER_COMPANY_ID",
                        "FORMAT" => "COMPANY_ID"
                    ),
                    "START_OWNER_COMPANY_ID" => array(
                        "CODE" => "EVENT_PARAMS_START_OWNER_COMPANY_ID",
                        "FORMAT" => "COMPANY_ID",
                    ),
                ),
                "crm_contact_responsible" => array(
                    "FINAL_RESPONSIBLE_ID" => array(
                        "CODE" => "EVENT_PARAMS_FINAL_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID",
                    ),
                    "START_RESPONSIBLE_ID" => array(
                        "CODE" => "EVENT_PARAMS_START_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID"
                    )
                ),
                "crm_contact_message" => array(
                    "MESSAGE_TITLE" => array(
                        "CODE" => "TITLE",
                        "FORMAT" => "TEXT_FORMATTED_BOLD",
                    ),
                    "MESSAGE" => array(
                        "CODE" => "MESSAGE",
                        "FORMAT" => "TEXT_FORMATTED",
                    ),
                ),
                "crm_company_add" => array(
                    "ADD_TITLE" => array(
                        "CODE" => "COMBI_EVENT_PARAMS_TITLE/EVENT_PARAMS_LOGO_ID/ENTITY_ID",
                        "FORMAT" => "COMBI_COMPANY",
                    ),
                    "COMPANY_TYPE" => array(
                        "CODE" => "EVENT_PARAMS_TYPE",
                        "FORMAT" => "COMPANY_TYPE",
                    ),
                    "REVENUE" => array(
                        "CODE" => array(
                            "VALUE" => "EVENT_PARAMS_REVENUE",
                            "CURRENCY" => "EVENT_PARAMS_CURRENCY_ID"
                        ),
                        "FORMAT" => "SUM"
                    ),
                    "PHONES" => array(
                        "CODE" => "EVENT_PARAMS_PHONES",
                        "FORMAT" => "PHONE",
                    ),
                    "EMAILS" => array(
                        "CODE" => "EVENT_PARAMS_EMAILS",
                        "FORMAT" => "EMAIL",
                    ),
                    "RESPONSIBLE" => array(
                        "CODE" => "EVENT_PARAMS_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID"
                    )
                ),
                "crm_company_responsible" => array(
                    "FINAL_RESPONSIBLE_ID" => array(
                        "CODE" => "EVENT_PARAMS_FINAL_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID",
                    ),
                    "START_RESPONSIBLE_ID" => array(
                        "CODE" => "EVENT_PARAMS_START_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID"
                    )
                ),
                "crm_company_denomination" => array(
                    "FINAL_TITLE" => array(
                        "CODE" => "EVENT_PARAMS_FINAL_TITLE",
                        "FORMAT" => "TEXT",
                    ),
                    "START_TITLE" => array(
                        "CODE" => "EVENT_PARAMS_START_TITLE",
                        "FORMAT" => "TEXT"
                    )
                ),
                "crm_company_message" => array(
                    "MESSAGE_TITLE" => array(
                        "CODE" => "TITLE",
                        "FORMAT" => "TEXT_FORMATTED_BOLD",
                    ),
                    "MESSAGE" => array(
                        "CODE" => "MESSAGE",
                        "FORMAT" => "TEXT_FORMATTED",
                    ),
                ),
                "crm_deal_add" => array(
                    "ADD_TITLE" => array(
                        "CODE" => "EVENT_PARAMS_TITLE",
                        "FORMAT" => "TEXT_ADD"
                    ),
                    "STATUS" => array(
                        "CODE" => "COMBI_EVENT_PARAMS_STAGE_ID/EVENT_PARAMS_CATEGORY_ID",
                        "FORMAT" => "DEAL_PROGRESS",
                    ),
                    "OPPORTUNITY" => array(
                        "CODE" => array(
                            "VALUE" => "EVENT_PARAMS_OPPORTUNITY",
                            "CURRENCY" => "EVENT_PARAMS_CURRENCY_ID"
                        ),
                        "FORMAT" => "SUM"
                    ),
                    "CLIENT_ID" => array(
                        "CODE" => "COMBI_EVENT_PARAMS_CONTACT_ID/EVENT_PARAMS_COMPANY_ID",
                        "FORMAT" => "COMBI_CLIENT",
                    ),
                    "RESPONSIBLE" => array(
                        "CODE" => "EVENT_PARAMS_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID"
                    )
                ),
                "crm_deal_progress" => array(
                    "FINAL_STATUS_ID" => array(
                        "CODE" => "COMBI_EVENT_PARAMS_FINAL_STATUS_ID/EVENT_PARAMS_CATEGORY_ID",
                        "FORMAT" => "DEAL_PROGRESS",
                    ),
                    "START_STATUS_ID" => array(
                        "CODE" => "COMBI_EVENT_PARAMS_START_STATUS_ID/EVENT_PARAMS_CATEGORY_ID",
                        "FORMAT" => "DEAL_PROGRESS"
                    )
                ),
                "crm_deal_responsible" => array(
                    "FINAL_RESPONSIBLE_ID" => array(
                        "CODE" => "EVENT_PARAMS_FINAL_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID",
                    ),
                    "START_RESPONSIBLE_ID" => array(
                        "CODE" => "EVENT_PARAMS_START_RESPONSIBLE_ID",
                        "FORMAT" => "PERSON_ID"
                    )
                ),
                "crm_deal_denomination" => array(
                    "FINAL_TITLE" => array(
                        "CODE" => "EVENT_PARAMS_FINAL_TITLE",
                        "FORMAT" => "TEXT",
                    ),
                    "START_TITLE" => array(
                        "CODE" => "EVENT_PARAMS_START_TITLE",
                        "FORMAT" => "TEXT"
                    )
                ),
                "crm_deal_message" => array(
                    "MESSAGE_TITLE" => array(
                        "CODE" => "TITLE",
                        "FORMAT" => "TEXT_FORMATTED_BOLD",
                    ),
                    "MESSAGE" => array(
                        "CODE" => "MESSAGE",
                        "FORMAT" => "TEXT_FORMATTED",
                    ),
                ),
                "crm_deal_client" => array(
                    "FINAL_CLIENT_ID" => array(
                        "CODE" => "COMBI_EVENT_PARAMS_FINAL_CLIENT_CONTACT_ID/EVENT_PARAMS_FINAL_CLIENT_COMPANY_ID",
                        "FORMAT" => "COMBI_CLIENT",
                    ),
                    "START_CLIENT_ID" => array(
                        "CODE" => "COMBI_EVENT_PARAMS_START_CLIENT_CONTACT_ID/EVENT_PARAMS_START_CLIENT_COMPANY_ID",
                        "FORMAT" => "COMBI_CLIENT",
                    ),
                )
            );
        }

        if (!array_key_exists($this->fields["EVENT_ID"], $this->eventMeta))
        {
            return false;
        }

        return true;
    }

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

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

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

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

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

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

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

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