ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilPDFCompInstaller.php
Go to the documentation of this file.
1 <?php
2 
4 {
5  const PURPOSE_CONF_TABLE = "pdfgen_conf";
6  const PURPOSE_MAP_TABLE = "pdfgen_map";
7  const PURPOSE_PURPOSES_TABLE = "pdfgen_purposes";
8  const RENDERER_TABLE = "pdfgen_renderer";
9  const RENDERER_AVAIL_TABLE = "pdfgen_renderer_avail";
10 
18  public static function registerPurpose($service, $purpose, $preferred)
19  {
20  self::addPurpose($service, $purpose);
21  self::addPreferred($service, $purpose, $preferred);
22  }
23 
28  protected static function addPurpose($service, $purpose)
29  {
30  global $DIC;
32  $ilDB = $DIC['ilDB'];
33 
34  $ilDB->insert(
35  self::PURPOSE_PURPOSES_TABLE,
36  array(
37  'purpose_id' => array('int', $ilDB->nextId(self::PURPOSE_PURPOSES_TABLE)),
38  'service' => array('text', $service),
39  'purpose' => array('text', $purpose),
40  )
41  );
42  }
43 
49  protected static function addPreferred($service, $purpose, $preferred)
50  {
51  global $DIC;
53  $ilDB = $DIC['ilDB'];
54  $ilDB->insert(
55  self::PURPOSE_MAP_TABLE,
56  array(
57  'map_id' => array('int', $ilDB->nextId(self::PURPOSE_MAP_TABLE)),
58  'service' => array('text', $service),
59  'purpose' => array('text', $purpose),
60  'preferred' => array('text', $preferred),
61  'selected' => array('text', $preferred)
62  )
63  );
64  }
65 
70  public static function unregisterPurpose($service, $purpose)
71  {
72  global $DIC;
73  $ilDB = $DIC['ilDB'];
74 
75  $ilDB->manipulate("DELETE FROM " . self::PURPOSE_PURPOSES_TABLE .
76  " WHERE service = " . $ilDB->quote($service, "txt") . " AND purpose = " . $ilDB->quote($purpose, "txt"));
77  }
78 
84  public static function unregisterPreferred($service, $purpose, $preferred)
85  {
86  global $DIC;
87  $ilDB = $DIC['ilDB'];
88 
89  $ilDB->manipulate("DELETE FROM " . self::PURPOSE_MAP_TABLE .
90  " WHERE service = " . $ilDB->quote($service, "txt") . " AND purpose = " . $ilDB->quote($purpose, "txt") .
91  " AND preferred = " . $ilDB->quote($preferred, "txt"));
92  }
93 
99  public static function flushPurposes($service)
100  {
101  global $DIC;
102  $ilDB = $DIC['ilDB'];
103 
104  $ilDB->manipulate("DELETE FROM " . self::PURPOSE_PURPOSES_TABLE . " WHERE service = " . $ilDB->quote($service, "txt"));
105  }
106 
113  public static function isPurposeRegistered($service, $purpose)
114  {
115  global $DIC;
116  $ilDB = $DIC['ilDB'];
117 
118  $query = 'SELECT count(*) num FROM ' . self::PURPOSE_PURPOSES_TABLE . ' WHERE service = '
119  . $ilDB->quote($service, 'text') . ' AND purpose = ' . $ilDB->quote($purpose, 'text');
120  $result = $ilDB->query($query);
121  $row = $ilDB->fetchAssoc($result);
122  if ($row['num'] != 0) {
123  return true;
124  }
125  return false;
126  }
127 
133  public static function getPurposesByService($service)
134  {
135  global $DIC;
136  $ilDB = $DIC['ilDB'];
137 
138  $query = 'SELECT purpose FROM ' . self::PURPOSE_PURPOSES_TABLE . ' WHERE service = ' . $ilDB->quote($service, 'text');
139  $result = $ilDB->query($query);
140  $purposes = array();
141  while ($row = $ilDB->fetchAssoc($result)) {
142  $purposes[] = $row['purpose'];
143  }
144  return $purposes;
145  }
146 
150  public static function getServices()
151  {
152  global $DIC;
153  $ilDB = $DIC['ilDB'];
154 
155  $query = 'SELECT service FROM ' . self::PURPOSE_PURPOSES_TABLE . ' GROUP BY service';
156  $result = $ilDB->query($query);
157  $services = array();
158  while ($row = $ilDB->fetchAssoc($result)) {
159  $services[] = $row['service'];
160  }
161  return $services;
162  }
163 
168  {
169  global $DIC;
170  $ilDB = $DIC['ilDB'];
171  $query = 'SELECT service, purpose FROM ' . self::PURPOSE_PURPOSES_TABLE . ' GROUP BY service, purpose having count(*) > 1';
172  $result = $ilDB->query($query);
173  $row = $ilDB->fetchAssoc($result);
174  if (is_array($row) && count($row) > 0) {
175  return true;
176  }
177  return false;
178  }
179 
180  public static function doCleanUp()
181  {
182  global $DIC;
183  $ilDB = $DIC['ilDB'];
184  $query = 'SELECT service, purpose FROM ' . self::PURPOSE_PURPOSES_TABLE . ' GROUP BY service, purpose having count(*) > 1';
185  $result = $ilDB->query($query);
186  while ($row = $ilDB->fetchAssoc($result)) {
187  self::unregisterPurpose($row['service'], $row['purpose']);
188  self::addPurpose($row['service'], $row['purpose']);
189  }
190 
191  $query = 'SELECT service, purpose, preferred FROM ' . self::PURPOSE_MAP_TABLE . ' GROUP BY service, purpose, preferred having count(*) > 1';
192 
193  $result = $ilDB->query($query);
194  while ($row = $ilDB->fetchAssoc($result)) {
195  self::unregisterPreferred($row['service'], $row['purpose'], $row['preferred']);
196  self::addPreferred($row['service'], $row['purpose'], $row['preferred']);
197  }
198  }
199 
205  public static function updateFromXML($service, $purpose, $preferred)
206  {
207  $parts = explode('/', $service);
208  $service = $parts[1];
209 
210  if (!self::isPurposeRegistered($service, $purpose)) {
211  self::registerPurpose($service, $purpose, $preferred);
212  }
213  }
214 
219  public static function registerRenderer($renderer, $path)
220  {
221  global $DIC;
223  $ilDB = $DIC['ilDB'];
224 
225  $ilDB->insert(
226  self::RENDERER_TABLE,
227  array(
228  'renderer_id' => array('int', $ilDB->nextId(self::RENDERER_TABLE)),
229  'renderer' => array('text', $renderer),
230  'path' => array('text', $path)
231  )
232  );
233  }
234 
240  public static function registerRendererAvailability($renderer, $service, $purpose)
241  {
242  global $DIC;
244  $ilDB = $DIC['ilDB'];
245 
246  $ilDB->insert(
247  self::RENDERER_AVAIL_TABLE,
248  array(
249  'availability_id' => array('int', $ilDB->nextId(self::RENDERER_AVAIL_TABLE)),
250  'service' => array('text', $service),
251  'purpose' => array('text', $purpose),
252  'renderer' => array('text', $renderer)
253  )
254  );
255  }
256 }
$path
Definition: aliased.php:25
static updateFromXML($service, $purpose, $preferred)
$result
global $DIC
Definition: saml.php:7
static flushPurposes($service)
static unregisterPreferred($service, $purpose, $preferred)
static isPurposeRegistered($service, $purpose)
static registerPurpose($service, $purpose, $preferred)
static unregisterPurpose($service, $purpose)
$query
$row
global $ilDB
static getPurposesByService($service)
static checkForMultipleServiceAndPurposeCombination()