19 declare(strict_types=1);
37 $this->db = (is_null($db))
40 $this->tree = (is_null($tree))
41 ? $DIC->repositoryTree()
53 'SELECT * FROM desktop_item WHERE ' .
54 'item_id = %s AND type = %s AND user_id = %s',
55 [
'integer',
'text',
'integer'],
56 [$ref_id, $type, $user_id]
62 'INSERT INTO desktop_item (item_id, type, user_id, parameters) VALUES ' .
64 [
'integer',
'text',
'integer',
'text'],
65 [$ref_id, $type, $user_id,
'']
76 'DELETE FROM desktop_item WHERE ' .
77 ' item_id = %s AND user_id = %s',
78 [
'integer',
'integer'],
94 if (is_null($a_types)) {
95 $item_set =
$ilDB->queryF(
'SELECT obj.obj_id, obj.description, oref.ref_id, obj.title, obj.type ' .
96 ' FROM desktop_item it, object_reference oref ' .
99 'it.item_id = oref.ref_id AND ' .
100 'oref.obj_id = obj.obj_id AND ' .
101 'it.user_id = %s', [
'integer'], [$user_id]);
102 $items = $all_parent_path = [];
103 while ($item_rec =
$ilDB->fetchAssoc($item_set)) {
104 if ($item_rec[
'type'] !==
'rolf' &&
105 $item_rec[
'type'] !==
'itgr' &&
106 $tree->
isInTree((
int) $item_rec[
'ref_id'])) {
107 $parent_ref = $tree->
getParentId((
int) $item_rec[
'ref_id']);
109 if (!isset($all_parent_path[$parent_ref])) {
110 if ($parent_ref > 0) {
112 $all_parent_path[$parent_ref] = $node[
'title'];
114 $all_parent_path[$parent_ref] =
'';
118 $parent_path = $all_parent_path[$parent_ref];
122 $items[$parent_path . $title . $item_rec[
'ref_id']] =
124 'ref_id' => (
int) $item_rec[
'ref_id'],
125 'obj_id' => (
int) $item_rec[
'obj_id'],
126 'type' => $item_rec[
'type'],
128 'description' => $desc,
129 'parent_ref' => (
int) $parent_ref
135 foreach ($a_types as $a_type) {
136 if ($a_type ===
'itgr') {
139 $item_set =
$ilDB->queryF(
140 'SELECT obj.obj_id, obj.description, oref.ref_id, obj.title FROM desktop_item it, object_reference oref ' .
141 ', object_data obj WHERE ' .
142 'it.item_id = oref.ref_id AND ' .
143 'oref.obj_id = obj.obj_id AND ' .
144 'it.type = %s AND ' .
151 while ($item_rec =
$ilDB->fetchAssoc($item_set)) {
154 $items[$title . $a_type . $item_rec[
'ref_id']] =
156 'ref_id' => (
int) $item_rec[
'ref_id'],
157 'obj_id' => (
int) $item_rec[
'obj_id'],
160 'description' => $desc
174 $user_identification = $user_id .
':' .
$ref_id;
175 if (!isset(self::$is_desktop_item[$user_identification])) {
177 'SELECT item_id FROM desktop_item WHERE ' .
178 'item_id = %s AND user_id = %s',
179 [
'integer',
'integer'],
184 self::$is_desktop_item[$user_identification] =
true;
186 self::$is_desktop_item[$user_identification] =
false;
190 return self::$is_desktop_item[$user_identification];
194 public function loadData(
int $user_id, array $ref_ids): void
197 if (!is_array($ref_ids)) {
202 foreach ($ref_ids as
$ref_id) {
203 $user_identification = $user_id .
':' .
$ref_id;
204 if (!isset(self::$is_desktop_item[$user_identification])) {
209 if (count($load_ref_ids) > 0) {
210 $item_set = $db->
query(
'SELECT item_id FROM desktop_item WHERE ' .
211 $db->
in(
'item_id', $load_ref_ids,
false,
'integer') .
212 ' AND user_id = ' . $db->
quote($user_id,
'integer'));
214 self::$is_desktop_item[$user_id .
':' .
$r[
'item_id']] =
true;
216 foreach ($load_ref_ids as $ref_id) {
217 $user_identification = $user_id .
':' .
$ref_id;
218 if (!isset(self::$is_desktop_item[$user_identification])) {
219 self::$is_desktop_item[$user_id .
':' .
$ref_id] =
false;
231 'DELETE FROM desktop_item WHERE ' .
244 'DELETE FROM desktop_item WHERE ' .
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
manipulateF(string $query, array $types, array $values)
fetchAssoc(ilDBStatement $statement)
isInTree(?int $a_node_id)
get all information of a node.
quote($value, string $type)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _lookupTitle(int $obj_id)
ifIsFavourite(int $user_id, int $ref_id)
query(string $query)
Run a (read-only) Query on the database.
getParentId(int $a_node_id)
get parent id of given node
static _lookupDescription(int $obj_id)
queryF(string $query, array $types, array $values)
in(string $field, array $values, bool $negate=false, string $type="")
removeFavouritesOfRefId(int $ref_id)
loadData(int $user_id, array $ref_ids)
__construct(?ilDBInterface $db=null, ?ilTree $tree=null)
static _lookupType(int $id, bool $reference=false)
removeFavouritesOfUser(int $user_id)
add(int $user_id, int $ref_id)
getFavouritesOfUser(int $user_id, ?array $a_types=null)
Get all desktop items of user and specified type.
static array $is_desktop_item