Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
taskstask.php
1
<?php
2
namespace
Bitrix\Socialnetwork\Livefeed
;
3
4
use
Bitrix\Main\Loader
;
5
use
Bitrix\Main\Config\Option
;
6
use
Bitrix\Main\Localization\Loc
;
7
8
Loc::loadMessages
(__FILE__);
9
10
final
class
TasksTask
extends
Provider
11
{
12
public
const
PROVIDER_ID
=
'TASK'
;
13
public
const
CONTENT_TYPE_ID
=
'TASK'
;
14
15
protected
static
$tasksTaskClass
= \CTasks::class;
16
17
public
static
function
getId
(): string
18
{
19
return
static::PROVIDER_ID;
20
}
21
22
public
function
getEventId
(): array
23
{
24
return
[
25
'tasks'
,
26
'crm_activity_add'
27
];
28
}
29
30
public
function
getType
(): string
31
{
32
return
Provider::TYPE_POST
;
33
}
34
35
public
function
getCommentProvider
():
Provider
36
{
37
return
new
ForumPost
();
38
}
39
40
public
function
initSourceFields
()
41
{
42
static
$cache = [];
43
44
$taskId =
$this->entityId
;
45
46
if
($taskId <= 0)
47
{
48
return
;
49
}
50
51
$checkAccess = ($this->
getOption
(
'checkAccess'
) !==
false
);
52
$cacheKey = $taskId .
'_'
. ($checkAccess ?
'Y'
:
'N'
);
53
54
if
(isset($cache[$cacheKey]))
55
{
56
$task = $cache[$cacheKey];
57
}
58
elseif (Loader::includeModule(
'tasks'
))
59
{
60
$res = self::$tasksTaskClass::getByID($taskId, $checkAccess);
61
$task = $res->fetch();
62
$cache[$cacheKey] = $task;
63
}
64
65
if
(empty($task))
66
{
67
return
;
68
}
69
70
$this->
setSourceFields
($task);
71
$this->
setSourceDescription
($task[
'DESCRIPTION'
]);
72
$this->
setSourceTitle
($task[
'TITLE'
]);
73
$this->
setSourceAttachedDiskObjects
($this->
getAttachedDiskObjects
($this->cloneDiskObjects));
74
$this->
setSourceDiskObjects
($this->
getDiskObjects
($taskId, $this->cloneDiskObjects));
75
76
}
77
78
public
function
getPinnedTitle
(): string
79
{
80
$result =
''
;
81
82
if
(empty($this->sourceFields))
83
{
84
$this->
initSourceFields
();
85
}
86
87
$task = $this->
getSourceFields
();
88
if
(empty($task))
89
{
90
return
$result;
91
}
92
93
return
(
string
)
Loc::getMessage
(
'SONET_LIVEFEED_TASKS_TASK_PINNED_TITLE'
, [
94
'#TITLE#'
=> $task[
'TITLE'
]
95
]);
96
}
97
98
public
function
getPinnedDescription
(): string
99
{
100
$result =
''
;
101
102
if
(empty($this->sourceFields))
103
{
104
$this->
initSourceFields
();
105
}
106
107
$task = $this->
getSourceFields
();
108
if
(empty($task))
109
{
110
return
$result;
111
}
112
113
return
(
string
)
Loc::getMessage
(
'SONET_LIVEFEED_TASKS_TASK_PINNED_DESCRIPTION'
, [
114
'#RESPONSIBLE#'
=> \CUser::formatName(
115
\CSite::getNameFormat(),
116
[
117
'NAME'
=> $task[
'RESPONSIBLE_NAME'
],
118
'LAST_NAME'
=> $task[
'RESPONSIBLE_LAST_NAME'
],
119
'SECOND_NAME'
=> $task[
'RESPONSIBLE_SECOND_NAME'
]
120
],
121
true
,
122
false
123
)
124
]);
125
}
126
127
protected
function
getAttachedDiskObjects
($clone =
false
): array
128
{
129
return
$this->
getEntityAttachedDiskObjects
([
130
'userFieldEntity'
=>
'TASKS_TASK'
,
131
'userFieldCode'
=>
'UF_TASK_WEBDAV_FILES'
,
132
'clone'
=> $clone,
133
]);
134
}
135
136
public
static
function
canRead
($params): bool
137
{
138
return
true
;
139
}
140
141
protected
function
getPermissions
(array $post): string
142
{
143
return
self::PERMISSION_READ
;
144
}
145
146
public
function
getLiveFeedUrl
(): string
147
{
148
$pathToTask =
''
;
149
$userPage = Option::get(
'socialnetwork'
,
'user_page'
,
''
, SITE_ID);
150
if
(
151
!empty($userPage)
152
&& ($task = $this->
getSourceFields
())
153
&& !empty($task)
154
)
155
{
156
$pathToTask = \CComponentEngine::makePathFromTemplate($userPage.
"user/#user_id#/tasks/task/#action#/#task_id#/"
, array(
157
"user_id"
=> $task[
"CREATED_BY"
],
158
"action"
=>
"view"
,
159
"task_id"
=> $task[
"ID"
]
160
));
161
}
162
163
return
$pathToTask;
164
}
165
}
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\setSourceFields
setSourceFields(array $fields)
Definition
provider.php:627
Bitrix\Socialnetwork\Livefeed\Provider\getOption
getOption(string $key)
Definition
provider.php:115
Bitrix\Socialnetwork\Livefeed\Provider\setSourceTitle
setSourceTitle($title)
Definition
provider.php:665
Bitrix\Socialnetwork\Livefeed\Provider\setSourceDiskObjects
setSourceDiskObjects(array $files)
Definition
provider.php:744
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\setSourceAttachedDiskObjects
setSourceAttachedDiskObjects(array $diskAttachedObjects)
Definition
provider.php:739
Bitrix\Socialnetwork\Livefeed\Provider\getEntityAttachedDiskObjects
getEntityAttachedDiskObjects(array $params=[])
Definition
provider.php:1477
Bitrix\Socialnetwork\Livefeed\Provider\TYPE_POST
const TYPE_POST
Definition
provider.php:25
Bitrix\Socialnetwork\Livefeed\Provider\setSourceDescription
setSourceDescription($description)
Definition
provider.php:642
Bitrix\Socialnetwork\Livefeed\Provider\$entityId
$entityId
Definition
provider.php:52
Bitrix\Socialnetwork\Livefeed\Provider\getDiskObjects
getDiskObjects($entityId, $clone=false)
Definition
provider.php:822
Bitrix\Socialnetwork\Livefeed\TasksTask
Definition
taskstask.php:11
Bitrix\Socialnetwork\Livefeed\TasksTask\initSourceFields
initSourceFields()
Definition
taskstask.php:40
Bitrix\Socialnetwork\Livefeed\TasksTask\getCommentProvider
getCommentProvider()
Definition
taskstask.php:35
Bitrix\Socialnetwork\Livefeed\TasksTask\CONTENT_TYPE_ID
const CONTENT_TYPE_ID
Definition
taskstask.php:13
Bitrix\Socialnetwork\Livefeed\TasksTask\getPinnedTitle
getPinnedTitle()
Definition
taskstask.php:78
Bitrix\Socialnetwork\Livefeed\TasksTask\getPermissions
getPermissions(array $post)
Definition
taskstask.php:141
Bitrix\Socialnetwork\Livefeed\TasksTask\getAttachedDiskObjects
getAttachedDiskObjects($clone=false)
Definition
taskstask.php:127
Bitrix\Socialnetwork\Livefeed\TasksTask\getType
getType()
Definition
taskstask.php:30
Bitrix\Socialnetwork\Livefeed\TasksTask\getLiveFeedUrl
getLiveFeedUrl()
Definition
taskstask.php:146
Bitrix\Socialnetwork\Livefeed\TasksTask\getEventId
getEventId()
Definition
taskstask.php:22
Bitrix\Socialnetwork\Livefeed\TasksTask\canRead
static canRead($params)
Definition
taskstask.php:136
Bitrix\Socialnetwork\Livefeed\TasksTask\$tasksTaskClass
static $tasksTaskClass
Definition
taskstask.php:15
Bitrix\Socialnetwork\Livefeed\TasksTask\getId
static getId()
Definition
taskstask.php:17
Bitrix\Socialnetwork\Livefeed\TasksTask\PROVIDER_ID
const PROVIDER_ID
Definition
taskstask.php:12
Bitrix\Socialnetwork\Livefeed\TasksTask\getPinnedDescription
getPinnedDescription()
Definition
taskstask.php:98
Bitrix\Socialnetwork\Livefeed
Definition
bitrix24newuser.php:3
modules
socialnetwork
lib
livefeed
taskstask.php
Создано системой
1.10.0