ILIAS  release_8 Revision v8.23
ilContainerMemberSkills Class Reference

Skills of a container. More...

+ Collaboration diagram for ilContainerMemberSkills:

Public Member Functions

 __construct (int $a_obj_id, int $a_user_id)
 
 setObjId (int $a_val)
 
 getObjId ()
 
 setUserId (int $a_val)
 
 getUserId ()
 
 read ()
 
 getSkillLevels ()
 
 getOrderedSkillLevels ()
 
 getPublished ()
 
 saveLevelForSkills (array $a_level_data)
 
 delete ()
 Delete all level data for current user. More...
 
 publish (int $a_ref_id)
 
 removeAllSkillLevels ()
 

Protected Attributes

ilDBInterface $db
 
SkillTreeService $tree_service
 
SkillProfileService $profile_service
 
array $skills = []
 
int $obj_id = 0
 
int $user_id = 0
 
array $skill_levels = []
 
bool $published = false
 

Detailed Description

Skills of a container.

Author
Alex Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 28 of file class.ilContainerMemberSkills.php.

Constructor & Destructor Documentation

◆ __construct()

ilContainerMemberSkills::__construct ( int  $a_obj_id,
int  $a_user_id 
)

Definition at line 39 of file class.ilContainerMemberSkills.php.

References $DIC, read(), setObjId(), and setUserId().

40  {
41  global $DIC;
42 
43  $this->db = $DIC->database();
44  $this->tree_service = $DIC->skills()->tree();
45  $this->profile_service = $DIC->skills()->profile();
46 
47  $this->setObjId($a_obj_id);
48  $this->setUserId($a_user_id);
49  if ($a_obj_id > 0 && $a_user_id > 0) {
50  $this->read();
51  }
52  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ delete()

ilContainerMemberSkills::delete ( )

Delete all level data for current user.

Definition at line 144 of file class.ilContainerMemberSkills.php.

References $db, ilDBInterface\manipulate(), and ilDBInterface\quote().

144  : void
145  {
146  $db = $this->db;
147 
148  $db->manipulate("DELETE FROM cont_member_skills WHERE " .
149  " obj_id = " . $db->quote($this->getObjId(), "integer") .
150  " AND user_id = " . $db->quote($this->getUserId(), "integer"));
151  }
quote($value, string $type)
manipulate(string $query)
Run a (write) Query on the database.
+ Here is the call graph for this function:

◆ getObjId()

ilContainerMemberSkills::getObjId ( )

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

References $obj_id.

Referenced by publish(), and removeAllSkillLevels().

59  : int
60  {
61  return $this->obj_id;
62  }
+ Here is the caller graph for this function:

◆ getOrderedSkillLevels()

ilContainerMemberSkills::getOrderedSkillLevels ( )
Returns
array[] each item comes with keys "level_id", "skill_id", "tref_id"

Definition at line 101 of file class.ilContainerMemberSkills.php.

References Vendor\Package\$a, and getSkillLevels().

101  : array
102  {
103  $skill_levels = array_map(static function ($a, $k): array {
104  $s = explode(":", $k);
105  return ["level_id" => $a, "skill_id" => $s[0], "tref_id" => $s[1]];
106  }, $this->getSkillLevels(), array_keys($this->getSkillLevels()));
107 
108  $vtree = $this->tree_service->getGlobalVirtualSkillTree();
109  return $vtree->getOrderedNodeset($skill_levels, "skill_id", "tref_id");
110  }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ Here is the call graph for this function:

◆ getPublished()

ilContainerMemberSkills::getPublished ( )

Definition at line 112 of file class.ilContainerMemberSkills.php.

References $published.

112  : bool
113  {
114  return $this->published;
115  }

◆ getSkillLevels()

ilContainerMemberSkills::getSkillLevels ( )
Returns
array (key is skill_id:tref_id, value is level id)

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

References $skill_levels.

Referenced by getOrderedSkillLevels(), and ilContSkillAdminGUI\initCompetenceAssignmentForm().

93  : array
94  {
95  return $this->skill_levels;
96  }
+ Here is the caller graph for this function:

◆ getUserId()

ilContainerMemberSkills::getUserId ( )

Definition at line 69 of file class.ilContainerMemberSkills.php.

References $user_id.

Referenced by publish(), and removeAllSkillLevels().

69  : int
70  {
71  return $this->user_id;
72  }
+ Here is the caller graph for this function:

◆ publish()

ilContainerMemberSkills::publish ( int  $a_ref_id)

Definition at line 153 of file class.ilContainerMemberSkills.php.

References $db, ilBasicSkill\ACHIEVED, ilPersonalSkill\addPersonalSkill(), getObjId(), getUserId(), ilDBInterface\manipulate(), ilDBInterface\quote(), ilBasicSkill\removeAllUserSkillLevelStatusOfObject(), and ilBasicSkill\writeUserSkillLevelStatus().

153  : bool
154  {
155  $db = $this->db;
156 
158  $this->getUserId(),
159  $this->getObjId(),
160  false,
161  (string) $this->getObjId()
162  );
163 
164  foreach ($this->skill_levels as $sk => $l) {
165  $changed = true;
166  $sk = explode(":", $sk);
168  $l,
169  $this->user_id,
170  $a_ref_id,
171  $sk[1],
173  false,
174  false,
175  $this->obj_id
176  );
177 
178  if ($sk[1] > 0) {
180  } else {
182  }
183  }
184 
185  //write profile completion entries if fulfilment status has changed
186  $this->profile_service->writeCompletionEntryForAllProfiles($this->getUserId());
187 
188  $db->manipulate("UPDATE cont_member_skills SET " .
189  " published = " . $db->quote(1, "integer") .
190  " WHERE obj_id = " . $db->quote($this->getObjId(), "integer") .
191  " AND user_id = " . $db->quote($this->getUserId(), "integer"));
192 
193  return $changed;
194  }
quote($value, string $type)
static removeAllUserSkillLevelStatusOfObject(int $a_user_id, int $a_trigger_obj_id, bool $a_self_eval=false, string $a_unique_identifier="")
static writeUserSkillLevelStatus(int $a_level_id, int $a_user_id, int $a_trigger_ref_id, int $a_tref_id=0, int $a_status=ilBasicSkill::ACHIEVED, bool $a_force=false, bool $a_self_eval=false, string $a_unique_identifier="", float $a_next_level_fulfilment=0.0, string $trigger_user_id="")
static addPersonalSkill(int $a_user_id, int $a_skill_node_id)
manipulate(string $query)
Run a (write) Query on the database.
+ Here is the call graph for this function:

◆ read()

ilContainerMemberSkills::read ( )

Definition at line 74 of file class.ilContainerMemberSkills.php.

References $db, ilDBInterface\query(), and ilDBInterface\quote().

Referenced by __construct().

74  : void
75  {
76  $db = $this->db;
77 
78  $set = $db->query(
79  "SELECT * FROM cont_member_skills " .
80  " WHERE obj_id = " . $db->quote($this->getObjId(), "integer") .
81  " AND user_id = " . $db->quote($this->getUserId(), "integer")
82  );
83  $this->skill_levels = [];
84  while ($rec = $this->db->fetchAssoc($set)) {
85  $this->skill_levels[$rec["skill_id"] . ":" . $rec["tref_id"]] = $rec["level_id"];
86  $this->published = $rec["published"]; // this is a little weak, but the value should be the same for all save skills
87  }
88  }
quote($value, string $type)
query(string $query)
Run a (read-only) Query on the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeAllSkillLevels()

ilContainerMemberSkills::removeAllSkillLevels ( )

Definition at line 196 of file class.ilContainerMemberSkills.php.

References getObjId(), getUserId(), and ilBasicSkill\removeAllUserSkillLevelStatusOfObject().

Referenced by ilContSkillAdminGUI\deassignCompetences().

196  : void
197  {
199  $this->getUserId(),
200  $this->getObjId(),
201  false,
202  (string) $this->getObjId()
203  );
204 
205  $this->delete();
206  }
static removeAllUserSkillLevelStatusOfObject(int $a_user_id, int $a_trigger_obj_id, bool $a_self_eval=false, string $a_unique_identifier="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveLevelForSkills()

ilContainerMemberSkills::saveLevelForSkills ( array  $a_level_data)
Parameters
array$a_level_data(key is skill_id:tref_id, value is level id)

Definition at line 120 of file class.ilContainerMemberSkills.php.

References $db, ilDBInterface\manipulate(), and ilDBInterface\quote().

Referenced by ilContSkillAdminGUI\saveCompetenceAssignment().

120  : void
121  {
122  $db = $this->db;
123 
124  $this->delete();
125  foreach ($a_level_data as $k => $v) {
126  $sk = explode(":", $k);
127  $db->manipulate("INSERT INTO cont_member_skills " .
128  "(obj_id, user_id, skill_id, tref_id, level_id, published) VALUES (" .
129  $db->quote($this->getObjId(), "integer") . "," .
130  $db->quote($this->getUserId(), "integer") . "," .
131  $db->quote($sk[0], "integer") . "," .
132  $db->quote($sk[1], "integer") . "," .
133  $db->quote($v, "integer") . "," .
134  $db->quote(0, "integer") .
135  ")");
136  }
137 
138  $this->skill_levels = $a_level_data;
139  }
quote($value, string $type)
manipulate(string $query)
Run a (write) Query on the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setObjId()

ilContainerMemberSkills::setObjId ( int  $a_val)

Definition at line 54 of file class.ilContainerMemberSkills.php.

Referenced by __construct().

54  : void
55  {
56  $this->obj_id = $a_val;
57  }
+ Here is the caller graph for this function:

◆ setUserId()

ilContainerMemberSkills::setUserId ( int  $a_val)

Definition at line 64 of file class.ilContainerMemberSkills.php.

Referenced by __construct().

64  : void
65  {
66  $this->user_id = $a_val;
67  }
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilDBInterface ilContainerMemberSkills::$db
protected

Definition at line 30 of file class.ilContainerMemberSkills.php.

Referenced by delete(), publish(), read(), and saveLevelForSkills().

◆ $obj_id

int ilContainerMemberSkills::$obj_id = 0
protected

Definition at line 34 of file class.ilContainerMemberSkills.php.

Referenced by getObjId().

◆ $profile_service

SkillProfileService ilContainerMemberSkills::$profile_service
protected

Definition at line 32 of file class.ilContainerMemberSkills.php.

◆ $published

bool ilContainerMemberSkills::$published = false
protected

Definition at line 37 of file class.ilContainerMemberSkills.php.

Referenced by getPublished().

◆ $skill_levels

array ilContainerMemberSkills::$skill_levels = []
protected

Definition at line 36 of file class.ilContainerMemberSkills.php.

Referenced by getSkillLevels().

◆ $skills

array ilContainerMemberSkills::$skills = []
protected

Definition at line 33 of file class.ilContainerMemberSkills.php.

◆ $tree_service

SkillTreeService ilContainerMemberSkills::$tree_service
protected

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

◆ $user_id

int ilContainerMemberSkills::$user_id = 0
protected

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

Referenced by getUserId().


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