ILIAS  release_8 Revision v8.24
ilSkillNotifications Class Reference

Course/group skill notification. More...

+ Inheritance diagram for ilSkillNotifications:
+ Collaboration diagram for ilSkillNotifications:

Public Member Functions

 __construct ()
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 run ()
 
- Public Member Functions inherited from ilCronJob
 setDateTimeProvider (?Closure $date_time_provider)
 
 isDue (?DateTimeImmutable $last_run, ?int $schedule_type, ?int $schedule_value, bool $is_manually_executed=false)
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule (?int $a_type, ?int $a_value)
 Update current schedule (if flexible) More...
 
 getAllScheduleTypes ()
 Get all available schedule types. More...
 
 getScheduleTypesWithValues ()
 
 getValidScheduleTypes ()
 Returns a collection of all valid schedule types for a specific job. More...
 
 isManuallyExecutable ()
 
 hasCustomSettings ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 
 addToExternalSettingsForm (int $a_form_id, array &$a_fields, bool $a_is_active)
 
 activationWasToggled (ilDBInterface $db, ilSetting $setting, bool $a_currently_active)
 Important: This method is (also) called from the setup process, where the constructor of an ilCronJob ist NOT executed. More...
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 run ()
 

Protected Member Functions

 sendMail (int $a_user_id, array $a_achievements, string $a_last_run)
 Send news mail for 1 user and n objects. More...
 

Protected Attributes

ilLanguage $lng
 
ilObjUser $user
 
ilIniFile $client_ini
 
ilTree $tree
 
SkillTreeService $tree_service
 
- Protected Attributes inherited from ilCronJob
int $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_HOURS = 3
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_DAYS = 4
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_WEEKLY = 5
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_MONTHLY = 6
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_QUARTERLY = 7
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_YEARLY = 8
 @depracated This will be replaced with an ENUM in ILIAS 9 More...
 

Detailed Description

Course/group skill notification.

Author
Alex Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..com

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

Constructor & Destructor Documentation

◆ __construct()

ilSkillNotifications::__construct ( )

Definition at line 35 of file class.ilSkillNotifications.php.

36 {
37 global $DIC;
38
39 $this->lng = $DIC->language();
40 if (isset($DIC["ilUser"])) {
41 $this->user = $DIC->user();
42 }
43 if (isset($DIC["ilClientIniFile"])) {
44 $this->client_ini = $DIC["ilClientIniFile"];
45 }
46 if (isset($DIC["tree"])) {
47 $this->tree = $DIC->repositoryTree();
48 }
49 $this->tree_service = $DIC->skills()->tree();
50 }
global $DIC
Definition: feed.php:28

References $DIC, ILIAS\Repository\lng(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ getDefaultScheduleType()

ilSkillNotifications::getDefaultScheduleType ( )

Reimplemented from ilCronJob.

Definition at line 71 of file class.ilSkillNotifications.php.

71 : int
72 {
74 }
const SCHEDULE_TYPE_DAILY
@depracated This will be replaced with an ENUM in ILIAS 9

References ilCronJob\SCHEDULE_TYPE_DAILY.

◆ getDefaultScheduleValue()

ilSkillNotifications::getDefaultScheduleValue ( )

Reimplemented from ilCronJob.

Definition at line 76 of file class.ilSkillNotifications.php.

76 : ?int
77 {
78 return null;
79 }

◆ getDescription()

ilSkillNotifications::getDescription ( )

Reimplemented from ilCronJob.

Definition at line 64 of file class.ilSkillNotifications.php.

64 : string
65 {
67 $lng->loadLanguageModule("skll");
68 return $lng->txt("skll_skill_notification_desc");
69 }
loadLanguageModule(string $a_module)
Load language module.
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...

References $lng, ilLanguage\loadLanguageModule(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ getId()

ilSkillNotifications::getId ( )

Reimplemented from ilCronJob.

Definition at line 52 of file class.ilSkillNotifications.php.

52 : string
53 {
54 return "skll_notification";
55 }

◆ getTitle()

ilSkillNotifications::getTitle ( )

Reimplemented from ilCronJob.

Definition at line 57 of file class.ilSkillNotifications.php.

57 : string
58 {
60 $lng->loadLanguageModule("skll");
61 return $lng->txt("skll_skill_notification");
62 }

References $lng, ilLanguage\loadLanguageModule(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ hasAutoActivation()

ilSkillNotifications::hasAutoActivation ( )

Is to be activated on "installation", does only work for ILIAS core cron jobs.

Reimplemented from ilCronJob.

Definition at line 81 of file class.ilSkillNotifications.php.

81 : bool
82 {
83 return false;
84 }

◆ hasFlexibleSchedule()

ilSkillNotifications::hasFlexibleSchedule ( )

Reimplemented from ilCronJob.

Definition at line 86 of file class.ilSkillNotifications.php.

86 : bool
87 {
88 return true;
89 }

◆ run()

ilSkillNotifications::run ( )

Reimplemented from ilCronJob.

Definition at line 91 of file class.ilSkillNotifications.php.

92 {
93 global $DIC;
94
95 $lng = $DIC->language();
96
98 $log->debug("===Skill Notifications=== start");
99
101 $status_details = null;
102
103 $setting = new ilSetting("cron");
104 $last_run = $setting->get(get_class($this));
105
106 // no last run?
107 if (!$last_run) {
108 $last_run = date("Y-m-d H:i:s", strtotime("yesterday"));
109
110 $status_details = "No previous run found - starting from yesterday.";
111 } // migration: used to be date-only value
112 elseif (strlen($last_run) == 10) {
113 $last_run .= " 00:00:00";
114
115 $status_details = "Switched from daily runs to open schedule.";
116 }
117
118 // init language/date
119 $old_lng = $lng;
122
123
124 // get latest course/group skill changes per user
125 $achievements = ilBasicSkill::getNewAchievementsPerUser($last_run);
126
127 foreach ($achievements as $user_id => $a) {
128 $this->sendMail($user_id, $a, $last_run);
129 }
130
131 // mails were sent - set cron job status accordingly
133
134 // reset language/date
136 $lng = $old_lng;
137
138 $log->debug("save run");
139
140 // save last run
141 $setting->set(get_class($this), date("Y-m-d H:i:s"));
142
143 $result = new ilCronJobResult();
144 $result->setStatus($status);
145
146 if ($status_details) {
147 $result->setMessage($status_details);
148 }
149
150 $log->debug("===Skill Notifications=== done");
151
152 return $result;
153 }
static getNewAchievementsPerUser(string $a_timestamp, string $a_timestamp_to=null, int $a_user_id=0, int $a_self_eval=0)
static setUseRelativeDates(bool $a_status)
set use relative dates
static getLogger(string $a_component_id)
Get component logger.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
sendMail(int $a_user_id, array $a_achievements, string $a_last_run)
Send news mail for 1 user and n objects.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$log
Definition: result.php:33

References Vendor\Package\$a, $DIC, $lng, $log, ilLoggerFactory\getLogger(), ilBasicSkill\getNewAchievementsPerUser(), sendMail(), ilDatePresentation\setUseRelativeDates(), ilCronJobResult\STATUS_NO_ACTION, ilCronJobResult\STATUS_OK, and ilDatePresentation\useRelativeDates().

+ Here is the call graph for this function:

◆ sendMail()

ilSkillNotifications::sendMail ( int  $a_user_id,
array  $a_achievements,
string  $a_last_run 
)
protected

Send news mail for 1 user and n objects.

Definition at line 158 of file class.ilSkillNotifications.php.

158 : void
159 {
160 $ilClientIniFile = $this->client_ini;
162
163 $ntf = new ilSystemNotification();
164 $ntf->setLangModules(array("skll"));
165
166 // user specific language
167 $lng = $ntf->getUserLanguage($a_user_id);
168
169 $txt = "";
170 $last_obj_id = 0;
171
172 // order skill achievements per virtual skill tree
173 $vtree = $this->tree_service->getGlobalVirtualSkillTree();
174 $a_achievements = $vtree->getOrderedNodeset($a_achievements, "skill_id", "tref_id");
175
176 foreach ($a_achievements as $skill_level) {
177
178 // path
179 $path = [];
180 foreach ($tree->getPathId($skill_level["trigger_ref_id"]) as $node) {
181 $path[] = $node;
182 }
183 $path = implode("-", $path);
184
185 $ref_id = $skill_level["trigger_ref_id"];
186 $obj_id = $skill_level["trigger_obj_id"];
187 $type = $skill_level["trigger_obj_type"];
188 $title = $skill_level["trigger_title"];
189
190 if ($skill_level["trigger_obj_id"] != $last_obj_id) {
191 $last_obj_id = $skill_level["trigger_obj_id"];
192 $txt .= "\n\n" . $lng->txt("obj_" . $type) . ": " . $title;
193 if ($tree->isInTree($ref_id)) {
195 }
196 }
197
198 $date = ilDatePresentation::formatDate(new ilDateTime($skill_level["status_date"], IL_CAL_DATETIME));
199 $txt .= "\n $date, " . ilBasicSkill::_lookupTitle($skill_level["skill_id"], $skill_level["tref_id"]) . ": " .
200 ilBasicSkill::lookupLevelTitle($skill_level["level_id"]);
201 }
202
203 $ntf->setIntroductionLangId("skll_intro_skill_notification_for");
204
205 // index
206 $period = sprintf(
207 $lng->txt("skll_new_skill_achievements"),
210 );
211
212 // text
213 $ntf->addAdditionalInfo(
214 "",
215 trim($txt),
216 true
217 );
218
219 // :TODO: does it make sense to add client to subject?
220 $client = $ilClientIniFile->readVariable('client', 'name');
221 $subject = sprintf($lng->txt("skll_competence_achievements"), $client);
222
223 //die($ntf->composeAndGetMessage($a_user_id, null, "read", true));
224
225 // #10044
226 $mail = new ilMail(ANONYMOUS_USER_ID);
227 $mail->enqueue(
228 ilObjUser::_lookupLogin($a_user_id),
229 '',
230 '',
231 $subject,
232 $ntf->composeAndGetMessage($a_user_id, null, "read", true),
233 []
234 );
235 }
const IL_CAL_UNIX
const IL_CAL_DATETIME
static lookupLevelTitle(int $a_id)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
getUserLanguage()
Return language of user.
static _lookupLogin(int $a_user_id)
static _lookupTitle(int $a_obj_id, int $a_tref_id=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isInTree(?int $a_node_id)
get all information of a node.
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...
const ANONYMOUS_USER_ID
Definition: constants.php:27
$client
$txt
Definition: error.php:13
$ref_id
Definition: ltiauth.php:67
$path
Definition: ltiservices.php:32
$type

References $client, $client_ini, $lng, $path, $ref_id, $tree, $txt, $type, ilLink\_getStaticLink(), ilObjUser\_lookupLogin(), ilSkillTreeNode\_lookupTitle(), ANONYMOUS_USER_ID, ilDatePresentation\formatDate(), ilTree\getPathId(), ilLanguage\getUserLanguage(), IL_CAL_DATETIME, IL_CAL_UNIX, ilTree\isInTree(), ilBasicSkill\lookupLevelTitle(), and ilLanguage\txt().

Referenced by run().

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

Field Documentation

◆ $client_ini

ilIniFile ilSkillNotifications::$client_ini
protected

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

Referenced by sendMail().

◆ $lng

ilLanguage ilSkillNotifications::$lng
protected

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

Referenced by getDescription(), getTitle(), run(), and sendMail().

◆ $tree

ilTree ilSkillNotifications::$tree
protected

Definition at line 32 of file class.ilSkillNotifications.php.

Referenced by sendMail().

◆ $tree_service

SkillTreeService ilSkillNotifications::$tree_service
protected

Definition at line 33 of file class.ilSkillNotifications.php.

◆ $user

ilObjUser ilSkillNotifications::$user
protected

Definition at line 30 of file class.ilSkillNotifications.php.


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