5 include_once(
"./Services/Skill/interfaces/interface.ilSkillUsageInfo.php");
45 $this->db = $DIC->database();
46 $this->lng = $DIC->language();
47 $this->review = $DIC->rbac()->review();
81 $this->title = $a_val;
101 $this->description = $a_val;
123 $this->skill_level[] = array(
124 "base_skill_id" => $a_base_skill_id,
125 "tref_id" => $a_tref_id,
126 "level_id" => $a_level_id
138 foreach ($this->skill_level as $k => $sl) {
139 if ((
int) $sl[
"base_skill_id"] == (
int) $a_base_skill_id &&
140 (
int) $sl[
"tref_id"] == (
int) $a_tref_id &&
141 (
int) $sl[
"level_id"] == (
int) $a_level_id) {
142 unset($this->skill_level[$k]);
169 "SELECT * FROM skl_profile " .
170 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer")
172 $rec =
$ilDB->fetchAssoc($set);
177 "SELECT * FROM skl_profile_level " .
178 " WHERE profile_id = " .
$ilDB->quote($this->getId(),
"integer")
180 while ($rec =
$ilDB->fetchAssoc($set)) {
182 (
int) $rec[
"base_skill_id"],
183 (
int) $rec[
"tref_id"],
184 (
int) $rec[
"level_id"]
198 $ilDB->manipulate(
"INSERT INTO skl_profile " .
199 "(id, title, description) VALUES (" .
200 $ilDB->quote($this->getId(),
"integer") .
"," .
201 $ilDB->quote($this->getTitle(),
"text") .
"," .
202 $ilDB->quote($this->getDescription(),
"text") .
206 foreach ($this->skill_level as $level) {
209 array(
"profile_id" => array(
"integer", $this->
getId()),
210 "tref_id" => array(
"integer", (
int) $level[
"tref_id"]),
211 "base_skill_id" => array(
"integer", (
int) $level[
"base_skill_id"])
213 array(
"level_id" => array(
"integer", (
int) $level[
"level_id"]))
227 "UPDATE skl_profile SET " .
228 " title = " .
$ilDB->quote($this->getTitle(),
"text") .
"," .
229 " description = " .
$ilDB->quote($this->getDescription(),
"text") .
230 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer")
235 "DELETE FROM skl_profile_level WHERE " .
236 " profile_id = " .
$ilDB->quote($this->getId(),
"integer")
238 foreach ($this->skill_level as $level) {
241 array(
"profile_id" => array(
"integer", $this->
getId()),
242 "tref_id" => array(
"integer", (
int) $level[
"tref_id"]),
243 "base_skill_id" => array(
"integer", (
int) $level[
"base_skill_id"])
245 array(
"level_id" => array(
"integer", (
int) $level[
"level_id"]))
261 public function delete()
269 "DELETE FROM skl_profile_level WHERE " .
270 " profile_id = " .
$ilDB->quote($this->getId(),
"integer")
275 "DELETE FROM skl_profile_user WHERE " .
276 " profile_id = " .
$ilDB->quote($this->getId(),
"integer")
281 "DELETE FROM skl_profile_role WHERE " .
282 " profile_id = " .
$ilDB->quote($this->getId(),
"integer")
287 "DELETE FROM skl_profile WHERE " .
288 " id = " .
$ilDB->quote($this->getId(),
"integer")
302 $ilDB = $DIC->database();
305 "SELECT * FROM skl_profile " .
309 while ($rec =
$ilDB->fetchAssoc($set)) {
310 $profiles[$rec[
"id"]] = $rec;
322 protected static function lookup($a_id, $a_field)
326 $ilDB = $DIC->database();
329 "SELECT " . $a_field .
" FROM skl_profile " .
330 " WHERE id = " .
$ilDB->quote($a_id,
"integer")
332 $rec =
$ilDB->fetchAssoc($set);
333 return $rec[$a_field];
344 return self::lookup($a_id,
"title");
356 $assignments = array();
360 $assignments = $users + $roles;
375 "SELECT * FROM skl_profile_user " .
376 " WHERE profile_id = " .
$ilDB->quote($this->getId(),
"integer")
379 while ($rec =
$ilDB->fetchAssoc($set)) {
382 $users[$rec[
"user_id"]] = array(
385 "id" => $rec[
"user_id"]
402 array(
"profile_id" => array(
"integer", $this->
getId()),
403 "user_id" => array(
"integer", (
int) $a_user_id),
419 "DELETE FROM skl_profile_user WHERE " .
420 " profile_id = " .
$ilDB->quote($this->getId(),
"integer") .
421 " AND user_id = " .
$ilDB->quote($a_user_id,
"integer")
433 $ilDB = $DIC->database();
436 "DELETE FROM skl_profile_user WHERE " .
437 " user_id = " .
$ilDB->quote($a_user_id,
"integer")
451 $ilDB = $DIC->database();
452 $rbacreview = $DIC->rbac()->review();
454 $all_profiles = array();
457 $user_profiles = array();
459 "SELECT p.id, p.title FROM skl_profile_user u JOIN skl_profile p " .
460 " ON (u.profile_id = p.id) " .
461 " WHERE user_id = " .
$ilDB->quote($a_user_id,
"integer") .
462 " ORDER BY p.title ASC" 464 while ($rec =
$ilDB->fetchAssoc($set)) {
465 $user_profiles[] = $rec;
469 $role_profiles = array();
470 $user_roles = $rbacreview->assignedRoles($a_user_id);
471 foreach ($user_roles as $role) {
472 $profiles = self::getProfilesOfRole($role);
473 foreach ($profiles as $profile) {
474 $role_profiles[] = $profile;
479 $all_profiles = array_merge($user_profiles, $role_profiles);
480 $temp_profiles = array();
481 foreach ($all_profiles as &$v) {
482 if (!isset($temp_profiles[$v[
"id"]])) {
483 $temp_profiles[$v[
"id"]] = &$v;
486 $all_profiles = array_values($temp_profiles);
487 return $all_profiles;
497 $ilDB = $DIC->database();
500 "SELECT count(*) ucnt FROM skl_profile_user " .
501 " WHERE profile_id = " .
$ilDB->quote($a_profile_id,
"integer")
503 $rec =
$ilDB->fetchAssoc($set);
504 return (
int) $rec[
"ucnt"];
519 "SELECT * FROM skl_profile_role " .
520 " WHERE profile_id = " .
$ilDB->quote($this->getId(),
"integer")
523 while ($rec =
$ilDB->fetchAssoc($set)) {
533 $roles[$rec[
"role_id"]] = array(
536 "id" => $rec[
"role_id"],
537 "object" => $obj_title
555 array(
"profile_id" => array(
"integer", $this->
getId()),
556 "role_id" => array(
"integer", (
int) $a_role_id),
572 "DELETE FROM skl_profile_role WHERE " .
573 " profile_id = " .
$ilDB->quote($this->getId(),
"integer") .
574 " AND role_id = " .
$ilDB->quote($a_role_id,
"integer")
586 $ilDB = $DIC->database();
589 "DELETE FROM skl_profile_role WHERE " .
590 " role_id = " .
$ilDB->quote($a_role_id,
"integer")
604 $ilDB = $DIC->database();
608 "SELECT p.id, p.title FROM skl_profile_role r JOIN skl_profile p " .
609 " ON (r.profile_id = p.id) " .
610 " WHERE role_id = " .
$ilDB->quote($a_role_id,
"integer") .
611 " ORDER BY p.title ASC" 613 while ($rec =
$ilDB->fetchAssoc($set)) {
629 $ilDB = $DIC->database();
632 "SELECT count(*) rcnt FROM skl_profile_role " .
633 " WHERE profile_id = " .
$ilDB->quote($a_profile_id,
"integer")
635 $rec =
$ilDB->fetchAssoc($set);
636 return (
int) $rec[
"rcnt"];
649 $ilDB = $DIC->database();
651 include_once(
"./Services/Skill/classes/class.ilSkillUsage.php");
Get info on usages of skills.
static removeRoleFromAllProfiles(int $a_role_id)
Remove role from all profiles.
static getProfiles()
Get profiles.
removeRoleFromProfile(int $a_role_id)
Remove role from profile.
static removeUserFromAllProfiles($a_user_id)
Remove user from all profiles.
setTitle($a_val)
Set title.
static _lookupTitle($a_id)
lookup object title
static getUsageInfoGeneric( $a_cskill_ids, &$a_usages, $a_usage_type, $a_table, $a_key_field, $a_skill_field="skill_id", $a_tref_field="tref_id")
Get standard usage query.
addUserToProfile($a_user_id)
Add user to profile.
update()
Update skill profile.
static _lookupObjectId($a_ref_id)
lookup object id
getSkillLevels()
Get skill levels.
static getProfilesOfUser($a_user_id)
Get profiles of a user.
getDescription()
Get description.
__construct($a_id=0)
Constructor.
static getProfilesOfRole(int $a_role_id)
Get profiles of a role.
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
getAssignedRoles()
Get assigned roles.
static _getTranslation($a_role_title)
static _lookupType($a_id, $a_reference=false)
lookup object type
setDescription($a_val)
Set description.
static getUsageInfo($a_cskill_ids, &$a_usages)
Get usage info.
read()
Read skill profile from db.
removeSkillLevel($a_base_skill_id, $a_tref_id, $a_level_id)
Remove skill level.
static countUsers($a_profile_id)
Get assigned users.
getAssignments()
Get all assignments (users and roles)
addSkillLevel($a_base_skill_id, $a_tref_id, $a_level_id)
Add skill level.
create()
Create skill profile.
static lookup($a_id, $a_field)
Lookup.
static countRoles(int $a_profile_id)
Count assigned roles of a profile.
static lookupTitle($a_id)
Lookup title.
getAssignedUsers()
Get assigned users.
addRoleToProfile(int $a_role_id)
Add role to profile.
removeUserFromProfile($a_user_id)
Remove user from profile.