ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 ()
 
 hasFlexibleSchedule ()
 
 run ()
 
- Public Member Functions inherited from ILIAS\Cron\CronJob
 setDateTimeProvider (?\Closure $date_time_provider)
 
 isDue (?\DateTimeImmutable $last_run, ?JobScheduleType $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 (?JobScheduleType $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 ()
 
 usesLegacyForms ()
 
 getCustomConfigurationInput (\ILIAS\UI\Factory $ui_factory, \ILIAS\Refinery\Factory $factory, \ilLanguage $lng)
 
 addCustomSettingsToForm (\ilPropertyFormGUI $a_form)
 
 saveCustomConfiguration (mixed $form_data)
 
 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 ILIAS\Cron\CronJob
JobScheduleType $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Detailed Description

Course/group skill notification.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilSkillNotifications::__construct ( )

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

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

40  {
41  global $DIC;
42 
43  $this->lng = $DIC->language();
44  if (isset($DIC["ilUser"])) {
45  $this->user = $DIC->user();
46  }
47  if (isset($DIC["ilClientIniFile"])) {
48  $this->client_ini = $DIC["ilClientIniFile"];
49  }
50  if (isset($DIC["tree"])) {
51  $this->tree = $DIC->repositoryTree();
52  }
53  $this->tree_service = $DIC->skills()->tree();
54  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ getDefaultScheduleType()

ilSkillNotifications::getDefaultScheduleType ( )

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

76  {
77  return JobScheduleType::DAILY;
78  }

◆ getDefaultScheduleValue()

ilSkillNotifications::getDefaultScheduleValue ( )

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

References null.

80  : ?int
81  {
82  return null;
83  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getDescription()

ilSkillNotifications::getDescription ( )

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

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

68  : string
69  {
70  $lng = $this->lng;
71  $lng->loadLanguageModule("skll");
72  return $lng->txt("skll_skill_notification_desc");
73  }
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...
loadLanguageModule(string $a_module)
Load language module.
+ Here is the call graph for this function:

◆ getId()

ilSkillNotifications::getId ( )

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

56  : string
57  {
58  return "skll_notification";
59  }

◆ getTitle()

ilSkillNotifications::getTitle ( )

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

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

61  : string
62  {
63  $lng = $this->lng;
64  $lng->loadLanguageModule("skll");
65  return $lng->txt("skll_skill_notification");
66  }
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...
loadLanguageModule(string $a_module)
Load language module.
+ Here is the call graph for this function:

◆ hasAutoActivation()

ilSkillNotifications::hasAutoActivation ( )

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

85  : bool
86  {
87  return false;
88  }

◆ hasFlexibleSchedule()

ilSkillNotifications::hasFlexibleSchedule ( )

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

90  : bool
91  {
92  return true;
93  }

◆ run()

ilSkillNotifications::run ( )

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

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

95  : JobResult
96  {
97  global $DIC;
98 
99  $lng = $DIC->language();
100 
102  $log->debug("===Skill Notifications=== start");
103 
104  $status = JobResult::STATUS_NO_ACTION;
105  $status_details = null;
106 
107  $setting = new ilSetting("cron");
108  $last_run = $setting->get(get_class($this));
109 
110  // no last run?
111  if (!$last_run) {
112  $last_run = date("Y-m-d H:i:s", strtotime("yesterday"));
113 
114  $status_details = "No previous run found - starting from yesterday.";
115  } // migration: used to be date-only value
116  elseif (strlen($last_run) == 10) {
117  $last_run .= " 00:00:00";
118 
119  $status_details = "Switched from daily runs to open schedule.";
120  }
121 
122  // init language/date
123  $old_lng = $lng;
126 
127 
128  // get latest course/group skill changes per user
129  $achievements = ilBasicSkill::getNewAchievementsPerUser($last_run);
130 
131  foreach ($achievements as $user_id => $a) {
132  $this->sendMail($user_id, $a, $last_run);
133  }
134 
135  // mails were sent - set cron job status accordingly
136  $status = JobResult::STATUS_OK;
137 
138  // reset language/date
140  $lng = $old_lng;
141 
142  $log->debug("save run");
143 
144  // save last run
145  $setting->set(get_class($this), date("Y-m-d H:i:s"));
146 
147  $result = new JobResult();
148  $result->setStatus($status);
149 
150  if ($status_details) {
151  $result->setMessage($status_details);
152  }
153 
154  $log->debug("===Skill Notifications=== done");
155 
156  return $result;
157  }
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.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$log
Definition: result.php:32
global $DIC
Definition: shib_login.php:22
static getNewAchievementsPerUser(string $a_timestamp, ?string $a_timestamp_to=null, int $a_user_id=0, int $a_self_eval=0)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
+ 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 162 of file class.ilSkillNotifications.php.

References $client, $client_ini, $path, $ref_id, $tree, $txt, 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(), null, and ilLanguage\txt().

Referenced by run().

162  : void
163  {
164  $ilClientIniFile = $this->client_ini;
165  $tree = $this->tree;
166 
167  $ntf = new ilSystemNotification();
168  $ntf->setLangModules(array("skll"));
169 
170  // user specific language
171  $lng = $ntf->getUserLanguage($a_user_id);
172 
173  $txt = "";
174  $last_obj_id = 0;
175 
176  // order skill achievements per virtual skill tree
177  $vtree = $this->tree_service->getGlobalVirtualSkillTree();
178  $a_achievements = $vtree->getOrderedNodeset($a_achievements, "skill_id", "tref_id");
179 
180  foreach ($a_achievements as $skill_level) {
181  // path
182  $path = [];
183  foreach ($tree->getPathId($skill_level["trigger_ref_id"]) as $node) {
184  $path[] = $node;
185  }
186  $path = implode("-", $path);
187 
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"];
192 
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;
196  if ($tree->isInTree($ref_id)) {
198  }
199  }
200 
201  $date = ilDatePresentation::formatDate(new ilDateTime($skill_level["status_date"], IL_CAL_DATETIME));
202  $txt .= "\n $date, " . ilBasicSkill::_lookupTitle($skill_level["skill_id"], $skill_level["tref_id"]) . ": " .
203  ilBasicSkill::lookupLevelTitle($skill_level["level_id"]);
204  }
205 
206  $ntf->setIntroductionLangId("skll_intro_skill_notification_for");
207 
208  // index
209  $period = sprintf(
210  $lng->txt("skll_new_skill_achievements"),
213  );
214 
215  // text
216  $ntf->addAdditionalInfo(
217  "",
218  trim($txt),
219  true
220  );
221 
222  // :TODO: does it make sense to add client to subject?
223  $client = $ilClientIniFile->readVariable('client', 'name');
224  $subject = sprintf($lng->txt("skll_competence_achievements"), $client);
225 
226  //die($ntf->composeAndGetMessage($a_user_id, null, "read", true));
227 
228  // #10044
229  $mail = new ilMail(ANONYMOUS_USER_ID);
230  $mail->enqueue(
231  ilObjUser::_lookupLogin($a_user_id),
232  "",
233  "",
234  $subject,
235  $ntf->composeAndGetMessage($a_user_id, null, "read", true),
236  []
237  );
238  }
const IL_CAL_DATETIME
const ANONYMOUS_USER_ID
Definition: constants.php:27
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)
static lookupLevelTitle(int $a_id)
const IL_CAL_UNIX
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$client
$ref_id
Definition: ltiauth.php:65
$txt
Definition: error.php:31
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 formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupLogin(int $a_user_id)
+ 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 35 of file class.ilSkillNotifications.php.

Referenced by sendMail().

◆ $lng

ilLanguage ilSkillNotifications::$lng
protected

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

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

◆ $tree

ilTree ilSkillNotifications::$tree
protected

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

Referenced by sendMail().

◆ $tree_service

SkillTreeService ilSkillNotifications::$tree_service
protected

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

◆ $user

ilObjUser ilSkillNotifications::$user
protected

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


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