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

CIntranetTasksDocument::GetDocument: метод Битрикс

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

//    CIntranetTasksDocument::GetDocument()
//    /bitrix/modules/intranet/classes/general/tasks_document.php:73

    public function GetDocument($documentId, $nameTemplate = false, $bShowLogin = true, $bShowTooltip = false, $arTooltipParams = false)
    {
        $iblockId = COption::GetOptionInt("intranet", "iblock_tasks", 0);
        if ($iblockId <= 0)
            return false;

        $isInSecurity = CModule::IncludeModule("security");
        $arResult = false;

        $dbResult = CIBlockElement::GetList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "IBLOCK_ID" => $iblockId));
        if ($objResult = $dbResult->GetNextElement())
        {
            $arResult = array();

            $arFields = $objResult->GetFields();
            foreach ($arFields as $fieldKey => $fieldValue)
            {
                if (substr($fieldKey, 0, 1) == "~")
                    continue;

                $arResult[$fieldKey] = $fieldValue;

                if (in_array($fieldKey, array("MODIFIED_BY", "CREATED_BY")))
                {
                    $arResult[$fieldKey."_PRINTABLE"] = CIntranetTasks::PrepareUserForPrint($fieldValue, $nameTemplate, $bShowLogin, $bShowTooltip, $arTooltipParams);
                }
                elseif ($fieldKey == "DETAIL_TEXT")
                {
                    if ($isInSecurity)
                    {
                        $filter = new CSecurityFilter;
                        $arResult["DETAIL_TEXT_PRINTABLE"] = $filter->TestXSS(
                            $arFields["~DETAIL_TEXT_TYPE"] == "text" ? $arFields["DETAIL_TEXT"] : $arFields["~DETAIL_TEXT"],
                            'replace'
                        );

                        $arResult["DETAIL_TEXT"] = ($arFields["~DETAIL_TEXT_TYPE"] == "text" ? nl2br($arFields["~DETAIL_TEXT"]) : $arFields["~DETAIL_TEXT"]);
                    }
                    else
                    {
                        $arResult["DETAIL_TEXT_PRINTABLE"] = nl2br($arFields["DETAIL_TEXT"]);
                        $arResult["DETAIL_TEXT"] = $arFields["DETAIL_TEXT"];
                    }
                }
                else
                {
                    $arResult[$fieldKey."_PRINTABLE"] = $fieldValue;
                }
            }

            $arProperties = $objResult->GetProperties();
            foreach ($arProperties as $propertyKey => $propertyValue)
            {
                if (is_array($propertyValue["VALUE"]))
                {
                    $arResult["PROPERTY_".$propertyKey] = array();
                    foreach ($propertyValue["VALUE"] as $k => $v)
                        $arResult["PROPERTY_".$propertyKey][$propertyValue["PROPERTY_VALUE_ID"][$k]] = $v;
                }
                else
                {
                    $arResult["PROPERTY_".$propertyKey] = $propertyValue["VALUE"];
                }
                $arResult["PROPERTY_".$propertyKey."_PRINTABLE"] = $propertyValue["VALUE"];

                if (strlen($propertyValue["USER_TYPE"]) > 0)
                {
                    if ($propertyValue["USER_TYPE"] == "UserID")
                        $arResult["PROPERTY_".$propertyKey."_PRINTABLE"] = CIntranetTasks::PrepareUserForPrint($propertyValue["VALUE"], $nameTemplate, $bShowLogin, $bShowTooltip, $arTooltipParams);
                    else
                        $arResult["PROPERTY_".$propertyKey."_PRINTABLE"] = $propertyValue["VALUE"];
                }
                elseif ($arField["PROPERTY_TYPE"] == "G")
                {
                    $arResult["PROPERTY_".$propertyKey."_PRINTABLE"] = array();
                    $vx = CIntranetTasks::PrepareSectionForPrint($propertyValue["VALUE"], $propertyValue["LINK_IBLOCK_ID"]);
                    foreach ($vx as $vx1 => $vx2)
                        $arResult["PROPERTY_".$propertyKey."_PRINTABLE"][$vx1] = $vx2["NAME"];
                }
                elseif ($propertyValue["PROPERTY_TYPE"] == "L")
                {
                    $arResult["PROPERTY_".$propertyKey] = array();

                    $arPropertyValue = $propertyValue["VALUE"];
                    $arPropertyKey = $propertyValue["VALUE_ENUM_ID"];
                    if (!is_array($arPropertyValue))
                    {
                        $arPropertyValue = array($arPropertyValue);
                        $arPropertyKey = array($arPropertyKey);
                    }

                    for ($i = 0, $cnt = count($arPropertyValue); $i < $cnt; $i++)
                        $arResult["PROPERTY_".$propertyKey][$arPropertyKey[$i]] = $arPropertyValue[$i];

                    $arResult["PROPERTY_".$propertyKey."_PRINTABLE"] = $arResult["PROPERTY_".$propertyKey];
                }
                elseif ($propertyValue["PROPERTY_TYPE"] == "S" && $propertyValue["ROW_COUNT"] > 1)
                {
                    if (is_array($propertyValue["VALUE"]))
                    {
                        $arResult["PROPERTY_".$propertyKey] = array();
                        $arResult["PROPERTY_".$propertyKey."_PRINTABLE"] = array();

                        if ($isInSecurity)
                        {
                            foreach ($propertyValue["~VALUE"] as $k => $v)
                            {
                                $filter = new CSecurityFilter;
                                $arResult["PROPERTY_".$propertyKey."_PRINTABLE"][$k] = $filter->TestXSS($v, 'replace');
                                $arResult["PROPERTY_".$propertyKey][$k] = $arResult["PROPERTY_".$propertyKey."_PRINTABLE"][$k];
                            }
                        }
                        else
                        {
                            foreach ($propertyValue["VALUE"] as $k => $v)
                            {
                                $arResult["PROPERTY_".$propertyKey."_PRINTABLE"][$k] = nl2br($v);
                                $arResult["PROPERTY_".$propertyKey][$k] = $v;
                            }
                        }
                    }
                    else
                    {
                        if ($isInSecurity)
                        {
                            $filter = new CSecurityFilter;
                            $arResult["PROPERTY_".$propertyKey."_PRINTABLE"] = $filter->TestXSS($propertyValue["~VALUE"], 'replace');
                            $arResult["PROPERTY_".$propertyKey] = $arResult["PROPERTY_".$propertyKey."_PRINTABLE"];
                        }
                        else
                        {
                            $arResult["PROPERTY_".$propertyKey."_PRINTABLE"] = nl2br($propertyValue["VALUE"]);
                            $arResult["PROPERTY_".$propertyKey] = $propertyValue["VALUE"];
                        }
                    }
                }
            }

            $arResult["ROOT_SECTION_ID"] = 0;
            $arResult["IBLOCK_SECTION_ID_PRINTABLE"] = array();
            $v = CIntranetTasks::PrepareSectionForPrint($arResult["IBLOCK_SECTION_ID"]);
            foreach ($v as $k1 => $v1)
            {
                if ($arResult["ROOT_SECTION_ID"] == 0)
                {
                    $arResult["ROOT_SECTION_ID"] = $k1;
                    $arResult["TaskType"] = ($v1["XML_ID"] == "users_tasks" ? "user" : "group");
                    $arResult["OwnerId"] = ($arResult["TaskType"] == "user" ? $arResult["PROPERTY_TaskAssignedTo"] : $v1["XML_ID"]);
                }
                else
                {
                    $arResult["IBLOCK_SECTION_ID_PRINTABLE"][$k1] = $v1["NAME"];
                }
            }
        }

        return $arResult;
    }

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

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

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

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

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

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

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

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