Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
user.php
1<?php
2
4
5use \Bitrix\Forum;
6
7class User
8{
9 protected $id = 0;
10 protected $groups = [2];
11 protected $forumUser = null;
12
13 public function __construct($id)
14 {
15 global $USER;
16 if (is_object($USER) && $id == $USER->getId())
17 {
18 $this->id = $USER->getId();
19 $this->groups = $USER->GetUserGroupArray();
20 }
21 else if ($id > 0)
22 {
23 $this->id = $id;
24 $this->groups = \Bitrix\Main\UserTable::getUserGroupIds($id);
25 }
26 $this->forumUser = Forum\User::getById($this->id);
27 }
28
29 public function getId()
30 {
31 return $this->id;
32 }
33
34 public function getGroups()
35 {
36 return implode(",", $this->groups);
37 }
38
39 public function getUserGroupArray()
40 {
41 return $this->groups;
42 }
43
44 public function isAuthorized()
45 {
46 return true;
47 }
48
49 public function getParam(string $key)
50 {
51 if ($this->forumUser instanceof Forum\User)
52 {
53 return $this->forumUser[$key];
54 }
55 return null;
56 }
57 public function isAdmin()
58 {
59 return false;
60 }
61 public function getUserGroup()
62 {
63 return $this->groups;
64 }
65 public function getFirstName()
66 {
67 return '';
68 }
69 public function getLastName()
70 {
71 return '';
72 }
73 public function getSecondName()
74 {
75 return '';
76 }
77 public function getLogin()
78 {
79 return '';
80 }
81 public function getFullName()
82 {
83 return '';
84 }
85
86 public function getUnreadMessageId($topicId = 0)
87 {
88 if ($this->forumUser instanceof Forum\User)
89 {
90 return $this->forumUser->getUnreadMessageId($topicId);
91 }
92 return null;
93 }
94
95 public function readTopic($topicId = 0)
96 {
97 if ($this->forumUser instanceof Forum\User)
98 {
99 $this->forumUser->readTopic($topicId);
100 $this->forumUser->setLastVisit();
101 }
102 }
103
104 public function setLocation(int $forumId = 0, int $topicId = 0)
105 {
106 if ($this->forumUser instanceof Forum\User)
107 {
108 $this->forumUser->setLocation($forumId, $topicId);
109 }
110 }
111}
getUnreadMessageId($topicId=0)
Definition user.php:86
setLocation(int $forumId=0, int $topicId=0)
Definition user.php:104
readTopic($topicId=0)
Definition user.php:95
getParam(string $key)
Definition user.php:49