ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 36 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.

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

Member Function Documentation

◆ add()

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

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

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

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

◆ get()

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

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

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

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

◆ getFromRecord()

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

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

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

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

69  : SelectedUserSkill
70  {
71  $skill_node_id = (int) $rec["skill_node_id"];
72 
73  return $this->factory_service->personal()->selectedUserSkill(
74  $skill_node_id,
75  \ilSkillTreeNode::_lookupTitle($skill_node_id)
76  );
77  }
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 135 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().

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

◆ remove()

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

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

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

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

◆ removeAllForSkill()

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

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

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

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

◆ removeAllForUser()

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

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

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

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

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: