ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
CriteriaFileRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27
29{
30 protected \ilLogger $log;
31
32 public function __construct(
33 protected IRSSWrapper $irss,
34 protected InternalDataService $data,
35 protected \ilDBInterface $db
36 ) {
37 global $DIC;
38
39 $this->log = $DIC->logger()->exc();
40 }
41
42 public function deliverFileOfReview(
43 int $ass_id,
44 int $giver_id,
45 int $peer_id,
46 int $criteria_id
47 ): void {
48 $rid = $this->getFileRidOfReview($ass_id, $giver_id, $peer_id, $criteria_id);
49 $this->irss->deliverFile($rid);
50 }
51
52 public function getFileRidOfReview(int $ass_id, int $giver_id, int $peer_id, int $criteria_id): string
53 {
54 $set = $this->db->queryF(
55 "SELECT rid FROM exc_crit_file " .
56 " WHERE ass_id = %s AND giver_id = %s AND peer_id = %s and criteria_id = %s",
57 ["integer", "integer", "integer", "integer"],
58 [$ass_id, $giver_id, $peer_id, $criteria_id]
59 );
60 $rec = $this->db->fetchAssoc($set);
61 return $rec["rid"] ?? "";
62 }
63
64 public function getFile(
65 int $ass_id,
66 int $giver_id,
67 int $peer_id,
68 int $citeria_id
69 ): ?CriteriaFile {
70 $rid = $this->getFileRidOfReview($ass_id, $giver_id, $peer_id, $citeria_id);
71 if ($rid === "") {
72 return null;
73 }
74 $info = $this->irss->getResourceInfo($rid);
75 return $this->data->criteriaFile(
76 $ass_id,
77 $giver_id,
78 $peer_id,
79 $citeria_id,
80 $rid,
81 $info->getTitle()
82 );
83 }
84
85 public function getStream(string $rid): ?FileStream
86 {
87 return $this->irss->stream($rid);
88 }
89
90
91 public function addFromLegacyUpload(
92 int $ass_id,
93 array $file,
94 ResourceStakeholder $stakeholder,
95 int $giver_id,
96 int $peer_id,
97 int $criteria_id
98 ): void {
99 $rid = $this->irss->importFileFromLegacyUpload($file, $stakeholder);
100 $this->db->replace(
101 "exc_crit_file",
102 [
103 "ass_id" => ["integer", $ass_id],
104 "giver_id" => ["integer", $giver_id],
105 "peer_id" => ["integer", $peer_id],
106 "criteria_id" => ["integer", $criteria_id]
107 ],
108 [
109 "rid" => ["text", $rid]
110 ]
111 );
112
113 }
114
115 public function delete(
116 int $ass_id,
117 ResourceStakeholder $stakeholder,
118 int $giver_id,
119 int $peer_id,
120 int $criteria_id
121 ): void {
122 $rid = $this->getFileRidOfReview($ass_id, $giver_id, $peer_id, $criteria_id);
123 if ($rid !== "") {
124 $this->irss->deleteResource($rid, $stakeholder);
125 }
126 $this->db->manipulateF(
127 "DELETE FROM exc_crit_file WHERE " .
128 " ass_id = %s AND giver_id = %s AND peer_id = %s and criteria_id = %s ",
129 ["integer", "integer", "integer", "integer"],
130 [$ass_id, $giver_id, $peer_id, $criteria_id]
131 );
132 }
133}
Internal factory for data objects.
addFromLegacyUpload(int $ass_id, array $file, ResourceStakeholder $stakeholder, int $giver_id, int $peer_id, int $criteria_id)
getFile(int $ass_id, int $giver_id, int $peer_id, int $citeria_id)
deliverFileOfReview(int $ass_id, int $giver_id, int $peer_id, int $criteria_id)
getFileRidOfReview(int $ass_id, int $giver_id, int $peer_id, int $criteria_id)
__construct(protected IRSSWrapper $irss, protected InternalDataService $data, protected \ilDBInterface $db)
$info
Definition: entry_point.php:21
The base interface for all filesystem streams.
Definition: FileStream.php:32
Interface ilDBInterface.
global $DIC
Definition: shib_login.php:26