ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilSkillProfile Class Reference

Skill profile. More...

+ Inheritance diagram for ilSkillProfile:
+ Collaboration diagram for ilSkillProfile:

Public Member Functions

 __construct ($a_id=0)
 Constructor. More...
 
 setId ($a_val)
 Set id. More...
 
 getId ()
 Get id. More...
 
 setTitle ($a_val)
 Set title. More...
 
 getTitle ()
 Get title. More...
 
 setDescription ($a_val)
 Set description. More...
 
 getDescription ()
 Get description. More...
 
 addSkillLevel ($a_base_skill_id, $a_tref_id, $a_level_id)
 Add skill level. More...
 
 removeSkillLevel ($a_base_skill_id, $a_tref_id, $a_level_id)
 Remove skill level. More...
 
 getSkillLevels ()
 Get skill levels. More...
 
 read ()
 Read skill profile from db. More...
 
 create ()
 Create skill profile. More...
 
 update ()
 Update skill profile. More...
 
 delete ()
 Delete skill profile. More...
 
 getAssignedUsers ()
 Get assigned users. More...
 
 addUserToProfile ($a_user_id)
 Add user to profile. More...
 
 removeUserFromProfile ($a_user_id)
 Remove user from profile. More...
 

Static Public Member Functions

static getProfiles ()
 Get profiles. More...
 
static lookupTitle ($a_id)
 Lookup title. More...
 
static removeUserFromAllProfiles ($a_user_id)
 Remove user from all profiles. More...
 
static getProfilesOfUser ($a_user_id)
 Get profiles of a user. More...
 
static countUsers ($a_profile_id)
 Get assigned users. More...
 
static getUsageInfo ($a_cskill_ids, &$a_usages)
 Get usage info. More...
 

Static Protected Member Functions

static lookup ($a_id, $a_field)
 Lookup. More...
 

Protected Attributes

 $db
 
 $id
 
 $title
 
 $description
 
 $skill_level = array()
 

Detailed Description

Skill profile.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$ /

Definition at line 14 of file class.ilSkillProfile.php.

Constructor & Destructor Documentation

◆ __construct()

ilSkillProfile::__construct (   $a_id = 0)

Constructor.

Parameters
int$a_idprofile id

Definition at line 31 of file class.ilSkillProfile.php.

References $DIC, read(), and setId().

32  {
33  global $DIC;
34 
35  $this->db = $DIC->database();
36  if ($a_id > 0) {
37  $this->setId($a_id);
38  $this->read();
39  }
40  }
global $DIC
Definition: saml.php:7
setId($a_val)
Set id.
read()
Read skill profile from db.
+ Here is the call graph for this function:

Member Function Documentation

◆ addSkillLevel()

ilSkillProfile::addSkillLevel (   $a_base_skill_id,
  $a_tref_id,
  $a_level_id 
)

Add skill level.

Parameters

Definition at line 108 of file class.ilSkillProfile.php.

Referenced by read().

109  {
110  //echo "-".$a_base_skill_id."-";
111  $this->skill_level[] = array(
112  "base_skill_id" => $a_base_skill_id,
113  "tref_id" => $a_tref_id,
114  "level_id" => $a_level_id
115  );
116  }
+ Here is the caller graph for this function:

◆ addUserToProfile()

ilSkillProfile::addUserToProfile (   $a_user_id)

Add user to profile.

Parameters
int$a_user_iduser id

Definition at line 368 of file class.ilSkillProfile.php.

References $db, $ilDB, and getId().

369  {
370  $ilDB = $this->db;
371 
372  $ilDB->replace(
373  "skl_profile_user",
374  array("profile_id" => array("integer", $this->getId()),
375  "user_id" => array("integer", (int) $a_user_id),
376  ),
377  array()
378  );
379  }
global $ilDB
+ Here is the call graph for this function:

◆ countUsers()

static ilSkillProfile::countUsers (   $a_profile_id)
static

Get assigned users.

Definition at line 441 of file class.ilSkillProfile.php.

References $DIC, and $ilDB.

Referenced by ilSkillProfileTableGUI\fillRow().

