Esempio n. 1
0
 protected function checkUpdatePermissions()
 {
     if (!$this->attachedModel->canUpdate($this->getUser()->getId())) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_UF_DOCUMENT_CONTROLLER_ERROR_BAD_RIGHTS'), self::ERROR_BAD_RIGHTS)));
         $this->sendJsonErrorResponse();
     }
 }
Esempio n. 2
0
 /**
  * @param AttachedObject $attachedObject
  * @return static
  * @throws \Bitrix\Main\SystemException
  */
 public static function buildByAttachedObject(AttachedObject $attachedObject)
 {
     /** @var Entry $cloudImport */
     $cloudImport = $attachedObject->getObject()->getLastCloudImportEntry();
     $documentHandler = Driver::getInstance()->getDocumentHandlersManager()->getHandlerByCode($cloudImport->getService());
     if (!$documentHandler) {
         return null;
     }
     return new static($documentHandler);
 }
 /**
  * For UF and work with local editors we have special scenario:
  * If user don't have permission for update file,
  * we have to attach new file to entity by posting comment with
  * alternative version.
  */
 protected function processActionCommit()
 {
     $userId = $this->getUser()->getId();
     if ($this->attachedModel->canUpdate($userId)) {
         parent::processActionCommit();
         return;
     }
     $this->checkRequiredFilesParams(array('file'));
     if ($this->errorCollection->hasErrors()) {
         $this->sendJsonErrorResponse();
     }
     $userStorage = Driver::getInstance()->getStorageByUserId($userId);
     if (!$userStorage) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_LOCAL_DOC_CONTROLLER_ERROR_COULD_NOT_FIND_STORAGE'), self::ERROR_COULD_NOT_FIND_STORAGE)));
         $this->sendJsonErrorResponse();
     }
     $folder = $userStorage->getFolderForCreatedFiles();
     if (!$folder) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_LOCAL_DOC_CONTROLLER_ERROR_COULD_NOT_FIND_FOLDER_FOR_CREATED_FILES'), self::ERROR_COULD_NOT_FIND_FOLDER_FOR_CREATED_FILES)));
         $this->sendJsonErrorResponse();
     }
     if (!$folder->canAdd($folder->getStorage()->getCurrentUserSecurityContext())) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_LOCAL_DOC_CONTROLLER_ERROR_BAD_RIGHTS'), self::ERROR_BAD_RIGHTS)));
         $this->sendJsonErrorResponse();
     }
     //todo fix Cherezov. Ban encoding 1251
     $fileArray = $this->request->getFile('file');
     $fileArray['name'] = $this->file->getName();
     $newFile = $folder->uploadFile($fileArray, array('NAME' => $this->file->getName(), 'CREATED_BY' => $userId), array(), true);
     if (!$newFile) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_LOCAL_DOC_CONTROLLER_ERROR_COULD_NOT_CREATE_FILE'), self::ERROR_COULD_NOT_CREATE_FILE)));
         $this->errorCollection->add($folder->getErrors());
         $this->sendJsonErrorResponse();
     }
     $valueFileUf = FileUserType::NEW_FILE_PREFIX . $newFile->getId();
     /** @var User $createUser */
     $createUser = User::loadById($userId);
     if (!$createUser) {
         $this->sendJsonErrorResponse();
     }
     $text = Loc::getMessage('DISK_UF_LOCAL_DOC_CONTROLLER_UPLOAD_NEW_VERSION_IN_COMMENT_M');
     if ($createUser->getPersonalGender() == 'F') {
         $text = Loc::getMessage('DISK_UF_LOCAL_DOC_CONTROLLER_UPLOAD_NEW_VERSION_IN_COMMENT_F');
     }
     if ($this->attachedModel->getAllowAutoComment()) {
         $this->attachedModel->getConnector()->addComment($userId, array('text' => $text, 'fileId' => $valueFileUf));
     }
     $this->sendJsonSuccessResponse();
 }
Esempio n. 4
0
 private function loadData()
 {
     if (empty($this->arParams['PARAMS']['arUserField'])) {
         return array();
     }
     $userId = $this->getUser()->getId();
     $values = $this->arParams['PARAMS']['arUserField']['VALUE'];
     if (!is_array($this->arParams['PARAMS']['arUserField']['VALUE'])) {
         $values = array($values);
     }
     $urlManager = \Bitrix\Disk\Driver::getInstance()->getUrlManager();
     $versions = array();
     foreach ($values as $value) {
         $attachedObjectId = (int) $value;
         if ($attachedObjectId <= 0) {
             continue;
         }
         /** @var \Bitrix\Disk\AttachedObject $attachedModel */
         $attachedModel = \Bitrix\Disk\AttachedObject::loadById($attachedObjectId, array('VERSION.OBJECT'));
         if (!$attachedModel) {
             continue;
         }
         $version = $attachedModel->getVersion();
         if (!$version) {
             continue;
         }
         $extension = $version->getExtension();
         $versions[] = array('ID' => $attachedModel->getId(), 'NAME' => $version->getName(), 'CONVERT_EXTENSION' => DocumentHandler::isNeedConvertExtension($extension), 'EDITABLE' => DocumentHandler::isEditable($extension), 'CAN_UPDATE' => $attachedModel->canUpdate($userId), 'FROM_EXTERNAL_SYSTEM' => $version->getObject()->getContentProvider() && $version->getObject()->getCreatedBy() == $userId, 'EXTENSION' => $extension, 'SIZE' => \CFile::formatSize($version->getSize()), 'HISTORY_URL' => $urlManager->getUrlUfController('history', array('attachedId' => $attachedModel->getId())), 'DOWNLOAD_URL' => $urlManager->getUrlUfController('download', array('attachedId' => $attachedModel->getId())), 'COPY_TO_ME_URL' => $urlManager->getUrlUfController('copyTome', array('attachedId' => $attachedModel->getId())), 'VIEW_URL' => $urlManager->getUrlToShowAttachedFileByService($attachedModel->getId(), 'gvdrive'), 'EDIT_URL' => $urlManager->getUrlToStartEditUfFileByService($attachedModel->getId(), 'gdrive'), 'GLOBAL_CONTENT_VERSION' => $version->getGlobalContentVersion(), 'ATTRIBUTES_FOR_VIEWER' => Ui\Viewer::getAttributesByAttachedObject($attachedModel, array('version' => $version->getGlobalContentVersion(), 'canUpdate' => $attachedModel->canUpdate($userId), 'showStorage' => false, 'externalId' => false, 'relativePath' => false)));
     }
     unset($value);
     return $versions;
 }
Esempio n. 5
0
 private function getAttachedObjectById($id)
 {
     $attachedObject = Disk\AttachedObject::getById($id, array('OBJECT'));
     if (!$attachedObject || !$attachedObject->getFile()) {
         throw new RestException("Could not find entity with id '{$id}'.", RestException::ERROR_NOT_FOUND);
     }
     return $attachedObject;
 }
Esempio n. 6
0
 public static function onDelete($userField, $value)
 {
     list($type, $realValue) = self::detectType($value);
     if ($type != self::TYPE_ALREADY_ATTACHED) {
         return;
     }
     $attachedModel = AttachedObject::loadById($realValue);
     if (!$attachedModel) {
         return;
     }
     $userFieldManager = Driver::getInstance()->getUserFieldManager();
     if (!$userFieldManager->belongsToEntity($attachedModel, $userField['ENTITY_ID'], $userField['ENTITY_VALUE_ID'])) {
         return;
     }
     AttachedObject::detachByFilter(array('ID' => $realValue));
 }
Esempio n. 7
0
 /**
  * Returns all attached objects by the file.
  * @param array $parameters Parameters.
  * @return AttachedObject[]
  */
 public function getAttachedObjects(array $parameters = array())
 {
     if (!isset($parameters['filter'])) {
         $parameters['filter'] = array();
     }
     $parameters['filter']['OBJECT_ID'] = $this->id;
     $parameters['filter']['=VERSION_ID'] = null;
     return AttachedObject::getModelList($parameters);
 }
Esempio n. 8
0
 /**
  * @param AttachedObject $attachedModel
  * @return string
  */
 private function getContextForImage(AttachedObject $attachedModel)
 {
     $context = 'unknown';
     if ($this->request->getQuery('width') == 1024 && $this->request->getQuery('height') == 1024) {
         $context = 'viewer resize';
     } elseif ($this->request->getQuery('width') == 69 && $this->request->getQuery('height') == 69) {
         $context = 'list resize';
     } elseif ($this->request->getQuery('x')) {
         $context = 'inline resize';
     }
     $connector = $attachedModel->getConnector();
     if ($connector instanceof BlogPostConnector) {
         $context .= " (blog {$attachedModel->getEntityId()})";
         return $context;
     } elseif ($connector instanceof CalendarEventConnector) {
         $context .= " (calendar {$attachedModel->getEntityId()})";
         return $context;
     } elseif ($connector instanceof ForumMessageConnector) {
         $context .= " (forum {$attachedModel->getEntityId()})";
         return $context;
     } elseif ($connector instanceof SonetCommentConnector) {
         $context .= " (sonetcomm {$attachedModel->getEntityId()})";
         return $context;
     } elseif ($connector instanceof SonetLogConnector) {
         $context .= " (sonetlog {$attachedModel->getEntityId()})";
         return $context;
     } elseif ($connector instanceof TaskConnector) {
         $context .= " (task {$attachedModel->getEntityId()})";
         return $context;
     } else {
         $context .= " (stub {$attachedModel->getEntityId()})";
         return $context;
     }
 }
Esempio n. 9
0
 /**
  * Gets data attributes by attached object to viewer.
  * @param AttachedObject $attachedObject Target attached object.
  * @param array          $additionalParams Additional parameters 'relativePath', 'externalId', 'canUpdate', 'canFakeUpdate', 'showStorage', 'version'.
  * @return string
  */
 public static function getAttributesByAttachedObject(AttachedObject $attachedObject, array $additionalParams = array())
 {
     $urlManager = Driver::getInstance()->getUrlManager();
     $version = $object = null;
     if ($attachedObject->isSpecificVersion()) {
         $version = $attachedObject->getVersion();
         if (!$version) {
             return '';
         }
         $name = $version->getName();
         $extension = $version->getExtension();
         $size = $version->getSize();
         $updateTime = $version->getCreateTime();
     } else {
         $object = $attachedObject->getObject();
         if (!$object) {
             return '';
         }
         $name = $object->getName();
         $extension = $object->getExtension();
         $size = $object->getSize();
         $updateTime = $object->getUpdateTime();
     }
     if (DocumentHandler::isEditable($extension)) {
         $dataAttributesForViewer = 'data-bx-viewer="iframe" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-src="' . $urlManager->getUrlToShowAttachedFileByService($attachedObject->getId(), 'gvdrive') . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-askConvert="' . (DocumentHandler::isNeedConvertExtension($extension) ? '1' : '') . '" ' . 'data-bx-download="' . $urlManager->getUrlUfController('download', array('attachedId' => $attachedObject->getId())) . '" ' . 'data-bx-size="' . htmlspecialcharsbx(CFile::formatSize($size)) . '" ';
     } elseif (Viewer::isViewable($extension)) {
         $dataAttributesForViewer = 'data-bx-viewer="iframe" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-src="' . $urlManager->getUrlToShowAttachedFileByService($attachedObject->getId(), 'gvdrive') . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-askConvert="0" ' . 'data-bx-download="' . $urlManager->getUrlUfController('download', array('attachedId' => $attachedObject->getId())) . '" ' . 'data-bx-size="' . htmlspecialcharsbx(CFile::formatSize($size)) . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($updateTime) . '" ';
     } elseif (TypeFile::isImage($name)) {
         $dataAttributesForViewer = 'data-bx-viewer="image" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-src="' . $urlManager->getUrlUfController('download', array('attachedId' => $attachedObject->getId())) . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-download="' . $urlManager->getUrlUfController('download', array('attachedId' => $attachedObject->getId())) . '" ';
     } else {
         $user = $version ? $version->getCreateUser() : $object->getCreateUser();
         $formattedName = $user ? $user->getFormattedName() : '';
         $dataAttributesForViewer = 'data-bx-viewer="unknown" ' . 'data-bx-src="' . $urlManager->getUrlUfController('download', array('attachedId' => $attachedObject->getId())) . '" ' . 'data-bx-isFromUserLib="" ' . 'data-bx-download="' . $urlManager->getUrlUfController('download', array('attachedId' => $attachedObject->getId())) . '" ' . 'data-bx-title="' . htmlspecialcharsbx($name) . '" ' . 'data-bx-owner="' . htmlspecialcharsbx($formattedName) . '" ' . 'data-bx-dateModify="' . htmlspecialcharsbx($updateTime) . '" ' . 'data-bx-size="' . htmlspecialcharsbx(CFile::formatSize($size)) . '" ';
     }
     $dataAttributesForViewer .= " data-bx-history=\"\"" . " data-bx-historyPage=\"\"";
     if ($object) {
         $dataAttributesForViewer .= " bx-attach-file-id=\"{$object->getId()}\"";
     }
     if (!empty($additionalParams['relativePath'])) {
         $dataAttributesForViewer .= ' data-bx-relativePath="' . htmlspecialcharsbx($additionalParams['relativePath'] . '/' . $name) . '" ';
     }
     if (!empty($additionalParams['externalId'])) {
         $dataAttributesForViewer .= ' data-bx-externalId="' . htmlspecialcharsbx($additionalParams['externalId']) . '" ';
     }
     if (!empty($additionalParams['canUpdate'])) {
         $dataAttributesForViewer .= ' data-bx-edit="' . $urlManager->getUrlToStartEditUfFileByService($attachedObject->getId(), 'gdrive') . '" ';
     }
     if (!empty($additionalParams['canFakeUpdate'])) {
         $dataAttributesForViewer .= ' data-bx-fakeEdit="' . $urlManager->getUrlToStartEditUfFileByService($attachedObject->getId(), 'gdrive') . '" ';
     }
     if (!empty($additionalParams['showStorage']) && $object) {
         $dataAttributesForViewer .= ' data-bx-storage="' . htmlspecialcharsbx($object->getParent()->getName()) . '" ';
     }
     if (!empty($additionalParams['version'])) {
         $dataAttributesForViewer .= ' data-bx-version="' . htmlspecialcharsbx($additionalParams['version']) . '" ';
     }
     return $dataAttributesForViewer;
 }
