ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
24include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
25include_once './Services/WebServices/ECS/classes/class.ilECSDataMappingSetting.php';
26
36{
37 private static $instances = null;
38
39 private $settings = null;
40 private $mappings = array();
41
48 private function __construct($a_server_id)
49 {
50 $this->settings = ilECSSetting::getInstanceByServerId($a_server_id);
51 $this->read();
52 }
53
61 public static function _getInstance()
62 {
63 $GLOBALS['ilLog']->write(__METHOD__ . ': Using deprecate call');
64 $GLOBALS['ilLog']->logStack();
65
67 }
68
74 public static function getInstanceByServerId($a_server_id)
75 {
76 if (isset(self::$instances[$a_server_id])) {
77 return self::$instances[$a_server_id];
78 }
79 return self::$instances[$a_server_id] = new ilECSDataMappingSettings($a_server_id);
80 }
81
87 public static function delete($a_server_id)
88 {
89 global $ilDB;
90
91 $query = 'DELETE from ecs_data_mapping ' .
92 'WHERE sid = ' . $ilDB->quote($a_server_id, 'integer');
93 $ilDB->manipulate($query);
94 }
95
100 public function getServer()
101 {
102 return $this->settings;
103 }
104
105
112 public function getMappings($a_mapping_type = 0)
113 {
114 if (!$a_mapping_type) {
116 }
117 return $this->mappings[$a_mapping_type];
118 }
119
120
130 public function getMappingByECSName($a_mapping_type, $a_key)
131 {
132 if (!$a_mapping_type) {
134 }
135
136 return array_key_exists($a_key, (array) $this->mappings[$a_mapping_type]) ?
137 $this->mappings[$a_mapping_type][$a_key] :
138 0;
139 }
140
141
142
149 private function read()
150 {
151 global $ilDB;
152
153 $this->mappings = array();
154
155 $query = 'SELECT * FROM ecs_data_mapping ' .
156 'WHERE sid = ' . $ilDB->quote($this->getServer()->getServerId(), 'integer') . ' ';
157 $res = $ilDB->query($query);
158 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
159 $this->mappings[$row->mapping_type][$row->ecs_field] = $row->advmd_id;
160 }
161 }
162}
An exception for terminatinating execution or to throw for unit testing.
getMappings($a_mapping_type=0)
get mappings
__construct($a_server_id)
Singleton Constructor.
static _getInstance()
Get Singleton instance.
getMappingByECSName($a_mapping_type, $a_key)
get mapping by key
static getInstanceByServerId($a_server_id)
Get singleton instance.
static getInstanceByServerId($a_server_id)
Get singleton instance per server.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$query
foreach($_POST as $key=> $value) $res
settings()
Definition: settings.php:2
global $ilDB