442  {
443  global $DIC;
444 
445  $ilDB = $DIC->database();
446 
447  $set = $ilDB->query(
448  "SELECT count(*) ucnt FROM skl_profile_user " .
449  " WHERE profile_id = " . $ilDB->quote($a_profile_id, "integer")
450  );
451  $rec = $ilDB->fetchAssoc($set);
452  return (int) $rec["ucnt"];
453  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ create()

ilSkillProfile::create ( )

Create skill profile.

Definition at line 180 of file class.ilSkillProfile.php.

References $db, $ilDB, getId(), and setId().

181  {
182  $ilDB = $this->db;
183 
184  // profile
185  $this->setId($ilDB->nextId("skl_profile"));
186  $ilDB->manipulate("INSERT INTO skl_profile " .
187  "(id, title, description) VALUES (" .
188  $ilDB->quote($this->getId(), "integer") . "," .
189  $ilDB->quote($this->getTitle(), "text") . "," .
190  $ilDB->quote($this->getDescription(), "text") .
191  ")");
192 
193  // profile levels
194  foreach ($this->skill_level as $level) {
195  $ilDB->replace(
196  "skl_profile_level",
197  array("profile_id" => array("integer", $this->getId()),
198  "tref_id" => array("integer", (int) $level["tref_id"]),
199  "base_skill_id" => array("integer", (int) $level["base_skill_id"])
200  ),
201  array("level_id" => array("integer", (int) $level["level_id"]))
202  );
203  }
204  }
setId($a_val)
Set id.
global $ilDB
+ Here is the call graph for this function:

◆ delete()

ilSkillProfile::delete ( )

Delete skill profile.

Definition at line 249 of file class.ilSkillProfile.php.

References $db, and $ilDB.

250  {
251  $ilDB = $this->db;
252 
253  // TODO: Split the deletions when refactoring to repository pattern
254 
255  // profile levels
256  $ilDB->manipulate(
257  "DELETE FROM skl_profile_level WHERE " .
258  " profile_id = " . $ilDB->quote($this->getId(), "integer")
259  );
260 
261  // profile users
262  $ilDB->manipulate(
263  "DELETE FROM skl_profile_user WHERE " .
264  " profile_id = " . $ilDB->quote($this->getId(), "integer")
265  );
266 
267  // profile roles
268  $ilDB->manipulate(
269  "DELETE FROM skl_profile_role WHERE " .
270  " profile_id = " . $ilDB->quote($this->getId(), "integer")
271  );
272 
273  // profile
274  $ilDB->manipulate(
275  "DELETE FROM skl_profile WHERE " .
276  " id = " . $ilDB->quote($this->getId(), "integer")
277  );
278  }
global $ilDB

◆ getAssignedUsers()

ilSkillProfile::getAssignedUsers ( )

Get assigned users.

Definition at line 342 of file class.ilSkillProfile.php.

References $db, $ilDB, $name, $users, and ilObjUser\_lookupName().

343  {
344  $ilDB = $this->db;
345 
346  $set = $ilDB->query(
347  "SELECT * FROM skl_profile_user " .
348  " WHERE profile_id = " . $ilDB->quote($this->getId(), "integer")
349  );
350  $users = array();
351  while ($rec = $ilDB->fetchAssoc($set)) {
352  $name = ilObjUser::_lookupName($rec["user_id"]);
353  $users[$rec["user_id"]] = array(
354  "lastname" => $name["lastname"],
355  "firstname" => $name["firstname"],
356  "login" => $name["login"],
357  "id" => $name["user_id"]
358  );
359  }
360  return $users;
361  }
static _lookupName($a_user_id)
lookup user name
$users
Definition: authpage.php:44
global $ilDB
+ Here is the call graph for this function:

◆ getDescription()

ilSkillProfile::getDescription ( )

Get description.

Returns
string description

Definition at line 97 of file class.ilSkillProfile.php.

References $description.

98  {
99  return $this->description;
100  }

◆ getId()

ilSkillProfile::getId ( )

Get id.

Returns
int id

Definition at line 57 of file class.ilSkillProfile.php.

References $id.

Referenced by addUserToProfile(), create(), and update().

58  {
59  return $this->id;
60  }
+ Here is the caller graph for this function:

◆ getProfiles()

static ilSkillProfile::getProfiles ( )
static

Get profiles.

Parameters

Definition at line 286 of file class.ilSkillProfile.php.

References $DIC, and $ilDB.

Referenced by ilSkillProfileTableGUI\getProfiles().

287  {
288  global $DIC;
289 
290  $ilDB = $DIC->database();
291 
292  $set = $ilDB->query(
293  "SELECT * FROM skl_profile " .
294  " ORDER BY title "
295  );
296  $profiles = array();
297  while ($rec = $ilDB->fetchAssoc($set)) {
298  $profiles[$rec["id"]] = $rec;
299  }
300 
301  return $profiles;
302  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ getProfilesOfUser()

static ilSkillProfile::getProfilesOfUser (   $a_user_id)
static

Get profiles of a user.

Parameters
int$a_user_iduser id

Definition at line 419 of file class.ilSkillProfile.php.

References $DIC, and $ilDB.

Referenced by ilPersonalSkillsGUI\__construct(), ilSurveyEvaluationGUI\competenceEval(), and ilTestSkillEvaluation\getAssignedSkillMatchingSkillProfiles().

420  {
421  global $DIC;
422 
423  $ilDB = $DIC->database();
424 
425  $profiles = array();
426  $set = $ilDB->query(
427  "SELECT p.id, p.title FROM skl_profile_user u JOIN skl_profile p " .
428  " ON (u.profile_id = p.id) " .
429  " WHERE user_id = " . $ilDB->quote($a_user_id, "integer") .
430  " ORDER BY p.title ASC"
431  );
432  while ($rec = $ilDB->fetchAssoc($set)) {
433  $profiles[] = $rec;
434  }
435  return $profiles;
436  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ getSkillLevels()

ilSkillProfile::getSkillLevels ( )

Get skill levels.

Parameters

Definition at line 141 of file class.ilSkillProfile.php.

References $skill_level.

142  {
143  return $this->skill_level;
144  }

◆ getTitle()

ilSkillProfile::getTitle ( )

Get title.

Returns
string title

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

References $title.

78  {
79  return $this->title;
80  }

◆ getUsageInfo()

static ilSkillProfile::getUsageInfo (   $a_cskill_ids,
$a_usages 
)
static

Get usage info.

Parameters

Implements ilSkillUsageInfo.

Definition at line 461 of file class.ilSkillProfile.php.

References $DIC, $ilDB, ilSkillUsage\getUsageInfoGeneric(), and ilSkillUsage\PROFILE.

462  {
463  global $DIC;
464 
465  $ilDB = $DIC->database();
466 
467  include_once("./Services/Skill/classes/class.ilSkillUsage.php");
469  $a_cskill_ids,
470  $a_usages,
472  "skl_profile_level",
473  "profile_id",
474  "base_skill_id"
475  );
476  }
global $DIC
Definition: saml.php:7
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.
global $ilDB
+ Here is the call graph for this function:

◆ lookup()

static ilSkillProfile::lookup (   $a_id,
  $a_field 
)
staticprotected

Lookup.

Parameters

Definition at line 310 of file class.ilSkillProfile.php.

References $DIC, and $ilDB.

311  {
312  global $DIC;
313 
314  $ilDB = $DIC->database();
315 
316  $set = $ilDB->query(
317  "SELECT " . $a_field . " FROM skl_profile " .
318  " WHERE id = " . $ilDB->quote($a_id, "integer")
319  );
320  $rec = $ilDB->fetchAssoc($set);
321  return $rec[$a_field];
322  }
global $DIC
Definition: saml.php:7
global $ilDB

◆ lookupTitle()

static ilSkillProfile::lookupTitle (   $a_id)
static

Lookup title.

Parameters

Definition at line 330 of file class.ilSkillProfile.php.

Referenced by ilSkillProfileGUI\confirmDeleteProfiles().

331  {
332  return self::lookup($a_id, "title");
333  }
+ Here is the caller graph for this function:

◆ read()

ilSkillProfile::read ( )

Read skill profile from db.

Parameters

Definition at line 152 of file class.ilSkillProfile.php.

References $db, $ilDB, addSkillLevel(), setDescription(), and setTitle().

Referenced by __construct().

153  {
154  $ilDB = $this->db;
155 
156  $set = $ilDB->query(
157  "SELECT * FROM skl_profile " .
158  " WHERE id = " . $ilDB->quote($this->getId(), "integer")
159  );
160  $rec = $ilDB->fetchAssoc($set);
161  $this->setTitle($rec["title"]);
162  $this->setDescription($rec["description"]);
163 
164  $set = $ilDB->query(
165  "SELECT * FROM skl_profile_level " .
166  " WHERE profile_id = " . $ilDB->quote($this->getId(), "integer")
167  );
168  while ($rec = $ilDB->fetchAssoc($set)) {
169  $this->addSkillLevel(
170  (int) $rec["base_skill_id"],
171  (int) $rec["tref_id"],
172  (int) $rec["level_id"]
173  );
174  }
175  }
setTitle($a_val)
Set title.
setDescription($a_val)
Set description.
global $ilDB
addSkillLevel($a_base_skill_id, $a_tref_id, $a_level_id)
Add skill level.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeSkillLevel()

ilSkillProfile::removeSkillLevel (   $a_base_skill_id,
  $a_tref_id,
  $a_level_id 
)

Remove skill level.

Parameters

Definition at line 124 of file class.ilSkillProfile.php.

125  {
126  foreach ($this->skill_level as $k => $sl) {
127  if ((int) $sl["base_skill_id"] == (int) $a_base_skill_id &&
128  (int) $sl["tref_id"] == (int) $a_tref_id &&
129  (int) $sl["level_id"] == (int) $a_level_id) {
130  unset($this->skill_level[$k]);
131  }
132  }
133  }

◆ removeUserFromAllProfiles()

static ilSkillProfile::removeUserFromAllProfiles (   $a_user_id)
static

Remove user from all profiles.

Parameters
int$a_user_id

Definition at line 402 of file class.ilSkillProfile.php.

References $DIC, and $ilDB.

Referenced by ilSkillObjDeletionHandler\processDeletion().

403  {
404  global $DIC;
405  $ilDB = $DIC->database();
406 
407  $ilDB->manipulate(
408  "DELETE FROM skl_profile_user WHERE " .
409  " user_id = " . $ilDB->quote($a_user_id, "integer")
410  );
411  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ removeUserFromProfile()

ilSkillProfile::removeUserFromProfile (   $a_user_id)

Remove user from profile.

Parameters
int$a_user_iduser id

Definition at line 386 of file class.ilSkillProfile.php.

References $db, and $ilDB.

387  {
388  $ilDB = $this->db;
389 
390  $ilDB->manipulate(
391  "DELETE FROM skl_profile_user WHERE " .
392  " profile_id = " . $ilDB->quote($this->getId(), "integer") .
393  " AND user_id = " . $ilDB->quote($a_user_id, "integer")
394  );
395  }
global $ilDB

◆ setDescription()

ilSkillProfile::setDescription (   $a_val)

Set description.

Parameters
string$a_valdescription

Definition at line 87 of file class.ilSkillProfile.php.

Referenced by read().

88  {
89  $this->description = $a_val;
90  }
+ Here is the caller graph for this function:

◆ setId()

ilSkillProfile::setId (   $a_val)

Set id.

Parameters
int$a_valid

Definition at line 47 of file class.ilSkillProfile.php.

Referenced by __construct(), and create().

48  {
49  $this->id = $a_val;
50  }
+ Here is the caller graph for this function:

◆ setTitle()

ilSkillProfile::setTitle (   $a_val)

Set title.

Parameters
string$a_valtitle

Definition at line 67 of file class.ilSkillProfile.php.

Referenced by read().

68  {
69  $this->title = $a_val;
70  }
+ Here is the caller graph for this function:

◆ update()

ilSkillProfile::update ( )

Update skill profile.

Definition at line 209 of file class.ilSkillProfile.php.

References $db, $ilDB, and getId().

210  {
211  $ilDB = $this->db;
212 
213  // profile
214  $ilDB->manipulate(
215  "UPDATE skl_profile SET " .
216  " title = " . $ilDB->quote($this->getTitle(), "text") . "," .
217  " description = " . $ilDB->quote($this->getDescription(), "text") .
218  " WHERE id = " . $ilDB->quote($this->getId(), "integer")
219  );
220 
221  // profile levels
222  $ilDB->manipulate(
223  "DELETE FROM skl_profile_level WHERE " .
224  " profile_id = " . $ilDB->quote($this->getId(), "integer")
225  );
226  foreach ($this->skill_level as $level) {
227  $ilDB->replace(
228  "skl_profile_level",
229  array("profile_id" => array("integer", $this->getId()),
230  "tref_id" => array("integer", (int) $level["tref_id"]),
231  "base_skill_id" => array("integer", (int) $level["base_skill_id"])
232  ),
233  array("level_id" => array("integer", (int) $level["level_id"]))
234  );
235 
236  /*$ilDB->manipulate("INSERT INTO skl_profile_level ".
237  "(profile_id, base_skill_id, tref_id, level_id) VALUES (".
238  $ilDB->quote($this->getId(), "integer").",".
239  $ilDB->quote((int) $level["base_skill_id"], "integer").",".
240  $ilDB->quote((int) $level["tref_id"], "integer").",".
241  $ilDB->quote((int) $level["level_id"], "integer").
242  ")");*/
243  }
244  }
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilSkillProfile::$db
protected

◆ $description

ilSkillProfile::$description
protected

Definition at line 23 of file class.ilSkillProfile.php.

Referenced by getDescription().

◆ $id

ilSkillProfile::$id
protected

Definition at line 21 of file class.ilSkillProfile.php.

Referenced by getId().

◆ $skill_level

ilSkillProfile::$skill_level = array()
protected

Definition at line 24 of file class.ilSkillProfile.php.

Referenced by getSkillLevels().

◆ $title

ilSkillProfile::$title
protected

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

Referenced by getTitle().


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