ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ILIAS\Skill\Personal\AssignedMaterialDBRepository Class Reference
+ Collaboration diagram for ILIAS\Skill\Personal\AssignedMaterialDBRepository:

Public Member Functions

 __construct (\ilDBInterface $db=null, Service\SkillInternalFactoryService $factory_service=null)
 
 assign (int $user_id, int $top_skill_id, int $tref_id, int $basic_skill_id, int $level_id, int $wsp_id)
 Assign material to skill level. More...
 
 get (int $user_id, int $tref_id, int $level_id)
 Get assigned materials (for a skill level and user) More...
 
 getAll (int $user_id, int $skill_id, int $tref_id)
 Get all assigned materials (for a skill and user) More...
 
 count (int $user_id, int $tref_id, int $level_id)
 Count assigned materials (for a skill level and user) More...
 
 remove (int $user_id, int $tref_id, int $level_id, int $wsp_id)
 
 removeAllForUser (int $user_id)
 
 removeAllForSkill (int $skill_node_id, bool $is_reference)
 

Protected Member Functions

 getFromRecord (array $rec)
 

Protected Attributes

ilDBInterface $db
 
Service SkillInternalFactoryService $factory_service
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Skill\Personal\AssignedMaterialDBRepository::__construct ( \ilDBInterface  $db = null,
Service\SkillInternalFactoryService  $factory_service = null 
)

Definition at line 34 of file class.AssignedMaterialDBRepository.php.

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

37  {
38  global $DIC;
39 
40  $this->db = ($db) ?: $DIC->database();
41  $this->factory_service = ($factory_service) ?: $DIC->skills()->internal()->factory();
42  }
global $DIC
Definition: feed.php:28

Member Function Documentation

◆ assign()

ILIAS\Skill\Personal\AssignedMaterialDBRepository::assign ( int  $user_id,
int  $top_skill_id,
int  $tref_id,
int  $basic_skill_id,
int  $level_id,
int  $wsp_id 
)

Assign material to skill level.

Parameters
int$user_iduser id
int$top_skill_idthe "selectable" top skill
int$tref_idtemplate reference id
int$basic_skill_idthe basic skill the level belongs to
int$level_idlevel id
int$wsp_idworkspace object

Definition at line 54 of file class.AssignedMaterialDBRepository.php.

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

61  : void {
62  $ilDB = $this->db;
63 
64  $set = $ilDB->query(
65  "SELECT * FROM skl_assigned_material " .
66  " WHERE user_id = " . $ilDB->quote($user_id, "integer") .
67  " AND top_skill_id = " . $ilDB->quote($top_skill_id, "integer") .
68  " AND tref_id = " . $ilDB->quote($tref_id, "integer") .
69  " AND skill_id = " . $ilDB->quote($basic_skill_id, "integer") .
70  " AND level_id = " . $ilDB->quote($level_id, "integer") .
71  " AND wsp_id = " . $ilDB->quote($wsp_id, "integer")
72  );
73  if (!$ilDB->fetchAssoc($set)) {
74  $ilDB->manipulate("INSERT INTO skl_assigned_material " .
75  "(user_id, top_skill_id, tref_id, skill_id, level_id, wsp_id) VALUES (" .
76  $ilDB->quote($user_id, "integer") . "," .
77  $ilDB->quote($top_skill_id, "integer") . "," .
78  $ilDB->quote($tref_id, "integer") . "," .
79  $ilDB->quote($basic_skill_id, "integer") . "," .
80  $ilDB->quote($level_id, "integer") . "," .
81  $ilDB->quote($wsp_id, "integer") .
82  ")");
83  }
84  }

◆ count()

ILIAS\Skill\Personal\AssignedMaterialDBRepository::count ( int  $user_id,
int  $tref_id,
int  $level_id 
)

Count assigned materials (for a skill level and user)

Definition at line 150 of file class.AssignedMaterialDBRepository.php.

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

150  : int
151  {
152  $ilDB = $this->db;
153 
154  $set = $ilDB->query(
155  "SELECT count(*) as cnt FROM skl_assigned_material " .
156  " WHERE level_id = " . $ilDB->quote($level_id, "integer") .
157  " AND tref_id = " . $ilDB->quote($tref_id, "integer") .
158  " AND user_id = " . $ilDB->quote($user_id, "integer")
159  );
160  $rec = $ilDB->fetchAssoc($set);
161  return (int) $rec["cnt"];
162  }

◆ get()

ILIAS\Skill\Personal\AssignedMaterialDBRepository::get ( int  $user_id,
int  $tref_id,
int  $level_id 
)

Get assigned materials (for a skill level and user)

Returns
AssignedMaterial[]

Definition at line 90 of file class.AssignedMaterialDBRepository.php.

References ILIAS\Skill\Personal\AssignedMaterialDBRepository\$db, $ilDB, and ILIAS\Skill\Personal\AssignedMaterialDBRepository\getFromRecord().

