Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
taskstask.php
1<?php
3
7
8Loc::loadMessages(__FILE__);
9
10final 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 {
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 {
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}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
Definition forumpost.php:22
setSourceAttachedDiskObjects(array $diskAttachedObjects)
Definition provider.php:739
getEntityAttachedDiskObjects(array $params=[])
getDiskObjects($entityId, $clone=false)
Definition provider.php:822