42 $this->db = $DIC->database();
43 if (isset($DIC[
"tree"])) {
44 $this->tree = $DIC->repositoryTree();
56 if (!self::$instance) {
57 self::$instance =
new self();
59 return self::$instance;
69 return $this->
settings->get(
"active",
false);
74 $this->
settings->set(
"active", (
bool) $a_value);
82 return $this->
settings->get(
"obi_active",
false);
87 $this->
settings->set(
"obi_active", (
bool) $a_value);
92 return $this->
settings->get(
"obi_organisation", null);
97 $this->
settings->set(
"obi_organisation", trim($a_value));
102 return $this->
settings->get(
"obi_contact", null);
107 $this->
settings->set(
"obi_contact", trim($a_value));
112 return $this->
settings->get(
"obi_salt", null);
117 $this->
settings->set(
"obi_salt", trim($a_value));
122 $components = $this->
settings->get(
"components", null);
124 return unserialize($components);
131 if (is_array($a_components) &&
132 !
sizeof($a_components)) {
133 $a_components = null;
135 $this->
settings->set(
"components", $a_components !== null
136 ? serialize(array_unique($a_components))
150 $set =
$ilDB->query(
"SELECT * FROM il_component" .
151 " WHERE id = " .
$ilDB->quote($a_id,
"text"));
152 $rec =
$ilDB->fetchAssoc($set);
168 $class =
"il" . $comp[
"name"] .
"BadgeProvider";
169 $file = $comp[
"type"] .
"/" . $comp[
"name"] .
"/classes/class." . $class .
".php";
170 if (file_exists(
$file)) {
184 return $comp[
"type"] .
"/" . $comp[
"name"];
194 return $a_component_id .
"/" . $a_badge->
getId();
204 $parts = explode(
"/", $a_id);
205 $comp_id = $parts[0];
206 $type_id = $parts[1];
210 if (
$type->getId() == $type_id) {
219 $types = $this->
settings->get(
"inactive_types", null);
221 return unserialize($types);
228 if (is_array($a_types) &&
232 $this->
settings->set(
"inactive_types", $a_types !== null
233 ? serialize(array_unique($a_types))
252 if (!in_array(
$id, $inactive)) {
273 if (in_array($a_object_type,
$type->getValidObjectTypes())) {
292 if (!$a_parent_obj_type) {
296 include_once
"./Services/Badge/classes/class.ilBadge.php";
300 foreach ($badges as $badge) {
301 if ($badge->getTypeId() == $type_id &&
302 $badge->isActive()) {
303 $res[$badge->getId()] = $badge->getTitle();
327 $components =
$handler->getComponents();
328 $components[] = $a_component_id;
329 $handler->setComponents($components);
340 $components =
$handler->getComponents();
341 foreach ($components as $idx => $component) {
342 if ($component == $a_component_id) {
343 unset($components[$idx]);
346 $handler->setComponents($components);
364 if ($a_obj_type !=
"bdga") {
365 include_once
'Services/Container/classes/class.ilContainer.php';
366 include_once
'Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
392 include_once
"Services/Badge/classes/class.ilBadge.php";
393 include_once
"Services/Badge/classes/class.ilBadgeAssignment.php";
394 $new_badges =
array();
396 if ($badge->isActive()) {
399 if ((
bool)
$type->evaluate($a_user_id, (
array) $a_params, (
array) $badge->getConfiguration())) {
403 $new_badges[$a_user_id][] = $badge->getId();
412 public function getUserIds($a_parent_ref_id, $a_parent_obj_id = null, $a_parent_type = null)
416 if (!$a_parent_obj_id) {
419 if (!$a_parent_type) {
424 switch ($a_parent_type) {
426 include_once
"Modules/Course/classes/class.ilCourseParticipants.php";
428 return $member_obj->getMembers();
431 include_once
"Modules/Group/classes/class.ilGroupParticipants.php";
433 return $member_obj->getMembers();
439 foreach (array_reverse(
$path) as $path_ref_id) {
442 return $this->getParticipantsForObject($path_ref_id, null,
$type);
469 $path .= $hash .
".json";
486 foreach (glob($a_path .
"/*") as $item) {
489 } elseif (substr($item, -5) ==
".json") {
497 $hash = md5($a_badge->
getId());
500 floor($a_badge->
getId()/100) .
"/" .
510 $json =
new stdClass();
511 $json->{
"@context"} =
"https://w3id.org/openbadges/v1";
512 $json->type =
"Issuer";
515 $json->url = ILIAS_HTTP_PATH .
"/";
525 $path .=
"issuer.json";
527 $url = ILIAS_HTTP_PATH . substr(
$path, 1);
529 if (!file_exists(
$path)) {
531 file_put_contents(
$path, $json);
540 if (file_exists(
$path)) {
555 include_once
"Services/Badge/classes/class.ilBadge.php";
556 include_once
"Services/Badge/classes/class.ilBadgeAssignment.php";
557 include_once
"Services/Notification/classes/class.ilSystemNotification.php";
558 include_once
"Services/Link/classes/class.ilLink.php";
560 foreach ($a_user_map as $user_id => $badge_ids) {
561 $user_badges =
array();
563 foreach ($badge_ids as $badge_id) {
569 if (!array_key_exists($badge_id, $badges)) {
570 $badges[$badge_id] =
new ilBadge($badge_id);
573 $badge = $badges[$badge_id];
575 $user_badges[] = $badge->getTitle();
578 if (
sizeof($user_badges)) {
582 $ntf->setLangModules(
array(
"badge"));
584 $ntf->setRefId($a_parent_ref_id);
585 $ntf->setGotoLangId(
"badge_notification_parent_goto");
588 $lng = $ntf->getUserLanguage($user_id);
590 $ntf->setIntroductionLangId(
"badge_notification_body");
592 $ntf->addAdditionalInfo(
"badge_notification_badges", implode(
"\n", $user_badges),
true);
595 $ntf->addAdditionalInfo(
"badge_notification_badges_goto",
$url);
597 $ntf->setReasonLangId(
"badge_notification_reason");
600 $mail =
new ilMail(ANONYMOUS_USER_ID);
601 $mail->enableSOAP(
false);
606 $lng->txt(
"badge_notification_subject"),
607 $ntf->composeAndGetMessage($user_id, null,
"read",
true),
616 $osd_params =
array(
"badge_list" =>
"<br />" . implode(
"<br />", $user_badges));
618 require_once
"Services/Notifications/classes/class.ilNotificationConfig.php";
620 $notification->setTitleVar(
"badge_notification_subject",
array(),
"badge");
621 $notification->setShortDescriptionVar(
"badge_notification_osd", $osd_params,
"badge");
622 $notification->setLongDescriptionVar(
"", $osd_params,
"");
623 $notification->setAutoDisable(
false);
624 $notification->setLink(
$url);
628 $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.
if(!array_key_exists('StateId', $_REQUEST)) $id
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)
foreach($_POST as $key=> $value) $res
triggerEvaluation($a_type_id, $a_user_id, array $a_params=null)
getId()
Get typ id (unique for component)
setComponents(array $a_components=null)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static hasHTML()
Has HTML output.
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
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 _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.
static getInstance()
Constructor.