ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSkillNotifications Class Reference

Course/group skill notification. More...

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

Public Member Functions

 __construct ()
 Constructor. More...
 
 getId ()
 Get id. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 run ()
 Run job. More...
 
- Public Member Functions inherited from ilCronJob
 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active? More...
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule ($a_type, $a_value)
 Update current schedule (if flexible) More...
 
 getValidScheduleTypes ()
 Get all available schedule types. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually. More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 Run job. More...
 

Protected Member Functions

 sendMail ($a_user_id, array $a_achievements, $a_last_run)
 Send news mail for 1 user and n objects. More...
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Protected Attributes

 $lng
 
 $user
 
 $client_ini
 
 $tree
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 
const SCHEDULE_TYPE_IN_HOURS = 3
 
const SCHEDULE_TYPE_IN_DAYS = 4
 
const SCHEDULE_TYPE_WEEKLY = 5
 
const SCHEDULE_TYPE_MONTHLY = 6
 
const SCHEDULE_TYPE_QUARTERLY = 7
 
const SCHEDULE_TYPE_YEARLY = 8
 

Detailed Description

Course/group skill notification.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilSkillNotifications::__construct ( )

Constructor.

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

39 {
40 global $DIC;
41
42 $this->lng = $DIC->language();
43 if (isset($DIC["ilUser"])) {
44 $this->user = $DIC->user();
45 }
46 if (isset($DIC["ilClientIniFile"])) {
47 $this->client_ini = $DIC["ilClientIniFile"];
48 }
49 if (isset($DIC["tree"])) {
50 $this->tree = $DIC->repositoryTree();
51 }
52 }
user()
Definition: user.php:4
global $DIC
Definition: saml.php:7

References $DIC, and user().

+ Here is the call graph for this function:

Member Function Documentation

◆ getDefaultScheduleType()

ilSkillNotifications::getDefaultScheduleType ( )

Get schedule type.

Returns
int

Reimplemented from ilCronJob.

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

74 {
76 }
const SCHEDULE_TYPE_DAILY

References ilCronJob\SCHEDULE_TYPE_DAILY.

◆ getDefaultScheduleValue()

ilSkillNotifications::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

Reimplemented from ilCronJob.

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

79 {
80 return;
81 }

◆ getDescription()

ilSkillNotifications::getDescription ( )

Get description.

Returns
string

Reimplemented from ilCronJob.

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

67 {
69 $lng->loadLanguageModule("skll");
70 return $lng->txt("skll_skill_notification_desc");
71 }

References $lng.

◆ getId()

ilSkillNotifications::getId ( )

Get id.

Returns
string

Reimplemented from ilCronJob.

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

55 {
56 return "skll_notification";
57 }

◆ getTitle()

ilSkillNotifications::getTitle ( )

Get title.

Returns
string

Reimplemented from ilCronJob.

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

60 {
62 $lng->loadLanguageModule("skll");
63 return $lng->txt("skll_skill_notification");
64 }

References $lng.

◆ hasAutoActivation()

ilSkillNotifications::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

Reimplemented from ilCronJob.

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

84 {
85 return false;
86 }

◆ hasFlexibleSchedule()

ilSkillNotifications::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

Reimplemented from ilCronJob.

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

89 {
90 return true;
91 }

◆ run()

ilSkillNotifications::run ( )

Run job.

Returns
ilCronJobResult

Reimplemented from ilCronJob.

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

94 {
95 global $DIC;
96
97 $lng = $DIC->language();
98
100 $log->debug("===Skill Notifications=== start");
101
103 $status_details = null;
104
105 $setting = new ilSetting("cron");
106 $last_run = $setting->get(get_class($this));
107
108 // no last run?
109 if (!$last_run) {
110 $last_run = date("Y-m-d H:i:s", strtotime("yesterday"));
111
112 $status_details = "No previous run found - starting from yesterday.";
113 } // migration: used to be date-only value
114 elseif (strlen($last_run) == 10) {
115 $last_run .= " 00:00:00";
116
117 $status_details = "Switched from daily runs to open schedule.";
118 }
119
120 // init language/date
121 $old_lng = $lng;
124
125
126 // $last_run = "2017-07-20 12:00:00";
127
128 // get latest course/group skill changes per user
129 include_once("./Services/Skill/classes/class.ilBasicSkill.php");
130 $achievements = ilBasicSkill::getNewAchievementsPerUser($last_run);
131
132 foreach ($achievements as $user_id => $a) {
133 $this->sendMail($user_id, $a, $last_run);
134 }
135
136 // mails were sent - set cron job status accordingly
138
139 // reset language/date
141 $lng = $old_lng;
142
143 $log->debug("save run");
144
145 // save last run
146 $setting->set(get_class($this), date("Y-m-d H:i:s"));
147
148 $result = new ilCronJobResult();
149 $result->setStatus($status);
150
151 if ($status_details) {
152 $result->setMessage($status_details);
153 }
154
155 $log->debug("===Skill Notifications=== done");
156
157 return $result;
158 }
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$result
static getNewAchievementsPerUser($a_timestamp)
Get new achievements.
Cron job result data container.
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
static getLogger($a_component_id)
Get component logger.
ILIAS Setting Class.
sendMail($a_user_id, array $a_achievements, $a_last_run)
Send news mail for 1 user and n objects.

