ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilECSDataMappingSettings.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 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 
33 {
34  private static $instance = null;
35 
36  private $mappings = array();
37 
44  private function __construct()
45  {
46  $this->initStorage();
47  $this->read();
48  }
49 
57  public static function _getInstance()
58  {
59  if(self::$instance)
60  {
61  return self::$instance;
62  }
63  return self::$instance = new ilECSDataMappingSettings();
64  }
65 
72  public function getMappings()
73  {
74  return $this->mappings ? $this->mappings : array();
75  }
76 
84  public function setMappings($a_mappings)
85  {
86  if(!is_array($a_mappings))
87  {
88  return false;
89  }
90  $this->mappings = array();
91  foreach($a_mappings as $key => $field_id)
92  {
93  $this->mappings[$key] = (int) $field_id;
94  }
95  return true;
96  }
97 
106  public function getMappingByECSName($a_key)
107  {
108  return isset($this->mappings[$a_key]) ? $this->mappings[$a_key] : 0;
109  }
110 
117  public function save()
118  {
119  $this->storage->set('mappings',addslashes(serialize($this->mappings)));
120  }
121 
127  private function initStorage()
128  {
129  include_once('./Services/Administration/classes/class.ilSetting.php');
130  $this->storage = new ilSetting('ecs_mappings');
131  }
132 
139  private function read()
140  {
141  $mappings = $this->storage->get('mappings');
142  if($mappings)
143  {
144  $this->mappings = unserialize(stripslashes($mappings));
145  }
146  }
147 
148 }
149 
150 
151 ?>