37                        self::$instance = 
new self();
 
   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();
 
  330                $components = $handler->getComponents();
 
  331                $components[] = $a_component_id;        
 
  332                $handler->setComponents($components);
 
  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.
"/";       
 
  547                $path = $this->getBasePath().
"issuer/";
 
  549                $path .= 
"issuer.json";
 
  553                if(!file_exists(
$path))
 
  555                        $json = json_encode($this->prepareIssuerJson(
$url));
 
  556                        file_put_contents(
$path, $json);
 
  564                $path = $this->getBasePath().
"issuer/issuer.json";
 
  565                if(file_exists(
$path))
 
  569                $this->getIssuerStaticUrl();
 
  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));
 
An exception for terminatinating execution or to throw for unit testing.
static exists($a_badge_id, $a_user_id)
setInactiveTypes(array $a_types=null)
getUniqueTypeId($a_component_id, ilBadgeType $a_badge)
prepareIssuerJson($a_url)
getAvailableTypesForObjType($a_object_type)
Get valid badges types for object type.
__construct()
Constructor.
setComponents(array $a_components=null)
isObjectActive($a_obj_id, $a_obj_type=null)
static updateFromXML($a_component_id)
Import component definition.
triggerEvaluation($a_type_id, $a_user_id, array $a_params=null)
getAvailableTypes()
Get badges types.
setObiOrganisation($a_value)
countStaticBadgeInstancesHelper(&$a_cnt, $a_path)
getProviderInstance($a_component_id)
Get provider instance.
static getInstance()
Constructor.
getComponentCaption($a_component_id)
getInstancePath(ilBadgeAssignment $a_ass)
getBadgePath(ilBadge $a_badge)
getUserIds($a_parent_ref_id, $a_parent_obj_id=null, $a_parent_type=null)
countStaticBadgeInstances(ilBadge $a_badge)
getTypeInstanceByUniqueId($a_id)
Get type instance by unique id (component, type)
sendNotification(array $a_user_map, $a_parent_ref_id=null)
getAvailableManualBadges($a_parent_obj_id, $a_parent_obj_type=null)
Get available manual badges for object id.
static clearFromXML($a_component_id)
Remove component definition.
static getInstancesByParentId($a_parent_id, array $a_filter=null)
static getInstancesByType($a_type_id)
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=NULL)
Lookup a container setting.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
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.
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupType($a_id, $a_reference=false)
lookup object type
Wrapper classes for system notifications.
static getWebspaceDir($mode="filesystem")
get webspace directory
static makeDirParents($a_dir)
Create a new directory and all parent directories.
Badge Provider interface.
getId()
Get typ id (unique for component)
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file