ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.PortfolioRoleAssignmentDBRepository.php
Go to the documentation of this file.
1<?php
2
20
26{
27 protected \ilDBInterface $db;
28
29 public function __construct()
30 {
31 global $DIC;
32 $this->db = $DIC->database();
33 }
34
35 public function add(
36 int $template_ref_id,
37 int $role_id
38 ): void {
39 $db = $this->db;
40 $db->replace(
41 "prtf_role_assignment",
42 [
43 "role_id" => ["integer", $role_id],
44 "template_ref_id" => ["integer", $template_ref_id]
45 ],
46 []
47 );
48 }
49
50 public function delete(
51 int $template_ref_id,
52 int $role_id
53 ): void {
54 $db = $this->db;
55 $db->manipulateF(
56 "DELETE FROM prtf_role_assignment WHERE " .
57 " role_id = %s AND template_ref_id = %s",
58 ["integer", "integer"],
59 [$role_id, $template_ref_id]
60 );
61 }
62
63 public function getTemplatesForRoles(
64 array $role_ids
65 ): array {
66 $db = $this->db;
67 $set = $db->queryF(
68 "SELECT * FROM prtf_role_assignment " .
69 " WHERE " . $db->in("role_id", $role_ids, false, "integer"),
70 [],
71 []
72 );
73 $template_ref_ids = [];
74 while ($rec = $db->fetchAssoc($set)) {
75 $template_ref_ids[$rec["template_ref_id"]] = $rec["template_ref_id"];
76 }
77 return $template_ref_ids;
78 }
79
80 public function getAllAssignmentData(): array
81 {
82 $db = $this->db;
83 $set = $db->queryF(
84 "SELECT * FROM prtf_role_assignment ",
85 [],
86 []
87 );
88 $data = [];
89 while ($rec = $db->fetchAssoc($set)) {
90 $role_title = \ilObject::_lookupTitle($rec["role_id"]);
91 $template_title = \ilObject::_lookupTitle(
92 \ilObject::_lookupObjId($rec["template_ref_id"])
93 );
94 $data[] = [
95 "role_id" => $rec["role_id"],
96 "template_ref_id" => $rec["template_ref_id"],
97 "role_title" => $role_title,
98 "template_title" => $template_title
99 ];
100 }
101 return $data;
102 }
103}
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
replace(string $table, array $primary_keys, array $other_columns)
Replace into method.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26