19 declare(strict_types=1);
58 protected array
$classes = [\ilBasicSkill::class, AssignedMaterialManager::class, SkillProfileManager::class,
59 SkillResourcesManager::class, SkillUsageManager::class];
65 protected \ilLanguage
$lng;
75 $this->usage_repo = (
$usage_repo) ?: $DIC->skills()->internal()->repo()->getUsageRepo();
76 $this->tree_factory = (
$tree_factory) ?: $DIC->skills()->internal()->factory()->tree();
77 $this->tree_repo = (
$tree_repo) ?: $DIC->skills()->internal()->repo()->getTreeRepo();
78 $this->profile_manager = (
$profile_manager) ?: $DIC->skills()->internal()->manager()->getProfileManager();
79 $this->
lng = $DIC->language();
82 public function addUsage(
int $obj_id,
int $skill_id,
int $tref_id): void
84 $this->usage_repo->add($obj_id, $skill_id, $tref_id);
87 public function removeUsage(
int $obj_id,
int $skill_id,
int $tref_id): void
89 $this->usage_repo->remove($obj_id, $skill_id, $tref_id);
94 $this->usage_repo->removeFromObject($obj_id);
99 $this->usage_repo->removeForSkill($node_id, $is_referenece);
105 public function getUsages(
int $skill_id,
int $tref_id): array
107 $obj_ids = $this->usage_repo->getUsages($skill_id, $tref_id);
118 return $class->getUsageInfoGeneric(
137 string $skill_field =
"skill_id",
138 string $tref_field =
"tref_id" 140 if (count($cskill_ids) === 0) {
144 $usages = $this->usage_repo->getUsageInfoGeneric(
165 foreach ($classes as $class) {
166 $usages = array_merge_recursive($usages, $class::getUsageInfo($cskill_ids));
180 foreach ($tree_ids as $t) {
181 $vtree = $this->tree_factory->getGlobalVirtualTree();
182 $nodes = $vtree->getSubTreeForTreeId((
string) $t);
183 foreach ($nodes as $n) {
197 $vtree = $this->tree_repo->getVirtualTreeForNodeId($skill_id);
198 $nodes = $vtree->getSubTreeForCSkillId($skill_id .
":" . $tref_id);
211 foreach ($cskill_ids as $s) {
212 $vtree = $this->tree_repo->getVirtualTreeForNodeId($s[
"skill_id"]);
213 $nodes = $vtree->getSubTreeForCSkillId($s[
"skill_id"] .
":" . $s[
"tref_id"]);
214 foreach ($nodes as $n) {
228 $skill_logger->debug(
"SkillUsageManager: getAllUsagesOfTemplate(" . $template_id .
")");
235 foreach ($trefs as $tref) {
236 $cskill_ids[] = array(
"skill_id" => $template_id,
"tref_id" => $tref);
237 $skill_logger->debug(
"SkillUsageManager: ... skill_id: " . $template_id .
", tref_id: " . $tref .
".");
240 $skill_logger->debug(
"SkillUsageManager: ... count cskill_ids: " . count($cskill_ids) .
".");
247 return $this->
lng->txt(
"skmg_usage_type_info_" . $type);
253 case self::TYPE_GENERAL:
255 return $this->
lng->txt(
"skmg_usage_obj_objects");
257 case self::USER_ASSIGNED:
258 case self::PERSONAL_SKILL:
259 case self::USER_MATERIAL:
260 case self::SELF_EVAL:
261 return $this->
lng->txt(
"skmg_usage_obj_users");
264 return $this->
lng->txt(
"skmg_usage_obj_profiles");
267 return $this->
lng->txt(
"skmg_usage_type_info_" . $type);
277 $objects = $this->
getUsages($skill_id, $tref_id);
288 $obj_usages = array_column($usages,
"gen");
290 return array_column(current(array_reverse($obj_usages)) ?: [],
"key");
298 $skills = $this->profile_manager->getSkillLevels($profile_id);
302 foreach ($skills as $skill) {
303 $obj_usages = $this->
getUsages($skill->getBaseSkillId(), $skill->getTrefId());
304 foreach ($obj_usages as
$id) {
312 $roles = $this->profile_manager->getRoleAssignments($profile_id);
313 foreach ($roles as $role) {
314 if (($role->getObjType() ==
"crs" || $role->getObjType() ==
"grp")
315 && !in_array($role->getObjId(), $objects)) {
317 $obj_ref_id = end($obj_ref_id);
319 $objects[] = $role->getObjId();
getAssignedObjectsForSkillTemplate(int $template_id)
static getLogger(string $a_component_id)
Get component logger.
SkillUsageDBRepository $usage_repo
addUsage(int $obj_id, int $skill_id, int $tref_id)
getAllUsagesOfTemplate(int $template_id)
ilSkillTreeRepository $tree_repo
SkillTreeFactory $tree_factory
static _getAllReferences(int $id)
get all reference ids for object ID
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash
static getDefaultMemberRole(int $a_ref_id)
SkillProfileManager $profile_manager
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getUsages(int $skill_id, int $tref_id)
static _lookupTrefIdsForTemplateId(int $a_tid)
getUsageInfoGeneric(array $cskill_ids, string $usage_type, string $table, string $key_field, string $skill_field="skill_id", string $tref_field="tref_id")
Get standard usage query.
__construct(?SkillUsageDBRepository $usage_repo=null, ?SkillTreeFactory $tree_factory=null, ?\ilSkillTreeRepository $tree_repo=null, ?SkillProfileManager $profile_manager=null)
removeUsagesForSkill(int $node_id, bool $is_referenece=false)
getAllUsagesInfoOfSubtrees(array $cskill_ids)
getAssignedObjectsForSkillProfile(int $profile_id)
getAssignedObjectsForSkill(int $skill_id, int $tref_id)
getAllUsagesInfo(array $cskill_ids)
getAllUsagesInfoOfTrees(array $tree_ids)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static getUsageInfo(array $a_cskill_ids)
Get title of an assigned item.int, tref_id: int}[] $a_cskill_ids array of common skill idsarray<strin...
getAllUsagesInfoOfSubtree(int $skill_id, int $tref_id=0)
removeUsagesFromObject(int $obj_id)
removeUsage(int $obj_id, int $skill_id, int $tref_id)
Get info on usages of skills.
getTypeInfoString(string $type)
getObjTypeString(string $type)