ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilUserClipboard.php
Go to the documentation of this file.
1<?php
2
24{
25 public const SESSION_KEYWORD = 'usr_clipboard';
26 private static ?ilUserClipboard $instance = null;
27 private array $clipboard = []; // Missing array type.
28
29 protected function __construct(int $a_user_id)
30 {
31 $this->read();
32 }
33
34 public static function getInstance(int $a_usr_id): self
35 {
36 if (!self::$instance) {
37 self::$instance = new self($a_usr_id);
38 }
39 return self::$instance;
40 }
41
45 public function hasContent(): bool
46 {
47 return (bool) count($this->clipboard);
48 }
49
53 public function get(): array // Missing array type.
54 {
55 return $this->clipboard;
56 }
57
61 public function getValidatedContent(): array // Missing array type.
62 {
63 $valid = [];
64 foreach ($this->clipboard as $usr_id) {
65 if (strlen(ilObjUser::_lookupLogin($usr_id))) {
66 $valid[] = $usr_id;
67 }
68 }
69 return $valid;
70 }
71
75 public function add(array $a_usr_ids): void // Missing array type.
76 {
77 $this->clipboard = array_unique(array_merge($this->clipboard, $a_usr_ids));
78 }
79
83 public function delete(array $a_usr_ids): void // Missing array type.
84 {
85 $remaining = [];
86 foreach ($this->get() as $usr_id) {
87 if (!in_array($usr_id, $a_usr_ids)) {
88 $remaining[] = $usr_id;
89 }
90 }
91 $this->replace($remaining);
92 }
93
97 public function replace(array $a_usr_ids): void // Missing array type.
98 {
99 $this->clipboard = $a_usr_ids;
100 }
101
102 public function clear(): void
103 {
104 $this->clipboard = [];
105 }
106
110 public function save(): void
111 {
112 ilSession::set(self::SESSION_KEYWORD, $this->clipboard);
113 }
114
118 protected function read(): void
119 {
120 $this->clipboard = (array) ilSession::get(self::SESSION_KEYWORD);
121 }
122}
static _lookupLogin(int $a_user_id)
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
save()
Save clipboard content in session.
static getInstance(int $a_usr_id)
replace(array $a_usr_ids)
Replace clipboard content.
hasContent()
Check if clipboard has content.
__construct(int $a_user_id)
getValidatedContent()
Get validated content of clipboard.
static ilUserClipboard $instance
add(array $a_usr_ids)
Add entries to clipboard.
read()
Read from session.
$valid