ILIAS  Release_4_4_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 
24 include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
25 include_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  {
78  return self::$instances[$a_server_id];
79  }
80  return self::$instances[$a_server_id] = new ilECSDataMappingSettings($a_server_id);
81  }
82 
88  public static function delete($a_server_id)
89  {
90  global $ilDB;
91 
92  $query = 'DELETE from ecs_data_mapping '.
93  'WHERE sid = '.$ilDB->quote($a_server_id,'integer');
94  $ilDB->manipulate($query);
95  }
96 
101  public function getServer()
102  {
103  return $this->settings;
104  }
105 
106 
113  public function getMappings($a_mapping_type = 0)
114  {
115  if(!$a_mapping_type)
116  {
118  }
119  return $this->mappings[$a_mapping_type];
120  }
121 
122 
132  public function getMappingByECSName($a_mapping_type,$a_key)
133  {
134  if(!$a_mapping_type)
135  {
137  }
138 
139  return array_key_exists($a_key, (array) $this->mappings[$a_mapping_type]) ?
140  $this->mappings[$a_mapping_type][$a_key] :
141  0;
142  }
143 
144 
145 
152  private function read()
153  {
154  global $ilDB;
155 
156  $this->mappings = array();
157 
158  $query = 'SELECT * FROM ecs_data_mapping '.
159  'WHERE sid = '.$ilDB->quote($this->getServer()->getServerId(),'integer').' ';
160  $res = $ilDB->query($query);
161  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
162  {
163  $this->mappings[$row->mapping_type][$row->ecs_field] = $row->advmd_id;
164  }
165  }
166 }
167 ?>