ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilMembershipCronNotifications Class Reference

Course/group notifications. More...

+ Inheritance diagram for ilMembershipCronNotifications:
+ Collaboration diagram for ilMembershipCronNotifications:

Public Member Functions

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

Protected Member Functions

 sendMail ($a_user_id, $a_ref_id, array $news)
 Send news mail for 1 object and 1 user.
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)

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 notifications.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

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

Member Function Documentation

ilMembershipCronNotifications::activationWasToggled (   $a_currently_active)

Cron job status was changed.

Parameters
bool$a_currently_active

Reimplemented from ilCronJob.

Definition at line 250 of file class.ilMembershipCronNotifications.php.

References $ilSetting.

{
global $ilSetting;
// propagate cron-job setting to object setting
$ilSetting->set("crsgrp_ntf", (bool)$a_currently_active);
}
ilMembershipCronNotifications::addToExternalSettingsForm (   $a_form_id,
array &  $a_fields,
  $a_is_active 
)

Add external settings to form.

Parameters
int$a_form_id
array$a_fields
bool$a_is_active

Reimplemented from ilCronJob.

Definition at line 235 of file class.ilMembershipCronNotifications.php.

References $lng, ilAdministrationSettingsFormHandler\FORM_COURSE, and ilAdministrationSettingsFormHandler\FORM_GROUP.

{
global $lng;
switch($a_form_id)
{
$a_fields["enable_course_group_notifications"] = $a_is_active ?
$lng->txt("enabled") :
$lng->txt("disabled");
break;
}
}
ilMembershipCronNotifications::getDefaultScheduleType ( )

Get schedule type.

Returns
int

Reimplemented from ilCronJob.

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

References ilCronJob\SCHEDULE_TYPE_DAILY.

ilMembershipCronNotifications::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

Reimplemented from ilCronJob.

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

{
return;
}
ilMembershipCronNotifications::getDescription ( )

Get description.

Returns
string

Reimplemented from ilCronJob.

Definition at line 26 of file class.ilMembershipCronNotifications.php.

References $lng.

{
global $lng;
return $lng->txt("enable_course_group_notifications_desc");
}
ilMembershipCronNotifications::getId ( )

Get id.

Returns
string

Reimplemented from ilCronJob.

Definition at line 14 of file class.ilMembershipCronNotifications.php.

Referenced by run().

{
return "mem_notification";
}

+ Here is the caller graph for this function:

ilMembershipCronNotifications::getTitle ( )

Get title.

Returns
string

Reimplemented from ilCronJob.

Definition at line 19 of file class.ilMembershipCronNotifications.php.

References $lng.

{
global $lng;
return $lng->txt("enable_course_group_notifications");
}
ilMembershipCronNotifications::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

Reimplemented from ilCronJob.

Definition at line 43 of file class.ilMembershipCronNotifications.php.

{
return false;
}
ilMembershipCronNotifications::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

Reimplemented from ilCronJob.

Definition at line 48 of file class.ilMembershipCronNotifications.php.

{
return false;
}
ilMembershipCronNotifications::run ( )

Run job.

Returns
ilCronJobResult

Reimplemented from ilCronJob.

Definition at line 53 of file class.ilMembershipCronNotifications.php.

References $ilDB, $lng, $ref_id, $result, $row, ilObject\_lookupType(), getId(), ilCronManager\ping(), sendMail(), ilCronJobResult\STATUS_NO_ACTION, and ilCronJobResult\STATUS_OK.