Esempio n. 10
0
 /**
  * Clones uf values from entity and creates new files (copies from attach) to save in new entity.
  * @param array $attachedIds List of attached objects id.
  * @param int $userId Id of user.
  * @internal
  * @return array
  */
 public function cloneUfValuesFromAttachedObject(array $attachedIds, $userId)
 {
     $this->errorCollection->clear();
     $userId = (int) $userId;
     if ($userId <= 0) {
         $this->errorCollection->addOne(new Error('Invalid $userId'));
         return null;
     }
     $userStorage = Driver::getInstance()->getStorageByUserId($userId);
     if (!$userStorage) {
         $this->errorCollection->addOne(new Error("Could not find storage for user {$userId}"));
         $this->errorCollection->add(Driver::getInstance()->getErrors());
         return null;
     }
     $folder = $userStorage->getFolderForUploadedFiles();
     if (!$folder) {
         $this->errorCollection->addOne(new Error("Could not create/find folder for upload"));
         $this->errorCollection->add($userStorage->getErrors());
         return null;
     }
     $newValues = array();
     foreach ($attachedIds as $id) {
         list($type, $realValue) = FileUserType::detectType($id);
         if (FileUserType::TYPE_ALREADY_ATTACHED != $type) {
             continue;
         }
         $attachedObject = AttachedObject::loadById($realValue, array('OBJECT'));
         if (!$attachedObject) {
             continue;
         }
         if (!$attachedObject->canRead($userId)) {
             continue;
         }
         $file = $attachedObject->getFile();
         if (!$file) {
             continue;
         }
         $newFile = $file->copyTo($folder, $userId, true);
         if (!$newFile) {
             $this->errorCollection->add($file->getErrors());
             continue;
         }
         $newValues[] = FileUserType::NEW_FILE_PREFIX . $newFile->getId();
     }
     return $newValues;
 }
Esempio n. 11
0
 public static function getObjectId($attachedId)
 {
     $attachedId = (int) $attachedId;
     $attachedModel = AttachedObject::loadById($attachedId, array('OBJECT'));
     if (!$attachedModel) {
         return null;
     }
     $objectId = $attachedModel->getObjectId();
     if (!$objectId) {
         return null;
     }
     return $objectId;
 }
Esempio n. 12
0
         $_SESSION["MFU_UPLOADED_FILES_" . $GLOBALS["USER"]->GetId() . "_" . intval($_REQUEST["post_id"])] = $arPostField["VALUE"];
     } elseif ($FIELD_NAME == "UF_BLOG_POST_FILE") {
         if ($arResult["diskEnabled"]) {
             $_SESSION["MFU_UPLOADED_DOCS_" . $GLOBALS["USER"]->GetId() . "_" . intval($_REQUEST["post_id"])] = array();
             if (is_array($arPostField["VALUE"])) {
                 foreach ($arPostField["VALUE"] as $val) {
                     $oAttachedModel = \Bitrix\Disk\AttachedObject::loadById($val, array('OBJECT.STORAGE', 'VERSION'));
                     if ($oAttachedModel) {
                         $oDiskFile = $oAttachedModel->getFile();
                         if ($oDiskFile) {
                             $_SESSION["MFU_UPLOADED_DOCS_" . $GLOBALS["USER"]->GetId() . "_" . intval($_REQUEST["post_id"])][] = $oDiskFile->getId();
                         }
                     }
                 }
             } elseif (intval($arPostField["VALUE"]) > 0) {
                 $oAttachedModel = \Bitrix\Disk\AttachedObject::loadById($arPostField["VALUE"], array('OBJECT.STORAGE', 'VERSION'));
                 if ($oAttachedModel) {
                     $oDiskFile = $oAttachedModel->getFile();
                     if ($oDiskFile) {
                         $rsFile = CFile::GetByID($oDiskFile->getFileId());
                         if ($arFile = $rsFile->Fetch()) {
                             $_SESSION["MFU_UPLOADED_DOCS_" . $GLOBALS["USER"]->GetId() . "_" . intval($_REQUEST["post_id"])] = array($arFile["ID"]);
                         }
                     }
                 }
             }
         } else {
             $_SESSION["MFU_UPLOADED_DOCS_" . $GLOBALS["USER"]->GetId() . "_" . intval($_REQUEST["post_id"])] = $arPostField["VALUE"];
         }
     }
 }
