ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilECSParticipantSettings.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 $instances = null;
35 
36  private $export = array();
37  private $import = array();
38  private $export_type = array();
39 
46  private function __construct($a_server_id)
47  {
48  $this->server_id = $a_server_id;
49  $this->read();
50  }
51 
59  public static function _getInstance()
60  {
61  $GLOBALS['ilLog']->write(__METHOD__.': Using deprecated call');
62  $GLOBALS['ilLog']->logStack();
63  return self::getInstanceByServerId(15);
64  }
65 
71  public static function getInstanceByServerId($a_server_id)
72  {
73  if(isset(self::$instances[$a_server_id]))
74  {
75  return self::$instances[$a_server_id];
76  }
77  return self::$instances[$a_server_id] = new ilECSParticipantSettings($a_server_id);
78  }
79 
83  public static function getExportableParticipants()
84  {
85  global $ilDB;
86 
87  $query = 'SELECT sid,mid FROM ecs_part_settings ep '.
88  'JOIN ecs_server es ON ep.sid = es.server_id '.
89  'WHERE export = '.$ilDB->quote(1,'integer').' '.
90  'AND active = '.$ilDB->quote(1,'integer').' '.
91  'ORDER BY cname,es.title';
92 
93  $res = $ilDB->query($query);
94  $mids = array();
95  $counter = 0;
96  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
97  {
98  $mids[$counter]['sid'] = $row->sid;
99  $mids[$counter]['mid'] = $row->mid;
100  $counter++;
101  }
102  return $mids;
103  }
104 
110  public static function getExportServers()
111  {
112  global $ilDB;
113 
114  $query = 'SELECT DISTINCT(sid) FROM ecs_part_settings ep '.
115  'JOIN ecs_server es ON ep.sid = es.server_id '.
116  'WHERE export = '.$ilDB->quote(1,'integer').' '.
117  'AND active = '.$ilDB->quote(1,'integer').' ';
118  $res = $ilDB->query($query);
119  $sids = array();
120  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
121  {
122  $sids[] = $row->sid;
123  }
124  return $sids;
125  }
126 
132  public static function deleteByServer($a_server_id)
133  {
134  global $ilDB;
135 
136  $query = 'DELETE from ecs_part_settings '.
137  'WHERE sid = '.$ilDB->quote($a_server_id,'integer');
138  $ilDB->manipulate($query);
139  }
140 
145  public function getServerId()
146  {
147  return $this->server_id;
148  }
149 
150 
155  public function read()
156  {
157  global $ilDB;
158 
159  $query = 'SELECT * FROM ecs_part_settings '.
160  'WHERE sid = '.$ilDB->quote($this->getServerId(),'integer').' ';
161  $res = $ilDB->query($query);
162  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
163  {
164  $this->export[$row->mid] = $row->export;
165  $this->import[$row->mid] = $row->import;
166  $this->import_type[$row->mid] = $row->import_type;
167  }
168  return true;
169  }
170 
176  public function isImportAllowed($a_mid)
177  {
178  return $this->import[$a_mid] ? true : false;
179  }
180 
187  public function getEnabledParticipants()
188  {
189  $ret = array();
190  foreach($this->export as $mid => $enabled)
191  {
192  if($enabled)
193  {
194  $ret[] = $mid;
195  }
196  }
197  return $ret;
198  #return $this->enabled ? $this->enabled : array();
199  }
200 
209  public function isEnabled($a_mid)
210  {
211  return $this->export[$a_mid] ? true : false;
212  }
213 
221  public function setEnabledParticipants($a_parts)
222  {
223  $this->enabled = (array) $a_parts;
224  }
225 }
226 ?>