1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
timemanentry.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\Livefeed;
4
5use Bitrix\Main\Config\Option;
6use Bitrix\Main\Loader;
7use Bitrix\Main\Localization\Loc;
8use Bitrix\Timeman\Model\Worktime\Record\WorktimeRecordTable;
9
10Loc::loadMessages(__FILE__);
11
12final class TimemanEntry extends Provider
13{
14 public const PROVIDER_ID = 'TIMEMAN_ENTRY';
15 public const CONTENT_TYPE_ID = 'TIMEMAN_ENTRY';
16
17 public static function getId(): string
18 {
19 return static::PROVIDER_ID;
20 }
21
22 public function getEventId(): array
23 {
24 return [ 'timeman_entry' ];
25 }
26
27 public function getType(): string
28 {
30 }
31
32 public function getCommentProvider(): Provider
33 {
34 return new ForumPost();
35 }
36
37 public function initSourceFields()
38 {
39 static $cache = [];
40
41 $timemanEntryId = $this->entityId;
42
43 if ($timemanEntryId <= 0)
44 {
45 return;
46 }
47
48 if (isset($cache[$timemanEntryId]))
49 {
50 $timemanEntry = $cache[$timemanEntryId];
51 }
52 elseif (Loader::includeModule('timeman'))
53 {
54 $res = WorktimeRecordTable::getList([
55 'filter' => [
56 'ID' => $timemanEntryId
57 ],
58 'select' => [ 'ID', 'USER_ID', 'DATE_START', 'APPROVED_BY' ]
59 ]);
60 $timemanEntry = $res->fetch();
61 $cache[$timemanEntryId] = $timemanEntry;
62 }
63
64 if (!empty($timemanEntry))
65 {
66 $this->setSourceFields($timemanEntry);
67
68 $userName = '';
69 $res = \CUser::getById($timemanEntry['USER_ID']);
70 if ($userFields = $res->fetch())
71 {
72 $userName = \CUser::formatName(
73 \CSite::getNameFormat(),
74 $userFields,
75 true,
76 false
77 );
78 }
79
80 $this->setSourceTitle(Loc::getMessage('SONET_LIVEFEED_TIMEMAN_ENTRY_TITLE', [
81 '#USER_NAME#' => $userName,
82 '#DATE#' => FormatDate('j F', makeTimeStamp($timemanEntry['DATE_START']))
83 ]));
84 }
85 else
86 {
87 $this->setSourceTitle($this->getUnavailableTitle());
88 }
89 }
90
91 public function getPinnedDescription(): string
92 {
93 $result = '';
94
95 if (empty($this->sourceFields))
96 {
97 $this->initSourceFields();
98 }
99
100 $timemanEntry = $this->getSourceFields();
101 if (empty($timemanEntry))
102 {
103 return $result;
104 }
105
106 return (string)Loc::getMessage((int)$timemanEntry['APPROVED_BY'] <= 0 ? 'SONET_LIVEFEED_TIMEMAN_ENTRY_PINNED_DESCRIPTION' : 'SONET_LIVEFEED_TIMEMAN_ENTRY_PINNED_DESCRIPTION2');
107 }
108
109 public static function canRead($params): bool
110 {
111 return true;
112 }
113
114 protected function getPermissions(array $post): string
115 {
116 return self::PERMISSION_READ;
117 }
118
119 public function getLiveFeedUrl(): string
120 {
121 $pathToLogEntry = '';
122
123 $logId = $this->getLogId();
124 if ($logId)
125 {
126 $pathToLogEntry = Option::get('socialnetwork', 'log_entry_page', '', $this->getSiteId());
127 if (!empty($pathToLogEntry))
128 {
129 $pathToLogEntry = \CComponentEngine::makePathFromTemplate($pathToLogEntry, [ 'log_id' => $logId ]);
130 }
131 }
132 return $pathToLogEntry;
133 }
134}
Определения forumpost.php:22
setSourceFields(array $fields)
Определения provider.php:639
getLogId($params=[])
Определения provider.php:336
Определения timemanentry.php:13
initSourceFields()
Определения timemanentry.php:37
getCommentProvider()
Определения timemanentry.php:32
const CONTENT_TYPE_ID
Определения timemanentry.php:15
getPermissions(array $post)
Определения timemanentry.php:114
getType()
Определения timemanentry.php:27
getLiveFeedUrl()
Определения timemanentry.php:119
getEventId()
Определения timemanentry.php:22
static canRead($params)
Определения timemanentry.php:109
static getId()
Определения timemanentry.php:17
const PROVIDER_ID
Определения timemanentry.php:14
getPinnedDescription()
Определения timemanentry.php:91
static makePathFromTemplate($template, $arParams=array())
Определения component_engine.php:355
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
FormatDate($format="", $timestamp=false, $now=false, ?string $languageId=null)
Определения tools.php:871
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
else $userName
Определения order_form.php:75
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$post
Определения template.php:8