90  : array
91  {
92  $ilDB = $this->db;
93 
94  $set = $ilDB->query(
95  "SELECT * FROM skl_assigned_material " .
96  " WHERE level_id = " . $ilDB->quote($level_id, "integer") .
97  " AND tref_id = " . $ilDB->quote($tref_id, "integer") .
98  " AND user_id = " . $ilDB->quote($user_id, "integer")
99  );
100  $mat = [];
101  while ($rec = $ilDB->fetchAssoc($set)) {
102  $mat[] = $this->getFromRecord($rec);
103  }
104  return $mat;
105  }
+ Here is the call graph for this function:

◆ getAll()

ILIAS\Skill\Personal\AssignedMaterialDBRepository::getAll ( int  $user_id,
int  $skill_id,
int  $tref_id 
)

Get all assigned materials (for a skill and user)

Returns
AssignedMaterial[]

Definition at line 111 of file class.AssignedMaterialDBRepository.php.

References ILIAS\Skill\Personal\AssignedMaterialDBRepository\$db, $ilDB, and ILIAS\Skill\Personal\AssignedMaterialDBRepository\getFromRecord().

111  : array
112  {
113  $ilDB = $this->db;
114 
115  $set = $ilDB->query(
116  "SELECT * FROM skl_assigned_material " .
117  " WHERE skill_id = " . $ilDB->quote($skill_id, "integer") .
118  " AND tref_id = " . $ilDB->quote($tref_id, "integer") .
119  " AND user_id = " . $ilDB->quote($user_id, "integer")
120  );
121  $mat = [];
122  while ($rec = $ilDB->fetchAssoc($set)) {
123  $mat[] = $this->getFromRecord($rec);
124  }
125  return $mat;
126  }
+ Here is the call graph for this function:

◆ getFromRecord()

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

Definition at line 128 of file class.AssignedMaterialDBRepository.php.

References ILIAS\Repository\int().

Referenced by ILIAS\Skill\Personal\AssignedMaterialDBRepository\get(), and ILIAS\Skill\Personal\AssignedMaterialDBRepository\getAll().

128  : AssignedMaterial
129  {
130  $rec['user_id'] = (int) $rec['user_id'];
131  $rec['top_skill_id'] = (int) $rec['top_skill_id'];
132  $rec['skill_id'] = (int) $rec['skill_id'];
133  $rec['level_id'] = (int) $rec['level_id'];
134  $rec['wsp_id'] = (int) $rec['wsp_id'];
135  $rec['tref_id'] = (int) $rec['tref_id'];
136 
137  return $this->factory_service->personal()->assignedMaterial(
138  $rec['user_id'],
139  $rec['top_skill_id'],
140  $rec['skill_id'],
141  $rec['level_id'],
142  $rec['wsp_id'],
143  $rec['tref_id']
144  );
145  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remove()

ILIAS\Skill\Personal\AssignedMaterialDBRepository::remove ( int  $user_id,
int  $tref_id,
int  $level_id,
int  $wsp_id 
)

Definition at line 164 of file class.AssignedMaterialDBRepository.php.

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

164  : void
165  {
166  $ilDB = $this->db;
167 
168  $t = "DELETE FROM skl_assigned_material WHERE " .
169  " user_id = " . $ilDB->quote($user_id, "integer") .
170  " AND tref_id = " . $ilDB->quote($tref_id, "integer") .
171  " AND level_id = " . $ilDB->quote($level_id, "integer") .
172  " AND wsp_id = " . $ilDB->quote($wsp_id, "integer");
173 
174  $ilDB->manipulate($t);
175  }

◆ removeAllForSkill()

ILIAS\Skill\Personal\AssignedMaterialDBRepository::removeAllForSkill ( int  $skill_node_id,
bool  $is_reference 
)

Definition at line 186 of file class.AssignedMaterialDBRepository.php.

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

186  : void
187  {
188  $ilDB = $this->db;
189 
190  if (!$is_reference) {
191  $t = "DELETE FROM skl_assigned_material WHERE " .
192  " skill_id = " . $ilDB->quote($skill_node_id, "integer");
193  } else {
194  $t = "DELETE FROM skl_assigned_material WHERE " .
195  " tref_id = " . $ilDB->quote($skill_node_id, "integer");
196  }
197  $ilDB->manipulate($t);
198  }

◆ removeAllForUser()

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

Definition at line 177 of file class.AssignedMaterialDBRepository.php.

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

177  : void
178  {
179  $ilDB = $this->db;
180 
181  $t = "DELETE FROM skl_assigned_material WHERE " .
182  " user_id = " . $ilDB->quote($user_id, "integer");
183  $ilDB->manipulate($t);
184  }

Field Documentation

◆ $db

◆ $factory_service

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

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