public function OnAfterIBlockElementDelete($fields) { $errors = array(); if (Loader::includeModule('socialnetwork')) { $states = CBPStateService::getDocumentStates(array('lists', get_called_class(), $fields['ID'])); foreach ($states as $workflowId => $state) { $sourceId = CBPStateService::getWorkflowIntegerId($workflowId); $resultQuery = CSocNetLog::getList(array(), array('EVENT_ID' => 'lists_new_element', 'SOURCE_ID' => $sourceId), false, false, array('ID')); while ($log = $resultQuery->fetch()) { CSocNetLog::delete($log['ID']); } } } CBPDocument::onDocumentDelete(array('lists', get_called_class(), $fields['ID']), $errors); }
public static function setMessageLiveFeed($users, $elementId, $workflowId, $flagCompleteProcess) { $elementId = intval($elementId); $elementObject = CIBlockElement::getList(array(), array('ID' => $elementId), false, false, array('ID', 'CREATED_BY', 'IBLOCK_NAME', 'NAME', 'IBLOCK_ID', 'LANG_DIR')); $element = $elementObject->fetch(); if (!CLists::getLiveFeed($element["IBLOCK_ID"])) { return false; } $params = serialize(array("ELEMENT_NAME" => $element['NAME'])); $element['NAME'] = preg_replace_callback('#^[^\\[\\]]+?\\[(\\d+)\\]#i', function ($matches) { $userId = $matches[1]; $db = CUser::GetByID($userId); if ($ar = $db->GetNext()) { $ix = randString(5); return '<a class="feed-post-user-name" id="bp_' . $userId . '_' . $ix . '" href="/company/personal/user/' . $userId . '/" bx-post-author-id="' . $userId . '">' . CUser::FormatName(CSite::GetNameFormat(false), $ar, false, false) . '</a> <script type="text/javascript">if (BX.tooltip) BX.tooltip(\'' . $userId . '\', "bp_' . $userId . '_' . $ix . '", "");</script>'; } return $matches[0]; }, $element['NAME']); $path = rtrim($element['LANG_DIR'], '/'); $urlElement = $path . COption::GetOptionString('lists', 'livefeed_url') . '?livefeed=y&list_id=' . $element["IBLOCK_ID"] . '&element_id=' . $elementId; $createdBy = $element['CREATED_BY']; if (!Loader::includeModule('socialnetwork') || $createdBy <= 0) { return false; } $sourceId = CBPStateService::getWorkflowIntegerId($workflowId); $logId = 0; $userObject = CUser::getByID($createdBy); $siteId = array(); $siteObject = CSite::getList($by = "sort", $order = "desc", array("ACTIVE" => "Y")); while ($site = $siteObject->fetch()) { $siteId[] = $site['LID']; } if ($userObject->fetch()) { global $DB; $soFields = array('ENTITY_TYPE' => SONET_LISTS_NEW_POST_ENTITY, 'EVENT_ID' => 'lists_new_element', 'ENTITY_ID' => 1, '=LOG_UPDATE' => $DB->currentTimeFunction(), 'SOURCE_ID' => $sourceId, 'USER_ID' => $createdBy, 'MODULE_ID' => 'lists', 'TITLE_TEMPLATE' => $urlElement, 'TITLE' => $element['IBLOCK_NAME'], 'PARAMS' => $params, 'MESSAGE' => $workflowId, 'CALLBACK_FUNC' => false, 'SITE_ID' => $siteId, 'ENABLE_COMMENTS' => 'Y', 'RATING_TYPE_ID' => 'LISTS_NEW_ELEMENT', 'RATING_ENTITY_ID' => $sourceId, 'URL' => '#SITE_DIR#' . COption::GetOptionString('socialnetwork', 'user_page', false, SITE_ID) . 'log/'); $logObject = CSocNetLog::getList(array(), array('ENTITY_TYPE' => $soFields['ENTITY_TYPE'], 'ENTITY_ID' => $soFields['ENTITY_ID'], 'EVENT_ID' => $soFields['EVENT_ID'], 'SOURCE_ID' => $soFields['SOURCE_ID'])); $iblockPicture = CIBlock::getArrayByID($element['IBLOCK_ID'], 'PICTURE'); $imageFile = CFile::getFileArray($iblockPicture); if ($imageFile !== false) { $imageFile = CFile::ResizeImageGet($imageFile, array("width" => 36, "height" => 30), BX_RESIZE_IMAGE_PROPORTIONAL, false); } if (empty($imageFile['src'])) { $imageFile['src'] = '/bitrix/images/lists/default.png'; } $soFields['TEXT_MESSAGE'] = ' <span class="bp-title-desc"> <span class="bp-title-desc-icon"> <img src="' . $imageFile['src'] . '" width="36" height="30" border="0" /> </span> ' . $element['NAME'] . ' </span> '; if ($log = $logObject->fetch()) { if (intval($log['ID']) > 0) { if (empty($users)) { CSocNetLog::update($log['ID'], $soFields); } else { $activeUsers = CBPTaskService::getWorkflowParticipants($workflowId); $rights = self::getRights($activeUsers, $log['ID'], $createdBy, 'post'); $usersRight = self::getUserIdForRight($rights); self::setSocnetFollow($usersRight, $log['ID'], 'Y', true); /* Recipients tasks bp */ CSocNetLog::update($log['ID'], $soFields); /* Increment the counter for participants */ CSocNetLogRights::deleteByLogID($log['ID']); $rightsCounter = self::getRights($users, $log['ID'], $createdBy, 'counter'); CSocNetLogRights::add($log['ID'], $rightsCounter, false, false); CSocNetLog::counterIncrement($log['ID'], $soFields['EVENT_ID'], false, 'L', false); /* Return previous state rights */ CSocNetLogRights::deleteByLogID($log['ID']); CSocNetLogRights::add($log['ID'], $rights, false, false); self::setSocnetFollow($users, $log['ID'], 'Y'); self::setSocnetFollow($users, $log['ID'], 'N'); } /* Completion of the process for the author */ if ($flagCompleteProcess) { $activeUsers = CBPTaskService::getWorkflowParticipants($workflowId); $rights = self::getRights($activeUsers, $log['ID'], $createdBy, 'post'); $usersRight = self::getUserIdForRight($rights); /* Increment the counter for author */ $users[] = $createdBy; CSocNetLogRights::deleteByLogID($log['ID']); $rightsCounter = self::getRights($users, $log['ID'], $createdBy, 'counter'); CSocNetLogRights::add($log['ID'], $rightsCounter, false, false); CSocNetLog::counterIncrement($log['ID'], $soFields['EVENT_ID'], false, 'L', false); /* Return previous state rights */ CSocNetLogRights::deleteByLogID($log['ID']); CSocNetLogRights::add($log['ID'], $rights, false, false); self::setSocnetFollow($users, $log['ID'], 'Y'); self::setSocnetFollow($usersRight, $log['ID'], 'N'); } } } else { $activeUsers = CBPTaskService::getWorkflowParticipants($workflowId); $soFields['=LOG_DATE'] = $DB->currentTimeFunction(); $logId = CSocNetLog::add($soFields, false); if (intval($logId) > 0) { $rights = self::getRights($activeUsers, $logId, $createdBy, 'post'); CSocNetLogRights::add($logId, $rights, false, false); $usersRight = self::getUserIdForRight($rights); self::setSocnetFollow($usersRight, $logId, 'N'); } CSocNetLog::counterIncrement($logId, $soFields['EVENT_ID'], false, 'L', false); } } return $logId; }
</span> </div> <div id="bp-task-tabs-content" class="bp-tab-contents"> <div id="bp-task-tab-1-content" class="bp-tab-content active"> <?php } ?> <?php if (!isset($arParams['IFRAME']) || $arParams['IFRAME'] == 'N') { // A < E < I < M < Q < U < Y // A - NO ACCESS, E - READ, I - ANSWER // M - NEW TOPIC // Q - MODERATE, U - EDIT, Y - FULL_ACCESS $APPLICATION->IncludeComponent("bitrix:forum.comments", "bitrix24", array("FORUM_ID" => CBPHelper::getForumId(), "ENTITY_TYPE" => "WF", "ENTITY_ID" => CBPStateService::getWorkflowIntegerId($arResult["TASK"]['WORKFLOW_ID']), "ENTITY_XML_ID" => "WF_" . $arResult["TASK"]['WORKFLOW_ID'], "PERMISSION" => "Y", "URL_TEMPLATES_PROFILE_VIEW" => "/company/personal/user/#user_id#/", "SHOW_RATING" => "Y", "SHOW_LINK_TO_MESSAGE" => "N", "BIND_VIEWER" => "Y"), false, array('HIDE_ICONS' => 'Y')); } else { ?> <iframe src="/bitrix/components/bitrix/bizproc.task/comments.php?TASK_ID=<?php echo $arResult['TASK']['ID']; ?> &USER_ID=<?php echo $arParams['USER_ID']; ?> &site_id=<?php echo SITE_ID; ?> &sessid=<?php echo bitrix_sessid(); ?>
public static function deleteSocnetLog(array $listWorkflowId) { if (CModule::includeModule('socialnetwork')) { foreach ($listWorkflowId as $workflowId) { $sourceId = CBPStateService::getWorkflowIntegerId($workflowId); $resultQuery = CSocNetLog::getList(array(), array('EVENT_ID' => 'lists_new_element', 'SOURCE_ID' => $sourceId), false, false, array('ID')); while ($log = $resultQuery->fetch()) { CSocNetLog::delete($log['ID']); } } } }