ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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['DIC']['ilLog']->write(__METHOD__ . ': Using deprecated call');
62  $GLOBALS['DIC']['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  return self::$instances[$a_server_id];
75  }
76  return self::$instances[$a_server_id] = new ilECSParticipantSettings($a_server_id);
77  }
78 
85  public static function getAvailabeMids($a_server_id)
86  {
87  global $DIC;
88 
89  $ilDB = $DIC['ilDB'];
90 
91  $query = 'SELECT mid FROM ecs_part_settings ' .
92  'WHERE sid = ' . $ilDB->quote($a_server_id, 'integer');
93  $res = $ilDB->query($query);
94 
95  $mids = array();
96  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
97  $mids[] = $row->mid;
98  }
99  return $mids;
100  }
101 
102 
106  public static function getExportableParticipants($a_type)
107  {
108  global $DIC;
109 
110  $ilDB = $DIC['ilDB'];
111 
112  $query = 'SELECT sid,mid,export_types FROM ecs_part_settings ep ' .
113  'JOIN ecs_server es ON ep.sid = es.server_id ' .
114  'WHERE export = ' . $ilDB->quote(1, 'integer') . ' ' .
115  'AND active = ' . $ilDB->quote(1, 'integer') . ' ' .
116  'ORDER BY cname,es.title';
117 
118  $res = $ilDB->query($query);
119  $mids = array();
120  $counter = 0;
121  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
122  if (in_array($a_type, (array) unserialize($row->export_types))) {
123  $mids[$counter]['sid'] = $row->sid;
124  $mids[$counter]['mid'] = $row->mid;
125  $counter++;
126  }
127  }
128  return $mids;
129  }
130 
136  public static function getExportServers()
137  {
138  global $DIC;
139 
140  $ilDB = $DIC['ilDB'];
141 
142  $query = 'SELECT DISTINCT(sid) FROM ecs_part_settings ep ' .
143  'JOIN ecs_server es ON ep.sid = es.server_id ' .
144  'WHERE export = ' . $ilDB->quote(1, 'integer') . ' ' .
145  'AND active = ' . $ilDB->quote(1, 'integer') . ' ';
146  $res = $ilDB->query($query);
147  $sids = array();
148  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
149  $sids[] = $row->sid;
150  }
151  return $sids;
152  }
153 
159  public static function deleteByServer($a_server_id)
160  {
161  global $DIC;
162 
163  $ilDB = $DIC['ilDB'];
164 
165  $query = 'DELETE from ecs_part_settings ' .
166  'WHERE sid = ' . $ilDB->quote($a_server_id, 'integer');
167  $ilDB->manipulate($query);
168  }
169 
175  public static function loookupCmsMid($a_server_id)
176  {
177  global $DIC;
178 
179  $ilDB = $DIC['ilDB'];
180 
181  include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php';
182 
183  $query = 'SELECT mid FROM ecs_part_settings ' .
184  'WHERE sid = ' . $ilDB->quote($a_server_id, 'integer') . ' ' .
185  'AND import_type = ' . $ilDB->quote(ilECSParticipantSetting::IMPORT_CMS);
186  $res = $ilDB->query($query);
187  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
188  return $row->mid;
189  }
190  return 0;
191  }
192 
197  public function getServerId()
198  {
199  return $this->server_id;
200  }
201 
202 
207  public function read()
208  {
209  global $DIC;
210 
211  $ilDB = $DIC['ilDB'];
212 
213  $query = 'SELECT * FROM ecs_part_settings ' .
214  'WHERE sid = ' . $ilDB->quote($this->getServerId(), 'integer') . ' ';
215  $res = $ilDB->query($query);
216  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
217  $this->export[$row->mid] = $row->export;
218  $this->import[$row->mid] = $row->import;
219  $this->import_type[$row->mid] = $row->import_type;
220  $this->export_types[$row->mid] = (array) unserialize($row->export_types);
221  $this->import_types[$row->mid] = (array) unserialize($row->import_types);
222  }
223  return true;
224  }
225 
231  public function isImportAllowed(array $a_mids)
232  {
233  foreach ($a_mids as $mid) {
234  if ($this->import[$mid]) {
235  return true;
236  }
237  }
238  return false;
239  }
240 
247  public function getEnabledParticipants()
248  {
249  $ret = array();
250  foreach ($this->export as $mid => $enabled) {
251  if ($enabled) {
252  $ret[] = $mid;
253  }
254  }
255  return $ret;
256  #return $this->enabled ? $this->enabled : array();
257  }
258 
267  public function isEnabled($a_mid)
268  {
269  return $this->export[$a_mid] ? true : false;
270  }
271 
279  public function setEnabledParticipants($a_parts)
280  {
281  $this->enabled = (array) $a_parts;
282  }
283 }
global $DIC
Definition: saml.php:7
static getExportableParticipants($a_type)
Get participants which are enabled and export is allowed.
setEnabledParticipants($a_parts)
set enabled participants by community
__construct($a_server_id)
Constructor (Singleton)
isEnabled($a_mid)
is partivcipant enabled
static getInstanceByServerId($a_server_id)
Get instance by server id.
$a_type
Definition: workflow.php:92
foreach($_POST as $key=> $value) $res
$query
$row
static loookupCmsMid($a_server_id)
Lookup mid of current cms participant $ilDB.
static deleteByServer($a_server_id)
Delete by server $ilDB.
global $ilDB
$ret
Definition: parser.php:6
static getAvailabeMids($a_server_id)
Get all available mids $ilDB.
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
static getExportServers()
Get server ids which allow an export <type> $ilDB.
getEnabledParticipants()
get number of participants that are enabled
isImportAllowed(array $a_mids)
Check if import is allowed for scecific mid.