19 declare(strict_types=1);
43 $this->
lng = $DIC->language();
44 if (isset($DIC[
"ilUser"])) {
45 $this->
user = $DIC->user();
47 if (isset($DIC[
"ilClientIniFile"])) {
48 $this->client_ini = $DIC[
"ilClientIniFile"];
50 if (isset($DIC[
"tree"])) {
51 $this->tree = $DIC->repositoryTree();
53 $this->tree_service = $DIC->skills()->tree();
58 return "skll_notification";
65 return $lng->
txt(
"skll_skill_notification");
72 return $lng->
txt(
"skll_skill_notification_desc");
77 return JobScheduleType::DAILY;
99 $lng = $DIC->language();
102 $log->debug(
"===Skill Notifications=== start");
104 $status = JobResult::STATUS_NO_ACTION;
105 $status_details =
null;
108 $last_run = $setting->get(get_class($this));
112 $last_run = date(
"Y-m-d H:i:s", strtotime(
"yesterday"));
114 $status_details =
"No previous run found - starting from yesterday.";
116 elseif (strlen($last_run) == 10) {
117 $last_run .=
" 00:00:00";
119 $status_details =
"Switched from daily runs to open schedule.";
136 $status = JobResult::STATUS_OK;
142 $log->debug(
"save run");
145 $setting->set(get_class($this), date(
"Y-m-d H:i:s"));
148 $result->setStatus($status);
150 if ($status_details) {
151 $result->setMessage($status_details);
154 $log->debug(
"===Skill Notifications=== done");
162 protected function sendMail(
int $a_user_id, array $a_achievements,
string $a_last_run): void
168 $ntf->setLangModules(array(
"skll"));
177 $vtree = $this->tree_service->getGlobalVirtualSkillTree();
178 $a_achievements = $vtree->getOrderedNodeset($a_achievements,
"skill_id",
"tref_id");
180 foreach ($a_achievements as $skill_level) {
183 foreach ($tree->
getPathId($skill_level[
"trigger_ref_id"]) as $node) {
188 $ref_id = $skill_level[
"trigger_ref_id"];
189 $obj_id = $skill_level[
"trigger_obj_id"];
190 $type = $skill_level[
"trigger_obj_type"];
191 $title = $skill_level[
"trigger_title"];
193 if ($skill_level[
"trigger_obj_id"] != $last_obj_id) {
194 $last_obj_id = $skill_level[
"trigger_obj_id"];
195 $txt .=
"\n\n" . $lng->
txt(
"obj_" . $type) .
": " . $title;
206 $ntf->setIntroductionLangId(
"skll_intro_skill_notification_for");
210 $lng->
txt(
"skll_new_skill_achievements"),
216 $ntf->addAdditionalInfo(
223 $client = $ilClientIniFile->readVariable(
'client',
'name');
224 $subject = sprintf($lng->
txt(
"skll_competence_achievements"),
$client);
235 $ntf->composeAndGetMessage($a_user_id,
null,
"read",
true),
static array static setUseRelativeDates(bool $a_status)
set use relative dates
sendMail(int $a_user_id, array $a_achievements, string $a_last_run)
Send news mail for 1 user and n objects.
static getLogger(string $a_component_id)
Get component logger.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
getUserLanguage()
Return language of user.
isInTree(?int $a_node_id)
get all information of a node.
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
loadLanguageModule(string $a_module)
Load language module.
static lookupLevelTitle(int $a_id)
static useRelativeDates()
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
getDefaultScheduleValue()
Course/group skill notification.
static _getStaticLink(?int $a_ref_id, string $a_type='', bool $a_fallback_goto=true, string $append="")
SkillTreeService $tree_service
getPathId(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
static getNewAchievementsPerUser(string $a_timestamp, ?string $a_timestamp_to=null, int $a_user_id=0, int $a_self_eval=0)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupLogin(int $a_user_id)