ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilLocalUser.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4/*
5* Helper class for local user accounts (in categories)
6*
7* @author Stefan Meyer <meyer@leifos.com>
8* @version $Id$
9*
10*/
11
13{
14 public $db;
15
16 public $parent_id;
17
24 public function __construct($a_parent_id)
25 {
26 global $DIC;
27
28 $ilDB = $DIC['ilDB'];
29
30 $this->db = $ilDB;
31 $this->parent_id = $a_parent_id;
32 }
33
34 public function setParentId($a_parent_id)
35 {
36 $this->parent_id = $a_parent_id;
37 }
38 public function getParentId()
39 {
40 return $this->parent_id;
41 }
42
43 public static function _getUserData($a_filter)
44 {
45 include_once './Services/User/classes/class.ilObjUser.php';
46
47 $users_data = ilObjUser::_getAllUserData(array("login","firstname","lastname","time_limit_owner"), -1);
48
49 foreach ($users_data as $usr_data) {
50 if (!$a_filter or $a_filter == $usr_data['time_limit_owner']) {
51 $users[] = $usr_data;
52 }
53 }
54 return $users ? $users : array();
55 }
56
57 public static function _getFolderIds($access_with_orgunit = false)
58 {
59 global $DIC;
60
61 $ilDB = $DIC['ilDB'];
62 $access = $DIC->access();
63 $rbacsystem = $DIC['rbacsystem'];
64
65 $query = "SELECT DISTINCT(time_limit_owner) as parent_id FROM usr_data ";
66
67 $res = $ilDB->query($query);
68 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
69 // Workaround for users with time limit owner "0".
70 if (!$row->parent_id || (int) $row->parent_id === USER_FOLDER_ID) {
71 if ($rbacsystem->checkAccess('read', USER_FOLDER_ID) ||
72 ($access_with_orgunit && $access->checkPositionAccess(\ilObjUserFolder::ORG_OP_EDIT_USER_ACCOUNTS, USER_FOLDER_ID))) {
73 $parent[] = $row->parent_id;
74 }
75 continue;
76 }
77
78 if ($rbacsystem->checkAccess('read_users', $row->parent_id) ||
79 ($access_with_orgunit && $access->checkPositionAccess(ilObjUserFolder::ORG_OP_EDIT_USER_ACCOUNTS, $row->parent_id))
80 or $rbacsystem->checkAccess('cat_administrate_users', $row->parent_id)) {
81 if ($row->parent_id) {
82 $parent[] = $row->parent_id;
83 }
84 }
85 }
86 return $parent ? $parent : array();
87 }
88
89 public static function _getAllUserIds($a_filter = 0)
90 {
91 global $DIC;
92
93 $ilDB = $DIC['ilDB'];
94 switch ($a_filter) {
95 case 0:
96 if (self::_getFolderIds()) {
97 $where = "WHERE " . $ilDB->in("time_limit_owner", self::_getFolderIds(), false, "integer") . " ";
98 } else {
99 return [];
100 }
101
102 break;
103
104 default:
105 $where = "WHERE time_limit_owner = " . $ilDB->quote($a_filter, "integer") . " ";
106
107 break;
108 }
109
110 $query = "SELECT usr_id FROM usr_data " . $where;
111 $res = $ilDB->query($query);
112
113 while ($row = $ilDB->fetchObject($res)) {
114 $users[] = $row->usr_id;
115 }
116
117 return $users ? $users : array();
118 }
119
120 public static function _getUserFolderId()
121 {
122 return 7;
123 }
124} // CLASS ilLocalUser
An exception for terminatinating execution or to throw for unit testing.
static _getUserFolderId()
static _getFolderIds($access_with_orgunit=false)
static _getAllUserIds($a_filter=0)
setParentId($a_parent_id)
static _getUserData($a_filter)
__construct($a_parent_id)
Constructor @access public.
static _getAllUserData($a_fields=null, $active=-1)
STATIC METHOD get all user data.
const USER_FOLDER_ID
Definition: constants.php:31
global $DIC
Definition: goto.php:24
$query
foreach($_POST as $key=> $value) $res
global $ilDB