Esempio n. 1
0
 protected function getBizProcData(BaseObject $object, SecurityContext $securityContext, array $actions, array $columnsBizProc, array $bizprocIcon, array $exportData)
 {
     $documentData = array('DISK' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocument::generateDocumentComplexType($this->storage->getId()), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocument::getDocumentComplexId($object->getId())), 'WEBDAV' => array('DOCUMENT_TYPE' => \Bitrix\Disk\BizProcDocumentCompatible::generateDocumentComplexType($this->storage->getId()), 'DOCUMENT_ID' => \Bitrix\Disk\BizProcDocumentCompatible::getDocumentComplexId($object->getId())));
     $listBpTemplates = array();
     foreach ($this->arParams['TEMPLATE_BIZPROC'] as $idTemplate => $valueTemplate) {
         $url = CComponentEngine::MakePathFromTemplate($valueTemplate['URL'], array("ELEMENT_ID" => $object->getId()));
         $listBpTemplates[] = array("ICONCLASS" => "", "TEXT" => $valueTemplate['NAME'], "ONCLICK" => "jsUtils.Redirect([], '" . CUtil::JSEscape($url) . "');");
     }
     if ($object->canStartBizProc($securityContext) && !empty($listBpTemplates)) {
         $actions[] = array("ICONCLASS" => "bizproc_start", "TEXT" => Loc::getMessage("DISK_FOLDER_LIST_ACT_START_BIZPROC"), "MENU" => $listBpTemplates);
     }
     $webdavFileId = $object->getXmlId();
     if (!empty($webdavFileId)) {
         if (Loader::includeModule("iblock")) {
             if ($this->storage->getProxyType() instanceof ProxyType\Group) {
                 $iblock = CIBlockElement::getList(array(), array("ID" => $webdavFileId, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'IBLOCK_ID'))->fetch();
                 $entity = 'CIBlockDocumentWebdavSocnet';
             } else {
                 $iblock = CIBlockElement::getList(array(), array("ID" => $webdavFileId, 'SHOW_NEW' => 'Y'), false, false, array('ID', 'IBLOCK_ID'))->fetch();
                 $entity = 'CIBlockDocumentWebdav';
             }
             if (!empty($iblock)) {
                 $documentData['OLD_FILE'] = array('DOCUMENT_TYPE' => array('webdav', $entity, "iblock_" . $iblock['IBLOCK_ID']), 'DOCUMENT_ID' => array('webdav', $entity, $iblock['ID']));
             }
         }
     }
     foreach ($documentData as $nameModuleId => $data) {
         $temporary[$nameModuleId] = CBPDocument::getDocumentStates($data['DOCUMENT_TYPE'], $data['DOCUMENT_ID']);
     }
     if (isset($temporary['OLD_FILE'])) {
         $documentStates = array_merge($temporary['DISK'], $temporary['WEBDAV'], $temporary['OLD_FILE']);
     } else {
         $documentStates = array_merge($temporary['DISK'], $temporary['WEBDAV']);
     }
     foreach ($documentStates as $key => $documentState) {
         if (empty($documentState['ID'])) {
             unset($documentStates[$key]);
         }
     }
     $columnsBizProc['BIZPROC'] = "";
     $bizprocIcon['BIZPROC'] = "";
     if (!empty($documentStates)) {
         if (count($documentStates) == 1) {
             $documentState = reset($documentStates);
             if ($documentState['WORKFLOW_STATUS'] > 0 || empty($documentState['WORKFLOW_STATUS'])) {
                 $tasksWorkflow = CBPDocument::getUserTasksForWorkflow($this->getUser()->GetID(), $documentState["ID"]);
                 $columnsBizProc["BIZPROC"] = '<div class="bizproc-item-title">' . htmlspecialcharsbx($documentState["TEMPLATE_NAME"]) . ': ' . '<span class="bizproc-item-title bizproc-state-title" style="">' . '<a href="' . $exportData["OPEN_URL"] . '#tab-bp">' . (strlen($documentState["STATE_TITLE"]) > 0 ? htmlspecialcharsbx($documentState["STATE_TITLE"]) : htmlspecialcharsbx($documentState["STATE_NAME"])) . '</a>' . '</span>' . '</div>';
                 $columnsBizProc['BIZPROC'] = str_replace("'", "\"", $columnsBizProc['BIZPROC']);
                 $bizprocIcon["BIZPROC"] = "<div class=\"element-bizproc-status bizproc-statuses " . (!(strlen($documentState["ID"]) <= 0 || strlen($documentState["WORKFLOW_STATUS"]) <= 0) ? 'bizproc-status-' . (empty($tasksWorkflow) ? "inprogress" : "attention") : '') . "\" onmouseover='BX.hint(this, \"" . addslashes($columnsBizProc["BIZPROC"]) . "\")'></div>";
                 if (!empty($tasksWorkflow)) {
                     $tmp = array();
                     foreach ($tasksWorkflow as $val) {
                         $url = CComponentEngine::makePathFromTemplate($this->arParams["PATH_TO_DISK_TASK"], array("ID" => $val["ID"]));
                         $url .= "?back_url=" . urlencode($this->getApplication()->getCurPageParam());
                         $tmp[] = '<a href="' . $url . '">' . $val["NAME"] . '</a>';
                     }
                     $columnsBizProc["BIZPROC"] .= '<div class="bizproc-tasks">' . implode(", ", $tmp) . '</div>';
                     return array($actions, $columnsBizProc, $bizprocIcon);
                 }
                 return array($actions, $columnsBizProc, $bizprocIcon);
             }
             return array($actions, $columnsBizProc, $bizprocIcon);
         } else {
             $tasks = array();
             $inprogress = false;
             foreach ($documentStates as $key => $documentState) {
                 if ($documentState['WORKFLOW_STATUS'] > 0 || empty($documentState['WORKFLOW_STATUS'])) {
                     $tasksWorkflow = CBPDocument::getUserTasksForWorkflow($this->getUser()->GetID(), $documentState["ID"]);
                     if (!$inprogress) {
                         $inprogress = strlen($documentState['ID']) > 0 && strlen($documentState['WORKFLOW_STATUS']) > 0;
                     }
                     if (!empty($tasksWorkflow)) {
                         foreach ($tasksWorkflow as $val) {
                             $tasks[] = $val;
                         }
                     }
                 }
             }
             $columnsBizProc["BIZPROC"] = '<span class="bizproc-item-title">' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC") . ': <a href="' . $exportData["OPEN_URL"] . '#tab-bp" title="' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC_TITLE") . '">' . count($documentStates) . '</a></span>' . (!empty($tasks) ? '<br /><span class="bizproc-item-title">' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC_TASKS") . ': <a href="' . $this->arParams["PATH_TO_DISK_TASK_LIST"] . '" title="' . Loc::getMessage("DISK_FOLDER_LIST_GRID_BIZPROC_TASKS_TITLE") . '">' . count($tasks) . '</a></span>' : '');
             $bizprocIcon["BIZPROC"] = "<div class=\"element-bizproc-status bizproc-statuses " . ($inprogress ? ' bizproc-status-' . (empty($tasks) ? "inprogress" : "attention") : '') . "\" onmouseover='BX.hint(this, \"" . addslashes($columnsBizProc['BIZPROC']) . "\")'></div>";
             return array($actions, $columnsBizProc, $bizprocIcon);
         }
     }
     return array($actions, $columnsBizProc, $bizprocIcon);
 }