ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilBadgeHandler Class Reference
+ Collaboration diagram for ilBadgeHandler:

Public Member Functions

 isActive ()
 
 setActive ($a_value)
 
 isObiActive ()
 
 setObiActive ($a_value)
 
 getObiOrganistation ()
 
 setObiOrganisation ($a_value)
 
 getObiContact ()
 
 setObiContact ($a_value)
 
 getObiSalt ()
 
 setObiSalt ($a_value)
 
 getComponents ()
 
 setComponents (array $a_components=null)
 
 getProviderInstance ($a_component_id)
 Get provider instance. More...
 
 getComponentCaption ($a_component_id)
 
 getUniqueTypeId ($a_component_id, ilBadgeType $a_badge)
 
 getTypeInstanceByUniqueId ($a_id)
 Get type instance by unique id (component, type) More...
 
 getInactiveTypes ()
 
 setInactiveTypes (array $a_types=null)
 
 getAvailableTypes ()
 Get badges types. More...
 
 getAvailableTypesForObjType ($a_object_type)
 Get valid badges types for object type. More...
 
 getAvailableManualBadges ($a_parent_obj_id, $a_parent_obj_type=null)
 Get available manual badges for object id. More...
 
 isObjectActive ($a_obj_id, $a_obj_type=null)
 
 triggerEvaluation ($a_type_id, $a_user_id, array $a_params=null)
 
 getUserIds ($a_parent_ref_id, $a_parent_obj_id=null, $a_parent_type=null)
 
 getInstancePath (ilBadgeAssignment $a_ass)
 
 countStaticBadgeInstances (ilBadge $a_badge)
 
 getBadgePath (ilBadge $a_badge)
 
 getIssuerStaticUrl ()
 
 rebuildIssuerStaticUrl ()
 
 sendNotification (array $a_user_map, $a_parent_ref_id=null)
 

Static Public Member Functions

static getInstance ()
 Constructor. More...
 
static updateFromXML ($a_component_id)
 Import component definition. More...
 
static clearFromXML ($a_component_id)
 Remove component definition. More...
 

Protected Member Functions

 __construct ()
 Constructor. More...
 
 getComponent ($a_id)
 
 getBasePath ()
 
 countStaticBadgeInstancesHelper (&$a_cnt, $a_path)
 
 prepareIssuerJson ($a_url)
 

Protected Attributes

 $db
 
 $tree
 
 $lng
 
 $settings
 

Static Protected Attributes

static $instance
 

Detailed Description

Definition at line 12 of file class.ilBadgeHandler.php.

Constructor & Destructor Documentation

◆ __construct()

ilBadgeHandler::__construct ( )
protected

Constructor.

Returns
self

Definition at line 38 of file class.ilBadgeHandler.php.

39 {
40 global $DIC;
41
42 $this->db = $DIC->database();
43 if (isset($DIC["tree"])) {
44 $this->tree = $DIC->repositoryTree();
45 }
46 $this->settings = new ilSetting("bdga");
47 }
ILIAS Setting Class.
global $DIC
Definition: saml.php:7
settings()
Definition: settings.php:2

References $DIC, and settings().

+ Here is the call graph for this function:

Member Function Documentation

◆ clearFromXML()

static ilBadgeHandler::clearFromXML (   $a_component_id)
static

Remove component definition.

Parameters
string$a_component_id

Definition at line 337 of file class.ilBadgeHandler.php.

338 {
340 $components = $handler->getComponents();
341 foreach ($components as $idx => $component) {
342 if ($component == $a_component_id) {
343 unset($components[$idx]);
344 }
345 }
346 $handler->setComponents($components);
347 }
static getInstance()
Constructor.
$handler

References $handler, and getInstance().

+ Here is the call graph for this function:

◆ countStaticBadgeInstances()

ilBadgeHandler::countStaticBadgeInstances ( ilBadge  $a_badge)

Definition at line 474 of file class.ilBadgeHandler.php.

475 {
476 $path = $this->getBasePath() . "instances/" . $a_badge->getId();
477 $cnt = 0;
478 if (is_dir($path)) {
480 }
481 return $cnt;
482 }
countStaticBadgeInstancesHelper(&$a_cnt, $a_path)

References $path, countStaticBadgeInstancesHelper(), getBasePath(), and ilBadge\getId().

+ Here is the call graph for this function:

