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

Public Member Functions

 __construct (\ilDBInterface $db=null, Service\SkillInternalFactoryService $factory_service=null)
 
 get (int $profile_id)
 
 getFromRecord (array $rec)
 
 addUserToProfile (int $profile_id, int $user_id)
 
 removeUserFromProfile (int $profile_id, int $user_id)
 
 removeUserFromAllProfiles (int $user_id)
 
 deleteProfileUsers (int $profile_id)
 
 getProfilesOfUser (int $user_id)
 
 countUsers (int $profile_id)
 

Protected Member Functions

 getProfileFromRecord (array $rec)
 

Protected Attributes

ilDBInterface $db
 
Service SkillInternalFactoryService $factory_service
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References ILIAS\Skill\Profile\SkillProfileUserDBRepository\$db, $DIC, and ILIAS\Skill\Profile\SkillProfileUserDBRepository\$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

◆ addUserToProfile()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::addUserToProfile ( int  $profile_id,
int  $user_id 
)

Definition at line 65 of file class.SkillProfileUserDBRepository.php.

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

65  : void
66  {
67  $ilDB = $this->db;
68 
69  $ilDB->replace(
70  "skl_profile_user",
71  array("profile_id" => array("integer", $profile_id),
72  "user_id" => array("integer", $user_id),
73  ),
74  []
75  );
76  }

◆ countUsers()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::countUsers ( int  $profile_id)

Definition at line 149 of file class.SkillProfileUserDBRepository.php.

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

149  : int
150  {
151  $ilDB = $this->db;
152 
153  $set = $ilDB->query(
154  "SELECT count(*) ucnt FROM skl_profile_user " .
155  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer")
156  );
157  $rec = $ilDB->fetchAssoc($set);
158  return (int) $rec["ucnt"];
159  }

◆ deleteProfileUsers()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::deleteProfileUsers ( int  $profile_id)

Definition at line 99 of file class.SkillProfileUserDBRepository.php.

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

99  : void
100  {
101  $ilDB = $this->db;
102 
103  $ilDB->manipulate(
104  "DELETE FROM skl_profile_user WHERE " .
105  " profile_id = " . $ilDB->quote($profile_id, "integer")
106  );
107  }

◆ get()

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

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

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

41  : array
42  {
43  $ilDB = $this->db;
44 
45  $set = $ilDB->query(
46  "SELECT * FROM skl_profile_user " .
47  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer")
48  );
49  $users = [];
50  while ($rec = $ilDB->fetchAssoc($set)) {
51  $users[] = $rec;
52  }
53 
54  return $users;
55  }

◆ getFromRecord()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::getFromRecord ( array  $rec)

Definition at line 57 of file class.SkillProfileUserDBRepository.php.

57  : SkillProfileUserAssignment
58  {
59  return $this->factory_service->profile()->profileUserAssignment(
60  $rec["name"],
61  $rec["id"]
62  );
63  }

◆ getProfileFromRecord()

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

Definition at line 130 of file class.SkillProfileUserDBRepository.php.

References ILIAS\Repository\int().

Referenced by ILIAS\Skill\Profile\SkillProfileUserDBRepository\getProfilesOfUser().

130  : SkillProfile
131  {
132  $rec["id"] = (int) $rec["id"];
133  $rec["title"] = (string) $rec["title"];
134  $rec["description"] = (string) $rec["description"];
135  $rec["skill_tree_id"] = (int) $rec["skill_tree_id"];
136  $rec["image_id"] = (string) $rec["image_id"];
137  $rec["ref_id"] = (int) $rec["ref_id"];
138 
139  return $this->factory_service->profile()->profile(
140  $rec["id"],
141  $rec["title"],
142  $rec["description"],
143  $rec["skill_tree_id"],
144  $rec["image_id"],
145  $rec["ref_id"]
146  );
147  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getProfilesOfUser()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::getProfilesOfUser ( int  $user_id)
Returns
SkillProfile[]

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

References ILIAS\Skill\Profile\SkillProfileUserDBRepository\$db, $ilDB, and ILIAS\Skill\Profile\SkillProfileUserDBRepository\getProfileFromRecord().

112  : array
113  {
114  $ilDB = $this->db;
115 
116  $user_profiles = [];
117  $set = $ilDB->query(
118  "SELECT p.id, p.title, p.description, p.ref_id, p.skill_tree_id, p.image_id " .
119  " FROM skl_profile_user u JOIN skl_profile p ON (u.profile_id = p.id) " .
120  " WHERE u.user_id = " . $ilDB->quote($user_id, "integer") .
121  " ORDER BY p.title ASC"
122  );
123  while ($rec = $ilDB->fetchAssoc($set)) {
124  $user_profiles[] = $this->getProfileFromRecord($rec);
125  }
126 
127  return $user_profiles;
128  }
+ Here is the call graph for this function:

◆ removeUserFromAllProfiles()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::removeUserFromAllProfiles ( int  $user_id)

Definition at line 89 of file class.SkillProfileUserDBRepository.php.

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

89  : void
90  {
91  $ilDB = $this->db;
92 
93  $ilDB->manipulate(
94  "DELETE FROM skl_profile_user WHERE " .
95  " user_id = " . $ilDB->quote($user_id, "integer")
96  );
97  }

◆ removeUserFromProfile()

ILIAS\Skill\Profile\SkillProfileUserDBRepository::removeUserFromProfile ( int  $profile_id,
int  $user_id 
)

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

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

78  : void
79  {
80  $ilDB = $this->db;
81 
82  $ilDB->manipulate(
83  "DELETE FROM skl_profile_user WHERE " .
84  " profile_id = " . $ilDB->quote($profile_id, "integer") .
85  " AND user_id = " . $ilDB->quote($user_id, "integer")
86  );
87  }

Field Documentation

◆ $db

◆ $factory_service

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

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