5include_once 
"Services/Cron/classes/class.ilCronJob.php";
 
   16        return "mem_notification";
 
   23        return $lng->txt(
"enable_course_group_notifications");
 
   30        return $lng->txt(
"enable_course_group_notifications_desc");
 
   58        $log->debug(
"===Member Notifications=== start");
 
   61        $status_details = 
null;
 
   64        $last_run = $setting->get(get_class($this));
 
   68            $last_run = 
date(
"Y-m-d H:i:s", strtotime(
"yesterday"));
 
   70            $status_details = 
"No previous run found - starting from yesterday.";
 
   73        elseif (strlen($last_run) == 10) {
 
   74            $last_run .= 
" 00:00:00";
 
   76            $status_details = 
"Switched from daily runs to open schedule.";
 
   79        include_once 
"Services/Membership/classes/class.ilMembershipNotifications.php";
 
   82        if (
sizeof($objects)) {
 
   83            $log->debug(
"nr of objects: " . count($objects));
 
   87            $user_news_aggr = array();
 
   89            include_once 
"Services/News/classes/class.ilNewsItem.php";
 
   90            foreach ($objects as $ref_id => $user_ids) {
 
   91                $log->debug(
"handle ref id " . $ref_id . 
", users: " . count($user_ids));
 
   95                if ($news_item->checkNewsExistsForGroupCourse($ref_id, $last_run)) {
 
   96                    foreach ($user_ids as $user_id) {
 
   98                        $user_news = $news_item->getNewsForRefId(
 
  110                            $user_news_aggr[$user_id][$ref_id] = $user_news;
 
  120            $log->debug(
"prepare sending mails");
 
  128            if (
sizeof($user_news_aggr)) {
 
  129                foreach ($user_news_aggr as $user_id => $user_news) {
 
  130                    $log->debug(
"sending mails to user " . $user_id . 
", nr news: " . count($user_news));
 
  132                    $this->
sendMail($user_id, $user_news, $last_run);
 
  146        $log->debug(
"save run");
 
  149        $setting->set(get_class($this), 
date(
"Y-m-d H:i:s"));
 
  154        if ($status_details) {
 
  155            $result->setMessage($status_details);
 
  158        $log->debug(
"===Member Notifications=== done");
 
  172    protected function parseNewsItem($a_parent_ref_id, array &$a_filter_map, array $a_item, $a_is_sub = 
false)
 
  176        $lng->loadLanguageModule(
"news");
 
  178        $wrong_parent = (array_key_exists($a_item[
"id"], $a_filter_map) &&
 
  179                $a_parent_ref_id != $a_filter_map[$a_item[
"id"]]);
 
  187        $item_obj_type = $a_item[
"context_obj_type"];
 
  191        if ($a_item[
"aggregation"]) {
 
  193            if ($item_obj_type == 
"file" &&
 
  194                sizeof($a_item[
"aggregation"]) == 1) {
 
  199                foreach ($a_item[
"aggregation"] as $subitem) {
 
  200                    $sub_res = $this->
parseNewsItem($a_parent_ref_id, $a_filter_map, $subitem, 
true);
 
  202                        $sub[md5($sub_res)] = $sub_res;
 
  210                $a_item[
"context_obj_type"],
 
  212                $a_item[
"content_is_lang_var"],
 
  213                $a_item[
"agg_ref_id"],
 
  214                $a_item[
"aggregation"]
 
  218                $a_item[
"context_obj_type"],
 
  220                $a_item[
"content_is_lang_var"]
 
  225            $a_item[
"context_obj_type"],
 
  227            $a_item[
"content_text_is_lang_var"]
 
  236        switch ($item_obj_type) {
 
  239                    $res =  
$lng->txt(
"obj_" . $item_obj_type) .
 
  240                        ' "' . $item_obj_title . 
'": ' . 
$title;
 
  242                    $res .= 
'"' . 
$title . 
'": "' . $content . 
'"';
 
  247                if (!is_array($a_item[
"aggregation"]) ||
 
  248                    sizeof($a_item[
"aggregation"]) == 1) {
 
  249                    $res =  
$lng->txt(
"obj_" . $item_obj_type) .
 
  250                        ' "' . $item_obj_title . 
'" - ' . 
$title;
 
  254                        " " . 
sizeof($a_item[
"aggregation"]) . 
" ",
 
  255                        " " . 
sizeof($sub) . 
" ",
 
  263                $res = 
$lng->txt(
"obj_" . $item_obj_type) .
 
  264                    ' "' . $item_obj_title . 
'"';
 
  269                    $res .= 
' - ' . $content;
 
  278        if (is_array($sub) && 
sizeof($sub)) {
 
  279            $res .= 
"\n" . implode(
"\n", $sub);
 
  295        $parent_map = $news_map = $parsed_map = array();
 
  298        foreach ($a_objects as $parent_ref_id => $news) {
 
  299            foreach ($news as $item) {
 
  300                $news_map[$item[
"id"]] = $item[
"ref_id"];
 
  301                $parent_map[$item[
"id"]][$parent_ref_id] = $parent_ref_id;
 
  303                if ($item[
"aggregation"]) {
 
  304                    foreach ($item[
"aggregation"] as $subitem) {
 
  305                        $news_map[$subitem[
"id"]] = $subitem[
"ref_id"];
 
  306                        $parent_map[$subitem[
"id"]][$parent_ref_id] = $parent_ref_id;
 
  312        foreach ($parent_map as $news_id => $parents) {
 
  313            if (
sizeof($parents) > 1 && isset($news_map[$news_id])) {
 
  314                $path = $tree->getPathId($news_map[$news_id]);
 
  315                $lookup = array_flip(
$path);
 
  318                foreach ($parents as $parent_ref_id) {
 
  319                    $level = max($level, $lookup[$parent_ref_id]);
 
  322                $parsed_map[$news_id] = 
$path[$level];
 
  336    protected function sendMail($a_user_id, array $a_objects, $a_last_run)
 
  340        include_once 
"./Services/Notification/classes/class.ilSystemNotification.php";
 
  342        $ntf->setLangModules(array(
"crs", 
"news"));
 
  349        $lng = $ntf->getUserLanguage($a_user_id);
 
  351        include_once 
'./Services/Locator/classes/class.ilLocatorGUI.php';
 
  352        require_once 
"./Services/UICore/classes/class.ilTemplate.php";
 
  353        require_once 
"./Services/Link/classes/class.ilLink.php";
 
  358        foreach ($a_objects as $parent_ref_id => $news) {
 
  363            foreach ($tree->getPathId($parent_ref_id) as $node) {
 
  376            foreach ($news as $item) {
 
  377                $parsed_item = $this->
parseNewsItem($parent_ref_id, $filter_map, $item);
 
  379                    $parsed[md5($parsed_item)] = $parsed_item;
 
  383            if (
sizeof($parsed)) {
 
  384                $parent[
"news"] = implode(
"\n", $parsed);
 
  385                $tmp[
$path] = $parent;
 
  396        $obj_index = array();
 
  398        foreach ($tmp as 
$path => $item) {
 
  402                $item[
"url"] . 
"\n\n" .
 
  403                $item[
"news"] . 
"\n\n";
 
  405            $obj_index[] = 
"(" . 
$counter . 
") " . $item[
"title"];
 
  408        $ntf->setIntroductionLangId(
"crs_intro_course_group_notification_for");
 
  412            $lng->txt(
"crs_intro_course_group_notification_index"),
 
  416        $ntf->addAdditionalInfo(
 
  418            trim(implode(
"\n", $obj_index)),
 
  424        $ntf->addAdditionalInfo(
 
  431        $client = $ilClientIniFile->readVariable(
'client', 
'name');
 
  435        $mail = 
new ilMail(ANONYMOUS_USER_ID);
 
  436        $mail->enableSOAP(
false); 
 
  442            $ntf->composeAndGetMessage($a_user_id, 
null, 
"read", 
true),
 
  452        switch ($a_form_id) {
 
  455                $a_fields[
"enable_course_group_notifications"] = $a_is_active ?
 
  456                    $lng->txt(
"enabled") :
 
  457                    $lng->txt(
"disabled");
 
  467        $ilSetting->set(
"crsgrp_ntf", (
bool) $a_currently_active);
 
sprintf('%.4f', $callTime)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
An exception for terminatinating execution or to throw for unit testing.
Cron job result data container.
Cron job application base class.
const SCHEDULE_TYPE_DAILY
static ping($a_job_id)
Keep cron job alive.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
@classDescription Date and time handling
static _getStaticLink( $a_ref_id, $a_type='', $a_fallback_goto=true, $append="")
Get static link.
static getLogger($a_component_id)
Get component logger.
This class handles base functions for mail handling.
Course/group notifications.
getDefaultScheduleValue()
Get schedule value.
sendMail($a_user_id, array $a_objects, $a_last_run)
Send news mail for 1 user and n objects.
parseNewsItem($a_parent_ref_id, array &$a_filter_map, array $a_item, $a_is_sub=false)
Convert news item to summary html.
getDescription()
Get description.
activationWasToggled($a_currently_active)
Cron job status was changed.
getDefaultScheduleType()
Get schedule type.
filterDuplicateItems(array $a_objects)
Filter duplicate news items from structure.
addToExternalSettingsForm($a_form_id, array &$a_fields, $a_is_active)
Add external settings to form.
hasFlexibleSchedule()
Can the schedule be configured?
hasAutoActivation()
Is to be activated on "installation".
static getActiveUsersforAllObjects()
Get active notifications for all objects.
static determineNewsContent($a_context_obj_type, $a_content, $a_is_lang_var)
Determine new content.
static determineNewsTitle( $a_context_obj_type, $a_title, $a_content_is_lang_var, $a_agg_ref_id=0, $a_aggregation="")
Determine title for news item entry.
static _lookupLogin($a_user_id)
lookup login
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
static _lookupType($a_id, $a_reference=false)
lookup object type
Wrapper classes for system notifications.
static shortenText( $a_str, $a_len, $a_dots=false, $a_next_blank=false, $a_keep_extension=false)
shorten a string to given length.
foreach($_POST as $key=> $value) $res