◆ countStaticBadgeInstancesHelper()

ilBadgeHandler::countStaticBadgeInstancesHelper ( $a_cnt,
  $a_path 
)
protected

Definition at line 484 of file class.ilBadgeHandler.php.

485 {
486 foreach (glob($a_path . "/*") as $item) {
487 if (is_dir($item)) {
488 $this->countStaticBadgeInstancesHelper($a_cnt, $item);
489 } elseif (substr($item, -5) == ".json") {
490 $a_cnt++;
491 }
492 }
493 }

References countStaticBadgeInstancesHelper().

Referenced by countStaticBadgeInstances(), and countStaticBadgeInstancesHelper().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAvailableManualBadges()

ilBadgeHandler::getAvailableManualBadges (   $a_parent_obj_id,
  $a_parent_obj_type = null 
)

Get available manual badges for object id.

Parameters
int$a_parent_obj_id
string$a_parent_obj_type
Returns
array id,title

Definition at line 288 of file class.ilBadgeHandler.php.

289 {
290 $res = array();
291
292 if (!$a_parent_obj_type) {
293 $a_parent_obj_type = ilObject::_lookupType($a_parent_obj_id);
294 }
295
296 include_once "./Services/Badge/classes/class.ilBadge.php";
297 $badges = ilBadge::getInstancesByParentId($a_parent_obj_id);
298 foreach (ilBadgeHandler::getInstance()->getAvailableTypesForObjType($a_parent_obj_type) as $type_id => $type) {
299 if (!$type instanceof ilBadgeAuto) {
300 foreach ($badges as $badge) {
301 if ($badge->getTypeId() == $type_id &&
302 $badge->isActive()) {
303 $res[$badge->getId()] = $badge->getTitle();
304 }
305 }
306 }
307 }
308
309 asort($res);
310 return $res;
311 }
getAvailableTypesForObjType($a_object_type)
Get valid badges types for object type.
static getInstancesByParentId($a_parent_id, array $a_filter=null)
static _lookupType($a_id, $a_reference=false)
lookup object type
Manual Badge Auto.
$type
foreach($_POST as $key=> $value) $res

References $res, $type, ilObject\_lookupType(), getAvailableTypesForObjType(), getInstance(), and ilBadge\getInstancesByParentId().

+ Here is the call graph for this function:

◆ getAvailableTypes()

ilBadgeHandler::getAvailableTypes ( )

Get badges types.

Returns
ilBadgeType[]

Definition at line 242 of file class.ilBadgeHandler.php.

243 {
244 $res = array();
245
246 $inactive = $this->getInactiveTypes();
247 foreach ($this->getComponents() as $component_id) {
248 $provider = $this->getProviderInstance($component_id);
249 if ($provider) {
250 foreach ($provider->getBadgeTypes() as $type) {
251 $id = $this->getUniqueTypeId($component_id, $type);
252 if (!in_array($id, $inactive)) {
253 $res[$id] = $type;
254 }
255 }
256 }
257 }
258
259 return $res;
260 }
getUniqueTypeId($a_component_id, ilBadgeType $a_badge)
getProviderInstance($a_component_id)
Get provider instance.
if(!array_key_exists('StateId', $_REQUEST)) $id

References $id, League\OAuth2\Client\Provider\$provider, $res, $type, getComponents(), getInactiveTypes(), getProviderInstance(), and getUniqueTypeId().

Referenced by getAvailableTypesForObjType().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAvailableTypesForObjType()

ilBadgeHandler::getAvailableTypesForObjType (   $a_object_type)

Get valid badges types for object type.

Parameters
string$a_object_type
Returns
ilBadgeType[]

Definition at line 268 of file class.ilBadgeHandler.php.

269 {
270 $res = array();
271
272 foreach ($this->getAvailableTypes() as $id => $type) {
273 if (in_array($a_object_type, $type->getValidObjectTypes())) {
274 $res[$id] = $type;
275 }
276 }
277
278 return $res;
279 }
getAvailableTypes()
Get badges types.

References $id, $res, $type, and getAvailableTypes().

Referenced by getAvailableManualBadges().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBadgePath()

ilBadgeHandler::getBadgePath ( ilBadge  $a_badge)

Definition at line 495 of file class.ilBadgeHandler.php.

