ILIAS  release_8 Revision v8.24
class.ilLearningSequenceActivationDB.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
25{
26 public const TABLE_NAME = 'lso_activation';
27
29
31 {
32 $this->database = $database;
33 }
34
36 {
37 $data = $this->select($ref_id);
38 if (count($data) == 0) {
39 $settings = $this->buildActivationSettings($ref_id);
40 $this->insert($settings);
41 } else {
42 if ($data['activation_start_ts']) {
43 $start = new \DateTime();
44 $start->setTimestamp((int) $data['activation_start_ts']);
45 } else {
46 $start = null;
47 }
48
49 if ($data['activation_end_ts']) {
50 $end = new \DateTime();
51 $end->setTimestamp((int) $data['activation_end_ts']);
52 } else {
53 $end = null;
54 }
55
57 (int) $data['ref_id'],
58 (bool) $data['online'],
59 (bool) $data['effective_online'],
60 $start,
61 $end
62 );
63 }
64
65 return $settings;
66 }
67
68 public function deleteForRefId(int $ref_id): void
69 {
70 $query = "DELETE FROM " . static::TABLE_NAME . PHP_EOL
71 . "WHERE ref_id = " . $this->database->quote($ref_id, "integer") . PHP_EOL
72 ;
73 $this->database->manipulate($query);
74 }
75
77 {
78 $where = [
79 "ref_id" => ["integer", $settings->getRefId()]
80 ];
81
82 $start = $settings->getActivationStart();
83 $end = $settings->getActivationEnd();
84
85 if ($start) {
86 $start = $start->getTimestamp();
87 }
88
89 if ($end) {
90 $end = $end->getTimestamp();
91 }
92
93 $values = [
94 "online" => ["integer", $settings->getIsOnline()],
95 "activation_start_ts" => ["integer", $start],
96 "activation_end_ts" => ["integer", $end]
97 ];
98
99 $this->database->update(static::TABLE_NAME, $values, $where);
100 }
101
103 {
104 $start = $settings->getActivationStart();
105 $end = $settings->getActivationEnd();
106
107 if ($start) {
108 $start = $start->getTimestamp();
109 }
110
111 if ($end) {
112 $end = $end->getTimestamp();
113 }
114
115 $values = [
116 "ref_id" => ["integer", $settings->getRefId()],
117 "online" => ["integer", $settings->getIsOnline()],
118 "effective_online" => ["integer", $settings->getEffectiveOnlineStatus()],
119 "activation_start_ts" => ["integer", $start],
120 "activation_end_ts" => ["integer", $end]
121 ];
122
123 $this->database->insert(static::TABLE_NAME, $values);
124 }
125
129 protected function select(int $ref_id): array
130 {
131 $ret = [];
132 $query =
133 "SELECT ref_id, online, effective_online, activation_start_ts, activation_end_ts" . PHP_EOL
134 . "FROM " . static::TABLE_NAME . PHP_EOL
135 . "WHERE ref_id = " . $this->database->quote($ref_id, "integer") . PHP_EOL
136 ;
137
138 $result = $this->database->query($query);
139
140 if ($this->database->numRows($result) !== 0) {
141 $ret = $this->database->fetchAssoc($result);
142 }
143
144 return $ret;
145 }
146
147 protected function buildActivationSettings(
148 int $ref_id,
149 bool $online = false,
150 bool $effective_online = false,
151 \DateTime $activation_start = null,
152 \DateTime $activation_end = null
155 $ref_id,
156 $online,
157 $effective_online,
158 $activation_start,
159 $activation_end
160 );
161 }
162
163 public function setEffectiveOnlineStatus(int $ref_id, bool $status): void
164 {
165 $where = ["ref_id" => ["integer", $ref_id]];
166 $values = ["effective_online" => ["integer", $status]];
167
168 $this->database->update(static::TABLE_NAME, $values, $where);
169 }
170}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
insert(ilLearningSequenceActivation $settings)
store(ilLearningSequenceActivation $settings)
buildActivationSettings(int $ref_id, bool $online=false, bool $effective_online=false, \DateTime $activation_start=null, \DateTime $activation_end=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
Interface ilDBInterface.
$ref_id
Definition: ltiauth.php:67
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
$query