ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 
)

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

References ILIAS\Skill\Personal\PersonalSkillDBRepository\$db, $DIC, ILIAS\Skill\Personal\PersonalSkillDBRepository\$factory_service, and ILIAS\Skill\Personal\PersonalSkillDBRepository\$tree_repo.

39  {
40  global $DIC;
41 
42  $this->tree_repo = $tree_repo;
43  $this->db = ($db) ?: $DIC->database();
44  $this->factory_service = ($factory_service) ?: $DIC->skills()->internal()->factory();
45  }
global $DIC
Definition: shib_login.php:22

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.

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

78  : void
79  {
80  $ilDB = $this->db;
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  }

◆ get()

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

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

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

50  : array
51  {
52  $ilDB = $this->db;
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  }
+ 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.

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

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

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)
+ 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.

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

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

134  : array
135  {
136  $ilDB = $this->db;
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  }
+ 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.

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

96  : void
97  {
98  $ilDB = $this->db;
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  }

◆ removeAllForSkill()

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

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

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

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

◆ removeAllForUser()

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

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

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

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

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: