This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
More...
|
| static | writeTagsForUserAndObject (int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, int $a_user_id, array $a_tags) |
| |
| static | getTagsForUserAndObject (int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, int $a_user_id) |
| |
| static | getTagsForObject (int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, bool $a_only_online=true) |
| |
| static | getTagsForUser (int $a_user_id, int $a_max=0, bool $a_only_online=true) |
| |
| static | getObjectsForTagAndUser (int $a_user_id, string $a_tag) |
| |
| static | getRelevanceClass (int $cnt, int $max) |
| |
| static | setTagsOfObjectOffline (int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, bool $a_offline=true) |
| |
| static | deleteTagsOfObject (int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type) |
| |
| static | deleteTagOfObjectForUser (int $a_user_id, int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type, string $a_tag) |
| |
| static | getUsersForTag (string $a_tag) |
| |
| static | _countTags (array $a_obj_ids, bool $a_all_users=false) |
| | Count all tags for repository objects. More...
|
| |
| static | _getTagCloudForObjects (array $a_obj_ids, ?int $a_user_id=null, int $a_divide=0) |
| | Count tags for given object ids. More...
|
| |
| static | _findObjectsByTag (string $a_tag, int $a_user_id=null, bool $a_invert=false) |
| | Find all objects with given tag. More...
|
| |
| static | _getListTagsForObjects (array $a_obj_ids, int $a_user_id=null) |
| | Get tags for given object ids. More...
|
| |
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.
If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilTagging
- Author
- Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de
Definition at line 26 of file class.ilTagging.php.
◆ __construct()
| ilTagging::__construct |
( |
| ) |
|
◆ _countTags()
| static ilTagging::_countTags |
( |
array |
$a_obj_ids, |
|
|
bool |
$a_all_users = false |
|
) |
| |
|
static |
Count all tags for repository objects.
- Parameters
-
| int[] | $a_obj_ids | |
| bool | $a_all_users | |
- Returns
- int[] key is object id
Definition at line 342 of file class.ilTagging.php.
345 : array {
347
350
351 $q = "SELECT count(*) c, obj_id FROM il_tag WHERE " .
352 $ilDB->in(
"obj_id", $a_obj_ids,
false,
"integer");
353
354 if (!(bool) $a_all_users) {
355 $q .=
" AND user_id = " .
$ilDB->quote(
$ilUser->getId(),
"integer");
356 }
357 $q .= " GROUP BY obj_id";
358
359 $cnt = array();
360 $set =
$ilDB->query($q);
361 while ($rec =
$ilDB->fetchAssoc($set)) {
362 $cnt[$rec["obj_id"]] = $rec["c"];
363 }
364
365 return $cnt;
366 }
References $ilDB, and $ilUser.
Referenced by ilObjectListGUI\preloadCommonProperties().
◆ _findObjectsByTag()
| static ilTagging::_findObjectsByTag |
( |
string |
$a_tag, |
|
|
int |
$a_user_id = null, |
|
|
bool |
$a_invert = false |
|
) |
| |
|
static |
Find all objects with given tag.
- Parameters
-
- Returns
- int[]
Definition at line 422 of file class.ilTagging.php.
426 : array {
428
430
432
433 $sql = "SELECT obj_id, obj_type" .
434 " FROM il_tag" .
435 " WHERE tag = " .
$ilDB->quote($a_tag,
"text") .
436 " AND is_offline = " .
$ilDB->quote(0,
"integer");
437 if ($a_user_id) {
438 if (!$a_invert) {
439 $sql .=
" AND user_id = " .
$ilDB->quote($a_user_id,
"integer");
440 } else {
441 $sql .=
" AND user_id <> " .
$ilDB->quote($a_user_id,
"integer");
442 }
443 }
444 $set =
$ilDB->query($sql);
445 while ($row =
$ilDB->fetchAssoc($set)) {
446 $res[$row[
"obj_id"]] = $row[
"obj_type"];
447 }
448
450 }
Referenced by ilTaggingClassificationProvider\getFilteredObjects().
◆ _getListTagsForObjects()
| static ilTagging::_getListTagsForObjects |
( |
array |
$a_obj_ids, |
|
|
int |
$a_user_id = null |
|
) |
| |
|
static |
Get tags for given object ids.
- Parameters
-
| array | $a_obj_ids | |
| ?int | $a_user_id |
- Returns
- array
Definition at line 458 of file class.ilTagging.php.
461 : array {
463
466
468
469 $sql = "SELECT obj_id, tag, user_id" .
470 " FROM il_tag" .
471 " WHERE " .
$ilDB->in(
"obj_id", $a_obj_ids,
false,
"integer") .
472 " AND is_offline = " .
$ilDB->quote(0,
"integer");
473 if ($a_user_id) {
474 $sql .=
" AND user_id = " .
$ilDB->quote($a_user_id,
"integer");
475 }
476 $sql .= " ORDER BY tag";
477 $set =
$ilDB->query($sql);
478 while ($row =
$ilDB->fetchAssoc($set)) {
479 $tag = $row["tag"];
480 $res[$row[
"obj_id"]][$tag] =
false;
481 if ($row[
"user_id"] ==
$ilUser->getId()) {
482 $res[$row[
"obj_id"]][$tag] =
true;
483 }
484 }
485
487 }
Referenced by ilTaggingGUI\getHTML(), and ilObjectListGUI\preloadCommonProperties().
◆ _getTagCloudForObjects()
| static ilTagging::_getTagCloudForObjects |
( |
array |
$a_obj_ids, |
|
|
?int |
$a_user_id = null, |
|
|
int |
$a_divide = 0 |
|
) |
| |
|
static |
Count tags for given object ids.
- Parameters
-
Definition at line 372 of file class.ilTagging.php.
376 : array {
378
380
382
383 $sql = "SELECT obj_id, obj_type, tag, user_id" .
384 " FROM il_tag" .
385 " WHERE " .
$ilDB->in(
"obj_id", array_keys($a_obj_ids),
false,
"integer") .
386 " AND is_offline = " .
$ilDB->quote(0,
"integer");
387 if ($a_user_id) {
388 $sql .=
" AND user_id = " .
$ilDB->quote($a_user_id,
"integer");
389 }
390 $sql .= " ORDER BY tag";
391 $set =
$ilDB->query($sql);
392 while ($row =
$ilDB->fetchAssoc($set)) {
393 if ($a_obj_ids[$row["obj_id"]] == $row["obj_type"]) {
394 $tag = $row["tag"];
395
396 if ($a_divide > 0) {
397 if ($row["user_id"] == $a_divide) {
398 $res[
"personal"][$tag] = isset(
$res[
"personal"][$tag])
399 ?
$res[
"personal"][$tag]++
400 : 1;
401 } else {
402 $res[
"other"][$tag] = isset(
$res[
"other"][$tag])
403 ?
$res[
"other"][$tag]++
404 : 1;
405 }
406 } else {
409 : 1;
410 }
411 }
412 }
413
415 }
Referenced by ilTaggingClassificationProvider\getSubTreeTags().
◆ deleteTagOfObjectForUser()
| static ilTagging::deleteTagOfObjectForUser |
( |
int |
$a_user_id, |
|
|
int |
$a_obj_id, |
|
|
string |
$a_obj_type, |
|
|
int |
$a_sub_obj_id, |
|
|
string |
$a_sub_obj_type, |
|
|
string |
$a_tag |
|
) |
| |
|
static |
Definition at line 287 of file class.ilTagging.php.
294 : void {
296
298
299 if ($a_sub_obj_type == "") {
300 $a_sub_obj_type = "-";
301 }
302
304 "DELETE FROM il_tag " .
305 "WHERE " .
306 "user_id = %s AND " .
307 "obj_id = %s AND " .
308 "obj_type = %s AND " .
309 "sub_obj_id = %s AND " .
310 $ilDB->equals(
"sub_obj_type", $a_sub_obj_type,
"text",
true) .
" AND " .
311 "tag = %s",
312 array("integer", "integer", "text", "integer", "text"),
313 array($a_user_id, $a_obj_id, $a_obj_type, $a_sub_obj_id, $a_tag)
314 );
315 }
Referenced by ilTaggingSlateContentGUI\removeTagsWithoutAccess().
◆ deleteTagsOfObject()
| static ilTagging::deleteTagsOfObject |
( |
int |
$a_obj_id, |
|
|
string |
$a_obj_type, |
|
|
int |
$a_sub_obj_id, |
|
|
string |
$a_sub_obj_type |
|
) |
| |
|
static |
Definition at line 260 of file class.ilTagging.php.
265 : void {
267
269
270 if ($a_sub_obj_type == "") {
271 $a_sub_obj_type = "-";
272 }
273
275 "DELETE FROM il_tag " .
276 "WHERE " .
277 "obj_id = %s AND " .
278 "obj_type = %s AND " .
279 "sub_obj_id = %s AND " .
280 $ilDB->equals(
"sub_obj_type", $a_sub_obj_type,
"text",
true),
281 array("integer", "text", "integer"),
282 array($a_obj_id, $a_obj_type, $a_sub_obj_id)
283 );
284 }
Referenced by ilTaggingAppEventListener\handleEvent().
◆ getObjectsForTagAndUser()
| static ilTagging::getObjectsForTagAndUser |
( |
int |
$a_user_id, |
|
|
string |
$a_tag |
|
) |
| |
|
static |
Definition at line 179 of file class.ilTagging.php.
182 : array {
184
186
187 $q = "SELECT * FROM il_tag WHERE " .
188 "user_id = " .
$ilDB->quote($a_user_id,
"integer") .
189 " AND tag = " .
$ilDB->quote($a_tag,
"text");
190
191 $set =
$ilDB->query($q);
192 $objects = array();
193 while ($rec =
$ilDB->fetchAssoc($set)) {
195 if ($rec["sub_obj_type"] == "-") {
196 $rec["sub_obj_type"] = "";
197 }
198 $objects[] = $rec;
199 } else {
201 (int) $rec["obj_id"],
202 $rec["obj_type"],
203 (int) $rec["sub_obj_id"],
204 $rec["sub_obj_type"]
205 );
206 }
207 }
208
209 return $objects;
210 }
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static deleteTagsOfObject(int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type)
Referenced by ilTaggingSlateContentGUI\removeTagsWithoutAccess(), and ilTaggingSlateContentGUI\renderResourcesForTag().
◆ getRelevanceClass()
| static ilTagging::getRelevanceClass |
( |
int |
$cnt, |
|
|
int |
$max |
|
) |
| |
|
static |
◆ getTagsForObject()
| static ilTagging::getTagsForObject |
( |
int |
$a_obj_id, |
|
|
string |
$a_obj_type, |
|
|
int |
$a_sub_obj_id, |
|
|
string |
$a_sub_obj_type, |
|
|
bool |
$a_only_online = true |
|
) |
| |
|
static |
Definition at line 113 of file class.ilTagging.php.
119 : array {
121
123
124 $online_str = ($a_only_online)
125 ? $online_str =
" AND is_offline = " .
$ilDB->quote(0,
"integer") .
" "
126 : "";
127
128 if ($a_sub_obj_type == "") {
129 $a_sub_obj_type = "-";
130 }
131
132 $q = "SELECT count(user_id) as cnt, tag FROM il_tag WHERE " .
133 "obj_id = " .
$ilDB->quote($a_obj_id,
"integer") .
" AND " .
134 "obj_type = " .
$ilDB->quote($a_obj_type,
"text") .
" AND " .
135 "sub_obj_id = " .
$ilDB->quote($a_sub_obj_id,
"integer") .
" AND " .
136 $ilDB->equals(
"sub_obj_type", $a_sub_obj_type,
"text",
true) .
137 $online_str .
138 "GROUP BY tag ORDER BY tag ASC";
139 $set =
$ilDB->query($q);
140 $tags = array();
141 while ($rec =
$ilDB->fetchAssoc($set)) {
142 $tags[] = $rec;
143 }
144
145 return $tags;
146 }
Referenced by ilTaggingGUI\getAllUserTagsForObjectHTML().
◆ getTagsForUser()
| static ilTagging::getTagsForUser |
( |
int |
$a_user_id, |
|
|
int |
$a_max = 0, |
|
|
bool |
$a_only_online = true |
|
) |
| |
|
static |
Definition at line 149 of file class.ilTagging.php.
153 : array {
155
157
158 $online_str = ($a_only_online)
159 ? $online_str =
" AND is_offline = " .
$ilDB->quote(0,
"integer") .
" "
160 : "";
161
162 $set =
$ilDB->query(
"SELECT count(*) as cnt, tag FROM il_tag WHERE " .
163 "user_id = " .
$ilDB->quote($a_user_id,
"integer") .
" " .
164 $online_str .
165 " GROUP BY tag ORDER BY cnt DESC");
166 $tags = array();
167 $cnt = 1;
168 while (($rec =
$ilDB->fetchAssoc($set)) &&
169 ($a_max == 0 || $cnt <= $a_max)) {
170 $tags[] = $rec;
171 $cnt++;
172 }
174
175 return $tags;
176 }
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
Referenced by ilTaggingSlateContentGUI\__construct().
◆ getTagsForUserAndObject()
| static ilTagging::getTagsForUserAndObject |
( |
int |
$a_obj_id, |
|
|
string |
$a_obj_type, |
|
|
int |
$a_sub_obj_id, |
|
|
string |
$a_sub_obj_type, |
|
|
int |
$a_user_id |
|
) |
| |
|
static |
Definition at line 80 of file class.ilTagging.php.
86 : array {
88
90
91 if ($a_sub_obj_type == "") {
92 $a_sub_obj_type = "-";
93 }
94
95 $q = "SELECT * FROM il_tag WHERE " .
96 "user_id = " .
$ilDB->quote($a_user_id,
"integer") .
" AND " .
97 "obj_id = " .
$ilDB->quote($a_obj_id,
"integer") .
" AND " .
98 "obj_type = " .
$ilDB->quote($a_obj_type,
"text") .
" AND " .
99
100 "sub_obj_id = " .
$ilDB->quote((
int) $a_sub_obj_id,
"integer") .
" AND " .
101 $ilDB->equals(
"sub_obj_type", $a_sub_obj_type,
"text",
true) .
102 " ORDER BY tag";
103 $set =
$ilDB->query($q);
104 $tags = array();
105 while ($rec =
$ilDB->fetchAssoc($set)) {
106 $tags[] = $rec["tag"];
107 }
108
109 return $tags;
110 }
Referenced by ilObjectListGUI\getHeaderAction(), ilTaggingGUI\getHTML(), and ilTaggingGUI\getTaggingInputHTML().
◆ getUsersForTag()
| static ilTagging::getUsersForTag |
( |
string |
$a_tag | ) |
|
|
static |
Definition at line 318 of file class.ilTagging.php.
320 : array {
323
325 "SELECT DISTINCT user_id, firstname, lastname FROM il_tag JOIN usr_data ON (user_id = usr_id) " .
326 " WHERE LOWER(tag) = LOWER(" .
$ilDB->quote($a_tag,
"text") .
")" .
327 " ORDER BY lastname, firstname"
328 );
329 $users = array();
330 while ($rec =
$ilDB->fetchAssoc($set)) {
331 $users[] = array("id" => $rec["user_id"]);
332 }
333 return $users;
334 }
Referenced by ilUserForTagTableGUI\__construct().
◆ setTagsOfObjectOffline()
| static ilTagging::setTagsOfObjectOffline |
( |
int |
$a_obj_id, |
|
|
string |
$a_obj_type, |
|
|
int |
$a_sub_obj_id, |
|
|
string |
$a_sub_obj_type, |
|
|
bool |
$a_offline = true |
|
) |
| |
|
static |
Definition at line 232 of file class.ilTagging.php.
238 : void {
240
242
243 if ($a_sub_obj_type == "") {
244 $a_sub_obj_type = "-";
245 }
246
248 "UPDATE il_tag SET is_offline = %s " .
249 "WHERE " .
250 "obj_id = %s AND " .
251 "obj_type = %s AND " .
252 "sub_obj_id = %s AND " .
253 $ilDB->equals(
"sub_obj_type", $a_sub_obj_type,
"text",
true),
254 array("boolean", "integer", "text", "integer"),
255 array($a_offline, $a_obj_id, $a_obj_type, $a_sub_obj_id)
256 );
257 }
Referenced by ilTaggingAppEventListener\handleEvent().
◆ writeTagsForUserAndObject()
| static ilTagging::writeTagsForUserAndObject |
( |
int |
$a_obj_id, |
|
|
string |
$a_obj_type, |
|
|
int |
$a_sub_obj_id, |
|
|
string |
$a_sub_obj_type, |
|
|
int |
$a_user_id, |
|
|
array |
$a_tags |
|
) |
| |
|
static |
Definition at line 36 of file class.ilTagging.php.
43 : void {
45
47
48 if ($a_sub_obj_type == "") {
49 $a_sub_obj_type = "-";
50 }
51
52 $ilDB->manipulate(
"DELETE FROM il_tag WHERE " .
53 "user_id = " .
$ilDB->quote($a_user_id,
"integer") .
" AND " .
54 "obj_id = " .
$ilDB->quote($a_obj_id,
"integer") .
" AND " .
55 "obj_type = " .
$ilDB->quote($a_obj_type,
"text") .
" AND " .
56
57 "sub_obj_id = " .
$ilDB->quote((
int) $a_sub_obj_id,
"integer") .
" AND " .
58 $ilDB->equals(
"sub_obj_type", $a_sub_obj_type,
"text",
true));
59
60 if (is_array($a_tags)) {
61 $inserted = array();
62 foreach ($a_tags as $tag) {
63 if (!in_array(strtolower($tag), $inserted)) {
64 $ilDB->manipulate(
"INSERT INTO il_tag (user_id, obj_id, obj_type," .
65 "sub_obj_id, sub_obj_type, tag) VALUES (" .
66 $ilDB->quote($a_user_id,
"integer") .
"," .
67 $ilDB->quote($a_obj_id,
"integer") .
"," .
68 $ilDB->quote($a_obj_type,
"text") .
"," .
69
70 $ilDB->quote((
int) $a_sub_obj_id,
"integer") .
"," .
71 $ilDB->quote($a_sub_obj_type,
"text") .
"," .
72 $ilDB->quote($tag,
"text") .
")");
73 $inserted[] = strtolower($tag);
74 }
75 }
76 }
77 }
Referenced by ilTaggingGUI\saveInput(), and ilTaggingGUI\saveJS().
The documentation for this class was generated from the following file: