Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
timemanentry.php
1
<?php
2
3
namespace
Bitrix\Socialnetwork\Livefeed
;
4
5
use
Bitrix\Main\Config\Option
;
6
use
Bitrix\Main\Loader
;
7
use
Bitrix\Main\Localization\Loc
;
8
use Bitrix\Timeman\Model\Worktime\Record\WorktimeRecordTable;
9
10
Loc::loadMessages
(__FILE__);
11
12
final
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
{
29
return
Provider::TYPE_POST
;
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
}
Bitrix\Main\Config\Option
Definition
option.php:15
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Socialnetwork\Livefeed\ForumPost
Definition
forumpost.php:22
Bitrix\Socialnetwork\Livefeed\Provider
Definition
provider.php:22
Bitrix\Socialnetwork\Livefeed\Provider\$logId
$logId
Definition
provider.php:54
Bitrix\Socialnetwork\Livefeed\Provider\setSourceFields
setSourceFields(array $fields)
Definition
provider.php:627
Bitrix\Socialnetwork\Livefeed\Provider\getUnavailableTitle
getUnavailableTitle()
Definition
provider.php:1472
Bitrix\Socialnetwork\Livefeed\Provider\setSourceTitle
setSourceTitle($title)
Definition
provider.php:665
Bitrix\Socialnetwork\Livefeed\Provider\getSiteId
getSiteId()
Definition
provider.php:94
Bitrix\Socialnetwork\Livefeed\Provider\PERMISSION_READ
const PERMISSION_READ
Definition
provider.php:47
Bitrix\Socialnetwork\Livefeed\Provider\getSourceFields
getSourceFields()
Definition
provider.php:637
Bitrix\Socialnetwork\Livefeed\Provider\TYPE_POST
const TYPE_POST
Definition
provider.php:25
Bitrix\Socialnetwork\Livefeed\Provider\$entityId
$entityId
Definition
provider.php:52
Bitrix\Socialnetwork\Livefeed\Provider\getLogId
getLogId($params=[])
Definition
provider.php:333
Bitrix\Socialnetwork\Livefeed\TimemanEntry
Definition
timemanentry.php:13
Bitrix\Socialnetwork\Livefeed\TimemanEntry\initSourceFields
initSourceFields()
Definition
timemanentry.php:37
Bitrix\Socialnetwork\Livefeed\TimemanEntry\getCommentProvider
getCommentProvider()
Definition
timemanentry.php:32
Bitrix\Socialnetwork\Livefeed\TimemanEntry\CONTENT_TYPE_ID
const CONTENT_TYPE_ID
Definition
timemanentry.php:15
Bitrix\Socialnetwork\Livefeed\TimemanEntry\getPermissions
getPermissions(array $post)
Definition
timemanentry.php:114
Bitrix\Socialnetwork\Livefeed\TimemanEntry\getType
getType()
Definition
timemanentry.php:27
Bitrix\Socialnetwork\Livefeed\TimemanEntry\getLiveFeedUrl
getLiveFeedUrl()
Definition
timemanentry.php:119
Bitrix\Socialnetwork\Livefeed\TimemanEntry\getEventId
getEventId()
Definition
timemanentry.php:22
Bitrix\Socialnetwork\Livefeed\TimemanEntry\canRead
static canRead($params)
Definition
timemanentry.php:109
Bitrix\Socialnetwork\Livefeed\TimemanEntry\getId
static getId()
Definition
timemanentry.php:17
Bitrix\Socialnetwork\Livefeed\TimemanEntry\PROVIDER_ID
const PROVIDER_ID
Definition
timemanentry.php:14
Bitrix\Socialnetwork\Livefeed\TimemanEntry\getPinnedDescription
getPinnedDescription()
Definition
timemanentry.php:91
Bitrix\Socialnetwork\Livefeed
Definition
bitrix24newuser.php:3
modules
socialnetwork
lib
livefeed
timemanentry.php
Создано системой
1.10.0