ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ILIAS\Skill\Profile\SkillProfileLevelsDBRepository Class Reference
+ Collaboration diagram for ILIAS\Skill\Profile\SkillProfileLevelsDBRepository:

Public Member Functions

 __construct (\ilDBInterface $db=null)
 
 getProfileLevels (int $profile_id)
 
 createProfileLevels (int $profile_id, array $levels)
 
 updateProfileLevels (int $profile_id, array $levels)
 
 deleteProfileLevels (int $profile_id)
 
 updateSkillOrder (int $profile_id, array $order)
 
 fixSkillOrderNumbering (int $profile_id)
 
 getMaxLevelOrderNr (int $profile_id)
 

Protected Attributes

ilDBInterface $db
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::__construct ( \ilDBInterface  $db = null)

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

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

27  {
28  global $DIC;
29 
30  $this->db = ($db) ?: $DIC->database();
31  }
global $DIC
Definition: feed.php:28

Member Function Documentation

◆ createProfileLevels()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::createProfileLevels ( int  $profile_id,
array  $levels 
)

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

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

55  : void
56  {
57  $ilDB = $this->db;
58 
59  foreach ($levels as $level) {
60  $ilDB->replace(
61  "skl_profile_level",
62  array("profile_id" => array("integer", $profile_id),
63  "tref_id" => array("integer", (int) $level["tref_id"]),
64  "base_skill_id" => array("integer", (int) $level["base_skill_id"])
65  ),
66  array("order_nr" => array("integer", (int) $level["order_nr"]),
67  "level_id" => array("integer", (int) $level["level_id"])
68  )
69  );
70  }
71  }

◆ deleteProfileLevels()

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

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

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

95  : void
96  {
97  $ilDB = $this->db;
98 
99  $ilDB->manipulate(
100  "DELETE FROM skl_profile_level WHERE " .
101  " profile_id = " . $ilDB->quote($profile_id, "integer")
102  );
103  }

◆ fixSkillOrderNumbering()

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

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

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

123  : void
124  {
125  $ilDB = $this->db;
126 
127  $set = $ilDB->query(
128  "SELECT profile_id, base_skill_id, tref_id, order_nr FROM skl_profile_level WHERE " .
129  " profile_id = " . $ilDB->quote($profile_id, "integer") .
130  " ORDER BY order_nr ASC"
131  );
132  $cnt = 1;
133  while ($rec = $ilDB->fetchAssoc($set)) {
134  $ilDB->manipulate(
135  "UPDATE skl_profile_level SET " .
136  " order_nr = " . $ilDB->quote(($cnt * 10), "integer") .
137  " WHERE profile_id = " . $ilDB->quote($rec["profile_id"], "integer") .
138  " AND base_skill_id = " . $ilDB->quote($rec["base_skill_id"], "integer") .
139  " AND tref_id = " . $ilDB->quote($rec["tref_id"], "integer")
140  );
141  $cnt++;
142  }
143  }

◆ getMaxLevelOrderNr()

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

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

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

145  : int
146  {
147  $ilDB = $this->db;
148 
149  $set = $ilDB->query(
150  "SELECT MAX(order_nr) mnr FROM skl_profile_level WHERE " .
151  " profile_id = " . $ilDB->quote($profile_id, "integer")
152  );
153  $rec = $ilDB->fetchAssoc($set);
154  return (int) $rec["mnr"];
155  }

◆ getProfileLevels()

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

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

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

33  : array
34  {
35  $ilDB = $this->db;
36 
37  $set = $ilDB->query(
38  "SELECT * FROM skl_profile_level " .
39  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer")
40  );
41 
42  $levels = [];
43  while ($rec = $ilDB->fetchAssoc($set)) {
44  $levels[] = [
45  "base_skill_id" => (int) $rec["base_skill_id"],
46  "tref_id" => (int) $rec["tref_id"],
47  "level_id" => (int) $rec["level_id"],
48  "order_nr" => (int) $rec["order_nr"]
49  ];
50  }
51 
52  return $levels;
53  }
+ Here is the call graph for this function:

◆ updateProfileLevels()

ILIAS\Skill\Profile\SkillProfileLevelsDBRepository::updateProfileLevels ( int  $profile_id,
array  $levels 
)

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

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

73  : void
74  {
75  $ilDB = $this->db;
76 
77  $ilDB->manipulate(
78  "DELETE FROM skl_profile_level WHERE " .
79  " profile_id = " . $ilDB->quote($profile_id, "integer")
80  );
81  foreach ($levels as $level) {
82  $ilDB->replace(
83  "skl_profile_level",
84  array("profile_id" => array("integer", $profile_id),
85  "tref_id" => array("integer", (int) $level["tref_id"]),
86  "base_skill_id" => array("integer", (int) $level["base_skill_id"])
87  ),
88  array("order_nr" => array("integer", (int) $level["order_nr"]),
89  "level_id" => array("integer", (int) $level["level_id"])
90  )
91  );
92  }
93  }

◆ updateSkillOrder()

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

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

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

105  : void
106  {
107  $ilDB = $this->db;
108 
109  $cnt = 1;
110  foreach ($order as $id => $o) {
111  $id_arr = explode("_", $id);
112  $ilDB->manipulate(
113  "UPDATE skl_profile_level SET " .
114  " order_nr = " . $ilDB->quote(($cnt * 10), "integer") .
115  " WHERE base_skill_id = " . $ilDB->quote($id_arr[0], "integer") .
116  " AND tref_id = " . $ilDB->quote($id_arr[1], "integer") .
117  " AND profile_id = " . $ilDB->quote($profile_id, "integer")
118  );
119  $cnt++;
120  }
121  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

Field Documentation

◆ $db


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