Esempio n. 13
0
if (!$arParams['INPUT_NAME']) {
    showError(GetMessage('MFI_ERR_NO_INPUT_NAME'));
    return false;
}
if (!IsModuleInstalled("webdav") && !IsModuleInstalled("disk")) {
    $arResult['FILES'] = array();
    if (is_array($arParams['INPUT_VALUE'])) {
        $dbRes = CFile::GetList(array(), array("@ID" => implode(",", $arParams["INPUT_VALUE"])));
        while ($arFile = $dbRes->GetNext()) {
            $arFile['URL'] = CHTTP::URN2URI($APPLICATION->GetCurPageParam("mfi_mode=down&fileID=" . $arFile['ID'] . "&cid=" . $arResult['CONTROL_UID'] . "&" . bitrix_sessid_get(), array("mfi_mode", "fileID", "cid")));
            $arFile['FILE_SIZE_FORMATTED'] = CFile::FormatSize($arFile['FILE_SIZE']);
            $arResult['FILES'][$arFile['ID']] = $arFile;
            $_SESSION["MFU_UPLOADED_FILES_" . $GLOBALS["USER"]->GetId() . "_" . $arResult['CONTROL_UID']][] = $arFile['ID'];
        }
    }
}
if ($arResult["diskEnabled"] && isset($arParams["arAttachedObject"]) && is_array($arParams["arAttachedObject"]) && !empty($arParams["arAttachedObject"])) {
    $arResult["arAttachedObject"] = array();
    foreach ($arParams["arAttachedObject"] as $val) {
        $oAttachedModel = \Bitrix\Disk\AttachedObject::loadById($val, array('OBJECT.STORAGE', 'VERSION'));
        if ($oAttachedModel) {
            $oDiskFile = $oAttachedModel->getFile();
            if ($oDiskFile) {
                $arResult["arAttachedObject"][] = array("ID" => $val, "DISK_FILE_ID" => $oDiskFile->getId());
            }
        }
    }
}
CUtil::InitJSCore(array('ajax'));
$this->IncludeComponentTemplate();
return $arParams['CONTROL_ID'];
 public static function clearValueSingle(FieldType $fieldType, $value)
 {
     if (!Loader::includeModule('disk')) {
         return;
     }
     $value = (int) $value;
     if (!$value) {
         return;
     }
     $documentType = $fieldType->getDocumentType();
     $iblockId = intval(substr($documentType[2], strlen("iblock_")));
     if (!$iblockId) {
         return;
     }
     $userFieldManager = \Bitrix\Disk\Driver::getInstance()->getUserFieldManager();
     list($type, $realId) = \Bitrix\Disk\Uf\FileUserType::detectType($value);
     if ($type == \Bitrix\Disk\Uf\FileUserType::TYPE_ALREADY_ATTACHED) {
         $attachedModel = \Bitrix\Disk\AttachedObject::loadById($realId);
         if (!$attachedModel) {
             return;
         }
         if ($userFieldManager->belongsToEntity($attachedModel, "iblock_workflow", $iblockId)) {
             \Bitrix\Disk\AttachedObject::detachByFilter(array('ID' => $realId));
         }
     }
 }
 protected function migrateWebdavElementHistory()
 {
     $this->abortIfNeeded();
     if ($this->isStepFinished(__METHOD__)) {
         return;
     }
     $userFieldManager = Driver::getInstance()->getUserFieldManager();
     $connection = $this->connection;
     $rsData = CUserTypeEntity::GetList(array(), array("ENTITY_ID" => "BLOG_COMMENT", "XML_ID" => "UF_BLOG_COMMENT_FH"));
     if (!$rsData->fetch()) {
         $this->setStepFinished(__METHOD__);
         $this->log(array('Could not find UF_BLOG_COMMENT_FH in entity BLOG_COMMENT'));
         return;
     }
     unset($rsData);
     if (!$connection->isTableExists('b_uts_blog_comment') || !$connection->getTableField('b_uts_blog_comment', 'UF_BLOG_COMMENT_FH')) {
         $this->setStepFinished(__METHOD__);
         $this->log(array('b_uts_blog_comment does not exist or column UF_BLOG_COMMENT_FH does not exist.'));
         return;
     }
     unset($rsData);
     list($connectorClass, $moduleId) = $userFieldManager->getConnectorDataByEntityType('BLOG_COMMENT');
     $lastId = $this->getStorageId();
     $result = $connection->query("SELECT * from b_uts_blog_comment WHERE VALUE_ID > {$lastId} AND UF_BLOG_COMMENT_FH <> '' ORDER BY VALUE_ID ASC");
     while ($userFieldRow = $result->fetch()) {
         $this->abortIfNeeded();
         $dataFromValue = CUserTypeWebdavElementHistory::getDataFromValue($userFieldRow['UF_BLOG_COMMENT_FH']);
         if (!$dataFromValue) {
             $this->storeStorageId($userFieldRow['VALUE_ID']);
             continue;
         }
         $dataFromValue = $dataFromValue[0];
         //this is head version
         if (empty($dataFromValue['v'])) {
             list($newVersionId, $objectId) = $this->getLastVersionByElementId($dataFromValue['id']);
             if (!$newVersionId || !$objectId) {
                 $this->storeStorageId($userFieldRow['VALUE_ID']);
                 $this->log(array('Could not find migrate Head Version from disk. Skip.', $userFieldRow));
                 continue;
             }
             $errorCollection = new ErrorCollection();
             $attachedData = array('MODULE_ID' => $moduleId, 'OBJECT_ID' => $objectId, 'VERSION_ID' => $newVersionId, 'ENTITY_ID' => $userFieldRow['VALUE_ID'], 'ENTITY_TYPE' => $connectorClass, 'IS_EDITABLE' => 2);
             $attachedModel = AttachedObject::add($attachedData, $errorCollection);
             if (!$attachedModel || $errorCollection->hasErrors()) {
                 $this->storeStorageId($userFieldRow['VALUE_ID']);
                 $this->log(array('Could not created attached object'));
                 continue;
             }
             $connection->queryExecute("UPDATE b_uts_blog_comment SET UF_BLOG_COMMENT_FH = '{$attachedModel->getId()}' WHERE VALUE_ID = {$userFieldRow['VALUE_ID']}");
             $this->storeStorageId($userFieldRow['VALUE_ID']);
             continue;
         } else {
             list($newVersionId, $objectId) = $this->getLastVersionByBpId($dataFromValue['v']);
             if (!$newVersionId || !$objectId) {
                 $this->storeStorageId($userFieldRow['VALUE_ID']);
                 $this->log(array('Could not find migrate Version from disk. Skip.', $userFieldRow));
                 continue;
             }
             $errorCollection = new ErrorCollection();
             $attachedData = array('MODULE_ID' => $moduleId, 'OBJECT_ID' => $objectId, 'VERSION_ID' => $newVersionId, 'ENTITY_ID' => $userFieldRow['VALUE_ID'], 'ENTITY_TYPE' => $connectorClass, 'IS_EDITABLE' => 2);
             $attachedModel = AttachedObject::add($attachedData, $errorCollection);
             if (!$attachedModel || $errorCollection->hasErrors()) {
                 $this->storeStorageId($userFieldRow['VALUE_ID']);
                 $this->log(array('Could not created attached object', $userFieldRow));
                 continue;
             }
             $connection->queryExecute("UPDATE b_uts_blog_comment SET UF_BLOG_COMMENT_FH = '{$attachedModel->getId()}' WHERE VALUE_ID = {$userFieldRow['VALUE_ID']}");
             $this->storeStorageId($userFieldRow['VALUE_ID']);
             continue;
         }
     }
     $connection->queryExecute("UPDATE b_user_field SET USER_TYPE_ID = 'disk_version' WHERE ENTITY_ID = 'BLOG_COMMENT' AND XML_ID = 'UF_BLOG_COMMENT_FH'");
     $this->storeStorageId(0);
     $this->setStepFinished(__METHOD__);
     return;
 }
