3 declare(strict_types=1);
41 private function __construct(
int $a_user_id,
int $a_ref_id = 0)
44 $this->db = $DIC->database();
45 $this->user_id = $a_user_id;
46 $this->ref_id = $a_ref_id;
53 if (!isset(self::$instances[$a_user_id][$a_ref_id])) {
56 return self::$instances[$a_user_id][$a_ref_id];
63 $ilDB = $DIC->database();
64 $query =
"DELETE FROM cal_cat_visibility " .
65 "WHERE cat_id = " .
$ilDB->quote($a_cat_id,
'integer') .
" ";
73 $ilDB = $DIC->database();
75 $query =
"DELETE FROM cal_cat_visibility " .
76 "WHERE user_id = " .
$ilDB->quote($a_user_id,
'integer') .
" ";
83 public function filterHidden(array $categories, array $category_info): array
86 foreach ($category_info as $cat_id => $info) {
88 if (array_key_exists(
'subitem_ids', $info) && is_array($info[
'subitem_ids'])) {
89 $subitem_ids = $info[
'subitem_ids'];
92 if ($this->
isHidden($cat_id, $info)) {
93 $hidden = array_merge((array) $hidden, $subitem_ids, array($cat_id));
96 return array_diff($categories, $hidden);
99 protected function isHidden(
int $a_cat_id, array $info): bool
102 if ($this->obj_id == 0) {
103 return in_array($a_cat_id, $this->hidden);
110 ($info[
"obj_id"] == $this->obj_id || $info[
"source_ref_id"] == $this->ref_id)
114 return !in_array($a_cat_id, $this->visible);
120 if (in_array($cat_id, $this->hidden)) {
139 $this->hidden = $a_hidden;
144 $this->visible = $a_visible;
150 foreach ($this->hidden as $hidden) {
151 if ($hidden === $this->forced_visible) {
154 $query =
"INSERT INTO cal_cat_visibility (user_id, cat_id, obj_id, visible) " .
156 $this->db->quote($this->user_id,
'integer') .
", " .
157 $this->db->quote($hidden,
'integer') .
", " .
158 $this->db->quote($this->obj_id,
'integer') .
", " .
159 $this->db->quote(self::HIDDEN,
'integer') .
161 $this->db->manipulate(
$query);
163 foreach ($this->visible as $visible) {
164 if ($visible === $this->forced_visible) {
167 $query =
"INSERT INTO cal_cat_visibility (user_id, cat_id, obj_id, visible) " .
169 $this->db->quote($this->user_id,
'integer') .
", " .
170 $this->db->quote($visible,
'integer') .
", " .
171 $this->db->quote($this->obj_id,
'integer') .
", " .
172 $this->db->quote(self::VISIBLE,
'integer') .
174 $this->db->manipulate(
$query);
178 public function delete(
int $a_cat_id = null):
void 181 $query =
"DELETE FROM cal_cat_visibility " .
182 "WHERE user_id = " . $this->db->quote($this->user_id,
'integer') .
" " .
183 "AND obj_id = " . $this->db->quote($this->obj_id,
'integer') .
" " .
184 "AND cat_id = " . $this->db->quote($a_cat_id,
'integer') .
" ";
186 $query =
"DELETE FROM cal_cat_visibility " .
187 "WHERE user_id = " . $this->db->quote($this->user_id,
'integer') .
" " .
188 "AND obj_id = " . $this->db->quote($this->obj_id,
'integer');
190 $this->db->manipulate(
$query);
193 protected function read(): void
195 $query =
"SELECT * FROM cal_cat_visibility " .
196 "WHERE user_id = " . $this->db->quote($this->user_id,
'integer') .
" " .
197 " AND obj_id = " . $this->db->quote($this->obj_id,
'integer');
200 if ($row->visible == self::HIDDEN) {
201 $this->hidden[] = $row->cat_id;
203 if ($row->visible == self::VISIBLE) {
204 $this->visible[] = $row->cat_id;
211 $this->forced_visible = $a_cat_id;
212 if ((
$key = array_search($a_cat_id, $this->hidden)) !==
false) {
213 unset($this->hidden[
$key]);
215 if (!in_array($a_cat_id, $this->visible)) {
216 $this->visible[] = $a_cat_id;
isHidden(int $a_cat_id, array $info)
filterHidden(array $categories, array $category_info)
Filter hidden categories (and hidden subitem categories) from category array.
isAppointmentVisible(int $a_cal_id)
hideSelected(array $a_hidden)
static _lookupObjId(int $ref_id)
forceVisibility(int $a_cat_id)
static _deleteCategories(int $a_cat_id)
static _lookupCategories(int $a_cal_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _deleteUser(int $a_user_id)
showSelected(array $a_visible)
__construct(int $a_user_id, int $a_ref_id=0)
static _getInstanceByUserId(int $a_user_id, int $a_ref_id=0)