37 self::$instance =
new self();
39 return self::$instance;
49 return $this->
settings->get(
"active",
false);
54 $this->
settings->set(
"active", (
bool)$a_value);
62 return $this->
settings->get(
"obi_active",
false);
67 $this->
settings->set(
"obi_active", (
bool)$a_value);
72 return $this->
settings->get(
"obi_organisation", null);
77 $this->
settings->set(
"obi_organisation", trim($a_value));
82 return $this->
settings->get(
"obi_contact", null);
87 $this->
settings->set(
"obi_contact", trim($a_value));
92 return $this->
settings->get(
"obi_salt", null);
97 $this->
settings->set(
"obi_salt", trim($a_value));
102 $components = $this->
settings->get(
"components", null);
105 return unserialize($components);
112 if(is_array($a_components) &&
113 !
sizeof($a_components))
115 $a_components = null;
117 $this->
settings->set(
"components", $a_components !== null
118 ? serialize(array_unique($a_components))
132 $set = $ilDB->query(
"SELECT * FROM il_component".
133 " WHERE id = ".$ilDB->quote($a_id,
"text"));
134 $rec = $ilDB->fetchAssoc($set);
152 $class =
"il".$comp[
"name"].
"BadgeProvider";
153 $file = $comp[
"type"].
"/".$comp[
"name"].
"/classes/class.".$class.
".php";
154 if(file_exists(
$file))
171 return $comp[
"type"].
"/".$comp[
"name"];
181 return $a_component_id.
"/".$a_badge->
getId();
191 $parts = explode(
"/", $a_id);
192 $comp_id = $parts[0];
193 $type_id = $parts[1];
197 foreach(
$provider->getBadgeTypes() as $type)
199 if($type->getId() == $type_id)
209 $types = $this->
settings->get(
"inactive_types", null);
212 return unserialize($types);
219 if(is_array($a_types) &&
224 $this->
settings->set(
"inactive_types", $a_types !== null
225 ? serialize(array_unique($a_types))
244 foreach(
$provider->getBadgeTypes() as $type)
247 if(!in_array($id, $inactive))
270 if(in_array($a_object_type, $type->getValidObjectTypes()))
290 if(!$a_parent_obj_type)
295 include_once
"./Services/Badge/classes/class.ilBadge.php";
301 foreach($badges as $badge)
303 if($badge->getTypeId() == $type_id &&
306 $res[$badge->getId()] = $badge->getTitle();
329 $handler = self::getInstance();
330 $components = $handler->getComponents();
331 $components[] = $a_component_id;
332 $handler->setComponents($components);
342 $handler = self::getInstance();
343 $components = $handler->getComponents();
344 foreach($components as $idx => $component)
346 if($component == $a_component_id)
348 unset($components[$idx]);
351 $handler->setComponents($components);
371 if($a_obj_type !=
"bdga")
373 include_once
'Services/Container/classes/class.ilContainer.php';
374 include_once
'Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
402 include_once
"Services/Badge/classes/class.ilBadge.php";
403 include_once
"Services/Badge/classes/class.ilBadgeAssignment.php";
404 $new_badges =
array();
407 if($badge->isActive())
412 if((
bool)$type->evaluate($a_user_id, (
array)$a_params, (
array)$badge->getConfiguration()))
417 $new_badges[$a_user_id][] = $badge->getId();
426 public function getUserIds($a_parent_ref_id, $a_parent_obj_id = null, $a_parent_type = null)
430 if(!$a_parent_obj_id)
440 switch($a_parent_type)
443 include_once
"Modules/Course/classes/class.ilCourseParticipants.php";
445 return $member_obj->getMembers();
448 include_once
"Modules/Group/classes/class.ilGroupParticipants.php";
450 return $member_obj->getMembers();
454 $path = $tree->getPathId($a_parent_ref_id);
456 foreach(array_reverse(
$path) as $path_ref_id)
459 if($type ==
"crs" || $type ==
"grp")
461 return $this->getParticipantsForObject($path_ref_id, null, $type);
488 $path .= $hash.
".json";
506 foreach(glob($a_path.
"/*") as $item)
512 else if(substr($item, -5) ==
".json")
521 $hash = md5($a_badge->
getId());
524 floor($a_badge->
getId()/100).
"/".
534 $json =
new stdClass();
535 $json->{
"@context"} =
"https://w3id.org/openbadges/v1";
536 $json->type =
"Issuer";
539 $json->url = ILIAS_HTTP_PATH.
"/";
549 $path .=
"issuer.json";
553 if(!file_exists(
$path))
556 file_put_contents(
$path, $json);
565 if(file_exists(
$path))
583 include_once
"Services/Badge/classes/class.ilBadge.php";
584 include_once
"Services/Badge/classes/class.ilBadgeAssignment.php";
585 include_once
"Services/Notification/classes/class.ilSystemNotification.php";
586 include_once
"Services/Link/classes/class.ilLink.php";
588 foreach($a_user_map as $user_id => $badge_ids)
590 $user_badges =
array();
592 foreach($badge_ids as $badge_id)
600 if(!array_key_exists($badge_id, $badges))
602 $badges[$badge_id] =
new ilBadge($badge_id);
605 $badge = $badges[$badge_id];
607 $user_badges[] = $badge->getTitle();
610 if(
sizeof($user_badges))
615 $ntf->setLangModules(
array(
"badge"));
617 $ntf->setRefId($a_parent_ref_id);
618 $ntf->setGotoLangId(
"badge_notification_parent_goto");
621 $lng = $ntf->getUserLanguage($user_id);
623 $ntf->setIntroductionLangId(
"badge_notification_body");
625 $ntf->addAdditionalInfo(
"badge_notification_badges", implode(
"\n", $user_badges),
true);
628 $ntf->addAdditionalInfo(
"badge_notification_badges_goto",
$url);
630 $ntf->setReasonLangId(
"badge_notification_reason");
633 $mail =
new ilMail(ANONYMOUS_USER_ID);
634 $mail->enableSOAP(
false);
638 $lng->txt(
"badge_notification_subject"),
639 $ntf->composeAndGetMessage($user_id, null,
"read",
true),
646 $osd_params =
array(
"badge_list" =>
"<br />".implode(
"<br />", $user_badges));
648 require_once
"Services/Notifications/classes/class.ilNotificationConfig.php";
650 $notification->setTitleVar(
"badge_notification_subject",
array(),
"badge");
651 $notification->setShortDescriptionVar(
"badge_notification_osd", $osd_params,
"badge");
652 $notification->setLongDescriptionVar(
"", $osd_params,
"");
653 $notification->setAutoDisable(
false);
654 $notification->setLink(
$url);
655 $notification->setIconPath(
"templates/default/images/icon_bdga.svg");
658 $notification->notifyByUsers(
array($user_id));
Badge Provider interface.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
prepareIssuerJson($a_url)
getAvailableTypesForObjType($a_object_type)
Get valid badges types for object type.
isObjectActive($a_obj_id, $a_obj_type=null)
static exists($a_badge_id, $a_user_id)
getAvailableTypes()
Get badges types.
getTypeInstanceByUniqueId($a_id)
Get type instance by unique id (component, type)
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static updateFromXML($a_component_id)
Import component definition.
getProviderInstance($a_component_id)
Get provider instance.
sendNotification(array $a_user_map, $a_parent_ref_id=null)
getInstancePath(ilBadgeAssignment $a_ass)
static _lookupObjectId($a_ref_id)
lookup object id
Describes a notification and provides methods for publishing this notification.
static clearFromXML($a_component_id)
Remove component definition.
static getInstancesByParentId($a_parent_id, array $a_filter=null)
triggerEvaluation($a_type_id, $a_user_id, array $a_params=null)
getId()
Get typ id (unique for component)
setComponents(array $a_components=null)
This class handles base functions for mail handling.
__construct()
Constructor.
setInactiveTypes(array $a_types=null)
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=NULL)
Lookup a container setting.
getUniqueTypeId($a_component_id, ilBadgeType $a_badge)
getComponentCaption($a_component_id)
static _lookupEmail($a_user_id)
Lookup email.
getBadgePath(ilBadge $a_badge)
getAvailableManualBadges($a_parent_obj_id, $a_parent_obj_type=null)
Get available manual badges for object id.
countStaticBadgeInstancesHelper(&$a_cnt, $a_path)
setObiOrganisation($a_value)
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
countStaticBadgeInstances(ilBadge $a_badge)
getUserIds($a_parent_ref_id, $a_parent_obj_id=null, $a_parent_type=null)
static getWebspaceDir($mode="filesystem")
get webspace directory
Wrapper classes for system notifications.
static getInstancesByType($a_type_id)
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
static getInstance()
Constructor.