496 {
497 $hash = md5($a_badge->getId());
498
499 $path = $this->getBasePath() . "badges/" .
500 floor($a_badge->getId()/100) . "/" .
501 $hash . "/";
502
504
505 return $path;
506 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References $path, getBasePath(), ilBadge\getId(), and ilUtil\makeDirParents().

+ Here is the call graph for this function:

◆ getBasePath()

ilBadgeHandler::getBasePath ( )
protected

Definition at line 454 of file class.ilBadgeHandler.php.

455 {
456 return ilUtil::getWebspaceDir() . "/pub_badges/";
457 }
static getWebspaceDir($mode="filesystem")
get webspace directory

References ilUtil\getWebspaceDir().

Referenced by countStaticBadgeInstances(), getBadgePath(), and getInstancePath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponent()

ilBadgeHandler::getComponent (   $a_id)
protected

Definition at line 145 of file class.ilBadgeHandler.php.

146 {
148
149 // see ilCtrl
150 $set = $ilDB->query("SELECT * FROM il_component" .
151 " WHERE id = " . $ilDB->quote($a_id, "text"));
152 $rec = $ilDB->fetchAssoc($set);
153 if ($rec["type"]) {
154 return $rec;
155 }
156 }
global $ilDB

References $db, and $ilDB.

Referenced by getComponentCaption(), and getProviderInstance().

+ Here is the caller graph for this function:

◆ getComponentCaption()

ilBadgeHandler::getComponentCaption (   $a_component_id)

Definition at line 180 of file class.ilBadgeHandler.php.

181 {
182 $comp = $this->getComponent($a_component_id);
183 if ($comp) {
184 return $comp["type"] . "/" . $comp["name"];
185 }
186 }

References getComponent().

+ Here is the call graph for this function:

◆ getComponents()

ilBadgeHandler::getComponents ( )

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

121 {
122 $components = $this->settings->get("components", null);
123 if ($components) {
124 return unserialize($components);
125 }
126 return array();
127 }

References settings().

Referenced by getAvailableTypes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInactiveTypes()

ilBadgeHandler::getInactiveTypes ( )

Definition at line 217 of file class.ilBadgeHandler.php.

218 {
219 $types = $this->settings->get("inactive_types", null);
220 if ($types) {
221 return unserialize($types);
222 }
223 return array();
224 }

References settings().

Referenced by getAvailableTypes(), and triggerEvaluation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstance()

static ilBadgeHandler::getInstance ( )
static

Constructor.

Returns
self

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

55 {
56 if (!self::$instance) {
57 self::$instance = new self();
58 }
59 return self::$instance;
60 }

References $instance.

Referenced by ilBadgePersonalTableGUI\__construct(), ilBadgeManagementGUI\__construct(), ilObjBadgeAdministrationGUI\activateTypes(), ilBadgeManagementGUI\addBadge(), ilBadgeProfileGUI\addToBackpack(), ilObjBadgeAdministrationGUI\assertActive(), ilBadgeManagementGUI\assignBadge(), ilBadgeManagementGUI\awardBadgeUserSelection(), clearFromXML(), ilObjBadgeAdministrationGUI\deactivateTypes(), ilBadge\deleteStaticFiles(), ilBadgeAssignment\deleteStaticFiles(), ilBadgeManagementGUI\editBadge(), ilBadgeProfileGUI\editSettings(), ilBadgeManagementGUI\executeCommand(), ilBadgePersonalTableGUI\fillRow(), ilObjBadgeAdministrationGUI\getAdminTabs(), getAvailableManualBadges(), ilBadgeAssignment\getImagePath(), ilBadgeUserTableGUI\getItems(), ilBadgeTypesTableGUI\getItems(), ilObjectBadgeTableGUI\getItems(), ilBadge\getStaticUrl(), ilBadgeAssignment\getStaticUrl(), ilBadgeProfileGUI\getSubTabs(), ilObjCourseGUI\getTabs(), ilObjGroupGUI\getTabs(), ilBadge\getTypeInstance(), ilBadgeManagementGUI\getValidBadgesFromClipboard(), ilBadgeAppEventListener\handleEvent(), ilBadgeTableGUI\initFilter(), ilObjectBadgeTableGUI\initFilter(), ilObjBadgeAdministrationGUI\initFormSettings(), ilObjBadgeAdministrationGUI\initImageTemplateForm(), ilObjectServiceSettingsGUI\initServiceSettingsForm(), ilBadgeProfileGUI\listBackpackGroups(), ilBadgeManagementGUI\listBadges(), ilBadgeManagementGUI\listUsers(), ilBadgeAssignment\prepareJson(), ilMainMenuGUI\renderEntry(), ilBadgeManagementGUI\saveBadge(), ilPersonalProfileGUI\savePublicProfile(), ilObjBadgeAdministrationGUI\saveSettings(), ilBadgeProfileGUI\setTabs(), ilPersonalProfileGUI\showPublicProfileFields(), updateFromXML(), and ilObjectServiceSettingsGUI\updateServiceSettingsForm().

+ Here is the caller graph for this function:

◆ getInstancePath()

ilBadgeHandler::getInstancePath ( ilBadgeAssignment  $a_ass)

Definition at line 459 of file class.ilBadgeHandler.php.

460 {
461 $hash = md5($a_ass->getBadgeId() . "_" . $a_ass->getUserId());
462
463 $path = $this->getBasePath() . "instances/" .
464 $a_ass->getBadgeId() . "/" .
465 floor($a_ass->getUserId()/1000) . "/";
466
468
469 $path .= $hash . ".json";
470
471 return $path;
472 }

References $path, ilBadgeAssignment\getBadgeId(), getBasePath(), ilBadgeAssignment\getUserId(), and ilUtil\makeDirParents().

+ Here is the call graph for this function:

◆ getIssuerStaticUrl()

ilBadgeHandler::getIssuerStaticUrl ( )

Definition at line 521 of file class.ilBadgeHandler.php.

522 {
523 $path = $this->getBasePath() . "issuer/";
525 $path .= "issuer.json";
526
527 $url = ILIAS_HTTP_PATH . substr($path, 1);
528
529 if (!file_exists($path)) {
530 $json = json_encode($this->prepareIssuerJson($url));
531 file_put_contents($path, $json);
532 }
533
534 return $url;
535 }
$url

References $path, $url, and ilUtil\makeDirParents().

+ Here is the call graph for this function:

◆ getObiContact()

ilBadgeHandler::getObiContact ( )

Definition at line 100 of file class.ilBadgeHandler.php.

101 {
102 return $this->settings->get("obi_contact", null);
103 }

References settings().

+ Here is the call graph for this function:

◆ getObiOrganistation()

ilBadgeHandler::getObiOrganistation ( )

Definition at line 90 of file class.ilBadgeHandler.php.

91 {
92 return $this->settings->get("obi_organisation", null);
93 }

References settings().

+ Here is the call graph for this function:

◆ getObiSalt()

ilBadgeHandler::getObiSalt ( )

Definition at line 110 of file class.ilBadgeHandler.php.

111 {
112 return $this->settings->get("obi_salt", null);
113 }

References settings().

+ Here is the call graph for this function:

◆ getProviderInstance()

ilBadgeHandler::getProviderInstance (   $a_component_id)

Get provider instance.

Parameters
string$a_component_id
Returns
ilBadgeProvider

Definition at line 164 of file class.ilBadgeHandler.php.

165 {
166 $comp = $this->getComponent($a_component_id);
167 if ($comp) {
168 $class = "il" . $comp["name"] . "BadgeProvider";
169 $file = $comp["type"] . "/" . $comp["name"] . "/classes/class." . $class . ".php";
170 if (file_exists($file)) {
171 include_once $file;
172 $obj = new $class;
173 if ($obj instanceof ilBadgeProvider) {
174 return $obj;
175 }
176 }
177 }
178 }
Badge Provider interface.
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file

References $file, and getComponent().

Referenced by getAvailableTypes(), and getTypeInstanceByUniqueId().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTypeInstanceByUniqueId()

ilBadgeHandler::getTypeInstanceByUniqueId (   $a_id)

Get type instance by unique id (component, type)

Parameters
string$a_id
Returns
ilBadgeType

Definition at line 202 of file class.ilBadgeHandler.php.

203 {
204 $parts = explode("/", $a_id);
205 $comp_id = $parts[0];
206 $type_id = $parts[1];
207 $provider = $this->getProviderInstance($comp_id);
208 if ($provider) {
209 foreach ($provider->getBadgeTypes() as $type) {
210 if ($type->getId() == $type_id) {
211 return $type;
212 }
213 }
214 }
215 }

References League\OAuth2\Client\Provider\$provider, $type, and getProviderInstance().

Referenced by triggerEvaluation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUniqueTypeId()

ilBadgeHandler::getUniqueTypeId (   $a_component_id,
ilBadgeType  $a_badge 
)

Definition at line 192 of file class.ilBadgeHandler.php.

193 {
194 return $a_component_id . "/" . $a_badge->getId();
195 }
getId()
Get typ id (unique for component)

References ilBadgeType\getId().

Referenced by getAvailableTypes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserIds()

ilBadgeHandler::getUserIds (   $a_parent_ref_id,
  $a_parent_obj_id = null,
  $a_parent_type = null 
)

Definition at line 412 of file class.ilBadgeHandler.php.

413 {
415
416 if (!$a_parent_obj_id) {
417 $a_parent_obj_id = ilObject::_lookupObjectId($a_parent_ref_id);
418 }
419 if (!$a_parent_type) {
420 $a_parent_type = ilObject::_lookupType($a_parent_obj_id);
421 }
422
423 // try to get participants from (parent) course/group
424 switch ($a_parent_type) {
425 case "crs":
426 include_once "Modules/Course/classes/class.ilCourseParticipants.php";
427 $member_obj = ilCourseParticipants::_getInstanceByObjId($a_parent_obj_id);
428 return $member_obj->getMembers();
429
430 case "grp":
431 include_once "Modules/Group/classes/class.ilGroupParticipants.php";
432 $member_obj = ilGroupParticipants::_getInstanceByObjId($a_parent_obj_id);
433 return $member_obj->getMembers();
434
435 default:
436 // walk path to find course or group object and use members of that object
437 $path = $tree->getPathId($a_parent_ref_id);
438 array_pop($path);
439 foreach (array_reverse($path) as $path_ref_id) {
440 $type = ilObject::_lookupType($path_ref_id, true);
441 if ($type == "crs" || $type == "grp") {
442 return $this->getParticipantsForObject($path_ref_id, null, $type);
443 }
444 }
445 break;
446 }
447 }
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _lookupObjectId($a_ref_id)
lookup object id

References $path, $tree, $type, ilCourseParticipants\_getInstanceByObjId(), ilGroupParticipants\_getInstanceByObjId(), ilObject\_lookupObjectId(), and ilObject\_lookupType().

+ Here is the call graph for this function:

◆ isActive()

ilBadgeHandler::isActive ( )

Definition at line 67 of file class.ilBadgeHandler.php.

68 {
69 return $this->settings->get("active", false);
70 }

References settings().

Referenced by isObjectActive(), and triggerEvaluation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isObiActive()

ilBadgeHandler::isObiActive ( )

Definition at line 77 of file class.ilBadgeHandler.php.

78 {
79 // see bug #20124
80 return false;
81
82 return $this->settings->get("obi_active", false);
83 }

References settings().

+ Here is the call graph for this function:

◆ isObjectActive()

ilBadgeHandler::isObjectActive (   $a_obj_id,
  $a_obj_type = null 
)

Definition at line 354 of file class.ilBadgeHandler.php.

355 {
356 if (!$this->isActive()) {
357 return false;
358 }
359
360 if (!$a_obj_type) {
361 $a_obj_type = ilObject::_lookupType($a_obj_id);
362 }
363
364 if ($a_obj_type != "bdga") {
365 include_once 'Services/Container/classes/class.ilContainer.php';
366 include_once 'Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
368 $a_obj_id,
370 false
371 )) {
372 return false;
373 }
374 }
375
376 return true;
377 }
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.

