ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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) {
71 if ($rbacsystem->checkAccess('read_users', 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:
97 $where = "WHERE " . $ilDB->in("time_limit_owner", ilLocalUser::_getFolderIds(), false, "integer") . " ";
98 //$where .= '(';
99 //$where .= implode(",",ilUtil::quoteArray(ilLocalUser::_getFolderIds()));
100 //$where .= ')';
101 } else {
102 //$where = "WHERE time_limit_owner IN ('')";
103 return array();
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 while ($row = $ilDB->fetchObject($res)) {
118 $users[] = $row->usr_id;
119 }
120
121 return $users ? $users : array();
122 }
123
124 public static function _getUserFolderId()
125 {
126 return 7;
127 }
128} // CLASS ilLocalUser
An exception for terminatinating execution or to throw for unit testing.
const USER_FOLDER_ID
Class ilObjUserFolder.
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.
$query
foreach($_POST as $key=> $value) $res
global $ilDB
$DIC
Definition: xapitoken.php:46