ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
ilMStListCompetencesSkills Class Reference

Class ilMStListCompetencesSkills. More...

+ Collaboration diagram for ilMStListCompetencesSkills:

Public Member Functions

 __construct (Container $dic)
 ilMStListCompetencesSkills constructor. More...
 
 getData (array $options)
 

Protected Member Functions

 getAdditionalWhereStatement (array $filters)
 

Protected Attributes

Container $dic
 

Private Member Functions

 getSafeSortDirection (string $sort_direction)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilMStListCompetencesSkills::__construct ( Container  $dic)

ilMStListCompetencesSkills constructor.

Parameters
Container$dic

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

36 {
37 $this->dic = $dic;
38 }

References $dic.

Member Function Documentation

◆ getAdditionalWhereStatement()

ilMStListCompetencesSkills::getAdditionalWhereStatement ( array  $filters)
protected

Definition at line 119 of file class.ilMStListCompetencesSkills.php.

119 : string
120 {
121 $wheres = [];
122
123 if (!empty($filters['skill'])) {
124 $wheres[] = $this->dic->database()->like(
125 "sktree.title",
126 "text",
127 "%" . $filters['skill'] . "%"
128 );
129 }
130
131 if (!empty($filters['skill_level'])) {
132 $wheres[] = $this->dic->database()->like(
133 "lvl.title",
134 "text",
135 "%" . $filters['skill_level'] . "%"
136 );
137 }
138
139 if (!empty($filters['user'])) {
140 $wheres[] = "(" . $this->dic->database()->like(
141 "ud.login",
142 "text",
143 "%" . $filters['user'] . "%"
144 ) . " " . "OR " . $this->dic->database()
145 ->like(
146 "ud.firstname",
147 "text",
148 "%" . $filters['user'] . "%"
149 ) . " " . "OR " . $this->dic->database()
150 ->like(
151 "ud.lastname",
152 "text",
153 "%" . $filters['user'] . "%"
154 ) . " " . "OR " . $this->dic->database()
155 ->like(
156 "ud.email",
157 "text",
158 "%" . $filters['user'] . "%"
159 ) . ") ";
160 }
161
162 if (!empty($filters['org_unit'])) {
163 $wheres[] = 'ud.usr_id IN (SELECT user_id FROM il_orgu_ua WHERE orgu_id = ' .
164 $this->dic->database()->quote($filters['org_unit'], 'integer') . ')';
165 }
166
167 return empty($wheres) ? '' : ' AND ' . implode(' AND ', $wheres);
168 }

Referenced by getData().

+ Here is the caller graph for this function:

◆ getData()

ilMStListCompetencesSkills::getData ( array  $options)
final
Parameters
int[]$options
Returns
ilMStListCompetencesSkill[]

Definition at line 44 of file class.ilMStListCompetencesSkills.php.

45 {
46 //Permission Filter
48
49 $select = 'SELECT sktree.title as skill_title, skill_node_id, ulvl.trigger_obj_id, ulvl.user_id, login, firstname, lastname, email, lvl.title as skill_level';
50
51 $query = $select .
52 ' FROM skl_personal_skill sk ' .
53 ' INNER JOIN usr_data ud ON ud.usr_id = sk.user_id ' .
54 ' INNER JOIN skl_tree_node sktree ON sktree.obj_id = sk.skill_node_id ' .
55 ' INNER JOIN (SELECT user_id, trigger_obj_id, skill_id, MAX(level_id) AS level_id ' .
56 ' FROM skl_user_has_level WHERE self_eval = 0 GROUP BY skill_id, user_id) ulvl ON sk.skill_node_id = ulvl.skill_id AND sk.user_id = ulvl.user_id ' .
57 ' INNER JOIN skl_level lvl ON lvl.id = ulvl.level_id ' .
58 ' WHERE ';
59
60 $users_per_position = ilMyStaffAccess::getInstance()->getUsersForUserPerPosition($this->dic->user()->getId());
61
62 if (empty($users_per_position)) {
63 return new ListFetcherResult([], 0);
64 }
65
66 $arr_query = [];
67 foreach ($users_per_position as $position_id => $users) {
68 $obj_ids = ilMyStaffAccess::getInstance()->getIdsForUserAndOperation(
69 $this->dic->user()->getId(),
70 $operation_access
71 );
72 $arr_query[] = $query . $this->dic->database()->in(
73 'ulvl.trigger_obj_id',
74 $obj_ids,
75 false,
76 'integer'
77 ) . " AND " . $this->dic->database()->in('sk.user_id ', $users, false, 'integer')
78 . $this->getAdditionalWhereStatement((array) $options['filters']);
79 }
80
81 $union_query = "SELECT * FROM ((" . implode(') UNION (', $arr_query) . ")) as a_table";
82
83 $set = $this->dic->database()->query($union_query);
84 $numRows = $this->dic->database()->numRows($set);
85
86 if ($options['sort']) {
87 /*
88 * Sort field is validated in ilMStListCompetencesSkillsTableGUI::getSafeOrderField,
89 * the available columns depend on user administration settings.
90 */
91 $sort_field = (string) ($options['sort']['field'] ?? '');
92 $sort_direction = $this->getSafeSortDirection((string) ($options['sort']['direction'] ?? ''));
93 $union_query .= " ORDER BY " . $this->dic->database()->quoteIdentifier($sort_field) . " " . $sort_direction;
94 }
95
96 if (isset($options['limit']['start']) && isset($options['limit']['end'])) {
97 $union_query .= " LIMIT " . (int) $options['limit']['start'] . "," . (int) $options['limit']['end'];
98 }
99
100 $set = $this->dic->database()->query($union_query);
101
102 $skills = [];
103 while ($rec = $this->dic->database()->fetchAssoc($set)) {
104 $skills[] = new ilMStListCompetencesSkill(
105 intval($rec['skill_node_id']),
106 $rec['skill_title'],
107 $rec['skill_level'],
108 $rec['login'],
109 $rec['lastname'],
110 $rec['firstname'],
111 $rec['email'],
112 intval($rec['user_id'])
113 );
114 }
115
116 return new ListFetcherResult($skills, $numRows);
117 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\UI\Implementation\Component\Input\Field\$options, getAdditionalWhereStatement(), getSafeSortDirection(), ILIAS\Repository\int(), and ilOrgUnitOperation\OP_VIEW_COMPETENCES.

+ Here is the call graph for this function:

◆ getSafeSortDirection()

ilMStListCompetencesSkills::getSafeSortDirection ( string  $sort_direction)
private

Definition at line 170 of file class.ilMStListCompetencesSkills.php.

170 : string
171 {
172 return strtolower($sort_direction) === 'asc'
173 ? 'asc'
174 : 'desc';
175 }

Referenced by getData().

+ Here is the caller graph for this function:

Field Documentation

◆ $dic

Container ilMStListCompetencesSkills::$dic
protected

Definition at line 29 of file class.ilMStListCompetencesSkills.php.

Referenced by __construct().


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