ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLocalUser.php
Go to the documentation of this file.
1<?php
2
25{
27 public int $parent_id;
28
29 public function __construct(
30 int $a_parent_id
31 ) {
32 global $DIC;
33
34 $ilDB = $DIC['ilDB'];
35
36 $this->db = $ilDB;
37 $this->parent_id = $a_parent_id;
38 }
39
40 public function setParentId(int $a_parent_id): void
41 {
42 $this->parent_id = $a_parent_id;
43 }
44
45 public function getParentId(): int
46 {
47 return $this->parent_id;
48 }
49
54 public static function _getFolderIds(
55 bool $access_with_orgunit = false
56 ): array {
57 global $DIC;
58
59 $ilDB = $DIC['ilDB'];
60 $access = $DIC->access();
61 $rbacsystem = $DIC['rbacsystem'];
62 $parent = [];
63
64 $query = "SELECT DISTINCT(time_limit_owner) as parent_id FROM usr_data ";
65
66 $res = $ilDB->query($query);
67 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
68 // Workaround for users with time limit owner "0".
69 if (!$row->parent_id || (int) $row->parent_id === USER_FOLDER_ID) {
70 if ($rbacsystem->checkAccess('read', USER_FOLDER_ID) ||
71 ($access_with_orgunit && $access->checkPositionAccess(\ilObjUserFolder::ORG_OP_EDIT_USER_ACCOUNTS, USER_FOLDER_ID))) {
72 $parent[] = (int) $row->parent_id;
73 }
74 continue;
75 }
76
77 if ($rbacsystem->checkAccess('read_users', $row->parent_id) ||
78 ($access_with_orgunit && $access->checkPositionAccess(ilObjUserFolder::ORG_OP_EDIT_USER_ACCOUNTS, $row->parent_id))
79 || $rbacsystem->checkAccess('cat_administrate_users', $row->parent_id)) {
80 if ($row->parent_id) {
81 $parent[] = (int) $row->parent_id;
82 }
83 }
84 }
85 return $parent ?: [];
86 }
87
92 public static function _getAllUserIds(
93 int $a_filter = 0
94 ): array {
95 global $DIC;
96
97 $ilDB = $DIC['ilDB'];
98 switch ($a_filter) {
99 case 0:
100 if (self::_getFolderIds()) {
101 $where = "WHERE " . $ilDB->in("time_limit_owner", self::_getFolderIds(), false, "integer") . " ";
102 } else {
103 return [];
104 }
105
106 break;
107
108 default:
109 $where = "WHERE time_limit_owner = " . $ilDB->quote($a_filter, "integer") . " ";
110
111 break;
112 }
113
114 $query = "SELECT usr_id FROM usr_data " . $where;
115 $res = $ilDB->query($query);
116
117 $users = [];
118 while ($row = $ilDB->fetchObject($res)) {
119 $users[] = (int) $row->usr_id;
120 }
121
122 return $users;
123 }
124
125 public static function _getUserFolderId(): int
126 {
127 return 7;
128 }
129}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getUserFolderId()
setParentId(int $a_parent_id)
static _getFolderIds(bool $access_with_orgunit=false)
__construct(int $a_parent_id)
ilDBInterface $db
static _getAllUserIds(int $a_filter=0)
const USER_FOLDER_ID
Definition: constants.php:33
Interface ilDBInterface.
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26