23 private $editOwn =
false;
24 protected static $pathToUser =
'/company/personal/user/#user_id#/';
36 $this->entity = array(
37 "type" => $entity[
"type"],
38 "id" => $entity[
"id"],
39 "xml_id" => $entity[
"xml_id"]
41 $this->forum = $storage;
42 $this->editOwn = (\COption::GetOptionString(
"forum",
"USER_EDIT_OWN_POST",
"Y") ==
"Y");
47 return $this->entity[
"id"];
52 return $this->entity[
"type"];
57 if (!empty($this->entity[
"xml_id"]))
58 return $this->entity[
"xml_id"];
59 return mb_strtoupper($this->entity[
"type"].
"_".$this->entity[
"id"]);
72 return get_called_class();
77 return static::MODULE_ID;
82 return static::ENTITY_TYPE;
87 return static::XML_ID_PREFIX;
141 if (is_string($permission))
143 if (!isset(self::$permissions[$userId]))
144 self::$permissions[$userId] = [];
145 self::$permissions[$userId][$this->forum[
"ID"]] = $permission;
156 $this->editOwn = $permission;
166 if (!array_key_exists($userId, self::$permissions))
168 self::$permissions[$userId] = [];
169 if (!array_key_exists($this->forum[
"ID"], self::$permissions[$userId]))
171 if (\CForumUser::IsAdmin($userId))
173 else if ($this->forum[
"ACTIVE"] !=
"Y")
175 else if (\CForumUser::IsLocked($userId))
176 $result = \CForumNew::GetPermissionUserDefault($this->forum[
"ID"]);
179 if (in_array($this->
getType(), array(
'PH',
'TR',
'TM',
'IBLOCK')))
185 $res = ForumTable::getList(array(
187 '=ID' => $this->forum[
"ID"],
192 'select' => array(
'ID')
194 if ($forumFields = $res->fetch())
200 $result = \CForumNew::GetUserPermission($this->forum[
"ID"], $userId);
205 self::$permissions[$userId][$this->forum[
"ID"]] = $result;
208 return self::$permissions[$userId][$this->forum[
"ID"]];
216 $type = mb_strtolower($type);
227 $xmlId = mb_strtoupper($xmlId);
232 if (preg_match(
"/^".$entity[
"xmlIdPrefix"].
"(\\d+)/", $xmlId))
241 private static function getEntities()
243 if (!is_array(self::$entities))
245 self::$entities = array(
247 "entityType" =>
"tk",
248 "className" => TaskEntity::className(),
249 "moduleId" =>
"tasks",
250 "xmlIdPrefix" => TaskEntity::getXmlIdPrefix()),
252 "entityType" =>
"wf",
253 "className" => WorkflowEntity::className(),
254 "moduleId" =>
"lists",
255 "xmlIdPrefix" => WorkflowEntity::getXmlIdPrefix()),
257 "entityType" =>
"ev",
258 "className" => CalendarEntity::className(),
259 "moduleId" =>
"calendar",
260 "xmlIdPrefix" => CalendarEntity::getXmlIdPrefix()),
262 "entityType" =>
"tm",
263 "className" => Entity::className(),
264 "moduleId" =>
"timeman",
265 "xmlIdPrefix" =>
'TIMEMAN_ENTRY_'
268 "entityType" =>
"tr",
269 "className" => Entity::className(),
270 "moduleId" =>
"timeman",
271 "xmlIdPrefix" =>
'TIMEMAN_REPORT_'
274 "entityType" =>
"default",
275 "className" => Entity::className(),
276 "moduleId" =>
"forum",
277 "xmlIdPrefix" => Entity::getXmlIdPrefix()
281 $event =
new Event(
"forum",
"onBuildAdditionalEntitiesList");
284 foreach ($event->getResults() as $evenResult)
286 $result = $evenResult->getParameters();
287 if (!is_array($result))
289 throw new SystemException(
'Event onBuildAdditionalEntitiesList: result must be an array.');
292 foreach ($result as $connector)
294 if (empty($connector[
'ENTITY_TYPE']))
296 throw new SystemException(
'Event onBuildAdditionalEntitiesList: key ENTITY_TYPE is not found.');
299 if (empty($connector[
'MODULE_ID']))
301 throw new SystemException(
'Event onBuildAdditionalEntitiesList: key MODULE_ID is not found.');
304 if (empty($connector[
'CLASS']))
306 throw new SystemException(
'Event onBuildAdditionalEntitiesList: key CLASS is not found.');
309 if (is_string($connector[
'CLASS']) && class_exists($connector[
'CLASS']))
311 self::$entities[mb_strtolower($connector[
'ENTITY_TYPE'])] = array(
312 "id" => mb_strtolower($connector[
'ENTITY_TYPE']),
313 "className" => str_replace(
'\\\\',
'\\', $connector[
'CLASS']),
314 "moduleId" => $connector[
'MODULE_ID'],
315 "xmlIdPrefix" => mb_strtoupper($connector[
'ENTITY_TYPE']).
"_"
321 return self::$entities;
332 return (empty($message[
"PARAM1"]) && empty($message[
"PARAM2"]));