ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Skill\Personal\PersonalSkillDBRepository Class Reference
+ Collaboration diagram for ILIAS\Skill\Personal\PersonalSkillDBRepository:

Public Member Functions

 __construct (\ilSkillTreeRepository $tree_repo, ?\ilDBInterface $db=null, ?Service\SkillInternalFactoryService $factory_service=null)
 
 get (int $user_id)
 
 add (int $user_id, int $skill_node_id)
 
 remove (int $user_id, int $skill_node_id)
 
 removeAllForUser (int $user_id)
 
 removeAllForSkill (int $skill_node_id)
 
 getUsages (array $usages, array $pskill_ids, array $tref_ids)
 

Protected Member Functions

 getFromRecord (array $rec)
 

Protected Attributes

ilSkillTreeRepository $tree_repo
 
ilDBInterface $db
 
Service SkillInternalFactoryService $factory_service
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Skill\Personal\PersonalSkillDBRepository::__construct ( \ilSkillTreeRepository  $tree_repo,
?\ilDBInterface  $db = null,
?Service\SkillInternalFactoryService  $factory_service = null 
)

Member Function Documentation

◆ add()

ILIAS\Skill\Personal\PersonalSkillDBRepository::add ( int  $user_id,
int  $skill_node_id 
)

Definition at line 78 of file class.PersonalSkillDBRepository.php.

78 : void
79 {
81
82 $set = $ilDB->query(
83 "SELECT * FROM skl_personal_skill " .
84 " WHERE user_id = " . $ilDB->quote($user_id, "integer") .
85 " AND skill_node_id = " . $ilDB->quote($skill_node_id, "integer")
86 );
87 if (!$ilDB->fetchAssoc($set)) {
88 $ilDB->manipulate("INSERT INTO skl_personal_skill " .
89 "(user_id, skill_node_id) VALUES (" .
90 $ilDB->quote($user_id, "integer") . "," .
91 $ilDB->quote($skill_node_id, "integer") .
92 ")");
93 }
94 }

References ILIAS\Skill\Personal\PersonalSkillDBRepository\$db, $ilDB, and $user_id.

◆ get()

ILIAS\Skill\Personal\PersonalSkillDBRepository::get ( int  $user_id)
Returns
array<int, SelectedUserSkill>

Definition at line 50 of file class.PersonalSkillDBRepository.php.

50 : array
51 {
53
54 $set = $ilDB->query(
55 "SELECT * FROM skl_personal_skill " .
56 " WHERE user_id = " . $ilDB->quote($user_id, "integer")
57 );
58 $pskills = [];
59 while ($rec = $ilDB->fetchAssoc($set)) {
60 $skill_node_id = (int) $rec["skill_node_id"];
61 if ($this->tree_repo->isInAnyTree($skill_node_id)) {
62 $pskills[$skill_node_id] = $this->getFromRecord($rec);
63 }
64 }
65 return $pskills;
66 }

References ILIAS\Skill\Personal\PersonalSkillDBRepository\$db, $ilDB, $user_id, ILIAS\Skill\Personal\PersonalSkillDBRepository\getFromRecord(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getFromRecord()

ILIAS\Skill\Personal\PersonalSkillDBRepository::getFromRecord ( array  $rec)
protected

Definition at line 68 of file class.PersonalSkillDBRepository.php.

68 : SelectedUserSkill
69 {
70 $skill_node_id = (int) $rec["skill_node_id"];
71
72 return $this->factory_service->personal()->selectedUserSkill(
73 $skill_node_id,
74 \ilSkillTreeNode::_lookupTitle($skill_node_id)
75 );
76 }
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)

References ilSkillTreeNode\_lookupTitle(), and ILIAS\Repository\int().

Referenced by ILIAS\Skill\Personal\PersonalSkillDBRepository\get().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUsages()

ILIAS\Skill\Personal\PersonalSkillDBRepository::getUsages ( array  $usages,
array  $pskill_ids,
array  $tref_ids 
)
Parameters
array<string,array<string,array{keystring}[]>> $usages
int[]$pskill_ids
int[]$tref_ids
Returns
array<string, array<string, array{key: string}[]>>

Definition at line 134 of file class.PersonalSkillDBRepository.php.

134 : array
135 {
137
138 $set = $ilDB->query(
139 "SELECT skill_node_id, user_id FROM skl_personal_skill " .
140 " WHERE " . $ilDB->in("skill_node_id", $pskill_ids, false, "integer") .
141 " GROUP BY skill_node_id, user_id"
142 );
143 while ($rec = $ilDB->fetchAssoc($set)) {
144 if (isset($tref_ids[(int) $rec["skill_node_id"]])) {
145 $usages[$tref_ids[$rec["skill_node_id"]] . ":" . $rec["skill_node_id"]][SkillUsageManager::PERSONAL_SKILL][] =
146 array("key" => $rec["user_id"]);
147 } else {
148 $usages[$rec["skill_node_id"] . ":0"][SkillUsageManager::PERSONAL_SKILL][] =
149 array("key" => $rec["user_id"]);
150 }
151 }
152
153 return $usages;
154 }

References ILIAS\Skill\Personal\PersonalSkillDBRepository\$db, $ilDB, and ILIAS\Skill\Usage\SkillUsageManager\PERSONAL_SKILL.

Referenced by ILIAS\Skill\Personal\AssignedMaterialManager\getUsageInfo().

+ Here is the caller graph for this function:

◆ remove()

ILIAS\Skill\Personal\PersonalSkillDBRepository::remove ( int  $user_id,
int  $skill_node_id 
)

Definition at line 96 of file class.PersonalSkillDBRepository.php.

96 : void
97 {
99
100 $ilDB->manipulate(
101 "DELETE FROM skl_personal_skill WHERE " .
102 " user_id = " . $ilDB->quote($user_id, "integer") .
103 " AND skill_node_id = " . $ilDB->quote($skill_node_id, "integer")
104 );
105 }

References ILIAS\Skill\Personal\PersonalSkillDBRepository\$db, $ilDB, and $user_id.

◆ removeAllForSkill()

ILIAS\Skill\Personal\PersonalSkillDBRepository::removeAllForSkill ( int  $skill_node_id)

Definition at line 117 of file class.PersonalSkillDBRepository.php.

117 : void
118 {
120
121 $ilDB->manipulate(
122 "DELETE FROM skl_personal_skill WHERE " .
123 " skill_node_id = " . $ilDB->quote($skill_node_id, "integer")
124 );
125 }

References ILIAS\Skill\Personal\PersonalSkillDBRepository\$db, and $ilDB.

◆ removeAllForUser()

ILIAS\Skill\Personal\PersonalSkillDBRepository::removeAllForUser ( int  $user_id)

Definition at line 107 of file class.PersonalSkillDBRepository.php.

107 : void
108 {
110
111 $ilDB->manipulate(
112 "DELETE FROM skl_personal_skill WHERE " .
113 " user_id = " . $ilDB->quote($user_id, "integer")
114 );
115 }

References ILIAS\Skill\Personal\PersonalSkillDBRepository\$db, $ilDB, and $user_id.

Field Documentation

◆ $db

◆ $factory_service

Service SkillInternalFactoryService ILIAS\Skill\Personal\PersonalSkillDBRepository::$factory_service
protected

◆ $tree_repo

ilSkillTreeRepository ILIAS\Skill\Personal\PersonalSkillDBRepository::$tree_repo
protected

The documentation for this class was generated from the following file: