1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
createtask.php
См. документацию.
1<?php
2
3namespace Bitrix\Socialnetwork\CommentAux;
4
5use Bitrix\Main\Config\Option;
6use Bitrix\Main\Loader;
7use Bitrix\Main\Localization\Loc;
8use Bitrix\Main\Web\Uri;
9use Bitrix\Tasks\Slider\Path\PathMaker;
10use Bitrix\Tasks\Slider\Path\TaskPathMaker;
11
12Loc::loadMessages(__FILE__);
13
15{
16 public const TYPE = 'CREATETASK';
17 public const POST_TEXT = 'commentAuxCreateTask';
18
19 public function getText(): string
20 {
21 static $userPage = null;
22 static $parser = null;
23
24 $result = '';
27
28 $siteId = (!empty($options['siteId']) ? $options['siteId'] : SITE_ID);
29
30 if (
31 !isset($params['sourcetype'], $params['sourceid'], $params['taskid'])
32 || (int)$params['sourceid'] <= 0
33 || (int)$params['taskid'] <= 0
34 || !in_array($params['sourcetype'], $this->getSourceTypeList(), true)
35 )
36 {
37 return $result;
38 }
39
40 if ($provider = $this->getLivefeedProvider())
41 {
42 $options['suffix'] = $provider->getSuffix($options['suffix']);
43 }
44
45 if ($userPage === null)
46 {
47 $userPage = Option::get(
48 'socialnetwork',
49 'user_page',
50 SITE_DIR . 'company/personal/',
52 ) . 'user/#user_id#/';
53 }
54
55 $taskPath = '';
56 if ($task = $this->getTask($params['taskid'], false))
57 {
58 if (
59 (!isset($options['cache']) || !$options['cache'])
60 && (!isset($options['im']) || !$options['im'])
61 && (!isset($options['bPublicPage']) || !$options['bPublicPage'])
62 )
63 {
64 $taskPath = (new TaskPathMaker((int)$task['ID'], PathMaker::DEFAULT_ACTION, (int)$task['RESPONSIBLE_ID']))->makeEntityPath();
65 }
66
67 if (!empty($taskPath))
68 {
69 $taskUri = new Uri($taskPath);
70 $taskUri->addParams([
71 'ta_sec' => 'comment',
72 'ta_el' => 'title_click',
73 ]);
74 $taskPath = $taskUri->getUri();
75 }
76
77 $taskTitle = $task['TITLE'];
78 }
79 else
80 {
81 $taskTitle = Loc::getMessage('SONET_COMMENTAUX_CREATETASK_NOT_FOUND');
82 }
83
84 if (in_array($params['sourcetype'], $this->getCommentTypeList(), true))
85 {
86 $sourceData = $this->getSourceCommentData([
87 'userPage' => $userPage,
88 ]);
89
90 $suffix = (
91 $options['suffix']
92 ? '_' . $options['suffix']
93 : (!empty($sourceData['suffix']) ? '_' . $sourceData['suffix'] : '')
94 );
95
96 $result = Loc::getMessage('SONET_COMMENTAUX_CREATETASK_COMMENT_' . $params['sourcetype'] . $suffix, [
97 '#TASK_NAME#' => (!empty($taskPath) ? '[URL=' . $taskPath . ']' . $taskTitle . '[/URL]' : $taskTitle),
98 '#A_BEGIN#' => (!empty($sourceData['path']) ? '[URL=' . $sourceData['path'] . ']' : ''),
99 '#A_END#' => (!empty($sourceData['path']) ? '[/URL]' : '')
100 ]);
101 }
102 elseif (in_array($params['sourcetype'], $this->getPostTypeList(), true))
103 {
104 $suffix = ($options['suffix'] ?? ($params['sourcetype'] === static::SOURCE_TYPE_BLOG_POST ? '2' : ''));
105
106 $result = Loc::getMessage('SONET_COMMENTAUX_CREATETASK_POST_' . $params['sourcetype'].(!empty($suffix) ? '_' . $suffix : ''), [
107 '#TASK_NAME#' => (!empty($taskPath) ? '[URL='.$taskPath.']'.$taskTitle.'[/URL]' : $taskTitle),
108 ]);
109 }
110
111 if (!empty($result))
112 {
113 if ($parser === null)
114 {
115 $parser = new \CTextParser();
116 $parser->allow = [ 'HTML' => 'N', 'ANCHOR' => 'Y' ];
117 }
118 $result = $parser->convertText($result);
119 }
120
121 return $result;
122 }
123
124 public function checkRecalcNeeded($fields, $params): bool
125 {
126 $result = false;
127
128 if (
129 !empty($params['bPublicPage'])
130 && $params['bPublicPage']
131 )
132 {
133 $result = true;
134 }
135 else
136 {
137 $handlerParams = $this->getParamsFromFields($fields);
138
139 if (
140 !empty($handlerParams)
141 && !empty($handlerParams['taskid'])
142 && (int)$handlerParams['taskid'] > 0
143 && ($this->getTask((int)$handlerParams['taskid']))
144 )
145 {
146 $result = true;
147 }
148 }
149
150 return $result;
151 }
152
153 public function getTask($taskId, $checkPermissions = true)
154 {
155 static $cache = array(
156 'Y' => [],
157 'N' => [],
158 );
159
160 $result = false;
161 $permissionCacheKey = ($checkPermissions ? 'Y' : 'N');
162
163 if (isset($cache[$permissionCacheKey][$taskId]))
164 {
165 $result = $cache[$permissionCacheKey][$taskId];
166 }
167 elseif (Loader::includeModule('tasks'))
168 {
169 $res = \CTasks::getByID((int)$taskId, $checkPermissions);
170 if ($task = $res->fetch())
171 {
172 $result = $cache[$permissionCacheKey][$taskId] = $task;
173 }
174 elseif(!$checkPermissions)
175 {
176 $result = $cache[$permissionCacheKey][$taskId] = false;
177 }
178 }
179
180 return $result;
181 }
182
183 protected function getForumType(): string
184 {
185 return \Bitrix\Forum\Comments\Service\Manager::TYPE_TASK_CREATED;
186 }
187
188 protected function getForumServiceData(array $commentData = [])
189 {
190 return (!empty($commentData['SERVICE_DATA']) ? $commentData['SERVICE_DATA'] : $commentData['POST_MESSAGE']);
191 }
192
193 protected function getForumMessageFields(): array
194 {
195 return [ 'SERVICE_DATA', 'POST_MESSAGE' ];
196 }
197
198 protected function getSocNetData($data = ''): array
199 {
200 $result = [];
201
202 $paramsList = explode('|', $data);
203
204 if (!empty($paramsList))
205 {
206 foreach ($paramsList as $pair)
207 {
208 [ $key, $value ] = explode('=', $pair);
209 if (isset($key, $value))
210 {
211 $result[$key] = $value;
212 }
213 }
214 }
215
216 return $result;
217 }
218}
if(!Loader::includeModule('messageservice')) $provider
Определения callback_ednaruimhpx.php:21
Определения uri.php:17
getSourceCommentData(array $additionalParams=[])
Определения createentity.php:537
checkRecalcNeeded($fields, $params)
Определения createtask.php:124
getTask($taskId, $checkPermissions=true)
Определения createtask.php:153
getForumServiceData(array $commentData=[])
Определения createtask.php:188
$data['IS_AVAILABLE']
Определения .description.php:13
</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
const SITE_DIR(!defined('LANG'))
Определения include.php:72
$siteId
Определения ajax.php:8
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
const SITE_ID
Определения sonet_set_content_view.php:12
$fields
Определения yandex_run.php:501