42 $this->db = $DIC->database();
43 $this->lng = $DIC->language();
44 $this->review = $DIC->rbac()->review();
78 $this->title = $a_val;
98 $this->description = $a_val;
116 $this->ref_id = $a_val;
133 public function addSkillLevel($a_base_skill_id, $a_tref_id, $a_level_id, $a_order_nr)
136 $this->skill_level[] = array(
137 "base_skill_id" => $a_base_skill_id,
138 "tref_id" => $a_tref_id,
139 "level_id" => $a_level_id,
140 "order_nr" => $a_order_nr
152 foreach ($this->skill_level as $k => $sl) {
153 if ((
int) $sl[
"base_skill_id"] == (
int) $a_base_skill_id &&
154 (
int) $sl[
"tref_id"] == (
int) $a_tref_id &&
155 (
int) $sl[
"level_id"] == (
int) $a_level_id &&
156 (
int) $sl[
"order_nr"] == (
int) $a_order_nr) {
157 unset($this->skill_level[$k]);
170 usort($this->skill_level,
function($level_a, $level_b) {
171 return $level_a[
'order_nr'] <=> $level_b[
'order_nr'];
188 "SELECT * FROM skl_profile " .
189 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer")
191 $rec =
$ilDB->fetchAssoc($set);
197 "SELECT * FROM skl_profile_level " .
198 " WHERE profile_id = " .
$ilDB->quote($this->getId(),
"integer")
200 while ($rec =
$ilDB->fetchAssoc($set)) {
202 (
int) $rec[
"base_skill_id"],
203 (
int) $rec[
"tref_id"],
204 (
int) $rec[
"level_id"],
205 (
int) $rec[
"order_nr"]
219 $ilDB->manipulate(
"INSERT INTO skl_profile " .
220 "(id, title, description, ref_id) VALUES (" .
221 $ilDB->quote($this->getId(),
"integer") .
"," .
222 $ilDB->quote($this->getTitle(),
"text") .
"," .
223 $ilDB->quote($this->getDescription(),
"text") .
"," .
224 $ilDB->quote($this->getRefId(),
"integer") .
228 foreach ($this->skill_level as $level) {
231 array(
"profile_id" => array(
"integer", $this->
getId()),
232 "tref_id" => array(
"integer", (
int) $level[
"tref_id"]),
233 "base_skill_id" => array(
"integer", (
int) $level[
"base_skill_id"])
235 array(
"order_nr" => array(
"integer", (
int) $level[
"order_nr"]),
236 "level_id" => array(
"integer", (
int) $level[
"level_id"])
251 "UPDATE skl_profile SET " .
252 " title = " .
$ilDB->quote($this->getTitle(),
"text") .
"," .
253 " description = " .
$ilDB->quote($this->getDescription(),
"text") .
254 " WHERE id = " .
$ilDB->quote($this->getId(),
"integer") .
255 " AND ref_id = " .
$ilDB->quote($this->getRefId(),
"integer")
260 "DELETE FROM skl_profile_level WHERE " .
261 " profile_id = " .
$ilDB->quote($this->getId(),
"integer")
263 foreach ($this->skill_level as $level) {
266 array(
"profile_id" => array(
"integer", $this->
getId()),
267 "tref_id" => array(
"integer", (
int) $level[
"tref_id"]),
268 "base_skill_id" => array(
"integer", (
int) $level[
"base_skill_id"])
270 array(
"order_nr" => array(
"integer", (
int) $level[
"order_nr"]),
271 "level_id" => array(
"integer", (
int) $level[
"level_id"])
288 public function delete()
296 "DELETE FROM skl_profile_level WHERE " .
297 " profile_id = " .
$ilDB->quote($this->getId(),
"integer")
302 "DELETE FROM skl_profile_user WHERE " .
303 " profile_id = " .
$ilDB->quote($this->getId(),
"integer")
308 "DELETE FROM skl_profile_role WHERE " .
309 " profile_id = " .
$ilDB->quote($this->getId(),
"integer")
314 "DELETE FROM skl_profile WHERE " .
315 " id = " .
$ilDB->quote($this->getId(),
"integer")
323 $ilDB = $DIC->database();
326 "DELETE FROM skl_profile WHERE " .
327 " ref_id = " .
$ilDB->quote($a_ref_id,
"integer")
343 foreach ($order as
$id => $o) {
344 $id_arr = explode(
"_",
$id);
346 "UPDATE skl_profile_level SET " .
347 " order_nr = " .
$ilDB->quote(($cnt * 10),
"integer") .
348 " WHERE base_skill_id = " .
$ilDB->quote($id_arr[0],
"integer") .
349 " AND tref_id = " .
$ilDB->quote($id_arr[1],
"integer") .
350 " AND profile_id = " .
$ilDB->quote($this->
getId(),
"integer")
364 "SELECT profile_id, base_skill_id, tref_id, order_nr FROM skl_profile_level WHERE " .
365 " profile_id = " .
$ilDB->quote($this->getId(),
"integer") .
366 " ORDER BY order_nr ASC" 369 while ($rec =
$ilDB->fetchAssoc($set)) {
371 "UPDATE skl_profile_level SET " .
372 " order_nr = " .
$ilDB->quote(($cnt * 10),
"integer") .
373 " WHERE profile_id = " .
$ilDB->quote($rec[
"profile_id"],
"integer") .
374 " AND base_skill_id = " .
$ilDB->quote($rec[
"base_skill_id"],
"integer") .
375 " AND tref_id = " .
$ilDB->quote($rec[
"tref_id"],
"integer")
391 "SELECT MAX(order_nr) mnr FROM skl_profile_level WHERE " .
392 " profile_id = " .
$ilDB->quote($this->getId(),
"integer")
394 $rec =
$ilDB->fetchAssoc($set);
395 return (
int) $rec[
"mnr"];
408 $ilDB = $DIC->database();
411 "SELECT * FROM skl_profile " .
415 while ($rec =
$ilDB->fetchAssoc($set)) {
416 $profiles[$rec[
"id"]] = $rec;
431 $ilDB = $DIC->database();
434 "SELECT * FROM skl_profile " .
435 " WHERE ref_id = 0 " .
439 while ($rec =
$ilDB->fetchAssoc($set)) {
440 $profiles[$rec[
"id"]] = $rec;
456 $ilDB = $DIC->database();
459 "SELECT * FROM skl_profile " .
460 " WHERE ref_id = " . $a_ref_id .
464 while ($rec =
$ilDB->fetchAssoc($set)) {
465 $profiles[$rec[
"id"]] = $rec;
477 protected static function lookup($a_id, $a_field)
481 $ilDB = $DIC->database();
484 "SELECT " . $a_field .
" FROM skl_profile " .
485 " WHERE id = " .
$ilDB->quote($a_id,
"integer")
487 $rec =
$ilDB->fetchAssoc($set);
488 return $rec[$a_field];
499 return self::lookup($a_id,
"title");
504 return self::lookup($a_id,
"ref_id");
519 "ref_id" => array(
"integer", $a_new_ref_id)),
521 "id" => array(
"integer", $this->
getId()))
534 $assignments = array();
538 $assignments = $users + $roles;
553 "SELECT * FROM skl_profile_user " .
554 " WHERE profile_id = " .
$ilDB->quote($this->getId(),
"integer")
557 while ($rec =
$ilDB->fetchAssoc($set)) {
560 $users[$rec[
"user_id"]] = array(
563 "id" => $rec[
"user_id"]
580 array(
"profile_id" => array(
"integer", $this->
getId()),
581 "user_id" => array(
"integer", (
int) $a_user_id),
597 "DELETE FROM skl_profile_user WHERE " .
598 " profile_id = " .
$ilDB->quote($this->getId(),
"integer") .
599 " AND user_id = " .
$ilDB->quote($a_user_id,
"integer")
611 $ilDB = $DIC->database();
614 "DELETE FROM skl_profile_user WHERE " .
615 " user_id = " .
$ilDB->quote($a_user_id,
"integer")
629 $ilDB = $DIC->database();
630 $rbacreview = $DIC->rbac()->review();
632 $all_profiles = array();
635 $user_profiles = array();
637 "SELECT p.id, p.title FROM skl_profile_user u JOIN skl_profile p " .
638 " ON (u.profile_id = p.id) " .
639 " WHERE user_id = " .
$ilDB->quote($a_user_id,
"integer") .
640 " ORDER BY p.title ASC" 642 while ($rec =
$ilDB->fetchAssoc($set)) {
643 $user_profiles[] = $rec;
647 $role_profiles = array();
648 $user_roles = $rbacreview->assignedRoles($a_user_id);
649 foreach ($user_roles as $role) {
650 $profiles = self::getGlobalProfilesOfRole($role);
651 foreach ($profiles as $profile) {
652 $role_profiles[] = $profile;
657 $all_profiles = array_merge($user_profiles, $role_profiles);
658 $temp_profiles = array();
659 foreach ($all_profiles as &$v) {
660 if (!isset($temp_profiles[$v[
"id"]])) {
661 $temp_profiles[$v[
"id"]] = &$v;
664 $all_profiles = array_values($temp_profiles);
665 return $all_profiles;
675 $ilDB = $DIC->database();
678 "SELECT count(*) ucnt FROM skl_profile_user " .
679 " WHERE profile_id = " .
$ilDB->quote($a_profile_id,
"integer")
681 $rec =
$ilDB->fetchAssoc($set);
682 return (
int) $rec[
"ucnt"];
697 "SELECT * FROM skl_profile_role " .
698 " WHERE profile_id = " .
$ilDB->quote($this->getId(),
"integer")
701 while ($rec =
$ilDB->fetchAssoc($set)) {
714 $roles[$rec[
"role_id"]] = array(
717 "id" => $rec[
"role_id"],
718 "object_title" => $obj_title,
719 "object_type" => $obj_type,
720 "object_id" => $obj_id
738 array(
"profile_id" => array(
"integer", $this->
getId()),
739 "role_id" => array(
"integer", (
int) $a_role_id),
755 "DELETE FROM skl_profile_role WHERE " .
756 " profile_id = " .
$ilDB->quote($this->getId(),
"integer") .
757 " AND role_id = " .
$ilDB->quote($a_role_id,
"integer")
769 $ilDB = $DIC->database();
772 "DELETE FROM skl_profile_role WHERE " .
773 " role_id = " .
$ilDB->quote($a_role_id,
"integer")
787 $ilDB = $DIC->database();
791 "SELECT p.id, p.title FROM skl_profile_role r JOIN skl_profile p " .
792 " ON (r.profile_id = p.id) " .
793 " WHERE r.role_id = " .
$ilDB->quote($a_role_id,
"integer") .
794 " ORDER BY p.title ASC" 796 while ($rec =
$ilDB->fetchAssoc($set)) {
812 $ilDB = $DIC->database();
816 "SELECT p.id, p.title FROM skl_profile_role r JOIN skl_profile p " .
817 " ON (r.profile_id = p.id) " .
818 " WHERE r.role_id = " .
$ilDB->quote($a_role_id,
"integer") .
819 " AND p.ref_id = 0" .
820 " ORDER BY p.title ASC" 822 while ($rec =
$ilDB->fetchAssoc($set)) {
839 $ilDB = $DIC->database();
843 "SELECT p.id, p.title FROM skl_profile_role r JOIN skl_profile p " .
844 " ON (r.profile_id = p.id) " .
845 " WHERE r.role_id = " .
$ilDB->quote($a_role_id,
"integer") .
846 " AND p.ref_id = " .
$ilDB->quote($a_ref_id,
"integer") .
847 " ORDER BY p.title ASC" 849 while ($rec =
$ilDB->fetchAssoc($set)) {
865 $ilDB = $DIC->database();
868 "SELECT count(*) rcnt FROM skl_profile_role " .
869 " WHERE profile_id = " .
$ilDB->quote($a_profile_id,
"integer")
871 $rec =
$ilDB->fetchAssoc($set);
872 return (
int) $rec[
"rcnt"];
Get info on usages of skills.
static removeRoleFromAllProfiles(int $a_role_id)
Remove role from all profiles.
static getProfiles()
Get profiles.
removeSkillLevel($a_base_skill_id, $a_tref_id, $a_level_id, $a_order_nr)
Remove skill level.
removeRoleFromProfile(int $a_role_id)
Remove role from profile.
static removeUserFromAllProfiles($a_user_id)
Remove user from all profiles.
getMaxLevelOrderNr()
Get maximum order number of levels.
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
static getLocalProfilesOfRole(int $a_role_id, int $a_ref_id)
Get local profiles of a role.
getSkillLevels()
Get skill levels.
fixSkillOrderNumbering()
Fix skill order numbering.
static getProfilesOfUser($a_user_id)
Get profiles of a user.
getDescription()
Get description.
__construct($a_id=0)
Constructor.
updateRefIdAfterImport(int $a_new_ref_id)
Update the old ref id with the new ref id after import.
static getLocalProfiles(int $a_ref_id)
Get local profiles of object.
static getAllProfilesOfRole(int $a_role_id)
Get global and local 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:
static lookupRefId($a_id)
addSkillLevel($a_base_skill_id, $a_tref_id, $a_level_id, $a_order_nr)
Add skill level.
getAssignedRoles()
Get assigned roles.
static getGlobalProfilesOfRole(int $a_role_id)
Get global profiles of a role.
static _getTranslation($a_role_title)
static _lookupType($a_id, $a_reference=false)
lookup object type
static getGlobalProfiles()
Get global profiles.
setDescription($a_val)
Set description.
updateSkillOrder(array $order)
Update skill order.
static getUsageInfo($a_cskill_ids, &$a_usages)
Get usage info.
read()
Read skill profile from db.
static countUsers($a_profile_id)
Get assigned users.
getAssignments()
Get all assignments (users and roles)
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.
static deleteProfilesFromObject(int $a_ref_id)
getAssignedUsers()
Get assigned users.
addRoleToProfile(int $a_role_id)
Add role to profile.
removeUserFromProfile($a_user_id)
Remove user from profile.