protected function processActionShowProcesses() { $this->iblockTypeId = COption::GetOptionString("lists", "livefeed_iblock_type_id"); $this->checkPermission(); if ($this->errorCollection->hasErrors()) { $this->sendJsonErrorResponse(); } $siteDir = '/'; $siteId = true; if ($this->request->getPost('siteDir')) { $siteDir = $this->request->getPost('siteDir'); } if ($this->request->getPost('siteId')) { $siteId = $this->request->getPost('siteId'); } $path = rtrim($siteDir, '/'); $listData = array(); $lists = CIBlock::getList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y", "TYPE" => $this->iblockTypeId, "SITE_ID" => $siteId)); while ($list = $lists->fetch()) { if (CLists::getLiveFeed($list['ID'])) { $listData[$list['ID']]['name'] = $list['NAME']; $listData[$list['ID']]['url'] = $path . COption::GetOptionString('lists', 'livefeed_url') . '?livefeed=y&list_id=' . $list["ID"] . '&element_id=0'; if ($list['PICTURE'] > 0) { $imageFile = CFile::GetFileArray($list['PICTURE']); if ($imageFile !== false) { $imageFile = CFile::ResizeImageGet($imageFile, array("width" => 36, "height" => 30), BX_RESIZE_IMAGE_PROPORTIONAL, false); $listData[$list['ID']]['picture'] = '<img src="' . $imageFile["src"] . '" width="19" height="16" border="0" />'; } } else { $listData[$list['ID']]['picture'] = '<img src="/bitrix/images/lists/default.png" width="19" height="16" border="0" />'; } } } if (!empty($listData)) { $this->sendJsonSuccessResponse(array('lists' => $listData)); } else { $this->errorCollection->add(array(new Error(Loc::getMessage('LISTS_SEAC_NOT_PROCESSES')))); $this->sendJsonErrorResponse(); } }
protected function getIblockData() { $this->arResult['LIST_DATA'] = array(); $lists = CIBlock::getList(array("SORT" => "ASC", "NAME" => "ASC"), array('ACTIVE' => 'Y', 'ID' => $this->arResult['IBLOCK_ID'])); while ($list = $lists->fetch()) { if (CLists::getLiveFeed($list['ID'])) { $this->arResult['LIST_DATA']['ID'] = $list['ID']; $this->arResult['LIST_DATA']['NAME'] = $list['NAME']; $this->arResult['LIST_DATA']['DESCRIPTION'] = $list['DESCRIPTION']; $this->arResult['LIST_DATA']['CODE'] = $list['CODE']; if ($list['PICTURE'] > 0) { $imageFile = CFile::GetFileArray($list['PICTURE']); if ($imageFile !== false) { $this->arResult['LIST_DATA']['PICTURE'] = '<img src="' . $imageFile["SRC"] . '" width="36" height="30" border="0" />'; $this->arResult['LIST_DATA']['PICTURE_SMALL'] = '<img src="' . $imageFile["SRC"] . '" width="19" height="16" border="0" />'; } } else { $this->arResult['LIST_DATA']['PICTURE'] = "<img src=\"/bitrix/images/lists/default.png\" width=\"36\" height=\"30\" border=\"0\" />"; $this->arResult['LIST_DATA']['PICTURE_SMALL'] = "<img src=\"/bitrix/images/lists/default.png\" width=\"19\" height=\"16\" border=\"0\" />"; } } } }
$permissions['new'] = GetMessage("CC_BLL_TITLE_NEW_LIST"); $permissions['market'] = GetMessage("CC_BLL_TITLE_MARKETPLACE_NEW"); $permissions['settings'] = GetMessage("CC_BLL_TITLE_SETTINGS"); $admin = true; } elseif ($listsPerm >= CListPermissions::CAN_READ) { $permissions['market'] = GetMessage("CC_BLL_TITLE_MARKETPLACE_NEW"); $permissions['settings'] = GetMessage("CC_BLL_TITLE_SETTINGS"); } $listData = array(); $siteId = true; if ($_POST['siteId']) { $siteId = $_POST['siteId']; } $lists = CIBlock::getList(array("SORT" => "ASC", "NAME" => "ASC"), array("ACTIVE" => "Y", "TYPE" => COption::GetOptionString("lists", "livefeed_iblock_type_id"), 'SITE_ID' => $siteId)); while ($list = $lists->fetch()) { if (CLists::getLiveFeed($list['ID'])) { $listData[$list['ID']]['ID'] = $list['ID']; $shortName = substr($list['NAME'], 0, 50); if ($shortName == $list['NAME']) { $listData[$list['ID']]['NAME'] = $list['NAME']; } else { $listData[$list['ID']]['NAME'] = $shortName . '...'; } $listData[$list['ID']]['DESCRIPTION'] = $list['DESCRIPTION']; $listData[$list['ID']]['CODE'] = $list['CODE']; if ($list['PICTURE'] > 0) { $imageFile = CFile::GetFileArray($list['PICTURE']); if ($imageFile !== false) { $listData[$list['ID']]['PICTURE'] = '<img src="' . $imageFile["SRC"] . '" width="36" height="30" border="0" />'; $listData[$list['ID']]['PICTURE_SMALL'] = '<img src="' . $imageFile["SRC"] . '" width="19" height="16" border="0" />'; }
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; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $defaultImg = "<img src=\"/bitrix/images/lists/nopic_list_150.png\" width=\"36\" height=\"30\" border=\"0\" alt=\"\" />"; if ($arParams["IBLOCK_TYPE_ID"] == COption::GetOptionString("lists", "livefeed_iblock_type_id")) { $defaultImg = "<img src=\"/bitrix/images/lists/default.png\" width=\"36\" height=\"30\" border=\"0\" alt=\"\" />"; } foreach ($arResult["ITEMS"] as $key => $item) { if ($item["PICTURE"] > 0) { $imageFile = CFile::GetFileArray($item["PICTURE"]); if ($imageFile !== false) { $imageFile = CFile::ResizeImageGet($imageFile, array("width" => 36, "height" => 30), BX_RESIZE_IMAGE_PROPORTIONAL, false); $arResult["ITEMS"][$key]["IMAGE"] = '<img src="' . $imageFile["src"] . '" width="36" height="30" border="0" />'; } } if (!$arResult["ITEMS"][$key]["IMAGE"]) { $arResult["ITEMS"][$key]["IMAGE"] = $defaultImg; } if ($arParams["IBLOCK_TYPE_ID"] == COption::GetOptionString("lists", "livefeed_iblock_type_id")) { $arResult["ITEMS"][$key]["SHOW_LIVE_FEED"] = CLists::getLiveFeed($item['ID']); } }