References ilContainer\_lookupContainerSetting(), ilObject\_lookupType(), ilObjectServiceSettingsGUI\BADGES, and isActive().

+ Here is the call graph for this function:

◆ prepareIssuerJson()

ilBadgeHandler::prepareIssuerJson (   $a_url)
protected

Definition at line 508 of file class.ilBadgeHandler.php.

509 {
510 $json = new stdClass();
511 $json->{"@context"} = "https://w3id.org/openbadges/v1";
512 $json->type = "Issuer";
513 $json->id = $a_url;
514 $json->name = $this->getObiOrganistation();
515 $json->url = ILIAS_HTTP_PATH . "/";
516 $json->email = $this->getObiContact();
517
518 return $json;
519 }

◆ rebuildIssuerStaticUrl()

ilBadgeHandler::rebuildIssuerStaticUrl ( )

Definition at line 537 of file class.ilBadgeHandler.php.

538 {
539 $path = $this->getBasePath() . "issuer/issuer.json";
540 if (file_exists($path)) {
541 unlink($path);
542 }
543 $this->getIssuerStaticUrl();
544 }

References $path.

◆ sendNotification()

ilBadgeHandler::sendNotification ( array  $a_user_map,
  $a_parent_ref_id = null 
)

Definition at line 551 of file class.ilBadgeHandler.php.

