ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 25 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 30 of file class.SkillProfileUserDBRepository.php.

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

Member Function Documentation

◆ addUserToProfile()

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

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

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

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

◆ countUsers()

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

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

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

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

◆ deleteProfileUsers()

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

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

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

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

◆ get()

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

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

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

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

◆ getFromRecord()

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

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

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

◆ getProfileFromRecord()

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

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

References ILIAS\Repository\int().

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

129  : SkillProfile
130  {
131  $rec["id"] = (int) $rec["id"];
132  $rec["title"] = (string) $rec["title"];
133  $rec["description"] = (string) $rec["description"];
134  $rec["skill_tree_id"] = (int) $rec["skill_tree_id"];
135  $rec["image_id"] = (string) $rec["image_id"];
136  $rec["ref_id"] = (int) $rec["ref_id"];
137 
138  return $this->factory_service->profile()->profile(
139  $rec["id"],
140  $rec["title"],
141  $rec["description"],
142  $rec["skill_tree_id"],
143  $rec["image_id"],
144  $rec["ref_id"]
145  );
146  }
+ 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 111 of file class.SkillProfileUserDBRepository.php.

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

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

◆ removeUserFromAllProfiles()

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

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

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

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

◆ removeUserFromProfile()

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

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

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

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

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: