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

Public Member Functions

 __construct (\ilDBInterface $db=null, Service\SkillInternalFactoryService $factory_service=null)
 
 deleteProfileRoles (int $profile_id)
 
 get (int $profile_id)
 
 getRoleAssignmentFromRecord (array $rec)
 
 addRoleToProfile (int $profile_id, int $role_id)
 
 removeRoleFromProfile (int $profile_id, int $role_id)
 
 removeRoleFromAllProfiles (int $role_id)
 
 getAllProfilesOfRole (int $role_id)
 
 getGlobalProfilesOfRole (int $role_id)
 
 getLocalProfilesOfRole (int $role_id)
 
 countRoles (int $profile_id)
 

Protected Member Functions

 getProfileFromRecord (array $rec)
 
 getRoleProfileFromRecord (array $rec)
 

Protected Attributes

ilDBInterface $db
 
Service SkillInternalFactoryService $factory_service
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 31 of file class.SkillProfileRoleDBRepository.php.

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

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

Member Function Documentation

◆ addRoleToProfile()

ILIAS\Skill\Profile\SkillProfileRoleDBRepository::addRoleToProfile ( int  $profile_id,
int  $role_id 
)

Definition at line 78 of file class.SkillProfileRoleDBRepository.php.

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

78  : void
79  {
80  $ilDB = $this->db;
81 
82  $ilDB->replace(
83  "skl_profile_role",
84  array("profile_id" => array("integer", $profile_id),
85  "role_id" => array("integer", $role_id),
86  ),
87  []
88  );
89  }

◆ countRoles()

ILIAS\Skill\Profile\SkillProfileRoleDBRepository::countRoles ( int  $profile_id)

Definition at line 215 of file class.SkillProfileRoleDBRepository.php.

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

215  : int
216  {
217  $ilDB = $this->db;
218 
219  $set = $ilDB->query(
220  "SELECT count(*) rcnt FROM skl_profile_role " .
221  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer")
222  );
223  $rec = $ilDB->fetchAssoc($set);
224  return (int) $rec["rcnt"];
225  }

◆ deleteProfileRoles()

ILIAS\Skill\Profile\SkillProfileRoleDBRepository::deleteProfileRoles ( int  $profile_id)

Definition at line 41 of file class.SkillProfileRoleDBRepository.php.

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

41  : void
42  {
43  $ilDB = $this->db;
44 
45  $ilDB->manipulate(
46  "DELETE FROM skl_profile_role WHERE " .
47  " profile_id = " . $ilDB->quote($profile_id, "integer")
48  );
49  }

◆ get()

ILIAS\Skill\Profile\SkillProfileRoleDBRepository::get ( int  $profile_id)

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

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

51  : array
52  {
53  $ilDB = $this->db;
54 
55  $set = $ilDB->query(
56  "SELECT * FROM skl_profile_role " .
57  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer")
58  );
59  $roles = [];
60  while ($rec = $ilDB->fetchAssoc($set)) {
61  $roles[] = $rec;
62  }
63 
64  return $roles;
65  }

◆ getAllProfilesOfRole()

ILIAS\Skill\Profile\SkillProfileRoleDBRepository::getAllProfilesOfRole ( int  $role_id)
Returns
SkillRoleProfile[]

Definition at line 115 of file class.SkillProfileRoleDBRepository.php.

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

115  : array
116  {
117  $ilDB = $this->db;
118 
119  $profiles = [];
120  $set = $ilDB->query(
121  "SELECT spr.profile_id, spr.role_id, sp.title, sp.description, sp.ref_id, sp.skill_tree_id, sp.image_id " .
122  " FROM skl_profile_role spr INNER JOIN skl_profile sp ON (spr.profile_id = sp.id) " .
123  " WHERE spr.role_id = " . $ilDB->quote($role_id, "integer") .
124  " ORDER BY sp.title ASC"
125  );
126  while ($rec = $ilDB->fetchAssoc($set)) {
127  $profiles[(int) $rec["profile_id"]] = $this->getRoleProfileFromRecord($rec);
128  }
129  return $profiles;
130  }
+ Here is the call graph for this function:

◆ getGlobalProfilesOfRole()

ILIAS\Skill\Profile\SkillProfileRoleDBRepository::getGlobalProfilesOfRole ( int  $role_id)
Returns
SkillRoleProfile[]

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

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

135  : array
136  {
137  $ilDB = $this->db;
138 
139  $profiles = [];
140  $set = $ilDB->query(
141  "SELECT spr.profile_id, spr.role_id, sp.title, sp.description, sp.ref_id, sp.skill_tree_id, sp.image_id " .
142  " FROM skl_profile_role spr INNER JOIN skl_profile sp ON (spr.profile_id = sp.id) " .
143  " WHERE spr.role_id = " . $ilDB->quote($role_id, "integer") .
144  " AND sp.ref_id = 0" .
145  " ORDER BY sp.title ASC"
146  );
147  while ($rec = $ilDB->fetchAssoc($set)) {
148  $profiles[(int) $rec["profile_id"]] = $this->getRoleProfileFromRecord($rec);
149  }
150 
151  return $profiles;
152  }
+ Here is the call graph for this function:

