Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/socialnetwork/lib/livefeed/ |
Upload File : |
<?php namespace Bitrix\Socialnetwork\Livefeed; use Bitrix\Main\Config\Option; use Bitrix\Main\Loader; use Bitrix\Main\Localization\Loc; use Bitrix\Timeman\Model\Worktime\Record\WorktimeRecordTable; Loc::loadMessages(__FILE__); final class TimemanEntry extends Provider { public const PROVIDER_ID = 'TIMEMAN_ENTRY'; public const CONTENT_TYPE_ID = 'TIMEMAN_ENTRY'; public static function getId(): string { return static::PROVIDER_ID; } public function getEventId(): array { return [ 'timeman_entry' ]; } public function getType(): string { return Provider::TYPE_POST; } public function getCommentProvider(): Provider { return new ForumPost(); } public function initSourceFields() { static $cache = []; $timemanEntryId = $this->entityId; if ($timemanEntryId <= 0) { return; } if (isset($cache[$timemanEntryId])) { $timemanEntry = $cache[$timemanEntryId]; } elseif (Loader::includeModule('timeman')) { $res = WorktimeRecordTable::getList([ 'filter' => [ 'ID' => $timemanEntryId ], 'select' => [ 'ID', 'USER_ID', 'DATE_START', 'APPROVED_BY' ] ]); $timemanEntry = $res->fetch(); $cache[$timemanEntryId] = $timemanEntry; } if (!empty($timemanEntry)) { $this->setSourceFields($timemanEntry); $userName = ''; $res = \CUser::getById($timemanEntry['USER_ID']); if ($userFields = $res->fetch()) { $userName = \CUser::formatName( \CSite::getNameFormat(), $userFields, true, false ); } $this->setSourceTitle(Loc::getMessage('SONET_LIVEFEED_TIMEMAN_ENTRY_TITLE', [ '#USER_NAME#' => $userName, '#DATE#' => FormatDate('j F', makeTimeStamp($timemanEntry['DATE_START'])) ])); } else { $this->setSourceTitle($this->getUnavailableTitle()); } } public function getPinnedDescription(): string { $result = ''; if (empty($this->sourceFields)) { $this->initSourceFields(); } $timemanEntry = $this->getSourceFields(); if (empty($timemanEntry)) { return $result; } return (string)Loc::getMessage((int)$timemanEntry['APPROVED_BY'] <= 0 ? 'SONET_LIVEFEED_TIMEMAN_ENTRY_PINNED_DESCRIPTION' : 'SONET_LIVEFEED_TIMEMAN_ENTRY_PINNED_DESCRIPTION2'); } public static function canRead($params): bool { return true; } protected function getPermissions(array $post): string { return self::PERMISSION_READ; } public function getLiveFeedUrl(): string { $pathToLogEntry = ''; $logId = $this->getLogId(); if ($logId) { $pathToLogEntry = Option::get('socialnetwork', 'log_entry_page', '', $this->getSiteId()); if (!empty($pathToLogEntry)) { $pathToLogEntry = \CComponentEngine::makePathFromTemplate($pathToLogEntry, [ 'log_id' => $logId ]); } } return $pathToLogEntry; } }