ILIAS  release_8 Revision v8.24
class.ilBlockSetting.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
27{
31 public static array $setting = array();
32 public static bool $pd_preloaded = false;
33
37 public static function _lookup(
38 string $a_type,
39 string $a_setting,
40 int $a_user = 0,
41 int $a_block_id = 0
42 ): ?string {
43 global $DIC;
44
45 $ilDB = $DIC->database();
46 $ilSetting = $DIC->settings();
47
48 $key = $a_type . ":" . $a_setting . ":" . $a_user . ":" . $a_block_id;
49 if (isset(self::$setting[$key])) {
50 return (string) self::$setting[$key];
51 }
52
53 $set = $ilDB->query(sprintf(
54 "SELECT value FROM il_block_setting WHERE type = %s " .
55 "AND user_id = %s AND setting = %s AND block_id = %s",
56 $ilDB->quote($a_type, "text"),
57 $ilDB->quote($a_user, "integer"),
58 $ilDB->quote($a_setting, "text"),
59 $ilDB->quote($a_block_id, "integer")
60 ));
61 if ($rec = $ilDB->fetchAssoc($set)) {
62 self::$setting[$key] = $rec["value"];
63 return $rec["value"];
64 } elseif ($ilSetting->get('block_default_setting_' . $a_type . '_' . $a_setting, null)) {
65 self::$setting[$key] = $ilSetting->get('block_default_setting_' . $a_type . '_' . $a_setting, null);
66 return $ilSetting->get('block_default_setting_' . $a_type . '_' . $a_setting, null);
67 } else {
68 self::$setting[$key] = false;
69 return null;
70 }
71 }
72
76 public static function preloadPDBlockSettings(): void
77 {
78 global $DIC;
79
80 $ilDB = $DIC->database();
81 $ilUser = $DIC->user();
82
83 if (!self::$pd_preloaded) {
84 $blocks = array("pdbookm", "pdcal", "pdfeedb", "pditems",
85 "pdmail", "pdnews", "pdnotes", "pdtag");
86 $settings = array("detail", "nr", "side");
87 $user_id = $ilUser->getId();
88
89 foreach ($blocks as $b) {
90 foreach ($settings as $s) {
91 $key = $b . ":" . $s . ":" . $user_id . ":0";
92 if ($s == "detail") {
93 self::$setting[$key] = 2;
94 } else {
95 self::$setting[$key] = false;
96 }
97 }
98 }
99
100 $set = $ilDB->query(
101 $q = "SELECT type, setting, value FROM il_block_setting WHERE " .
102 " user_id = " . $ilDB->quote($user_id, "integer") .
103 " AND " . $ilDB->in("type", $blocks, false, "text") .
104 " AND " . $ilDB->in("setting", $settings, false, "text")
105 );
106 while ($rec = $ilDB->fetchAssoc($set)) {
107 $key = $rec["type"] . ":" . $rec["setting"] . ":" . $user_id . ":0";
108 self::$setting[$key] = $rec["value"];
109 }
110
111 self::$pd_preloaded = true;
112 }
113 }
114
118 public static function _write(
119 string $a_type,
120 string $a_setting,
121 string $a_value,
122 int $a_user = 0,
123 int $a_block_id = 0
124 ): void {
125 global $DIC;
126
127 $ilDB = $DIC->database();
128
129 $ilDB->manipulate(sprintf(
130 "DELETE FROM il_block_setting WHERE type = %s AND user_id = %s AND block_id = %s AND setting = %s",
131 $ilDB->quote($a_type, "text"),
132 $ilDB->quote($a_user, "integer"),
133 $ilDB->quote($a_block_id, "integer"),
134 $ilDB->quote($a_setting, "text")
135 ));
136 $ilDB->manipulate(sprintf(
137 "INSERT INTO il_block_setting (type, user_id, setting, block_id, value) VALUES (%s,%s,%s,%s,%s)",
138 $ilDB->quote($a_type, "text"),
139 $ilDB->quote($a_user, "integer"),
140 $ilDB->quote($a_setting, "text"),
141 $ilDB->quote($a_block_id, "integer"),
142 $ilDB->quote($a_value, "text")
143 ));
144 }
145
149 public static function _lookupDetailLevel(
150 string $a_type,
151 int $a_user = 0,
152 int $a_block_id = 0
153 ): int {
154 $detail = self::_lookup($a_type, "detail", $a_user, $a_block_id);
155
156 if (is_null($detail)) { // return a level of 2 (standard value) if record does not exist
157 return 2;
158 }
159
160 return (int) $detail;
161 }
162
163 public static function _writeDetailLevel(
164 string $a_type,
165 string $a_value,
166 int $a_user = 0,
167 int $a_block_id = 0
168 ): void {
169 ilBlockSetting::_write($a_type, "detail", $a_value, $a_user, $a_block_id);
170 }
171
172 public static function _writeNumber(
173 string $a_type,
174 string $a_value,
175 int $a_user = 0,
176 int $a_block_id = 0
177 ): void {
178 ilBlockSetting::_write($a_type, "nr", $a_value, $a_user, $a_block_id);
179 }
180
184 public static function _lookupSide(
185 string $a_type,
186 int $a_user = 0,
187 int $a_block_id = 0
188 ): ?string {
189 return ilBlockSetting::_lookup($a_type, "side", $a_user, $a_block_id);
190 }
191
192 public static function _writeSide(
193 string $a_type,
194 string $a_value,
195 int $a_user = 0,
196 int $a_block_id = 0
197 ): void {
198 ilBlockSetting::_write($a_type, "side", $a_value, $a_user, $a_block_id);
199 }
200
201 public static function _deleteSettingsOfUser(
202 int $a_user
203 ): void {
204 global $DIC;
205
206 $ilDB = $DIC->database();
207
208 if ($a_user > 0) {
209 $ilDB->manipulate("DELETE FROM il_block_setting WHERE user_id = " .
210 $ilDB->quote($a_user, "integer"));
211 }
212 }
213
214 public static function _deleteSettingsOfBlock(
215 int $a_block_id,
216 string $a_block_type
217 ): void {
218 global $DIC;
219
220 $ilDB = $DIC->database();
221
222 if ($a_block_id > 0) {
223 $ilDB->manipulate("DELETE FROM il_block_setting WHERE block_id = " .
224 $ilDB->quote($a_block_id, "integer") .
225 " AND type = " . $ilDB->quote($a_block_type, "text"));
226 }
227 }
228
229 public static function cloneSettingsOfBlock(
230 string $block_type,
231 int $block_id,
232 int $new_block_id
233 ): void {
234 global $DIC;
235
236 $db = $DIC->database();
237
238 $set = $db->queryF(
239 "SELECT * FROM il_block_setting " .
240 " WHERE block_id = %s AND type = %s AND user_id = %s",
241 array("integer", "text", "integer"),
242 array($block_id, $block_type, 0)
243 );
244 while ($rec = $db->fetchAssoc($set)) {
245 self::_write($block_type, (string) $rec["setting"], (string) $rec["value"], 0, $new_block_id);
246 }
247 }
248}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupSide(string $a_type, int $a_user=0, int $a_block_id=0)
Lookup side.
static _deleteSettingsOfBlock(int $a_block_id, string $a_block_type)
static _deleteSettingsOfUser(int $a_user)
static _lookupDetailLevel(string $a_type, int $a_user=0, int $a_block_id=0)
Lookup detail level.
static preloadPDBlockSettings()
Preload pd info.
static bool $pd_preloaded
static _write(string $a_type, string $a_setting, string $a_value, int $a_user=0, int $a_block_id=0)
Write setting to database.
static _writeDetailLevel(string $a_type, string $a_value, int $a_user=0, int $a_block_id=0)
static _writeSide(string $a_type, string $a_value, int $a_user=0, int $a_block_id=0)
static cloneSettingsOfBlock(string $block_type, int $block_id, int $new_block_id)
static _writeNumber(string $a_type, string $a_value, int $a_user=0, int $a_block_id=0)
static _lookup(string $a_type, string $a_setting, int $a_user=0, int $a_block_id=0)
Lookup setting from database.
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']
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
string $key
Consumer key/client ID value.
Definition: System.php:193
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
global $ilSetting
Definition: privfeed.php:17