ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilECSNodeMappingSettings.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
8 {
9  private static $instances = array();
10 
11  private $storage = null;
12 
13 
14  private $server_id = 0;
19  private $mid = 0;
20 
21  private $directory_active = false;
22  private $create_empty_containers = false;
23 
27  private $course_active = false;
28  private $default_cat = 0;
29  private $allinone = false;
30  private $allinone_cat = 0;
31  private $attributes = false;
32  private $role_mappings = array();
33  private $auth_mode = null;
34 
38  protected function __construct($a_server_id, $a_mid)
39  {
40  $this->server_id = $a_server_id;
41  $this->mid = $a_mid;
42 
43  $this->initStorage();
44  $this->read();
45  }
46 
51  public static function getInstance()
52  {
53  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ': Deprecated call...');
54  $GLOBALS['DIC']['ilLog']->logStack();
55 
56  if (self::$instance) {
57  return self::$instance;
58  }
59  return self::$instance = new ilECSNodeMappingSettings();
60  }
61 
68  public static function getInstanceByServerMid($a_server_id, $a_mid)
69  {
70  if (self::$instances[$a_server_id . '_' . $a_mid]) {
71  return self::$instances[$a_server_id . '_' . $a_mid];
72  }
73  return self::$instances[$a_server_id . '_' . $a_mid] = new self($a_server_id, $a_mid);
74  }
75 
80  public function getServerId()
81  {
82  return $this->server_id;
83  }
84 
89  public function getMid()
90  {
91  return $this->mid;
92  }
93 
98  public function isDirectoryMappingEnabled()
99  {
101  }
102 
107  public function enableDirectoryMapping($a_status)
108  {
109  $this->directory_active = $a_status;
110  }
111 
116  public function enableEmptyContainerCreation($a_status)
117  {
118  $this->create_empty_containers = $a_status;
119  }
120 
126  {
128  }
129 
130  public function enableCourseAllocation($a_stat)
131  {
132  $this->course_active = $a_stat;
133  }
134 
135  public function isCourseAllocationEnabled()
136  {
137  return $this->course_active;
138  }
139 
140  public function setDefaultCourseCategory($a_def)
141  {
142  $this->default_cat = $a_def;
143  }
144 
145  public function getDefaultCourseCategory()
146  {
147  return $this->default_cat;
148  }
149 
150  public function isAllInOneCategoryEnabled()
151  {
152  return $this->allinone;
153  }
154 
155  public function enableAllInOne($a_stat)
156  {
157  $this->allinone = $a_stat;
158  }
159 
160  public function setAllInOneCategory($a_cat)
161  {
162  $this->allinone_cat = $a_cat;
163  }
164 
165  public function getAllInOneCategory()
166  {
167  return $this->allinone_cat;
168  }
169 
170  public function enableAttributeMapping($a_stat)
171  {
172  $this->attributes = $a_stat;
173  }
174 
175  public function isAttributeMappingEnabled()
176  {
177  return $this->attributes;
178  }
179 
180  public function setRoleMappings($a_mappings)
181  {
182  $this->role_mappings = $a_mappings;
183  }
184 
185  public function getRoleMappings()
186  {
187  return $this->role_mappings;
188  }
189 
194  public function setAuthMode($a_auth_mode)
195  {
196  $this->auth_mode = $a_auth_mode;
197  }
198 
203  public function getAuthMode()
204  {
205  return $this->auth_mode;
206  }
207 
211  public function update()
212  {
213  $this->getStorage()->set('directory_active', (int) $this->isDirectoryMappingEnabled());
214  $this->getStorage()->set('create_empty', $this->isEmptyContainerCreationEnabled());
215  $this->getStorage()->set('course_active', $this->isCourseAllocationEnabled());
216  $this->getStorage()->set('default_category', $this->getDefaultCourseCategory());
217  $this->getStorage()->set('allinone', $this->isAllInOneCategoryEnabled());
218  $this->getStorage()->set('allinone_cat', $this->getAllInOneCategory());
219  $this->getStorage()->set('attributes', $this->isAttributeMappingEnabled());
220  $this->getStorage()->set('role_mappings', serialize($this->getRoleMappings()));
221  $this->getStorage()->set('auth_mode', $this->getAuthMode());
222  return true;
223  }
224 
229  protected function getStorage()
230  {
231  return $this->storage;
232  }
233 
237  protected function initStorage()
238  {
239  global $DIC;
240 
241  $ilSetting = $DIC['ilSetting'];
242 
243  $this->storage = new ilSetting('ecs_node_mapping_' . $this->getServerId() . '_' . $this->getMid());
244  }
245 
249  protected function read()
250  {
251  $this->enableDirectoryMapping($this->getStorage()->get('directory_active', $this->directory_active));
252  $this->enableEmptyContainerCreation($this->getStorage()->get('create_empty'), $this->create_empty_containers);
253  $this->enableCourseAllocation($this->getStorage()->get('course_active'), $this->course_active);
254  $this->setDefaultCourseCategory($this->getStorage()->get('default_category'), $this->default_cat);
255  $this->enableAllInOne($this->getStorage()->get('allinone'), $this->allinone);
256  $this->setAllInOneCategory($this->getStorage()->get('allinone_cat'), $this->allinone_cat);
257  $this->enableAttributeMapping($this->getStorage()->get('attributes'), $this->attributes);
258  $this->setRoleMappings(unserialize($this->getStorage()->get('role_mappings')), serialize($this->role_mappings));
259  $this->setAuthMode($this->getStorage()->get('auth_mode', $this->auth_mode));
260  }
261 }
global $DIC
Definition: saml.php:7
getServerId()
Get server id of setting.
static getInstanceByServerMid($a_server_id, $a_mid)
Get instance.
enableDirectoryMapping($a_status)
Enable node mapping.
enableEmptyContainerCreation($a_status)
enable creation of empty containers
static getInstance()
Get singeleton instance.
__construct($a_server_id, $a_mid)
Singeleton constructor.
global $ilSetting
Definition: privfeed.php:17
isDirectoryMappingEnabled()
Check if node mapping is enabled.
isEmptyContainerCreationEnabled()
Check if the creation of empty containers (pathes without courses) is enabled.
setAuthMode($a_auth_mode)
Set user auth mode.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.