552 {
553 $badges = array();
554
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";
559
560 foreach ($a_user_map as $user_id => $badge_ids) {
561 $user_badges = array();
562
563 foreach ($badge_ids as $badge_id) {
564 // making extra sure
565 if (!ilBadgeAssignment::exists($badge_id, $user_id)) {
566 continue;
567 }
568
569 if (!array_key_exists($badge_id, $badges)) {
570 $badges[$badge_id] = new ilBadge($badge_id);
571 }
572
573 $badge = $badges[$badge_id];
574
575 $user_badges[] = $badge->getTitle();
576 }
577
578 if (sizeof($user_badges)) {
579 // compose and send mail
580
581 $ntf = new ilSystemNotification(false);
582 $ntf->setLangModules(array("badge"));
583
584 $ntf->setRefId($a_parent_ref_id);
585 $ntf->setGotoLangId("badge_notification_parent_goto");
586
587 // user specific language
588 $lng = $ntf->getUserLanguage($user_id);
589
590 $ntf->setIntroductionLangId("badge_notification_body");
591
592 $ntf->addAdditionalInfo("badge_notification_badges", implode("\n", $user_badges), true);
593
594 $url = ilLink::_getLink($user_id, "usr", array(), "_bdg");
595 $ntf->addAdditionalInfo("badge_notification_badges_goto", $url);
596
597 $ntf->setReasonLangId("badge_notification_reason");
598
599 // force email
600 $mail = new ilMail(ANONYMOUS_USER_ID);
601 $mail->enableSOAP(false);
602 $mail->sendMail(
603 ilObjUser::_lookupEmail($user_id),
604 null,
605 null,
606 $lng->txt("badge_notification_subject"),
607 $ntf->composeAndGetMessage($user_id, null, "read", true),
608 null,
609 array("system")
610 );
611
612
613 // osd
614 // bug #24562
615 if (ilContext::hasHTML()) {
616 $osd_params = array("badge_list" => "<br />" . implode("<br />", $user_badges));
617
618 require_once "Services/Notifications/classes/class.ilNotificationConfig.php";
619 $notification = new ilNotificationConfig("osd_main");
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);
625 $notification->setIconPath(ilUtil::getImagePath('icon_bdga.svg'));
626 $notification->setValidForSeconds(ilNotificationConfig::TTL_SHORT);
627 $notification->setVisibleForSeconds(ilNotificationConfig::DEFAULT_TTS);
628 $notification->notifyByUsers(array($user_id));
629 }
630 }
631 }
632 }
static exists($a_badge_id, $a_user_id)
static hasHTML()
Has HTML output.
This class handles base functions for mail handling.
Describes a notification and provides methods for publishing this notification.
static _lookupEmail($a_user_id)
Lookup email.
Wrapper classes for system notifications.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)

