31 public static function _deleteAllUsages($a_type, $a_id,
int $a_usage_hist_nr = 0,
string $a_usage_lang =
"-")
36 $and_hist = ($a_usage_hist_nr !==
false) ?
" AND usage_hist_nr = " 37 .
$ilDB->quote($a_usage_hist_nr,
"integer") :
"";
40 $set =
$ilDB->query(
"SELECT id FROM file_usage" .
" WHERE usage_type = " 41 .
$ilDB->quote($a_type,
"text") .
" AND usage_id= " 42 .
$ilDB->quote($a_id,
"integer") .
" AND usage_lang= " 43 .
$ilDB->quote($a_usage_lang,
"text") . $and_hist);
44 while ($row =
$ilDB->fetchAssoc($set)) {
45 $file_ids[] = $row[
"id"];
48 $ilDB->manipulate(
"DELETE FROM file_usage WHERE usage_type = " 49 .
$ilDB->quote($a_type,
"text") .
" AND usage_id = " 50 .
$ilDB->quote((
int) $a_id,
"integer") .
" AND usage_lang= " 51 .
$ilDB->quote($a_usage_lang,
"text") .
" AND usage_hist_nr = " 52 .
$ilDB->quote($a_usage_hist_nr,
"integer"));
61 public static function _saveUsage($a_file_id, $a_type, $a_id,
int $a_usage_hist_nr = 0,
string $a_usage_lang =
"-")
71 $ilDB->replace(
"file_usage", array(
72 "id" => array(
"integer", (
int) $a_file_id),
73 "usage_type" => array(
"text", (
string) $a_type),
74 "usage_id" => array(
"integer", (
int) $a_id),
75 "usage_hist_nr" => array(
"integer", $a_usage_hist_nr),
76 "usage_lang" => array(
"text", $a_usage_lang),
84 public function getUsages(): array
90 $q =
"SELECT * FROM file_usage WHERE id = " .
$ilDB->quote($this->
getId(),
"integer");
91 $us_set =
$ilDB->query($q);
93 while ($us_rec =
$ilDB->fetchAssoc($us_set)) {
95 "type" => $us_rec[
"usage_type"],
96 "id" => $us_rec[
"usage_id"],
97 "lang" => $us_rec[
"usage_lang"],
98 "hist_nr" => $us_rec[
"usage_hist_nr"],
108 public static function _getFilesOfObject(
string $a_type,
int $a_id,
int $a_usage_hist_nr = 0,
string $a_usage_lang =
"-"): array
111 $ilDB = $DIC[
'ilDB'];
114 if ($a_usage_lang !=
"") {
115 $lstr =
"usage_lang = " .
$ilDB->quote($a_usage_lang,
"text") .
" AND ";
119 $q =
"SELECT * FROM file_usage WHERE " .
"usage_id = " .
$ilDB->quote($a_id,
"integer")
120 .
" AND " .
"usage_type = " .
$ilDB->quote($a_type,
"text") .
" AND " . $lstr
121 .
"usage_hist_nr = " .
$ilDB->quote($a_usage_hist_nr,
"integer");
122 $file_set =
$ilDB->query($q);
124 while ($file_rec =
$ilDB->fetchAssoc($file_set)) {
125 $ret[$file_rec[
"id"]] = $file_rec[
"id"];
static _lookupType(int $id, bool $reference=false)