ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\Skill\Profile\SkillProfileLevelsDBRepository Class Reference
+ Collaboration diagram for ILIAS\Skill\Profile\SkillProfileLevelsDBRepository:

Public Member Functions

 __construct (?\ilDBInterface $db=null, ?Service\SkillInternalFactoryService $factory_service=null)
 
 getAll (int $profile_id)
 
 get (int $profile_id, int $base_skill_id, int $tref_id)
 
 createOrUpdate (SkillProfileLevel $skill_level_obj)
 
 delete (SkillProfileLevel $skill_level_obj)
 
 deleteAllForProfile (int $profile_id)
 
 deleteAllForSkill (int $skill_node_id, bool $is_reference)
 
 updateSkillOrder (int $profile_id, array $order)
 
 fixSkillOrderNumbering (int $profile_id)
 
 getMaxOrderNr (int $profile_id)
 

Protected Member Functions

 getFromRecord (array $rec)
 

Protected Attributes

ilDBInterface $db
 
Service SkillInternalFactoryService $factory_service
 

Detailed Description

Definition at line 25 of file class.SkillProfileLevelsDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::__construct ( ?\ilDBInterface  $db = null,
?Service\SkillInternalFactoryService  $factory_service = null 
)

Definition at line 30 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, $DIC, and ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$factory_service.

33  {
34  global $DIC;
35 
36  $this->db = ($db) ?: $DIC->database();
37  $this->factory_service = ($factory_service) ?: $DIC->skills()->internal()->factory();
38  }
global $DIC
Definition: shib_login.php:26

Member Function Documentation

◆ createOrUpdate()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::createOrUpdate ( SkillProfileLevel  $skill_level_obj)

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

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, $ilDB, ILIAS\Skill\Profile\SkillProfileLevel\getBaseSkillId(), ILIAS\Skill\Profile\SkillProfileLevel\getLevelId(), ILIAS\Skill\Profile\SkillProfileLevel\getOrderNr(), ILIAS\Skill\Profile\SkillProfileLevel\getProfileId(), and ILIAS\Skill\Profile\SkillProfileLevel\getTrefId().

96  : void
97  {
98  $ilDB = $this->db;
99 
100  $ilDB->replace(
101  "skl_profile_level",
102  array("profile_id" => array("integer", $skill_level_obj->getProfileId()),
103  "tref_id" => array("integer", $skill_level_obj->getTrefId()),
104  "base_skill_id" => array("integer", $skill_level_obj->getBaseSkillId())
105  ),
106  array("order_nr" => array("integer", $skill_level_obj->getOrderNr()),
107  "level_id" => array("integer", $skill_level_obj->getLevelId())
108  )
109  );
110  }
+ Here is the call graph for this function:

◆ delete()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::delete ( SkillProfileLevel  $skill_level_obj)

Definition at line 112 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, and $ilDB.

112  : void
113  {
114  $ilDB = $this->db;
115 
116  $ilDB->manipulate(
117  "DELETE FROM skl_profile_level WHERE " .
118  " base_skill_id = " . $ilDB->quote($skill_level_obj->getBaseSkillId(), "integer") .
119  " AND tref_id = " . $ilDB->quote($skill_level_obj->getTrefId(), "integer") .
120  " AND level_id = " . $ilDB->quote($skill_level_obj->getLevelId(), "integer") .
121  " AND order_nr = " . $ilDB->quote($skill_level_obj->getOrderNr(), "integer")
122  );
123  }

◆ deleteAllForProfile()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::deleteAllForProfile ( int  $profile_id)

Definition at line 125 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, and $ilDB.

125  : void
126  {
127  $ilDB = $this->db;
128 
129  $ilDB->manipulate(
130  "DELETE FROM skl_profile_level WHERE " .
131  " profile_id = " . $ilDB->quote($profile_id, "integer")
132  );
133  }

◆ deleteAllForSkill()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::deleteAllForSkill ( int  $skill_node_id,
bool  $is_reference 
)

Definition at line 135 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, and $ilDB.

135  : void
136  {
137  $ilDB = $this->db;
138 
139  if (!$is_reference) {
140  $ilDB->manipulate(
141  "DELETE FROM skl_profile_level WHERE " .
142  " base_skill_id = " . $ilDB->quote($skill_node_id, "integer")
143  );
144  } else {
145  $ilDB->manipulate(
146  "DELETE FROM skl_profile_level WHERE " .
147  " tref_id = " . $ilDB->quote($skill_node_id, "integer")
148  );
149  }
150  }

◆ fixSkillOrderNumbering()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::fixSkillOrderNumbering ( int  $profile_id)

Definition at line 170 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, and $ilDB.