Esempio n. 16
0
 /**
  * @param string $documentId - document id.
  * @return array - document fields array.
  */
 public function GetDocument($documentId)
 {
     $documentId = intval($documentId);
     if ($documentId <= 0) {
         throw new CBPArgumentNullException("documentId");
     }
     $arResult = null;
     $dbDocumentList = CIBlockElement::GetList(array(), array("ID" => $documentId, "SHOW_NEW" => "Y", "SHOW_HISTORY" => "Y"));
     if ($objDocument = $dbDocumentList->GetNextElement(false, true)) {
         $arDocumentFields = $objDocument->GetFields();
         $arDocumentProperties = $objDocument->GetProperties();
         foreach ($arDocumentFields as $fieldKey => $fieldValue) {
             if (substr($fieldKey, 0, 1) == "~") {
                 continue;
             }
             $arResult[$fieldKey] = $fieldValue;
             if (in_array($fieldKey, array("MODIFIED_BY", "CREATED_BY"))) {
                 $arResult[$fieldKey] = "user_" . $fieldValue;
                 $arResult[$fieldKey . "_PRINTABLE"] = $arDocumentFields[$fieldKey == "MODIFIED_BY" ? "USER_NAME" : "CREATED_USER_NAME"];
             } elseif (in_array($fieldKey, array("PREVIEW_TEXT", "DETAIL_TEXT"))) {
                 if ($arDocumentFields[$fieldKey . "_TYPE"] == "html") {
                     $arResult[$fieldKey] = HTMLToTxt($arDocumentFields["~" . $fieldKey]);
                 }
             }
         }
         foreach ($arDocumentProperties as $propertyKey => $propertyValue) {
             if (strlen($propertyValue["USER_TYPE"]) > 0) {
                 if ($propertyValue["USER_TYPE"] == "UserID" || $propertyValue["USER_TYPE"] == "employee" && COption::GetOptionString("bizproc", "employee_compatible_mode", "N") != "Y") {
                     $arPropertyValue = $propertyValue["VALUE"];
                     $arPropertyKey = isset($propertyValue["VALUE_ENUM_ID"]) ? $propertyValue["VALUE_ENUM_ID"] : $propertyValue["PROPERTY_VALUE_ID"];
                     if (!is_array($arPropertyValue)) {
                         $db = CUser::GetByID($arPropertyValue);
                         if ($ar = $db->GetNext()) {
                             $arResult["PROPERTY_" . $propertyKey] = "user_" . intval($arPropertyValue);
                             $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"] = "(" . $ar["LOGIN"] . ")" . (strlen($ar["NAME"]) > 0 || strlen($ar["LAST_NAME"]) > 0 ? " " : "") . $ar["NAME"] . (strlen($ar["NAME"]) > 0 && strlen($ar["LAST_NAME"]) > 0 ? " " : "") . $ar["LAST_NAME"];
                         }
                     } else {
                         for ($i = 0, $cnt = count($arPropertyValue); $i < $cnt; $i++) {
                             $db = CUser::GetByID($arPropertyValue[$i]);
                             if ($ar = $db->GetNext()) {
                                 $arResult["PROPERTY_" . $propertyKey][$arPropertyKey[$i]] = "user_" . intval($arPropertyValue[$i]);
                                 $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"][$arPropertyKey[$i]] = "(" . $ar["LOGIN"] . ")" . (strlen($ar["NAME"]) > 0 || strlen($ar["LAST_NAME"]) > 0 ? " " : "") . $ar["NAME"] . (strlen($ar["NAME"]) > 0 && strlen($ar["LAST_NAME"]) > 0 ? " " : "") . $ar["LAST_NAME"];
                             }
                         }
                     }
                 } elseif ($propertyValue["USER_TYPE"] == "DiskFile") {
                     if (!CModule::includeModule("disk")) {
                         continue;
                     }
                     if (is_array($propertyValue["VALUE"])) {
                         if ($propertyValue["MULTIPLE"] == "Y") {
                             $propertyValue["VALUE"] = current($propertyValue["VALUE"]);
                         }
                         foreach ($propertyValue["VALUE"] as $attachedId) {
                             $attachedId = (int) $attachedId;
                             $attachedModel = \Bitrix\Disk\AttachedObject::loadById($attachedId, array('OBJECT'));
                             if (!$attachedModel) {
                                 continue;
                             }
                             global $USER;
                             $userId = $USER->getID();
                             if ($userId) {
                                 if (!$attachedModel->canRead($userId)) {
                                     continue;
                                 }
                             }
                             $file = $attachedModel->getFile();
                             if (!$file) {
                                 continue;
                             }
                             $driver = \Bitrix\Disk\Driver::getInstance();
                             $urlManager = $driver->getUrlManager();
                             $arResult["PROPERTY_" . $propertyKey][$attachedId] = $urlManager->getUrlUfController('download', array('attachedId' => $attachedModel->getId()));
                             $arResult["PROPERTY_" . $propertyKey . "_PRINTABLE"][$attachedId] = '[url=' . $urlManager->getUrlUfController('download', array('attachedId' => $attachedModel->getId())) . ']' . htmlspecialcharsbx($file->getName()) . '[/url] ';
                         }
                     } else {
                         continue;
                     }
                 } else {
                     $arResult["PROPERTY_" . $propertyKey] = $propertyValue["VALUE"];
                 }
             } elseif ($propertyValue["PROPERTY_TYPE"] == "L") {
                 $arPropertyValue = $propertyValue["VALUE"];
                 $arPropertyKey = self::GetVersion() > 1 ? $propertyValue["VALUE_XML_ID"] : $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];
                 }
             } elseif ($propertyValue["PROPERTY_TYPE"] == "F") {
                 $arPropertyValue = $propertyValue["VALUE"];
                 if (!is_array($arPropertyValue)) {
                     $arPropertyValue = array($arPropertyValue);
                 }
                 foreach ($arPropertyValue as $v) {
                     $ar = CFile::GetFileArray($v);
                     if ($ar) {
                         $arResult["PROPERTY_" . $propertyKey][intval($v)] = $ar["SRC"];
                         $arResult["PROPERTY_" . $propertyKey . "_printable"][intval($v)] = "[url=/bitrix/tools/bizproc_show_file.php?f=" . urlencode($ar["FILE_NAME"]) . "&i=" . $v . "&h=" . md5($ar["SUBDIR"]) . "]" . htmlspecialcharsbx($ar["ORIGINAL_NAME"]) . "[/url]";
                     }
                 }
             } else {
                 $arResult["PROPERTY_" . $propertyKey] = $propertyValue["VALUE"];
             }
         }
         $documentFields = static::GetDocumentFields(static::GetDocumentType($documentId));
         foreach ($documentFields as $fieldKey => $field) {
             if (!array_key_exists($fieldKey, $arResult)) {
                 $arResult[$fieldKey] = null;
             }
         }
     }
     return $arResult;
 }
