3 declare(strict_types=1);
26 protected \ilDBInterface
$db;
35 $this->db = (
$db) ?: $DIC->database();
36 $this->factory_service = (
$factory_service) ?: $DIC->skills()->internalContainer()->factory();
39 public function add(
int $cont_obj_id,
int $user_id,
int $skill_id,
int $tref_id,
int $level_id): void
44 "obj_id" => [
"integer", $cont_obj_id],
45 "user_id" => [
"integer", $user_id],
46 "skill_id" => [
"integer", $skill_id],
47 "tref_id" => [
"integer", $tref_id]
50 "level_id" => [
"integer", $level_id],
51 "published" => [
"integer", 0]
56 public function remove(
int $cont_obj_id,
int $user_id,
int $skill_id,
int $tref_id):
void 58 $this->db->manipulate(
"DELETE FROM cont_member_skills " .
59 " WHERE obj_id = " . $this->db->quote($cont_obj_id,
"integer") .
60 " AND user_id = " . $this->db->quote($user_id,
"integer") .
61 " AND skill_id = " . $this->db->quote($skill_id,
"integer") .
62 " AND tref_id = " . $this->db->quote($tref_id,
"integer"));
65 public function removeAll(
int $cont_obj_id,
int $user_id): void
67 $this->db->manipulate(
"DELETE FROM cont_member_skills " .
68 " WHERE obj_id = " . $this->db->quote($cont_obj_id,
"integer") .
69 " AND user_id = " . $this->db->quote($user_id,
"integer"));
75 $this->db->manipulate(
"DELETE FROM cont_member_skills " .
76 " WHERE skill_id = " . $this->db->quote($skill_node_id,
"integer"));
78 $this->db->manipulate(
"DELETE FROM cont_member_skills " .
79 " WHERE tref_id = " . $this->db->quote($skill_node_id,
"integer"));
83 public function publish(
int $cont_obj_id,
int $user_id): void
85 $this->db->manipulate(
"UPDATE cont_member_skills SET " .
86 " published = " . $this->db->quote(1,
"integer") .
87 " WHERE obj_id = " . $this->db->quote($cont_obj_id,
"integer") .
88 " AND user_id = " . $this->db->quote($user_id,
"integer"));
93 $set = $this->db->query(
94 "SELECT published FROM cont_member_skills " .
95 " WHERE obj_id = " . $this->db->quote($cont_obj_id,
"integer") .
96 " AND user_id = " . $this->db->quote($user_id,
"integer")
98 while ($rec = $this->db->fetchAssoc($set)) {
99 if ((
bool) $rec[
"published"] ===
true) {
109 public function getAll(
int $cont_obj_id,
int $user_id): array
112 $set = $this->db->query(
113 "SELECT * FROM cont_member_skills " .
114 " WHERE obj_id = " . $this->db->quote($cont_obj_id,
"integer") .
115 " AND user_id = " . $this->db->quote($user_id,
"integer")
117 while ($rec = $this->db->fetchAssoc($set)) {
123 public function getLevel(
int $cont_obj_id,
int $user_id,
int $skill_id,
int $tref_id): ?
int 125 $set = $this->db->query(
126 "SELECT * FROM cont_member_skills " .
127 " WHERE obj_id = " . $this->db->quote($cont_obj_id,
"integer") .
128 " AND user_id = " . $this->db->quote($user_id,
"integer") .
129 " AND skill_id = " . $this->db->quote($skill_id,
"integer") .
130 " AND tref_id = " . $this->db->quote($tref_id,
"integer")
132 if ($rec = $this->db->fetchAssoc($set)) {
133 return (
int) $rec[
"level_id"];
140 $rec[
"obj_id"] = (
int) $rec[
"obj_id"];
141 $rec[
"user_id"] = (
int) $rec[
"user_id"];
142 $rec[
"skill_id"] = (
int) $rec[
"skill_id"];
143 $rec[
"tref_id"] = (
int) $rec[
"tref_id"];
144 $rec[
"level_id"] = (
int) $rec[
"level_id"];
145 $rec[
"published"] = (bool) $rec[
"published"];
147 return $this->factory_service->containerSkill()->memberSkill(
publish(int $cont_obj_id, int $user_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
SkillInternalFactoryService $factory_service
removeForSkill(int $skill_node_id, bool $is_reference)
getContainerMemberSkillFromRecord(array $rec)
getPublished(int $cont_obj_id, int $user_id)
add(int $cont_obj_id, int $user_id, int $skill_id, int $tref_id, int $level_id)
removeAll(int $cont_obj_id, int $user_id)
__construct(\ilDBInterface $db=null, SkillInternalFactoryService $factory_service=null,)
getAll(int $cont_obj_id, int $user_id)
getLevel(int $cont_obj_id, int $user_id, int $skill_id, int $tref_id)