1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
taskentity.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Forum\Comments;
4
5
use Bitrix\Main\Config\Option;
6
use Bitrix\Main\Loader;
7
8
final
class
TaskEntity
extends
Entity
9
{
10
public
const
ENTITY_TYPE
=
'tk'
;
11
const
MODULE_ID
=
'tasks'
;
12
public
const
XML_ID_PREFIX
=
'TASK_'
;
13
14
private
$taskPostData;
15
private
$hasAccess;
16
17
protected
static
$permissions
=
array
();
18
23
public
function
canRead
(
$userId
)
24
{
25
// you are not allowed to view the task, so you can not read messages
26
if
(!$this->checkHasAccess(
$userId
))
27
{
28
return
false
;
29
}
30
31
return
true
;
32
}
33
37
public
function
canAdd
(
$userId
)
38
{
39
// you are not allowed to view the task, so you can not add new messages
40
if
(!$this->checkHasAccess(
$userId
))
41
{
42
return
false
;
43
}
44
45
return
true
;
46
}
47
52
public
function
canEditOwn
(
$userId
)
53
{
55
// in case of canEdit($userId) returns FALSE, canEditOwn($userId) may override this
56
57
// if you are not an admin, you must obey "tasks" module settings
58
if
(!static::checkEditOptionIsOn())
59
{
60
return
false
;
61
}
62
63
// if you are not an admin AND you are not allowed to view the task, you cant edit even your own comments
64
if
(!$this->checkHasAccess(
$userId
))
65
{
66
return
false
;
67
}
68
69
return
true
;
70
}
71
76
public
function
canEdit
(
$userId
)
77
{
78
// admin is always able to edit\remove comments
79
if
(
80
Loader::includeModule
(
"tasks"
)
81
&& (
82
\CTasksTools::isAdmin(
$userId
)
83
|| \CTasksTools::isPortalB24Admin(
$userId
)
84
)
85
)
86
{
87
return
true
;
88
}
89
90
return
false
;
91
}
92
96
public
function
dropCache
()
97
{
98
$this->taskPostData =
null
;
99
$this->hasAccess =
null
;
100
return
$this;
101
}
102
107
private
function
checkHasAccess(
$userId
)
108
{
109
if
($this->hasAccess ===
null
)
110
{
111
try
112
{
113
if
(
Loader::includeModule
(
"tasks"
))
114
{
115
$task = new \CTaskItem($this->
getId
(),
$userId
);
116
$this->hasAccess = $task->checkCanRead();
117
}
118
else
119
{
120
return
false
;
121
}
122
123
}
124
catch
(\TasksException | \CTaskAssertException $e)
125
{
126
return
false
;
127
}
128
}
129
130
return
$this->hasAccess;
131
}
132
133
private
static
function
checkEditOptionIsOn()
134
{
135
$value
= Option::get(
"tasks"
,
"task_comment_allow_edit"
);
136
137
return
$value
==
'Y'
||
$value
==
'1'
;
138
}
139
147
public
static
function
onMessageIsIndexed
($id,
array
$message
,
array
&$index)
148
{
149
if
(
$message
[
"PARAM1"
] == mb_strtoupper(self::ENTITY_TYPE))
150
{
151
return
false
;
152
}
153
154
if
(
155
preg_match(
"/"
.self::getXmlIdPrefix().
"(\\d+)/"
,
$message
[
"XML_ID"
],
$matches
) &&
156
($taskId = intval(
$matches
[1])) &&
157
$taskId > 0 &&
158
!array_key_exists($taskId, self::$permissions)
159
)
160
{
161
self::$permissions[$taskId] = [];
162
if
($task = \CTasks::GetList(
array
(),
array
(
"ID"
=> $taskId))->fetch())
163
{
164
self::$permissions[$taskId] = \CTasks::__GetSearchPermissions($task);
165
}
166
}
167
168
$index[
"PERMISSIONS"
] = self::$permissions[$taskId];
169
return
sizeof
(self::$permissions[$taskId]) > 0;
170
}
171
}
$userId
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения
check_mail.php:18
Bitrix\Forum\Comments\Entity\getId
getId()
Определения
entity.php:45
Bitrix\Forum\Comments\TaskEntity
Определения
taskentity.php:9
Bitrix\Forum\Comments\TaskEntity\canEdit
canEdit($userId)
Определения
taskentity.php:76
Bitrix\Forum\Comments\TaskEntity\XML_ID_PREFIX
const XML_ID_PREFIX
Определения
taskentity.php:12
Bitrix\Forum\Comments\TaskEntity\MODULE_ID
const MODULE_ID
Определения
taskentity.php:11
Bitrix\Forum\Comments\TaskEntity\dropCache
dropCache()
Определения
taskentity.php:96
Bitrix\Forum\Comments\TaskEntity\onMessageIsIndexed
static onMessageIsIndexed($id, array $message, array &$index)
Определения
taskentity.php:147
Bitrix\Forum\Comments\TaskEntity\canRead
canRead($userId)
Определения
taskentity.php:23
Bitrix\Forum\Comments\TaskEntity\canAdd
canAdd($userId)
Определения
taskentity.php:37
Bitrix\Forum\Comments\TaskEntity\ENTITY_TYPE
const ENTITY_TYPE
Определения
taskentity.php:10
Bitrix\Forum\Comments\TaskEntity\$permissions
static $permissions
Определения
taskentity.php:17
Bitrix\Forum\Comments\TaskEntity\canEditOwn
canEditOwn($userId)
Определения
taskentity.php:52
Bitrix\Main\Loader\includeModule
static includeModule($moduleName)
Определения
loader.php:67
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Im\V2\Chat\Param\$value
$value
Определения
Param.php:39
Bitrix\Main\Entity
Определения
ufield.php:9
$message
$message
Определения
payment.php:8
$matches
$matches
Определения
index.php:22
bitrix
modules
forum
lib
comments
taskentity.php
Создано системой
1.14.0