Esempio n. 17
0
 protected static function getIdByFileId($fileId, $ownerId, $entityId, $fieldName)
 {
     static::includeDisk();
     $currentValue = static::getValue($ownerId, $entityId, $fieldName);
     foreach ($currentValue as $value) {
         $attachedObject = AttachedObject::getById($value, array('OBJECT'));
         if ($attachedObject && $attachedObject->getFile()) {
             $attachmentFileId = $attachedObject->getObjectId();
             if ((int) $attachmentFileId == (int) $fileId) {
                 return $value;
             }
         }
     }
     return false;
 }
 public static function clearValueMultiple(FieldType $fieldType, $values)
 {
     if (!Loader::includeModule('disk')) {
         return;
     }
     if (!is_array($values)) {
         $values = array($values);
     }
     $userFieldManager = \Bitrix\Disk\Driver::getInstance()->getUserFieldManager();
     list($connectorClass, $moduleId) = $userFieldManager->getConnectorDataByEntityType('lists_workflow');
     $documentType = $fieldType->getDocumentType();
     $iblockId = intval(substr($documentType[2], strlen("iblock_")));
     if (!$iblockId) {
         return;
     }
     foreach ($values as $value) {
         $attachedModel = \Bitrix\Disk\AttachedObject::load(array('OBJECT_ID' => $value, '=ENTITY_TYPE' => $connectorClass, '=ENTITY_ID' => $iblockId, '=MODULE_ID' => $moduleId));
         if (!$attachedModel) {
             continue;
         }
         if ($userFieldManager->belongsToEntity($attachedModel, "lists_workflow", $iblockId)) {
             \Bitrix\Disk\AttachedObject::detachByFilter(array('ID' => $attachedModel->getId()));
         }
     }
 }
Esempio n. 19
0
 /**
  * @param $id
  * @return AttachedObject|null
  */
 protected static function getAttachedObjectById($id)
 {
     if (!isset(static::$loadedAttachedObjects[$id])) {
         static::$loadedAttachedObjects[$id] = AttachedObject::loadById($id, array('OBJECT'));
     }
     return static::$loadedAttachedObjects[$id];
 }
