ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilMemberViewSettings.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
30{
31 private static $instance = null;
32
33 private $active = false;
34 private $enabled = false;
35 private $container = null;
36 private $container_items = array();
37
38 private $current_ref_id = 0;
39
44 private function __construct()
45 {
46 $this->read();
47 }
48
53 public static function getInstance()
54 {
55 if(self::$instance != null)
56 {
57 return self::$instance;
58 }
59 return self::$instance = new ilMemberViewSettings();
60 }
61
66 public function getContainer()
67 {
68 return $this->container;
69 }
70
75 public function getCurrentRefId()
76 {
78 }
79
85 public function setContainer($container)
86 {
87 $this->container = $container;
88 $_SESSION['member_view_container'] = $this->container;
89 $_SESSION['il_cont_admin_panel'] = false;
90 }
91
96 public function isActive()
97 {
98 global $tree;
99
100 if(!$this->active)
101 {
102 // Not active
103 return false;
104 }
105
106
107 if(!$this->getCurrentRefId())
108 {
109 // No ref id given => mail, search, personal desktop menu in other tab
110 return false;
111 }
112
113 if(!in_array($this->getCurrentRefId(),$this->container_items) and
114 $this->getContainer() != $this->getCurrentRefId())
115 {
116 // outside of course
117 return false;
118 }
119 return true;
120 }
121
127 public function isActiveForRefId($a_ref_id)
128 {
129 if(!$this->active || !(int)$a_ref_id)
130 {
131 // Not active
132 return false;
133 }
134
135 if(!in_array($a_ref_id,$this->container_items) and
136 $this->getContainer() != $a_ref_id)
137 {
138 // outside of course
139 return false;
140 }
141 return true;
142 }
143
150 public function activate($a_ref_id)
151 {
152 $this->active = true;
153 $this->setContainer($a_ref_id);
154 }
155
160 public function deactivate()
161 {
162 $this->active = false;
163 $this->container = null;
164 unset($_SESSION['member_view_container']);
165 }
166
173 public function toggleActivation($a_ref_id,$a_activation)
174 {
175 if($a_activation)
176 {
177 return $this->activate($a_ref_id);
178 }
179 else
180 {
181 return $this->deactivate($a_ref_id);
182 }
183 }
184
189 public function isEnabled()
190 {
191 return (bool) $this->enabled;
192 }
193
198 protected function read()
199 {
200 global $ilSetting,$tree;
201
202 $this->findEffectiveRefId();
203
204 // member view is always enabled
205 // (2013-06-18, http://www.ilias.de/docu/goto_docu_wiki_1357_Reorganising_Administration.html)
206
207 // $this->enabled = $ilSetting->get('preview_learner');
208 $this->enabled = true;
209
210 if(isset($_SESSION['member_view_container']))
211 {
212 $this->active = true;
213 $this->container = (int) $_SESSION['member_view_container'];
214 $this->container_items = $tree->getSubTreeIds($this->getContainer());
215 }
216 }
217
221 protected function findEffectiveRefId()
222 {
223 if((int) $_GET['ref_id'])
224 {
225 return $this->current_ref_id = (int) $_GET['ref_id'];
226 }
227
228 $target_arr = explode('_',(string) $_GET['target']);
229 if(isset($target_arr[1]) and (int) $target_arr[1])
230 {
231 $this->current_ref_id = (int) $target_arr[1];
232 }
233 }
234}
235?>
$_GET["client_id"]
$_SESSION["AccountId"]
@classDescription Settings for members view
isActive()
Check if member view currently enabled.
findEffectiveRefId()
Find effective ref_id for request.
isEnabled()
Check if members view is enabled in the administration.
getCurrentRefId()
Get current ref_id of request.
isActiveForRefId($a_ref_id)
Check if member view is currently enabled for given ref id.
activate($a_ref_id)
Enable member view for this session and container.
__construct()
Constructor (singleton)
getContainer()
Returns $container.
setContainer($container)
Sets $container.
static getInstance()
Get instance.
toggleActivation($a_ref_id, $a_activation)
Toggle activation status.
deactivate()
Deactivate member view.
$target_arr
Definition: goto.php:86
global $ilSetting
Definition: privfeed.php:40