170  : void
171  {
172  $ilDB = $this->db;
173 
174  $set = $ilDB->query(
175  "SELECT profile_id, base_skill_id, tref_id, order_nr FROM skl_profile_level WHERE " .
176  " profile_id = " . $ilDB->quote($profile_id, "integer") .
177  " ORDER BY order_nr ASC"
178  );
179  $cnt = 1;
180  while ($rec = $ilDB->fetchAssoc($set)) {
181  $ilDB->manipulate(
182  "UPDATE skl_profile_level SET " .
183  " order_nr = " . $ilDB->quote(($cnt * 10), "integer") .
184  " WHERE profile_id = " . $ilDB->quote($rec["profile_id"], "integer") .
185  " AND base_skill_id = " . $ilDB->quote($rec["base_skill_id"], "integer") .
186  " AND tref_id = " . $ilDB->quote($rec["tref_id"], "integer")
187  );
188  $cnt++;
189  }
190  }

◆ get()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::get ( int  $profile_id,
int  $base_skill_id,
int  $tref_id 
)

Definition at line 60 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, $ilDB, and ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\getFromRecord().

60  : SkillProfileLevel
61  {
62  $ilDB = $this->db;
63 
64  $set = $ilDB->query(
65  "SELECT * FROM skl_profile_level " .
66  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer") .
67  " AND base_skill_id = " . $ilDB->quote($base_skill_id, "integer") .
68  " AND tref_id = " . $ilDB->quote($tref_id, "integer")
69  );
70 
71  $level = [];
72  if ($rec = $ilDB->fetchAssoc($set)) {
73  $level = $this->getFromRecord($rec);
74  }
75 
76  return $level;
77  }
+ Here is the call graph for this function:

◆ getAll()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::getAll ( int  $profile_id)
Returns
SkillProfileLevel[]

Definition at line 43 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, $ilDB, and ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\getFromRecord().

43  : array
44  {
45  $ilDB = $this->db;
46 
47  $set = $ilDB->query(
48  "SELECT * FROM skl_profile_level " .
49  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer")
50  );
51 
52  $levels = [];
53  while ($rec = $ilDB->fetchAssoc($set)) {
54  $levels[] = $this->getFromRecord($rec);
55  }
56 
57  return $levels;
58  }
+ Here is the call graph for this function:

◆ getFromRecord()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::getFromRecord ( array  $rec)
protected

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

References ILIAS\Repository\int().

Referenced by ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\get(), and ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\getAll().

79  : SkillProfileLevel
80  {
81  $rec["profile_id"] = (int) $rec["profile_id"];
82  $rec["base_skill_id"] = (int) $rec["base_skill_id"];
83  $rec["tref_id"] = (int) $rec["tref_id"];
84  $rec["level_id"] = (int) $rec["level_id"];
85  $rec["order_nr"] = (int) $rec["order_nr"];
86 
87  return $this->factory_service->profile()->profileLevel(
88  $rec["profile_id"],
89  $rec["base_skill_id"],
90  $rec["tref_id"],
91  $rec["level_id"],
92  $rec["order_nr"]
93  );
94  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMaxOrderNr()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::getMaxOrderNr ( int  $profile_id)

Definition at line 192 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, and $ilDB.

192  : int
193  {
194  $ilDB = $this->db;
195 
196  $set = $ilDB->query(
197  "SELECT MAX(order_nr) mnr FROM skl_profile_level WHERE " .
198  " profile_id = " . $ilDB->quote($profile_id, "integer")
199  );
200  $rec = $ilDB->fetchAssoc($set);
201  return (int) $rec["mnr"];
202  }

◆ updateSkillOrder()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::updateSkillOrder ( int  $profile_id,
array  $order 
)

Definition at line 152 of file class.SkillProfileLevelsDBRepository.php.

References ILIAS\Skill\Profile\SkillProfileLevelsDBRepository\$db, $id, and $ilDB.

152  : void
153  {
154  $ilDB = $this->db;
155 
156  $cnt = 1;
157  foreach ($order as $id => $o) {
158  $id_arr = explode("_", $id);
159  $ilDB->manipulate(
160  "UPDATE skl_profile_level SET " .
161  " order_nr = " . $ilDB->quote(($cnt * 10), "integer") .
162  " WHERE base_skill_id = " . $ilDB->quote($id_arr[0], "integer") .
163  " AND tref_id = " . $ilDB->quote($id_arr[1], "integer") .
164  " AND profile_id = " . $ilDB->quote($profile_id, "integer")
165  );
166  $cnt++;
167  }
168  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

Field Documentation

◆ $db

◆ $factory_service

Service SkillInternalFactoryService ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::$factory_service
protected

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