ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
37  protected function __construct($a_server_id, $a_mid)
38  {
39  $this->server_id = $a_server_id;
40  $this->mid = $a_mid;
41 
42  $this->initStorage();
43  $this->read();
44  }
45 
50  public static function getInstance()
51  {
52  $GLOBALS['ilLog']->write(__METHOD__.': Deprecated call...');
53  $GLOBALS['ilLog']->logStack();
54 
55  if(self::$instance)
56  {
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  {
72  return self::$instances[$a_server_id.'_'.$a_mid];
73  }
74  return self::$instances[$a_server_id.'_'.$a_mid] = new self($a_server_id,$a_mid);
75  }
76 
81  public function getServerId()
82  {
83  return $this->server_id;
84  }
85 
90  public function getMid()
91  {
92  return $this->mid;
93  }
94 
99  public function isDirectoryMappingEnabled()
100  {
102  }
103 
108  public function enableDirectoryMapping($a_status)
109  {
110  $this->directory_active = $a_status;
111  }
112 
117  public function enableEmptyContainerCreation($a_status)
118  {
119  $this->create_empty_containers = $a_status;
120  }
121 
127  {
129  }
130 
131  public function enableCourseAllocation($a_stat)
132  {
133  $this->course_active = $a_stat;
134  }
135 
136  public function isCourseAllocationEnabled()
137  {
138  return $this->course_active;
139  }
140 
141  public function setDefaultCourseCategory($a_def)
142  {
143  $this->default_cat = $a_def;
144  }
145 
146  public function getDefaultCourseCategory()
147  {
148  return $this->default_cat;
149  }
150 
151  public function isAllInOneCategoryEnabled()
152  {
153  return $this->allinone;
154  }
155 
156  public function enableAllInOne($a_stat)
157  {
158  $this->allinone = $a_stat;
159  }
160 
161  public function setAllInOneCategory($a_cat)
162  {
163  $this->allinone_cat = $a_cat;
164  }
165 
166  public function getAllInOneCategory()
167  {
168  return $this->allinone_cat;
169  }
170 
171  public function enableAttributeMapping($a_stat)
172  {
173  $this->attributes = $a_stat;
174  }
175 
176  public function isAttributeMappingEnabled()
177  {
178  return $this->attributes;
179  }
180 
181  public function setRoleMappings($a_mappings)
182  {
183  $this->role_mappings = $a_mappings;
184  }
185 
186  public function getRoleMappings()
187  {
188  return $this->role_mappings;
189  }
190 
194  public function update()
195  {
196  $this->getStorage()->set('directory_active', (int) $this->isDirectoryMappingEnabled());
197  $this->getStorage()->set('create_empty', $this->isEmptyContainerCreationEnabled());
198  $this->getStorage()->set('course_active', $this->isCourseAllocationEnabled());
199  $this->getStorage()->set('default_category', $this->getDefaultCourseCategory());
200  $this->getStorage()->set('allinone', $this->isAllInOneCategoryEnabled());
201  $this->getStorage()->set('allinone_cat', $this->getAllInOneCategory());
202  $this->getStorage()->set('attributes', $this->isAttributeMappingEnabled());
203  $this->getStorage()->set('role_mappings',serialize($this->getRoleMappings()));
204  return true;
205  }
206 
211  protected function getStorage()
212  {
213  return $this->storage;
214  }
215 
219  protected function initStorage()
220  {
221  global $ilSetting;
222 
223  $this->storage = new ilSetting('ecs_node_mapping_'.$this->getServerId().'_'.$this->getMid());
224  }
225 
229  protected function read()
230  {
231  $this->enableDirectoryMapping($this->getStorage()->get('directory_active', $this->directory_active));
232  $this->enableEmptyContainerCreation($this->getStorage()->get('create_empty'),$this->create_empty_containers);
233  $this->enableCourseAllocation($this->getStorage()->get('course_active'),$this->course_active);
234  $this->setDefaultCourseCategory($this->getStorage()->get('default_category'),$this->default_cat);
235  $this->enableAllInOne($this->getStorage()->get('allinone'),$this->allinone);
236  $this->setAllInOneCategory($this->getStorage()->get('allinone_cat'),$this->allinone_cat);
237  $this->enableAttributeMapping($this->getStorage()->get('attributes'),$this->attributes);
238  $this->setRoleMappings(unserialize($this->getStorage()->get('role_mappings')),serialize($this->role_mappings));
239  }
240 }
241 
242 ?>