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

Public Member Functions

 __construct (\ilDBInterface $db=null)
 
 getAssignedUsers (int $profile_id)
 
 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 Attributes

ilDBInterface $db
 
ilLanguage $lng
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References ILIAS\Skill\Profile\SkillProfileUserDBRepository\$db, $DIC, and ILIAS\Repository\lng().

28  {
29  global $DIC;
30 
31  $this->db = ($db) ?: $DIC->database();
32  $this->lng = $DIC->language();
33  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ addUserToProfile()

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

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

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

59  : void
60  {
61  $ilDB = $this->db;
62 
63  $ilDB->replace(
64  "skl_profile_user",
65  array("profile_id" => array("integer", $profile_id),
66  "user_id" => array("integer", $user_id),
67  ),
68  []
69  );
70  }

◆ countUsers()

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

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

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

122  : int
123  {
124  $ilDB = $this->db;
125 
126  $set = $ilDB->query(
127  "SELECT count(*) ucnt FROM skl_profile_user " .
128  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer")
129  );
130  $rec = $ilDB->fetchAssoc($set);
131  return (int) $rec["ucnt"];
132  }

◆ deleteProfileUsers()

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

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

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

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

◆ getAssignedUsers()

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

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

References ILIAS\Skill\Profile\SkillProfileUserDBRepository\$db, $ilDB, ILIAS\Skill\Profile\SkillProfileUserDBRepository\$lng, $name, $type, ilUserUtil\getNamePresentation(), and ILIAS\Repository\int().

35  : array
36  {
37  $ilDB = $this->db;
38  $lng = $this->lng;
39 
40  $set = $ilDB->query(
41  "SELECT * FROM skl_profile_user " .
42  " WHERE profile_id = " . $ilDB->quote($profile_id, "integer")
43  );
44  $users = [];
45  while ($rec = $ilDB->fetchAssoc($set)) {
46  $rec["user_id"] = (int) $rec["user_id"];
47  $name = \ilUserUtil::getNamePresentation($rec["user_id"]);
48  $type = $lng->txt("user");
49  $users[] = [
50  "type" => $type,
51  "name" => $name,
52  "id" => $rec["user_id"],
53  "object_title" => ""
54  ];
55  }
56  return $users;
57  }
static getNamePresentation( $a_user_id, bool $a_user_image=false, bool $a_profile_link=false, string $a_profile_back_link="", bool $a_force_first_lastname=false, bool $a_omit_login=false, bool $a_sortable=true, bool $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
$type
if($format !==null) $name
Definition: metadata.php:247
+ Here is the call graph for this function:

◆ getProfilesOfUser()

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

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

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

103  : array
104  {
105  $ilDB = $this->db;
106 
107  $user_profiles = [];
108  $set = $ilDB->query(
109  "SELECT p.id, p.title, p.description, p.image_id FROM skl_profile_user u JOIN skl_profile p " .
110  " ON (u.profile_id = p.id) " .
111  " WHERE user_id = " . $ilDB->quote($user_id, "integer") .
112  " ORDER BY p.title ASC"
113  );
114  while ($rec = $ilDB->fetchAssoc($set)) {
115  $rec['id'] = (int) $rec['id'];
116  $user_profiles[] = $rec;
117  }
118 
119  return $user_profiles;
120  }
+ Here is the call graph for this function:

◆ removeUserFromAllProfiles()

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

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

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

83  : void
84  {
85  $ilDB = $this->db;
86 
87  $ilDB->manipulate(
88  "DELETE FROM skl_profile_user WHERE " .
89  " user_id = " . $ilDB->quote($user_id, "integer")
90  );
91  }

◆ removeUserFromProfile()

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

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

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

72  : void
73  {
74  $ilDB = $this->db;
75 
76  $ilDB->manipulate(
77  "DELETE FROM skl_profile_user WHERE " .
78  " profile_id = " . $ilDB->quote($profile_id, "integer") .
79  " AND user_id = " . $ilDB->quote($user_id, "integer")
80  );
81  }

Field Documentation

◆ $db

◆ $lng

ilLanguage ILIAS\Skill\Profile\SkillProfileUserDBRepository::$lng
protected

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