ILIAS  release_8 Revision v8.23
class.ilECSParticipantSettingsRepository.php
Go to the documentation of this file.
1 <?php
2 
18 declare(strict_types=1);
19 
24 {
25  private ilDBInterface $db;
26 
27  public function __construct()
28  {
29  global $DIC;
30 
31  $this->db = $DIC->database();
32  }
33 
37  public function getExportableParticipants($a_type): array
38  {
39  $query = 'SELECT sid,mid,export_types FROM ecs_part_settings ep ' .
40  'JOIN ecs_server es ON ep.sid = es.server_id ' .
41  'WHERE export = ' . $this->db->quote(1, 'integer') . ' ' .
42  'AND active = ' . $this->db->quote(1, 'integer') . ' ' .
43  'ORDER BY cname,es.title';
44 
45  $res = $this->db->query($query);
46  $mids = array();
47  $counter = 0;
48  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
49  if (in_array($a_type, (array) unserialize($row->export_types, ['allowed_classes' => true]), true)) {
50  $mids[$counter]['sid'] = (int) $row->sid;
51  $mids[$counter]['mid'] = (int) $row->mid;
52  $counter++;
53  }
54  }
55  return $mids;
56  }
57 
61  public function getServersContaingExports(): array
62  {
63  $query = 'SELECT DISTINCT(sid) FROM ecs_part_settings ep ' .
64  'JOIN ecs_server es ON ep.sid = es.server_id ' .
65  'WHERE export = ' . $this->db->quote(1, 'integer') . ' ' .
66  'AND active = ' . $this->db->quote(1, 'integer') . ' ';
67  $res = $this->db->query($query);
68  $sids = array();
69  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
70  $sids[] = (int) $row->sid;
71  }
72  return $sids;
73  }
74 
75  // Code below is unused according to eclipse. keep around if not true, otherwise remove
76  // /**
77  // * Delete by server
78  // * @global $ilDB
79  // * @param int $a_server_id
80  // */
81  // public static function deleteByServer($a_server_id)
82  // {
83  // global $DIC;
84 
85  // $ilDB = $DIC['ilDB'];
86 
87  // $query = 'DELETE from ecs_part_settings ' .
88  // 'WHERE sid = ' . $this->db->quote($a_server_id, 'integer');
89  // $this->db->manipulate($query);
90  // }
91 }
$res
Definition: ltiservices.php:69
getExportableParticipants($a_type)
Get participants which are enabled and export is allowed.
global $DIC
Definition: feed.php:28
getServersContaingExports()
Get server ids which allow an export.
$query