{
global $lng, $ilDB;
$status_details = null;
$setting = new ilSetting("cron");
$last_run = $setting->get(get_class($this));
// #10284 - we already did send today, do nothing
if($last_run == date("Y-m-d"))
{
// #14005
$status_details = "Did already run today.";
}
else
{
// gather objects and participants with notification setting
$objects = array();
$set = $ilDB->query("SELECT usr_id,keyword FROM usr_pref".
" WHERE ".$ilDB->like("keyword", "text", "grpcrs_ntf_%").
" AND value = ".$ilDB->quote("1", "text"));
while($row = $ilDB->fetchAssoc($set))
{
$ref_id = substr($row["keyword"], 11);
if($type)
{
$objects[$type][$ref_id][] = $row["usr_id"];
}
}
$counter = 0;
if(sizeof($objects))
{
$old_lng = $lng;
include_once "Services/News/classes/class.ilNewsItem.php";
foreach($objects as $type => $ref_ids)
{
// type is not needed for now
foreach($ref_ids as $ref_id => $user_ids)
{
// gather news per object
$news_item = new ilNewsItem();
if($news_item->checkNewsExistsForGroupCourse($ref_id))
{
foreach($user_ids as $user_id)
{
// gather news for user
$user_news = $news_item->getNewsForRefId($ref_id,
false, false, 1, false, false, false, false,
$user_id);
if($user_news)
{
$this->sendMail($user_id, $ref_id, $user_news);
$counter++;
// #17928
}
}
}
}
}
$lng = $old_lng;
}
// save last run
$setting->set(get_class($this), date("Y-m-d"));
if($counter)
{
}
}
$result->setStatus($status);
if($status_details)
{
$result->setMessage($status_details);
}
return $result;
}

+ Here is the call graph for this function:

ilMembershipCronNotifications::sendMail (   $a_user_id,
  $a_ref_id,
array  $news 
)
protected

Send news mail for 1 object and 1 user.

Parameters
int$a_user_id
int$a_ref_id
array$news

Definition at line 150 of file class.ilMembershipCronNotifications.php.

References $ilUser, $lng, $txt, ilObjUser\_lookupLogin(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilNewsItem\determineNewsContent(), ilNewsItem\determineNewsTitle(), and ilMail\enableSOAP().

Referenced by run().

{
global $lng, $ilUser;
$obj_id = ilObject::_lookupObjId($a_ref_id);
$obj_type = ilObject::_lookupType($obj_id);
include_once "./Services/Notification/classes/class.ilSystemNotification.php";
$ntf = new ilSystemNotification();
$ntf->setLangModules(array("crs", "news"));
$ntf->setRefId($a_ref_id);
$ntf->setGotoLangId('url');
$ntf->setSubjectLangId('crs_subject_course_group_notification');
// user specific language
$lng = $ntf->getUserLanguage($a_user_id);
$obj_title = $lng->txt($obj_type)." \"".ilObject::_lookupTitle($obj_id)."\"";
$ntf->setIntroductionDirect(sprintf($lng->txt("crs_intro_course_group_notification_for"), $obj_title));
$subject = sprintf($lng->txt("crs_subject_course_group_notification"), $obj_title);
// news summary
$counter = 1;
$txt = "";
foreach($news as $item)
{
$title = ilNewsItem::determineNewsTitle($item["context_obj_type"],
$item["title"], $item["content_is_lang_var"], $item["agg_ref_id"],
$item["aggregation"]);
$content = ilNewsItem::determineNewsContent($item["context_obj_type"],
$item["content"], $item["content_text_is_lang_var"]);
$obj_id = ilObject::_lookupObjId($item["ref_id"]);
$obj_title = ilObject::_lookupTitle($obj_id);
// path
include_once './Services/Locator/classes/class.ilLocatorGUI.php';
$cont_loc = new ilLocatorGUI();
$cont_loc->addContextItems($item["ref_id"], true);
$cont_loc->setTextOnly(true);
// #9954/#10044
// see ilInitialisation::requireCommonIncludes()
@include_once "HTML/Template/ITX.php"; // new implementation
if (class_exists("HTML_Template_ITX"))
{
include_once "./Services/UICore/classes/class.ilTemplateHTMLITX.php";
}
else
{
include_once "HTML/ITX.php"; // old implementation
include_once "./Services/UICore/classes/class.ilTemplateITX.php";
}
require_once "./Services/UICore/classes/class.ilTemplate.php";
$loc = "[".$cont_loc->getHTML()."]";
if($counter > 1)
{
$txt .= $ntf->getBlockBorder();
}
$txt .= '#'.$counter." - ".$loc." ".$obj_title."\n\n";
$txt .= $title;
if($content)
{
$txt .= "\n".$content;
}
$txt .= "\n\n";
++$counter;
}
$ntf->addAdditionalInfo("news", $txt, true);
// #10044
$mail = new ilMail($ilUser->getId());
$mail->enableSOAP(false); // #10410
$mail->sendMail(ilObjUser::_lookupLogin($a_user_id),
null,
null,
$subject,
$ntf->composeAndGetMessage($a_user_id, null, "read", true),
null,
array("system"));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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