19 declare(strict_types=1);
25 protected \ilDBInterface
$db;
34 $this->db = (
$db) ?: $DIC->database();
35 $this->factory_service = (
$factory_service) ?: $DIC->skills()->internalContainer()->factory();
38 public function add(
int $cont_obj_id,
int $user_id,
int $skill_id,
int $tref_id,
int $level_id): void
43 "obj_id" => [
"integer", $cont_obj_id],
44 "user_id" => [
"integer", $user_id],
45 "skill_id" => [
"integer", $skill_id],
46 "tref_id" => [
"integer", $tref_id]
49 "level_id" => [
"integer", $level_id],
50 "published" => [
"integer", 0]
55 public function remove(
int $cont_obj_id,
int $user_id,
int $skill_id,
int $tref_id):
void 57 $this->db->manipulate(
"DELETE FROM cont_member_skills " .
58 " WHERE obj_id = " . $this->db->quote($cont_obj_id,
"integer") .
59 " AND user_id = " . $this->db->quote($user_id,
"integer") .
60 " AND skill_id = " . $this->db->quote($skill_id,
"integer") .
61 " AND tref_id = " . $this->db->quote($tref_id,
"integer"));
64 public function removeAll(
int $cont_obj_id,
int $user_id): void
66 $this->db->manipulate(
"DELETE FROM cont_member_skills " .
67 " WHERE obj_id = " . $this->db->quote($cont_obj_id,
"integer") .
68 " AND user_id = " . $this->db->quote($user_id,
"integer"));
74 $this->db->manipulate(
"DELETE FROM cont_member_skills " .
75 " WHERE skill_id = " . $this->db->quote($skill_node_id,
"integer"));
77 $this->db->manipulate(
"DELETE FROM cont_member_skills " .
78 " WHERE tref_id = " . $this->db->quote($skill_node_id,
"integer"));
82 public function publish(
int $cont_obj_id,
int $user_id): void
84 $this->db->manipulate(
"UPDATE cont_member_skills SET " .
85 " published = " . $this->db->quote(1,
"integer") .
86 " WHERE obj_id = " . $this->db->quote($cont_obj_id,
"integer") .
87 " AND user_id = " . $this->db->quote($user_id,
"integer"));
92 $set = $this->db->query(
93 "SELECT published FROM cont_member_skills " .
94 " WHERE obj_id = " . $this->db->quote($cont_obj_id,
"integer") .
95 " AND user_id = " . $this->db->quote($user_id,
"integer")
97 while ($rec = $this->db->fetchAssoc($set)) {
98 if ((
bool) $rec[
"published"] ===
true) {
108 public function getAll(
int $cont_obj_id,
int $user_id): array
111 $set = $this->db->query(
112 "SELECT * FROM cont_member_skills " .
113 " WHERE obj_id = " . $this->db->quote($cont_obj_id,
"integer") .
114 " AND user_id = " . $this->db->quote($user_id,
"integer")
116 while ($rec = $this->db->fetchAssoc($set)) {
122 public function getLevel(
int $cont_obj_id,
int $user_id,
int $skill_id,
int $tref_id): ?
int 124 $set = $this->db->query(
125 "SELECT * FROM cont_member_skills " .
126 " WHERE obj_id = " . $this->db->quote($cont_obj_id,
"integer") .
127 " AND user_id = " . $this->db->quote($user_id,
"integer") .
128 " AND skill_id = " . $this->db->quote($skill_id,
"integer") .
129 " AND tref_id = " . $this->db->quote($tref_id,
"integer")
131 if ($rec = $this->db->fetchAssoc($set)) {
132 return (
int) $rec[
"level_id"];
139 $rec[
"obj_id"] = (
int) $rec[
"obj_id"];
140 $rec[
"user_id"] = (
int) $rec[
"user_id"];
141 $rec[
"skill_id"] = (
int) $rec[
"skill_id"];
142 $rec[
"tref_id"] = (
int) $rec[
"tref_id"];
143 $rec[
"level_id"] = (
int) $rec[
"level_id"];
144 $rec[
"published"] = (bool) $rec[
"published"];
146 return $this->factory_service->containerSkill()->memberSkill(
publish(int $cont_obj_id, int $user_id)
SkillInternalFactoryService $factory_service
removeForSkill(int $skill_node_id, bool $is_reference)
getContainerMemberSkillFromRecord(array $rec)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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)