References $lng, $url, ilLink\_getLink(), ilObjUser\_lookupEmail(), ilNotificationConfig\DEFAULT_TTS, ilBadgeAssignment\exists(), ilUtil\getImagePath(), ilContext\hasHTML(), and ilNotificationConfig\TTL_SHORT.

Referenced by triggerEvaluation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setActive()

ilBadgeHandler::setActive (   $a_value)

Definition at line 72 of file class.ilBadgeHandler.php.

73 {
74 $this->settings->set("active", (bool) $a_value);
75 }

References settings().

+ Here is the call graph for this function:

◆ setComponents()

ilBadgeHandler::setComponents ( array  $a_components = null)

Definition at line 129 of file class.ilBadgeHandler.php.

130 {
131 if (is_array($a_components) &&
132 !sizeof($a_components)) {
133 $a_components = null;
134 }
135 $this->settings->set("components", $a_components !== null
136 ? serialize(array_unique($a_components))
137 : null);
138 }

References settings().

+ Here is the call graph for this function:

◆ setInactiveTypes()

ilBadgeHandler::setInactiveTypes ( array  $a_types = null)

Definition at line 226 of file class.ilBadgeHandler.php.

227 {
228 if (is_array($a_types) &&
229 !sizeof($a_types)) {
230 $a_types = null;
231 }
232 $this->settings->set("inactive_types", $a_types !== null
233 ? serialize(array_unique($a_types))
234 : null);
235 }

