Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
calendarentity.php
1<?php
2
4
7
8final class CalendarEntity extends Entity
9{
10 public const ENTITY_TYPE = 'ev';
11 const MODULE_ID = 'calendar';
12 public const XML_ID_PREFIX = 'EVENT_';
13
14 protected static $permissions = array();
15
16 private $canRead = null;
21 public function canRead($userId)
22 {
23 if($this->canRead !== null)
24 {
25 return $this->canRead;
26 }
27 $this->canRead = \CCalendarEvent::canView($this->getId(), $userId);
28
29 return $this->canRead;
30 }
35 public function canAdd($userId)
36 {
37 return $this->canRead($userId);
38 }
39
44 public function canEditOwn($userId)
45 {
46 return true;
47 }
48
53 public function canEdit($userId)
54 {
55 return false;
56 }
64 public static function onMessageIsIndexed($id, array $message, array &$index)
65 {
66 // not index yet because I do not have API from Calendar
67 return false;
68
69 if (!empty($message["PARAM1"]) || !empty($message["PARAM2"]))
70 return false;
71
72 if (
73 preg_match("/".self::getXmlIdPrefix()."(\\d+)(*.?)/", $message["XML_ID"], $matches) &&
74 ($eventId = intval($matches[1])) &&
75 $eventId > 0
76 )
77 {
78 if (!array_key_exists($eventId, self::$permissions))
79 {
80 self::$permissions[$eventId] = array();
81 }
82 $index["PERMISSIONS"] = self::$permissions[$eventId];
83 }
84 return true;
85 }
86}
static onMessageIsIndexed($id, array $message, array &$index)