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.
References $DIC, $ilDB, and $ilUser.
Referenced by ilObjectListGUI\preloadCommonProperties().
348 $ilDB = $DIC->database();
351 $q =
"SELECT count(*) c, obj_id FROM il_tag WHERE " .
352 $ilDB->in(
"obj_id", $a_obj_ids,
false,
"integer");
354 if (!(
bool) $a_all_users) {
355 $q .=
" AND user_id = " .
$ilDB->quote(
$ilUser->getId(),
"integer");
357 $q .=
" GROUP BY obj_id";
360 $set =
$ilDB->query($q);
361 while ($rec =
$ilDB->fetchAssoc($set)) {
362 $cnt[$rec[
"obj_id"]] = $rec[
"c"];
◆ _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.
References $DIC, $ilDB, and $res.
Referenced by ilTaggingClassificationProvider\getFilteredObjects().
429 $ilDB = $DIC->database();
433 $sql =
"SELECT obj_id, obj_type" .
435 " WHERE tag = " .
$ilDB->quote($a_tag,
"text") .
436 " AND is_offline = " .
$ilDB->quote(0,
"integer");
439 $sql .=
" AND user_id = " .
$ilDB->quote($a_user_id,
"integer");
441 $sql .=
" AND user_id <> " .
$ilDB->quote($a_user_id,
"integer");
444 $set =
$ilDB->query($sql);
445 while ($row =
$ilDB->fetchAssoc($set)) {
446 $res[$row[
"obj_id"]] = $row[
"obj_type"];
◆ _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.
References $DIC, $ilDB, $ilUser, and $res.
Referenced by ilTaggingGUI\getHTML(), and ilObjectListGUI\preloadCommonProperties().
464 $ilDB = $DIC->database();
469 $sql =
"SELECT obj_id, tag, user_id" .
471 " WHERE " .
$ilDB->in(
"obj_id", $a_obj_ids,
false,
"integer") .
472 " AND is_offline = " .
$ilDB->quote(0,
"integer");
474 $sql .=
" AND user_id = " .
$ilDB->quote($a_user_id,
"integer");
476 $sql .=
" ORDER BY tag";
477 $set =
$ilDB->query($sql);
478 while ($row =
$ilDB->fetchAssoc($set)) {
480 $res[$row[
"obj_id"]][$tag] =
false;
481 if ($row[
"user_id"] ==
$ilUser->getId()) {
482 $res[$row[
"obj_id"]][$tag] =
true;
◆ _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.
References $DIC, $ilDB, and $res.
Referenced by ilTaggingClassificationProvider\getSubTreeTags().
379 $ilDB = $DIC->database();
383 $sql =
"SELECT obj_id, obj_type, tag, user_id" .
385 " WHERE " .
$ilDB->in(
"obj_id", array_keys($a_obj_ids),
false,
"integer") .
386 " AND is_offline = " .
$ilDB->quote(0,
"integer");
388 $sql .=
" AND user_id = " .
$ilDB->quote($a_user_id,
"integer");
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"]) {
397 if ($row[
"user_id"] == $a_divide) {
398 $res[
"personal"][$tag] = isset(
$res[
"personal"][$tag])
399 ?
$res[
"personal"][$tag]++
402 $res[
"other"][$tag] = isset(
$res[
"other"][$tag])
403 ?
$res[
"other"][$tag]++
◆ 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.
References $DIC, and $ilDB.
Referenced by ilTaggingSlateContentGUI\removeTagsWithoutAccess().
297 $ilDB = $DIC->database();
299 if ($a_sub_obj_type ==
"") {
300 $a_sub_obj_type =
"-";
304 "DELETE FROM il_tag " .
306 "user_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 " .
312 array(
"integer",
"integer",
"text",
"integer",
"text"),
313 array($a_user_id, $a_obj_id, $a_obj_type, $a_sub_obj_id, $a_tag)
◆ 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.
References $DIC, and $ilDB.
Referenced by getObjectsForTagAndUser(), and ilTaggingAppEventListener\handleEvent().
268 $ilDB = $DIC->database();
270 if ($a_sub_obj_type ==
"") {
271 $a_sub_obj_type =
"-";
275 "DELETE FROM il_tag " .
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)
◆ getObjectsForTagAndUser()
static ilTagging::getObjectsForTagAndUser |
( |
int |
$a_user_id, |
|
|
string |
$a_tag |
|
) |
| |
|
static |
Definition at line 179 of file class.ilTagging.php.
References $DIC, $ilDB, ilObject\_exists(), and deleteTagsOfObject().
Referenced by ilTaggingSlateContentGUI\removeTagsWithoutAccess(), and ilTaggingSlateContentGUI\renderResourcesForTag().
185 $ilDB = $DIC->database();
187 $q =
"SELECT * FROM il_tag WHERE " .
188 "user_id = " .
$ilDB->quote($a_user_id,
"integer") .
189 " AND tag = " .
$ilDB->quote($a_tag,
"text");
191 $set =
$ilDB->query($q);
193 while ($rec =
$ilDB->fetchAssoc($set)) {
195 if ($rec[
"sub_obj_type"] ==
"-") {
196 $rec[
"sub_obj_type"] =
"";
201 (
int) $rec[
"obj_id"],
203 (
int) $rec[
"sub_obj_id"],
static deleteTagsOfObject(int $a_obj_id, string $a_obj_type, int $a_sub_obj_id, string $a_sub_obj_type)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
◆ 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.
References $DIC, and $ilDB.
Referenced by ilTaggingGUI\getAllUserTagsForObjectHTML().
122 $ilDB = $DIC->database();
124 $online_str = ($a_only_online)
125 ? $online_str =
" AND is_offline = " .
$ilDB->quote(0,
"integer") .
" " 128 if ($a_sub_obj_type ==
"") {
129 $a_sub_obj_type =
"-";
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) .
138 "GROUP BY tag ORDER BY tag ASC";
139 $set =
$ilDB->query($q);
141 while ($rec =
$ilDB->fetchAssoc($set)) {
◆ 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.
References $DIC, $ilDB, and ilArrayUtil\sortArray().
Referenced by ilTaggingSlateContentGUI\__construct().
156 $ilDB = $DIC->database();
158 $online_str = ($a_only_online)
159 ? $online_str =
" AND is_offline = " .
$ilDB->quote(0,
"integer") .
" " 162 $set =
$ilDB->query(
"SELECT count(*) as cnt, tag FROM il_tag WHERE " .
163 "user_id = " .
$ilDB->quote($a_user_id,
"integer") .
" " .
165 " GROUP BY tag ORDER BY cnt DESC");
168 while (($rec =
$ilDB->fetchAssoc($set)) &&
169 ($a_max == 0 || $cnt <= $a_max)) {
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
◆ 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.
References $DIC, and $ilDB.
Referenced by ilObjectListGUI\getHeaderAction(), ilTaggingGUI\getHTML(), and ilTaggingGUI\getTaggingInputHTML().
89 $ilDB = $DIC->database();
91 if ($a_sub_obj_type ==
"") {
92 $a_sub_obj_type =
"-";
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 " .
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) .
103 $set =
$ilDB->query($q);
105 while ($rec =
$ilDB->fetchAssoc($set)) {
106 $tags[] = $rec[
"tag"];
◆ getUsersForTag()
static ilTagging::getUsersForTag |
( |
string |
$a_tag | ) |
|
|
static |
Definition at line 318 of file class.ilTagging.php.
References $DIC, and $ilDB.
Referenced by ilUserForTagTableGUI\__construct().
322 $ilDB = $DIC->database();
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" 330 while ($rec =
$ilDB->fetchAssoc($set)) {
331 $users[] = array(
"id" => $rec[
"user_id"]);
◆ 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.
References $DIC, and $ilDB.
Referenced by ilTaggingAppEventListener\handleEvent().
241 $ilDB = $DIC->database();
243 if ($a_sub_obj_type ==
"") {
244 $a_sub_obj_type =
"-";
248 "UPDATE il_tag SET is_offline = %s " .
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)
◆ 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.
References $DIC, and $ilDB.
Referenced by ilTaggingGUI\saveInput(), and ilTaggingGUI\saveJS().
46 $ilDB = $DIC->database();
48 if ($a_sub_obj_type ==
"") {
49 $a_sub_obj_type =
"-";
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 " .
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));
60 if (is_array($a_tags)) {
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") .
"," .
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);
The documentation for this class was generated from the following file: