44 if (isset(
$DIC[
'component.repository'])) {
45 $this->component_repository =
$DIC[
'component.repository'];
47 $this->db =
$DIC->database();
48 if (isset(
$DIC[
'tree'])) {
49 $this->tree =
$DIC->repositoryTree();
56 if (!self::$instance) {
57 self::$instance =
new self();
69 return (
bool) $this->
settings->get(
'active',
'');
74 $this->
settings->set(
'active', (
string) $a_value);
84 return unserialize(
$components, [
'allowed_classes' =>
false]);
96 if (isset($a_components) && count($a_components) === 0) {
101 $a_components !==
null
102 ? serialize(array_unique($a_components))
114 if (!$this->component_repository->hasComponentId($a_id)) {
117 $component = $this->component_repository->getComponentById($a_id);
119 'type' => $component->getType(),
120 'name' => $component->getName()
128 $class =
'il' . $comp[
'name'] .
'BadgeProvider';
129 $file =
'../' . $comp[
'type'] .
'/' . $comp[
'name'] .
'/classes/class.' . $class .
'.php';
130 if (file_exists($file)) {
144 return $comp[
'type'] .
'/' . $comp[
'name'];
154 string $a_component_id,
166 $parts = explode(
'/', $a_id);
170 $provider = $this->getProviderInstance($comp_id);
172 foreach (
$provider->getBadgeTypes() as $type) {
173 if ($type->getId() === $type_id) {
186 $types = $this->
settings->get(
'inactive_types',
null);
188 return unserialize($types, [
'allowed_classes' =>
false]);
199 if (is_array($a_types) &&
206 ? serialize(array_unique($a_types))
219 $inactive = $this->getInactiveTypes();
220 foreach ($this->getComponents() as $component_id) {
221 $provider = $this->getProviderInstance($component_id);
223 foreach (
$provider->getBadgeTypes() as $type) {
224 $id = $this->getUniqueTypeId($component_id, $type);
225 if (!$exclude_inactive || !in_array(
$id, $inactive,
true)) {
243 foreach ($this->getAvailableTypes() as
$id => $type) {
244 if (in_array($a_object_type, $type->getValidObjectTypes(),
true)) {
257 int $a_parent_obj_id,
258 ?
string $a_parent_obj_type =
null
262 if (!$a_parent_obj_type) {
267 foreach (self::getInstance()->getAvailableTypesForObjType($a_parent_obj_type) as $type_id => $type) {
269 foreach ($badges as $badge) {
270 if ($badge->getTypeId() === $type_id &&
271 $badge->isActive()) {
272 $res[$badge->getId()] = $badge->getTitle();
307 if ($component === $a_component_id) {
321 ?
string $a_obj_type =
null
323 if (!$this->isActive()) {
345 ?array $a_params =
null
347 if (!$this->isActive() || in_array($a_type_id, $this->getInactiveTypes(),
true)) {
351 $type = $this->getTypeInstanceByUniqueId($a_type_id);
358 if ($badge->isActive()) {
361 if ($type->evaluate($a_user_id, (array) $a_params, $badge->getConfiguration())) {
365 $new_badges[$a_user_id][] = $badge->getId();
371 $this->sendNotification($new_badges);
380 int $a_parent_ref_id,
381 ?
int $a_parent_obj_id =
null,
382 ?
string $a_parent_type =
null
386 if (!$a_parent_obj_id) {
389 if (!$a_parent_type) {
394 switch ($a_parent_type) {
397 return $member_obj->getMembers();
401 return $member_obj->getMembers();
433 $path = $this->getBasePath() .
'instances/' .
439 $path .= $hash .
'.json';
446 $path = $this->getBasePath() .
'instances/' . $a_badge->
getId();
449 $this->countStaticBadgeInstancesHelper($cnt,
$path);
458 foreach (glob($a_path .
'/*') as $item) {
460 $this->countStaticBadgeInstancesHelper($a_cnt, $item);
461 } elseif (str_ends_with($item,
'.json')) {
469 $hash = md5($a_badge->
getId());
471 $path = $this->getBasePath() .
'badges/' .
472 floor($a_badge->
getId() / 100) .
'/' .
487 ?
int $a_parent_ref_id =
null
491 foreach ($a_user_map as
$user_id => $badge_ids) {
494 foreach ($badge_ids as $badge_id) {
500 if (!array_key_exists($badge_id, $badges)) {
501 $badges[$badge_id] =
new ilBadge($badge_id);
504 $badge = $badges[$badge_id];
506 $user_badges[] = $badge->getTitle();
509 if (count($user_badges)) {
513 $ntf->setLangModules([
'badge']);
515 if (isset($a_parent_ref_id)) {
516 $ntf->setRefId($a_parent_ref_id);
518 $ntf->setGotoLangId(
'badge_notification_parent_goto');
523 $ntf->setIntroductionLangId(
'badge_notification_body');
525 $ntf->addAdditionalInfo(
'badge_notification_badges', implode(
"\n", $user_badges),
true);
528 $ntf->addAdditionalInfo(
'badge_notification_badges_goto',
$url);
530 $ntf->setReasonLangId(
'badge_notification_reason');
538 $lng->txt(
'badge_notification_subject'),
539 $ntf->composeAndGetMessage(
$user_id,
null,
'read',
true),
548 $osd_params = [
'badge_list' => implode(
', ', $user_badges)];
551 $notification->setTitleVar(
'badge_notification_subject', [],
'badge');
552 $notification->setShortDescriptionVar(
'badge_notification_osd', $osd_params,
'badge');
553 $notification->setLongDescriptionVar(
'');
554 $notification->setLinks([
$url]);
556 $notification->setValidForSeconds(ilNotificationConfig::TTL_SHORT);
557 $notification->setVisibleForSeconds(ilNotificationConfig::DEFAULT_TTS);
559 BadgeNotificationProvider::NOTIFICATION_TYPE,
562 $notification->notifyByUsers([
$user_id]);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
description of a localized parameter this information is used locate translations while processing no...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static exists(int $a_badge_id, int $a_user_id)
static ilBadgeHandler $instance
getAvailableTypes(bool $exclude_inactive=true)
Get badges types.
getUniqueTypeId(string $a_component_id, ilBadgeType $a_badge)
static updateFromXML(string $a_component_id)
Import component definition.
setComponents(?array $a_components=null)
getProviderInstance(string $a_component_id)
getComponent(string $a_id)
getUserIds(int $a_parent_ref_id, ?int $a_parent_obj_id=null, ?string $a_parent_type=null)
sendNotification(array $a_user_map, ?int $a_parent_ref_id=null)
static clearFromXML(string $a_component_id)
Remove component definition.
triggerEvaluation(string $a_type_id, int $a_user_id, ?array $a_params=null)
getAvailableManualBadges(int $a_parent_obj_id, ?string $a_parent_obj_type=null)
Get available manual badges for object id.
getInstancePath(ilBadgeAssignment $a_ass)
getTypeInstanceByUniqueId(string $a_id)
Get type instance by unique id (component, type)
getBadgePath(ilBadge $a_badge)
getAvailableTypesForObjType(string $a_object_type)
Get valid badges types for object type.
ilComponentRepository $component_repository
countStaticBadgeInstances(ilBadge $a_badge)
isObjectActive(int $a_obj_id, ?string $a_obj_type=null)
countStaticBadgeInstancesHelper(int &$a_cnt, string $a_path)
getComponentCaption(string $a_component_id)
setInactiveTypes(?array $a_types=null)
static getInstancesByType(string $a_type_id)
static getInstancesByParentId(int $a_parent_id, ?array $a_filter=null)
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
static hasHTML()
Has HTML output.
static _getInstanceByObjId(int $a_obj_id)
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance.
static _lookupEmail(int $a_user_id)
static _lookupObjectId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Readable part of repository interface to ilComponentDataDB.
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
if(!file_exists('../ilias.ini.php'))