Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
intranetnewuser.php
1<?php
2
4
12
13Loc::loadMessages(__FILE__);
14
16{
17 public const PROVIDER_ID = 'INTRANET_NEW_USER';
18 public const CONTENT_TYPE_ID = 'INTRANET_NEW_USER';
19
20 public static function getId(): string
21 {
22 return static::PROVIDER_ID;
23 }
24
25 public function getEventId(): array
26 {
27 return [ 'intranet_new_user' ];
28 }
29
30 public function getType(): string
31 {
33 }
34
35 public function getCommentProvider(): Provider
36 {
37 return new LogComment();
38 }
39
40 public function initSourceFields()
41 {
42 static $cache = [];
43
45
46 if ($ratingEntityId <= 0)
47 {
48 return;
49 }
50
51 $sourceFields = [];
52
53 if (isset($cache[$ratingEntityId]))
54 {
56 }
57 else
58 {
59 $userId = 0;
60 $bitrix24NewUserProvider = new Bitrix24NewUser();
61
62 $res = LogTable::getList([
63 'filter' => [
64 '@EVENT_ID' => array_merge($this->getEventId(), $bitrix24NewUserProvider->getEventId() ),
65 '=RATING_ENTITY_ID' => $ratingEntityId
66 ],
67 'select' => [ 'ID', 'ENTITY_ID' ]
68 ]);
69 if ($logEntry = $res->fetch())
70 {
71 $userId = $logEntry['ENTITY_ID'];
72 }
73
74 if ($userId > 0)
75 {
76 $res = UserTable::getList(array(
77 'filter' => [
78 '=ID' => $userId
79 ],
80 'select' => [
81 'NAME', 'LAST_NAME', 'SECOND_NAME', 'LOGIN', 'UF_DEPARTMENT'
82 ]
83 ));
84 if ($user = $res->fetch())
85 {
86 $userName = \CUser::formatName(
87 \CSite::getNameFormat(),
88 $user,
89 true,
90 false
91 );
92 $user['FULL_NAME'] = $userName;
93
94 $user['DEPARTMENT_NAME'] = '';
95 if (
96 is_array($user['UF_DEPARTMENT'])
97 && !empty($user['UF_DEPARTMENT'])
98 && Loader::includeModule('iblock')
99 )
100 {
101 $res = SectionTable::getList([
102 'filter' => [
103 'ID' => $user['UF_DEPARTMENT']
104 ],
105 'select' => [ 'ID', 'NAME' ]
106 ]);
107 if ($sectionFields = $res->fetch())
108 {
109 $user['DEPARTMENT_NAME'] = $sectionFields['NAME'];
110 }
111 }
112
113 $sourceFields = array_merge($user, [ 'LOG_ENTRY' => $logEntry ]);
115 }
116 }
117 }
118
119 if (empty($sourceFields))
120 {
121 return;
122 }
123
124 $this->setLogId($sourceFields['LOG_ENTRY']['ID']);
126 $this->setSourceTitle(Loc::getMessage('SONET_LIVEFEED_INTRANET_NEW_USER_TITLE', [
127 '#USER_NAME#' => $sourceFields['FULL_NAME']
128 ]));
129 }
130
131 public function getPinnedTitle(): string
132 {
133 $result = '';
134
135 if (ModuleManager::isModuleInstalled('bitrix24'))
136 {
137 $result = Option::get('main', 'site_name');
138 }
139 else
140 {
141 if (empty($this->sourceFields))
142 {
143 $this->initSourceFields();
144 }
145
147 if (empty($sourceFields))
148 {
149 return $result;
150 }
151
152 $result = $sourceFields['DEPARTMENT_NAME'];
153 }
154
155 return $result;
156 }
157
158 public function getPinnedDescription()
159 {
160 $result = '';
161
162 if (empty($this->sourceFields))
163 {
164 $this->initSourceFields();
165 }
166
168 if (empty($sourceFields))
169 {
170 return $result;
171 }
172
173 return Loc::getMessage('SONET_LIVEFEED_INTRANET_NEW_USER_PINNED_DESCRIPTION', [
174 '#USER_NAME#' => $sourceFields['FULL_NAME']
175 ]);
176 }
177
178 public static function canRead($params): bool
179 {
180 return true;
181 }
182
183 protected function getPermissions(array $post): string
184 {
186 }
187
188 public function getLiveFeedUrl(): string
189 {
190 $pathToLogEntry = '';
191
192 $logId = $this->getLogId();
193 if ($logId)
194 {
195 $pathToLogEntry = Option::get('socialnetwork', 'log_entry_page', '', $this->getSiteId());
196 if (!empty($pathToLogEntry))
197 {
198 $pathToLogEntry = \CComponentEngine::makePathFromTemplate($pathToLogEntry, array("log_id" => $logId));
199 }
200 }
201
202 return $pathToLogEntry;
203 }
204}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static getList(array $parameters=array())