ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilUserClipboard.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
12 {
13  const SESSION_KEYWORD = 'usr_clipboard';
14 
15  private static $instance = null;
16 
17  private $user_id = 0;
18  private $clipboard = array();
19 
20 
24  protected function __construct($a_user_id)
25  {
26  $this->user_id = $a_user_id;
27  $this->read();
28  }
29 
35  public static function getInstance($a_usr_id)
36  {
37  if(!self::$instance)
38  {
39  self::$instance = new self($a_usr_id);
40  }
41  return self::$instance;
42  }
43 
48  public function hasContent()
49  {
50  return (bool) count($this->clipboard);
51  }
52 
57  public function get()
58  {
59  return (array) $this->clipboard;
60  }
61 
66  public function getValidatedContent()
67  {
68  $valid = array();
69  foreach($this->clipboard as $usr_id)
70  {
71  include_once './Services/User/classes/class.ilObjUser.php';
72  if(strlen(ilObjUser::_lookupLogin($usr_id)))
73  {
74  $valid[] = $usr_id;
75  }
76  }
77  return $valid;
78  }
79 
83  public function add($a_usr_ids)
84  {
85  $this->clipboard = array_unique(array_merge($this->clipboard, (array) $a_usr_ids));
86  }
87 
92  public function delete(array $a_usr_ids)
93  {
94  $remaining = array();
95  foreach($this->get() as $usr_id)
96  {
97  if(!in_array($usr_id, $a_usr_ids))
98  {
99  $remaining[] = $usr_id;
100  }
101  }
102  $this->replace($remaining);
103  }
104 
109  public function replace(array $a_usr_ids)
110  {
111  $this->clipboard = $a_usr_ids;
112  }
113 
114  public function clear()
115  {
116  $this->clipboard = array();
117  }
118 
122  public function save()
123  {
124  ilSession::set(self::SESSION_KEYWORD, (array) $this->clipboard);
125  }
126 
130  protected function read()
131  {
132  $this->clipboard = (array) ilSession::get(self::SESSION_KEYWORD);
133  }
134 }
135 ?>
static _lookupLogin($a_user_id)
lookup login
static getInstance($a_usr_id)
Get singelton instance.
add($a_usr_ids)
Add entries to clipboard.
$valid
static get($a_var)
Get a value.
static set($a_var, $a_val)
Set a value.
save()
Save clipboard content in session.
getValidatedContent()
Get validated content of clipboard.
replace(array $a_usr_ids)
Replace clipboard content.
hasContent()
Check if clipboard has content.
Create styles array
The data for the language used.
__construct($a_user_id)
singleton constructor
read()
Read from session.