ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilWorkspaceFolderUserSettingsRepository.php
Go to the documentation of this file.
1 <?php
2 
26 {
27  protected int $user_id;
28  protected ilDBInterface $db;
29 
33  public function __construct(
34  int $user_id,
35  ilDBInterface $db = null
36  ) {
37  global $DIC;
38 
39  $this->user_id = $user_id;
40  $this->db = ($db != null)
41  ? $db
42  : $DIC->database();
43  }
44 
45  public function getSortation(int $wfld_id): int
46  {
47  $db = $this->db;
48 
49  $set = $db->queryF(
50  "SELECT * FROM wfld_user_setting " .
51  " WHERE user_id = %s " .
52  " AND wfld_id = %s ",
53  array("integer", "integer"),
54  array($this->user_id, $wfld_id)
55  );
56  $rec = $db->fetchAssoc($set);
57  return (int) ($rec["sortation"] ?? 0);
58  }
59 
60  public function getSortationMultiple(array $wfld_ids): array
61  {
62  $db = $this->db;
63 
64  $set = $db->queryF(
65  "SELECT * FROM wfld_user_setting " .
66  " WHERE user_id = %s " .
67  " AND " . $db->in("wfld_id", $wfld_ids, false, "integer"),
68  array("integer"),
69  array($this->user_id)
70  );
71  $ret = [];
72 
73  while ($rec = $db->fetchAssoc($set)) {
74  $ret[$rec["wfld_id"]] = (int) $rec["sortation"];
75  }
76  foreach ($wfld_ids as $id) {
77  if (!isset($ret[$id])) {
78  $ret[$id] = 0;
79  }
80  }
81  return $ret;
82  }
83 
84  public function updateSortation(int $wfld_id, int $sortation)
85  {
86  $db = $this->db;
87 
88  $db->replace("wfld_user_setting", array( // pk
89  "user_id" => array("integer", $this->user_id),
90  "wfld_id" => array("integer", $wfld_id)
91  ), array(
92  "sortation" => array("integer", $sortation)
93  ));
94  }
95 }
fetchAssoc(ilDBStatement $statement)
global $DIC
Definition: feed.php:28
__construct(int $user_id, ilDBInterface $db=null)
Constructor.
queryF(string $query, array $types, array $values)
in(string $field, array $values, bool $negate=false, string $type="")
replace(string $table, array $primary_keys, array $other_columns)
Replace into method.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...