ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilWorkspaceFolderUserSettingsRepository.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12{
16 protected $user_id;
17
18
22 protected $db;
23
27 public function __construct($user_id, ilDBInterface $db = null)
28 {
29 global $DIC;
30
31 $this->user_id = $user_id;
32 $this->db = ($db != null)
33 ? $db
34 : $DIC->database();
35 }
36
42 public function getSortation(int $wfld_id) : int
43 {
44 $db = $this->db;
45
46 $set = $db->queryF(
47 "SELECT * FROM wfld_user_setting " .
48 " WHERE user_id = %s " .
49 " AND wfld_id = %s ",
50 array("integer", "integer"),
51 array($this->user_id, $wfld_id)
52 );
53 $rec = $db->fetchAssoc($set);
54 return (int) $rec["sortation"];
55 }
56
62 public function getSortationMultiple(array $wfld_ids) : array
63 {
64 $db = $this->db;
65
66 $set = $db->queryF(
67 "SELECT * FROM wfld_user_setting " .
68 " WHERE user_id = %s " .
69 " AND " . $db->in("wfld_id", $wfld_ids, false, "integer"),
70 array("integer"),
71 array($this->user_id)
72 );
73 $ret = [];
74
75 while ($rec = $db->fetchAssoc($set)) {
76 $ret[$rec["wfld_id"]] = (int) $rec["sortation"];
77 }
78 foreach ($wfld_ids as $id) {
79 if (!isset($ret[$id])) {
80 $ret[$id] = 0;
81 }
82 }
83 return $ret;
84 }
85
91 public function updateSortation(int $wfld_id, int $sortation)
92 {
93 $db = $this->db;
94
95 $db->replace("wfld_user_setting", array( // pk
96 "user_id" => array("integer", $this->user_id),
97 "wfld_id" => array("integer", $wfld_id)
98 ), array(
99 "sortation" => array("integer", $sortation)
100 ));
101 }
102}
An exception for terminatinating execution or to throw for unit testing.
Stores user settings per workspace folder Table: wfld_user_setting (rw)
getSortationMultiple(array $wfld_ids)
Get Sortation of workspace folder.
__construct($user_id, ilDBInterface $db=null)
Constructor.
updateSortation(int $wfld_id, int $sortation)
Update sortation for workspace folder.
getSortation(int $wfld_id)
Get Sortation of workspace folder.
Interface ilDBInterface.
$ret
Definition: parser.php:6
$DIC
Definition: xapitoken.php:46