Esempio n. 20
0
 public static function collectUFValues($rows, $columnInfo, $total)
 {
     // uf columns
     $fileColumns = array();
     $diskFileColumns = array();
     $employeeColumns = array();
     $crmColumns = array();
     $crmStatusColumns = array();
     $iblockElementColumns = array();
     $iblockSectionColumns = array();
     if (is_array($columnInfo)) {
         foreach ($columnInfo as $k => $cInfo) {
             if ($cInfo['isUF'] && is_array($cInfo['ufInfo']) && isset($cInfo['ufInfo']['USER_TYPE_ID'])) {
                 switch ($cInfo['ufInfo']['USER_TYPE_ID']) {
                     case 'file':
                         $fileColumns[$k] = true;
                         break;
                     case 'disk_file':
                         $diskFileColumns[$k] = true;
                         break;
                     case 'employee':
                         $employeeColumns[$k] = true;
                         break;
                     case 'crm':
                         $crmColumns[$k] = true;
                         break;
                     case 'crm_status':
                         $crmStatusColumns[$k] = true;
                         break;
                     case 'iblock_element':
                         $iblockElementColumns[$k] = true;
                         break;
                     case 'iblock_section':
                         $iblockSectionColumns[$k] = true;
                         break;
                 }
             }
         }
     }
     $arFileID = array();
     $arDiskFileID = array();
     $arEmployeeID = array();
     $arCrmID = array();
     $arCrmStatusID = array();
     $arCrmStatusEntityType = array();
     $arIblockElementID = array();
     $arIblockSectionID = array();
     if (count($fileColumns) > 0 || count($diskFileColumns) > 0 || count($employeeColumns) > 0 || count($crmColumns) > 0 || count($crmStatusColumns) > 0 || count($iblockElementColumns) > 0 || count($iblockSectionColumns) > 0) {
         foreach ($rows as $row) {
             foreach ($row as $k => $v) {
                 // file
                 if (isset($fileColumns[$k])) {
                     if (is_array($v)) {
                         foreach ($v as $subv) {
                             $value = intval($subv);
                             if ($value > 0) {
                                 $arFileID[] = $value;
                             }
                         }
                     } else {
                         $value = intval($v);
                         if ($value > 0) {
                             $arFileID[] = $value;
                         }
                     }
                 }
                 // disk file
                 if (isset($diskFileColumns[$k])) {
                     if (is_array($v)) {
                         foreach ($v as $subv) {
                             $value = intval($subv);
                             if ($value > 0) {
                                 $arDiskFileID[] = $value;
                             }
                         }
                     } else {
                         $value = intval($v);
                         if ($value > 0) {
                             $arDiskFileID[] = $value;
                         }
                     }
                 }
                 // employee
                 if (isset($employeeColumns[$k])) {
                     if (is_array($v)) {
                         foreach ($v as $subv) {
                             $value = intval($subv);
                             if ($value > 0) {
                                 $arEmployeeID[] = $value;
                             }
                         }
                     } else {
                         $value = intval($v);
                         if ($value > 0) {
                             $arEmployeeID[] = $value;
                         }
                     }
                 }
                 // crm
                 if (isset($crmColumns[$k])) {
                     $prefixByType = array('lead' => 'L', 'contact' => 'C', 'company' => 'CO', 'deal' => 'D', 'quote' => 'Q');
                     $maxPrefixLength = 2;
                     // 'CO'
                     $singleTypePrefix = '';
                     if (is_array($columnInfo[$k]['ufInfo']['SETTINGS'])) {
                         $supportedTypes = array();
                         foreach ($columnInfo[$k]['ufInfo']['SETTINGS'] as $type => $supported) {
                             if ($supported === 'Y') {
                                 $supportedTypes[$type] = true;
                             }
                         }
                         $supportedTypes = array_keys($supportedTypes);
                         if (count($supportedTypes) === 1) {
                             if (isset($prefixByType[strtolower($supportedTypes[0])])) {
                                 $singleTypePrefix = $prefixByType[strtolower($supportedTypes[0])];
                             }
                         }
                         unset($supportedTypes, $type, $supported);
                     }
                     if (is_array($v)) {
                         foreach ($v as $subv) {
                             if (strlen($subv) > 0) {
                                 $prefix = '';
                                 if (($pos = strpos(substr($subv, 0, $maxPrefixLength + 1), '_')) !== false && $pos > 0) {
                                     $prefix = substr($subv, 0, $pos);
                                 }
                                 if (empty($prefix)) {
                                     $subv = $singleTypePrefix . '_' . $subv;
                                 }
                                 unset($prefix, $pos);
                                 $value = explode('_', trim(strval($subv)));
                                 if (strlen($value[0]) > 0 && strlen($value[1]) > 0) {
                                     if (!is_array($arCrmID[$value[0]])) {
                                         $arCrmID[$value[0]] = array();
                                     }
                                     $arCrmID[$value[0]][] = $value[1];
                                 }
                             }
                         }
                     } else {
                         if (strlen($v) > 0) {
                             $prefix = '';
                             if (($pos = strpos(substr($v, 0, $maxPrefixLength + 1), '_')) !== false && $pos > 0) {
                                 $prefix = substr($v, 0, $pos);
                             }
                             if (empty($prefix)) {
                                 $v = $singleTypePrefix . '_' . $v;
                             }
                             unset($prefix, $pos);
                             $value = explode('_', trim(strval($v)));
                             if (strlen($value[0]) > 0 && strlen($value[1]) > 0) {
                                 if (!is_array($arCrmID[$value[0]])) {
                                     $arCrmID[$value[0]] = array();
                                 }
                                 $arCrmID[$value[0]][] = $value[1];
                             }
                         }
                     }
                     unset($maxPrefixLength);
                 }
                 // crm_status
                 if (isset($crmStatusColumns[$k])) {
                     if (!isset($arCrmStatusEntityType[$k])) {
                         if (isset($columnInfo[$k]['ufInfo']['SETTINGS']['ENTITY_TYPE'])) {
                             $arCrmStatusEntityType[$k] = strval($columnInfo[$k]['ufInfo']['SETTINGS']['ENTITY_TYPE']);
                         }
                     }
                     if (!empty($arCrmStatusEntityType[$k])) {
                         if (is_array($v)) {
                             foreach ($v as $subv) {
                                 if (strlen($subv) > 0) {
                                     if (!is_array($arCrmStatusID[$arCrmStatusEntityType[$k]])) {
                                         $arCrmStatusID[$arCrmStatusEntityType[$k]] = array();
                                     }
                                     $arCrmStatusID[$arCrmStatusEntityType[$k]][] = $subv;
                                 }
                             }
                         } else {
                             if (strlen($v) > 0) {
                                 if (!is_array($arCrmStatusID[$arCrmStatusEntityType[$k]])) {
                                     $arCrmStatusID[$arCrmStatusEntityType[$k]] = array();
                                 }
                                 $arCrmStatusID[$arCrmStatusEntityType[$k]][] = $v;
                             }
                         }
                     }
                 }
                 // iblock_element
                 if (isset($iblockElementColumns[$k])) {
                     if (is_array($v)) {
                         foreach ($v as $subv) {
                             $value = intval($subv);
                             if ($value > 0) {
                                 $arIblockElementID[] = $value;
                             }
                         }
                     } else {
                         $value = intval($v);
                         if ($value > 0) {
                             $arIblockElementID[] = $value;
                         }
                     }
                 }
                 // iblock_section
                 if (isset($iblockSectionColumns[$k])) {
                     if (is_array($v)) {
                         foreach ($v as $subv) {
                             $value = intval($subv);
                             if ($value > 0) {
                                 $arIblockSectionID[] = $value;
                             }
                         }
                     } else {
                         $value = intval($v);
                         if ($value > 0) {
                             $arIblockSectionID[] = $value;
                         }
                     }
                 }
             }
         }
     }
     // collect files
     if (count($fileColumns) > 0) {
         if (count($arFileID) > 0) {
             $arFileID = array_unique($arFileID);
         }
         $i = 0;
         $cnt = 0;
         $stepCnt = 500;
         $nIDs = count($arFileID);
         $arID = array();
         $file = new CFile();
         foreach ($arFileID as $fileID) {
             $arID[$cnt++] = $fileID;
             $i++;
             if ($cnt === $stepCnt || $i === $nIDs) {
                 $res = $file->GetList(array(), array('@ID' => implode(',', $arID)));
                 if (is_object($res)) {
                     while ($arFile = $res->Fetch()) {
                         if ($arFile) {
                             if (array_key_exists("~src", $arFile)) {
                                 if ($arFile["~src"]) {
                                     $arFile["SRC"] = $arFile["~src"];
                                 } else {
                                     $arFile["SRC"] = $file->GetFileSRC($arFile, false, false);
                                 }
                             } else {
                                 $arFile["SRC"] = $file->GetFileSRC($arFile, false);
                             }
                             self::$ufFiles[intval($arFile['ID'])] = $arFile;
                         }
                     }
                 }
                 $cnt = 0;
                 $arID = array();
             }
         }
     }
     // collect disk files
     if (count($diskFileColumns) > 0) {
         if (count($arDiskFileID) > 0) {
             $arDiskFileID = array_unique($arDiskFileID);
         }
         $i = 0;
         $cnt = 0;
         $stepCnt = 500;
         $nIDs = count($arDiskFileID);
         $arID = array();
         foreach ($arDiskFileID as $diskFileID) {
             $arID[$cnt++] = $diskFileID;
             $i++;
             if ($cnt === $stepCnt || $i === $nIDs) {
                 $res = \Bitrix\Disk\AttachedObject::getList(array('filter' => array('ID' => $arID), 'select' => array('ID', 'NAME' => 'OBJECT.NAME', 'SIZE' => 'OBJECT.SIZE')));
                 $urlManager = \Bitrix\Disk\Driver::getInstance()->getUrlManager();
                 if (is_object($res)) {
                     while ($arDiskFile = $res->Fetch()) {
                         if ($arDiskFile) {
                             $arDiskFile['DOWNLOAD_URL'] = $urlManager->getUrlUfController('download', array('attachedId' => $arDiskFile['ID']));
                             self::$ufDiskFiles[intval($arDiskFile['ID'])] = $arDiskFile;
                         }
                     }
                 }
                 $cnt = 0;
                 $arID = array();
             }
         }
     }
     // collect employees
     if (count($employeeColumns) > 0) {
         if (count($arEmployeeID) > 0) {
             $arEmployeeID = array_unique($arEmployeeID);
         }
         $i = 0;
         $cnt = 0;
         $stepCnt = 500;
         $nIDs = count($arEmployeeID);
         $arID = array();
         foreach ($arEmployeeID as $employeeID) {
             $arID[$cnt++] = $employeeID;
             $i++;
             if ($cnt === $stepCnt || $i === $nIDs) {
                 $res = \Bitrix\Main\UserTable::getList(array('filter' => array('ID' => $arID), 'select' => array('ID', 'LOGIN', 'NAME', 'LAST_NAME', 'SECOND_NAME', 'TITLE')));
                 if (is_object($res)) {
                     while ($arUser = $res->fetch()) {
                         self::$ufEmployees[intval($arUser['ID'])] = $arUser;
                     }
                 }
                 $cnt = 0;
                 $arID = array();
             }
         }
     }
     // collect crm elements
     if (count($crmColumns) > 0 && CModule::IncludeModule('crm')) {
         foreach ($arCrmID as $typeIndex => $arSubID) {
             if (count($arSubID) > 0) {
                 $arCrmID[$typeIndex] = array_unique($arSubID);
             }
             $i = 0;
             $cnt = 0;
             $stepCnt = 500;
             $nIDs = count($arSubID);
             $arID = array();
             foreach ($arSubID as $crmID) {
                 $arID[$cnt++] = $crmID;
                 $i++;
                 if ($cnt === $stepCnt || $i === $nIDs) {
                     $res = null;
                     switch ($typeIndex) {
                         case 'L':
                             $res = CCrmLead::GetList(array('ID' => 'DESC'), array('ID' => $arID), array('ID', 'TITLE', 'FULL_NAME', 'STATUS_ID'));
                             break;
                         case 'C':
                             $res = CCrmContact::GetList(array('ID' => 'DESC'), array('ID' => $arID), array('ID', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'FULL_NAME', 'COMPANY_TITLE', 'PHOTO'));
                             break;
                         case 'CO':
                             $res = CCrmCompany::GetList(array('ID' => 'DESC'), array('ID' => $arID), array('ID', 'TITLE', 'COMPANY_TYPE', 'INDUSTRY', 'LOGO'));
                             break;
                         case 'D':
                             $res = CCrmDeal::GetList(array('ID' => 'DESC'), array('ID' => $arID), array('ID', 'TITLE', 'STAGE_ID', 'COMPANY_TITLE', 'CONTACT_FULL_NAME'));
                             break;
                     }
                     if (is_object($res)) {
                         while ($arCrmElement = $res->Fetch()) {
                             self::$ufCrmElements[$typeIndex . '_' . $arCrmElement['ID']] = $arCrmElement;
                         }
                     }
                     $cnt = 0;
                     $arID = array();
                 }
             }
         }
     }
     // collect crm statuses
     if (count($crmStatusColumns) > 0 && CModule::IncludeModule('crm')) {
         foreach ($arCrmStatusID as $entityType => $arSubID) {
             if (count($arSubID) > 0) {
                 $arCrmID[$entityType] = array_unique($arSubID);
             }
             $res = null;
             $res = CCrmStatus::GetStatusList($entityType);
             if (is_array($res) && count($res) > 0) {
                 foreach ($arSubID as $crmStatusID) {
                     if (isset($res[$crmStatusID])) {
                         if (!isset(self::$ufCrmStatuses[$entityType])) {
                             self::$ufCrmStatuses[$entityType] = array();
                         }
                     }
                     self::$ufCrmStatuses[$entityType][$crmStatusID] = $res[$crmStatusID];
                 }
             }
         }
     }
     // collect iblock elements
     if (count($iblockElementColumns) > 0 && CModule::IncludeModule('iblock')) {
         if (count($arIblockElementID) > 0) {
             $arIblockElementID = array_unique($arIblockElementID);
         }
         $i = 0;
         $cnt = 0;
         $stepCnt = 500;
         $nIDs = count($arIblockElementID);
         $arID = array();
         foreach ($arIblockElementID as $iblockElementID) {
             $arID[$cnt++] = $iblockElementID;
             $i++;
             if ($cnt === $stepCnt || $i === $nIDs) {
                 $res = CIBlockElement::GetList(array('SORT' => 'ASC'), array('=ID' => $arID));
                 if (is_object($res)) {
                     while ($arIblockElement = $res->GetNext()) {
                         self::$ufIblockElements[intval($arIblockElement['ID'])] = $arIblockElement;
                     }
                 }
                 $cnt = 0;
                 $arID = array();
             }
         }
     }
     // collect iblock sections
     if (count($iblockSectionColumns) > 0 && CModule::IncludeModule('iblock')) {
         if (count($arIblockSectionID) > 0) {
             $arIblockSectionID = array_unique($arIblockSectionID);
         }
         $i = 0;
         $cnt = 0;
         $stepCnt = 500;
         $nIDs = count($arIblockSectionID);
         $arID = array();
         foreach ($arIblockSectionID as $iblockSectionID) {
             $arID[$cnt++] = $iblockSectionID;
             $i++;
             if ($cnt === $stepCnt || $i === $nIDs) {
                 $res = CIBlockSection::GetList(array('left_margin' => 'asc'), array('ID' => $arID), false, array('ID', 'NAME', 'SECTION_PAGE_URL'));
                 if (is_object($res)) {
                     while ($arIblockSection = $res->GetNext()) {
                         self::$ufIblockSections[intval($arIblockSection['ID'])] = $arIblockSection;
                     }
                 }
                 $cnt = 0;
                 $arID = array();
             }
         }
     }
 }