ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPageContentUsage.php
Go to the documentation of this file.
1<?php
2
24{
25 public static function saveUsage(
26 string $a_pc_type,
27 int $a_pc_id,
28 string $a_usage_type,
29 int $a_usage_id,
30 int $a_usage_hist_nr = 0,
31 string $a_lang = "-"
32 ): void {
33 global $DIC;
34
35 $ilDB = $DIC->database();
36
37 $ilDB->replace("page_pc_usage", array(
38 "pc_type" => array("text", $a_pc_type),
39 "pc_id" => array("integer", $a_pc_id),
40 "usage_type" => array("text", $a_usage_type),
41 "usage_id" => array("integer", $a_usage_id),
42 "usage_lang" => array("text", $a_lang),
43 "usage_hist_nr" => array("integer", $a_usage_hist_nr)
44 ), array());
45 }
46
47 public static function deleteAllUsages(
48 string $a_pc_type,
49 string $a_usage_type,
50 int $a_usage_id,
51 int $a_usage_hist_nr = 0,
52 string $a_lang = "-"
53 ): void {
54 global $DIC;
55
56 $ilDB = $DIC->database();
57
58 $and_hist = ($a_usage_hist_nr !== 0)
59 ? " AND usage_hist_nr = " . $ilDB->quote($a_usage_hist_nr, "integer")
60 : "";
61
62 $ilDB->manipulate($q = "DELETE FROM page_pc_usage WHERE usage_type = " .
63 $ilDB->quote($a_usage_type, "text") .
64 " AND usage_id = " . $ilDB->quote($a_usage_id, "integer") .
65 " AND usage_lang = " . $ilDB->quote($a_lang, "text") .
66 $and_hist .
67 " AND pc_type = " . $ilDB->quote($a_pc_type, "text"));
68 }
69
73 public static function getUsages(
74 string $a_pc_type,
75 int $a_pc_id,
76 bool $a_incl_hist = true
77 ): array {
78 global $DIC;
79
80 $ilDB = $DIC->database();
81
82 $q = "SELECT * FROM page_pc_usage " .
83 " WHERE pc_type = " . $ilDB->quote($a_pc_type, "text") .
84 " AND pc_id = " . $ilDB->quote($a_pc_id, "integer");
85
86 if (!$a_incl_hist) {
87 $q .= " AND usage_hist_nr = " . $ilDB->quote(0, "integer");
88 }
89
90 $set = $ilDB->query($q);
91 $usages = array();
92 while ($rec = $ilDB->fetchAssoc($set)) {
93 $usages[] = $rec;
94 }
95 return $usages;
96 }
97
101 public static function getUsagesOfPage(
102 int $a_usage_id,
103 string $a_usage_type,
104 int $a_hist_nr = 0,
105 bool $a_all_hist_nrs = false,
106 string $a_lang = "-"
107 ): array {
108 global $DIC;
109
110 $ilDB = $DIC->database();
111
112 $hist_str = "";
113 if (!$a_all_hist_nrs) {
114 $hist_str = " AND usage_hist_nr = " . $ilDB->quote($a_hist_nr, "integer");
115 }
116
117 $set = $ilDB->query(
118 "SELECT pc_type, pc_id FROM page_pc_usage WHERE " .
119 " usage_id = " . $ilDB->quote($a_usage_id, "integer") . " AND " .
120 " usage_lang = " . $ilDB->quote($a_lang, "text") . " AND " .
121 " usage_type = " . $ilDB->quote($a_usage_type, "text") .
122 $hist_str
123 );
124
125 $usages = array();
126 while ($rec = $ilDB->fetchAssoc($set)) {
127 $usages[$rec["pc_type"] . ":" . $rec["pc_id"]] = array(
128 "type" => $rec["pc_type"],
129 "id" => $rec["pc_id"]
130 );
131 }
132 return $usages;
133 }
134}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getUsages(string $a_pc_type, int $a_pc_id, bool $a_incl_hist=true)
Get usages.
static getUsagesOfPage(int $a_usage_id, string $a_usage_type, int $a_hist_nr=0, bool $a_all_hist_nrs=false, string $a_lang="-")
Get page content usages for page.
static saveUsage(string $a_pc_type, int $a_pc_id, string $a_usage_type, int $a_usage_id, int $a_usage_hist_nr=0, string $a_lang="-")
static deleteAllUsages(string $a_pc_type, string $a_usage_type, int $a_usage_id, int $a_usage_hist_nr=0, string $a_lang="-")
global $DIC
Definition: shib_login.php:26
$q
Definition: shib_logout.php:23