References $DIC, $lng, $log, $result, date, 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 (   $a_user_id,
array  $a_achievements,
  $a_last_run 
)
protected

Send news mail for 1 user and n objects.

Parameters
int$a_user_id
array$a_objects
string$a_last_run

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

169 {
172 $ilClientIniFile = $this->client_ini;
174
175 include_once "./Services/Notification/classes/class.ilSystemNotification.php";
176 $ntf = new ilSystemNotification();
177 $ntf->setLangModules(array("skll"));
178
179 // user specific language
180 $lng = $ntf->getUserLanguage($a_user_id);
181
182 include_once './Services/Locator/classes/class.ilLocatorGUI.php';
183 require_once "./Services/UICore/classes/class.ilTemplate.php";
184 require_once "./Services/Link/classes/class.ilLink.php";
185
186
187 $tmp = array();
188 $txt = "";
189 $last_obj_id = 0;
190
191 // order skill achievements per virtual skill tree
192 include_once("./Services/Skill/classes/class.ilVirtualSkillTree.php");
193 $vtree = new ilVirtualSkillTree();
194 $a_achievements = $vtree->getOrderedNodeset($a_achievements, "skill_id", "tref_id");
195
196 foreach ($a_achievements as $skill_level) {
197 $parent = array();
198
199 // path
200 $path = array();
201 foreach ($tree->getPathId($skill_level["trigger_ref_id"]) as $node) {
202 $path[] = $node;
203 }
204 $path = implode("-", $path);
205
206 $ref_id = $skill_level["trigger_ref_id"];
207 $obj_id = $skill_level["trigger_obj_id"];
208 $type = $skill_level["trigger_obj_type"];
209 $title = $skill_level["trigger_title"];
210
211 if ($skill_level["trigger_obj_id"] != $last_obj_id) {
212 $last_obj_id = $skill_level["trigger_obj_id"];
213 $txt .= "\n\n" . $lng->txt("obj_" . $type) . ": " . $title;
214 if ($tree->isInTree($ref_id)) {
215 $txt .= "\n" . ilLink::_getStaticLink($ref_id);
216 }
217 }
218
219 $date = ilDatePresentation::formatDate(new ilDateTime($skill_level["status_date"], IL_CAL_DATETIME));
220 $txt.= "\n $date, " . ilBasicSkill::_lookupTitle($skill_level["skill_id"], $skill_level["tref_id"]) . ": " .
221 ilBasicSkill::lookupLevelTitle($skill_level["level_id"]);
222 }
223
224 $ntf->setIntroductionLangId("skll_intro_skill_notification_for");
225
226 // index
227 $period = sprintf(
228 $lng->txt("skll_new_skill_achievements"),
231 );
232
233 // text
234 $ntf->addAdditionalInfo(
235 "",
236 trim($txt),
237 true
238 );
239
240 // :TODO: does it make sense to add client to subject?
241 $client = $ilClientIniFile->readVariable('client', 'name');
242 $subject = sprintf($lng->txt("skll_competence_achievements"), $client);
243
244 //die($ntf->composeAndGetMessage($a_user_id, null, "read", true));
245
246 // #10044
247 $mail = new ilMail(ANONYMOUS_USER_ID);
248 $mail->enableSOAP(false); // #10410
249 $mail->sendMail(
250 ilObjUser::_lookupLogin($a_user_id),
251 null,
252 null,
253 $subject,
254 $ntf->composeAndGetMessage($a_user_id, null, "read", true),
255 null,
256 array("system")
257 );
258 }
sprintf('%.4f', $callTime)
$client
Definition: resume.php:9
const IL_CAL_UNIX
const IL_CAL_DATETIME
static lookupLevelTitle($a_id)
Lookup level title.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
@classDescription Date and time handling
This class handles base functions for mail handling.
static _lookupLogin($a_user_id)
lookup login
static _lookupTitle($a_obj_id, $a_tref_id=0)
Lookup Title.
Wrapper classes for system notifications.
$txt
Definition: error.php:11
$type
$ilUser
Definition: imgupload.php:18

References $client, $client_ini, $ilUser, $lng, $path, $title, $tree, $txt, $type, $user, ilLink\_getStaticLink(), ilObjUser\_lookupLogin(), ilSkillTreeNode\_lookupTitle(), ilDatePresentation\formatDate(), IL_CAL_DATETIME, IL_CAL_UNIX, ilBasicSkill\lookupLevelTitle(), and sprintf.

Referenced by run().

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

Field Documentation

◆ $client_ini

ilSkillNotifications::$client_ini
protected

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

Referenced by sendMail().

◆ $lng

ilSkillNotifications::$lng
protected

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

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

◆ $tree

ilSkillNotifications::$tree
protected

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

Referenced by sendMail().

◆ $user

ilSkillNotifications::$user
protected

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

Referenced by sendMail().


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