References settings().

+ Here is the call graph for this function:

◆ setObiActive()

ilBadgeHandler::setObiActive (   $a_value)

Definition at line 85 of file class.ilBadgeHandler.php.

86 {
87 $this->settings->set("obi_active", (bool) $a_value);
88 }

References settings().

+ Here is the call graph for this function:

◆ setObiContact()

ilBadgeHandler::setObiContact (   $a_value)

Definition at line 105 of file class.ilBadgeHandler.php.

106 {
107 $this->settings->set("obi_contact", trim($a_value));
108 }

References settings().

+ Here is the call graph for this function:

◆ setObiOrganisation()

ilBadgeHandler::setObiOrganisation (   $a_value)

Definition at line 95 of file class.ilBadgeHandler.php.

96 {
97 $this->settings->set("obi_organisation", trim($a_value));
98 }

References settings().

+ Here is the call graph for this function:

◆ setObiSalt()

ilBadgeHandler::setObiSalt (   $a_value)

Definition at line 115 of file class.ilBadgeHandler.php.

116 {
117 $this->settings->set("obi_salt", trim($a_value));
118 }

References settings().

+ Here is the call graph for this function:

◆ triggerEvaluation()

ilBadgeHandler::triggerEvaluation (   $a_type_id,
  $a_user_id,
array  $a_params = null 
)

Definition at line 379 of file class.ilBadgeHandler.php.

380 {
381 if (!$this->isActive() ||
382 in_array($a_type_id, $this->getInactiveTypes())) {
383 return;
384 }
385
386 $type = $this->getTypeInstanceByUniqueId($a_type_id);
387 if (!$type ||
388 !$type instanceof ilBadgeAuto) {
389 return;
390 }
391
392 include_once "Services/Badge/classes/class.ilBadge.php";
393 include_once "Services/Badge/classes/class.ilBadgeAssignment.php";
394 $new_badges = array();
395 foreach (ilBadge::getInstancesByType($a_type_id) as $badge) {
396 if ($badge->isActive()) {
397 // already assigned?
398 if (!ilBadgeAssignment::exists($badge->getId(), $a_user_id)) {
399 if ((bool) $type->evaluate($a_user_id, (array) $a_params, (array) $badge->getConfiguration())) {
400 $ass = new ilBadgeAssignment($badge->getId(), $a_user_id);
401 $ass->store();
402
403 $new_badges[$a_user_id][] = $badge->getId();
404 }
405 }
406 }
407 }
408
409 $this->sendNotification($new_badges);
410 }
getTypeInstanceByUniqueId($a_id)
Get type instance by unique id (component, type)
sendNotification(array $a_user_map, $a_parent_ref_id=null)
static getInstancesByType($a_type_id)

References $type, ilBadgeAssignment\exists(), getInactiveTypes(), ilBadge\getInstancesByType(), getTypeInstanceByUniqueId(), isActive(), and sendNotification().

+ Here is the call graph for this function:

◆ updateFromXML()

static ilBadgeHandler::updateFromXML (   $a_component_id)
static

Import component definition.

Parameters
string$a_component_id

Definition at line 324 of file class.ilBadgeHandler.php.

325 {
327 $components = $handler->getComponents();
328 $components[] = $a_component_id;
329 $handler->setComponents($components);
330 }

References $handler, and getInstance().

Referenced by ilObjDefReader\handlerBeginTag().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilBadgeHandler::$db
protected

Definition at line 17 of file class.ilBadgeHandler.php.

Referenced by getComponent().

◆ $instance

ilBadgeHandler::$instance
staticprotected

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

Referenced by getInstance().

◆ $lng

ilBadgeHandler::$lng
protected

Definition at line 27 of file class.ilBadgeHandler.php.

◆ $settings

ilBadgeHandler::$settings
protected

Definition at line 29 of file class.ilBadgeHandler.php.

◆ $tree

ilBadgeHandler::$tree
protected

Definition at line 22 of file class.ilBadgeHandler.php.

Referenced by getUserIds().


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