◆ getLocalProfilesOfRole()

ILIAS\Skill\Profile\SkillProfileRoleDBRepository::getLocalProfilesOfRole ( int  $role_id)
Returns
SkillRoleProfile[]

Definition at line 157 of file class.SkillProfileRoleDBRepository.php.

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

157  : array
158  {
159  $ilDB = $this->db;
160 
161  $profiles = [];
162  $set = $ilDB->query(
163  "SELECT spr.profile_id, spr.role_id, sp.title, sp.description, sp.ref_id, sp.skill_tree_id, sp.image_id " .
164  " FROM skl_profile_role spr INNER JOIN skl_profile sp ON (spr.profile_id = sp.id) " .
165  " WHERE spr.role_id = " . $ilDB->quote($role_id, "integer") .
166  " AND sp.ref_id <> 0" .
167  " ORDER BY sp.title ASC"
168  );
169  while ($rec = $ilDB->fetchAssoc($set)) {
170  $profiles[(int) $rec["profile_id"]] = $this->getRoleProfileFromRecord($rec);
171  }
172  return $profiles;
173  }
+ Here is the call graph for this function:

◆ getProfileFromRecord()

ILIAS\Skill\Profile\SkillProfileRoleDBRepository::getProfileFromRecord ( array  $rec)
protected

Definition at line 175 of file class.SkillProfileRoleDBRepository.php.

References ILIAS\Repository\int().

175  : SkillProfile
176  {
177  $rec["id"] = (int) $rec["id"];
178  $rec["title"] = (string) $rec["title"];
179  $rec["description"] = (string) $rec["description"];
180  $rec["skill_tree_id"] = (int) $rec["skill_tree_id"];
181  $rec["image_id"] = (string) $rec["image_id"];
182  $rec["ref_id"] = (int) $rec["ref_id"];
183 
184  return $this->factory_service->profile()->profile(
185  $rec["id"],
186  $rec["title"],
187  $rec["description"],
188  $rec["skill_tree_id"],
189  $rec["image_id"],
190  $rec["ref_id"]
191  );
192  }
+ Here is the call graph for this function:

◆ getRoleAssignmentFromRecord()

ILIAS\Skill\Profile\SkillProfileRoleDBRepository::getRoleAssignmentFromRecord ( array  $rec)

Definition at line 67 of file class.SkillProfileRoleDBRepository.php.

67  : SkillProfileRoleAssignment
68  {
69  return $this->factory_service->profile()->profileRoleAssignment(
70  $rec["name"],
71  $rec["id"],
72  $rec["object_title"],
73  $rec["object_type"],
74  $rec["object_id"]
75  );
76  }

◆ getRoleProfileFromRecord()

ILIAS\Skill\Profile\SkillProfileRoleDBRepository::getRoleProfileFromRecord ( array  $rec)
protected

Definition at line 194 of file class.SkillProfileRoleDBRepository.php.

References ILIAS\Repository\int().

Referenced by ILIAS\Skill\Profile\SkillProfileRoleDBRepository\getAllProfilesOfRole(), ILIAS\Skill\Profile\SkillProfileRoleDBRepository\getGlobalProfilesOfRole(), and ILIAS\Skill\Profile\SkillProfileRoleDBRepository\getLocalProfilesOfRole().

194  : SkillRoleProfile
195  {
196  $rec["role_id"] = (int) $rec["role_id"];
197  $rec["profile_id"] = (int) $rec["profile_id"];
198  $rec["title"] = (string) $rec["title"];
199  $rec["description"] = (string) $rec["description"];
200  $rec["skill_tree_id"] = (int) $rec["skill_tree_id"];
201  $rec["image_id"] = (string) $rec["image_id"];
202  $rec["ref_id"] = (int) $rec["ref_id"];
203 
204  return $this->factory_service->profile()->roleProfile(
205  $rec["role_id"],
206  $rec["profile_id"],
207  $rec["title"],
208  $rec["description"],
209  $rec["skill_tree_id"],
210  $rec["image_id"],
211  $rec["ref_id"]
212  );
213  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeRoleFromAllProfiles()

ILIAS\Skill\Profile\SkillProfileRoleDBRepository::removeRoleFromAllProfiles ( int  $role_id)

Definition at line 102 of file class.SkillProfileRoleDBRepository.php.

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

102  : void
103  {
104  $ilDB = $this->db;
105 
106  $ilDB->manipulate(
107  "DELETE FROM skl_profile_role WHERE " .
108  " role_id = " . $ilDB->quote($role_id, "integer")
109  );
110  }

◆ removeRoleFromProfile()

ILIAS\Skill\Profile\SkillProfileRoleDBRepository::removeRoleFromProfile ( int  $profile_id,
int  $role_id 
)

Definition at line 91 of file class.SkillProfileRoleDBRepository.php.

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

91  : void
92  {
93  $ilDB = $this->db;
94 
95  $ilDB->manipulate(
96  "DELETE FROM skl_profile_role WHERE " .
97  " profile_id = " . $ilDB->quote($profile_id, "integer") .
98  " AND role_id = " . $ilDB->quote($role_id, "integer")
99  );
100  }

Field Documentation

◆ $db

◆ $factory_service

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

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