3 declare(strict_types=1);
    63         $this->
access = $DIC->access();
    65         $this->last_run_unix = $last_run;
    66         $this->last_run_date = date(
'Y-m-d H:i:s', $last_run);
    69         $this->notes = $DIC->notes();
    76     protected function load(): void
    83         if (count($this->objects)) {
    84             $this->log->debug(
"nr of objects: " . count($this->objects));
    87             $this->user_news_aggr = array();
    89             foreach ($this->objects as 
$ref_id => $user_ids) {
    90                 $this->log->debug(
"handle ref id " . 
$ref_id . 
", users: " . count($user_ids));
    91                 $this->log->debug(
"last run unix: " . $this->last_run_unix);
    92                 $this->log->debug(
"last run date: " . $this->last_run_date);
    97                     isset($objs[
"obj_id"]) &&
    98                     is_array($objs[
"obj_id"]) &&
    99                     $news_item->checkNewsExistsForObjects($objs[
"obj_id"], $this->last_run_date)
   101                     $this->log->debug(
"Got news");
   102                     foreach ($user_ids as $user_id) {
   104                         $user_news = $news_item->getNewsForRefId(
   108                             $this->last_run_date,
   116                             $this->user_news_aggr[$user_id][
$ref_id] = $user_news;
   119                             foreach ($this->user_news_aggr as $agg_news) {
   120                                 if (isset($agg_news[
"aggregation"]) && is_array($agg_news[
"aggregation"]) && $agg_news[
"aggregation"] !== []) {
   121                                     foreach ($agg_news[
"aggregation"] as $n) {
   122                                         $this->news[$n[
"id"]] = $n;
   123                                         $this->news_per_user[$user_id][
$ref_id][$n[
"id"]] = $n[
"id"];
   125                                 } elseif (is_array($agg_news)) {
   126                                     if (isset($agg_news[
"id"])) {
   127                                         $this->news[$agg_news[
"id"]] = $agg_news;
   128                                         $this->news_per_user[$user_id][
$ref_id][$agg_news[
"id"]] = $agg_news[
"id"];
   130                                         foreach ($agg_news as $agg_news_items) {
   131                                             foreach ($agg_news_items as $agg_news_item) {
   132                                                 if (isset($agg_news_item[
"id"])) {
   133                                                     $this->news[$agg_news_item[
"id"]] = $agg_news_item;
   134                                                     $this->news_per_user[$user_id][
$ref_id][$agg_news_item[
"id"]] = $agg_news_item[
"id"];
   146                     $this->log->debug(
"Got no news");
   151                 $ref_for_obj_id = array();
   152                 foreach ($objs[
"ref_id"] as $i) {
   153                     $ref_for_obj_id[$i[
"obj_id"]][$i[
"ref_id"]] = $i[
"ref_id"];
   155                 $like_data = 
new ilLikeData(array_keys($objs[
"obj_id"]));
   156                 foreach (array_keys($objs[
"obj_id"]) as $obj_id) {
   157                     $this->log->debug(
"Get like data for obj_id: " . $obj_id);
   158                     foreach ($like_data->getExpressionEntriesForObject($obj_id, $this->last_run_date) as $like) {
   160                         foreach ($user_ids as $user_id) {
   162                             foreach ($ref_for_obj_id[$obj_id] as $perm_ref_id) {
   163                                 if ($ilAccess->checkAccessOfUser($user_id, 
"read", 
"", (
int) $perm_ref_id)) {
   169                                 $this->likes[$user_id][$like[
"news_id"]][] = $like;
   180                 foreach (array_keys($objs[
"obj_id"]) as $obj_id) {
   183                         ->getAllCommentsForObjId(
   187                     foreach ($coms as 
$c) {
   188                         $comment_context = $c->getContext();
   189                         if ($comment_context->getNewsId() === 0) {
   193                         foreach ($user_ids as $user_id) {
   195                             foreach ($ref_for_obj_id[$obj_id] as $perm_ref_id) {
   196                                 if ($ilAccess->checkAccessOfUser($user_id, 
"read", 
"", (
int) $perm_ref_id)) {
   202                                 $this->comments[$user_id][$comment_context->getNewsId()][] = 
$c;
   221         $this->log->debug(
"Check missing news: " . $user_id . 
"-" . $ref_id . 
"-" . $news_id);
   222         if (!is_array($this->news_per_user[$user_id][$ref_id] ?? null) ||
   223             !in_array($news_id, $this->news_per_user[$user_id][$ref_id])) {
   224             $this->log->debug(
"Add missing news: " . $news_id);
   225             $this->missing_news[$news_id] = $news_id;
   226             $this->missing_news_per_user[$user_id][
$ref_id][$news_id] = $news_id;
   236             $this->log->debug(
"Got missing news: " . $news[
"id"]);
   237             $this->news[$news[
"id"]] = 
$news;
   239         foreach ($this->missing_news_per_user as $user_id => 
$r) {
   241                 foreach ($n as $news_id) {
   242                     $this->log->debug(
"Load missing news: " . $user_id . 
"-" . 
$ref_id . 
"-" . $news_id);
   243                     if (isset($this->news[$news_id])) {
   244                         $this->user_news_aggr[$user_id][
$ref_id][$news_id] = $this->news[$news_id];
   245                         $this->news_per_user[$user_id][
$ref_id][$news_id] = $news_id;
   259         $tree = $DIC->repositoryTree();
   262         if (!$tree->isDeleted($a_ref_id)) {
   265             $node = $tree->getNodeData($a_ref_id);
   266             foreach ($tree->getSubTree($node) as $child) {
   267                 if ($child[
"type"] !== 
"rolf") {
   268                     $nodes[
"obj_id"][$child[
"obj_id"]] = array(
   269                         "obj_id" => $child[
"obj_id"],
   270                         "type" => $child[
"type"]
   272                     $nodes[
"ref_id"][$child[
"child"]] = array(
   273                         "ref_id" => $child[
"child"],
   274                         "obj_id" => $child[
"obj_id"],
   275                         "type" => $child[
"type"]
   287     protected function ping(): void
   291         $DIC->cron()->manager()->ping($this->cron_id);
   305     public function getLikes(
int $news_id, 
int $user_id): array
   307         if (isset($this->likes[$user_id][$news_id])) {
   308             return $this->likes[$user_id][$news_id];
   318         if (isset($this->comments[$user_id][$news_id])) {
   319             return $this->comments[$user_id][$news_id];
 
getComments(int $news_id, int $user_id)
Get comments for a news and user. 
 
static getLogger(string $a_component_id)
Get component logger. 
 
array $missing_news_per_user
 
Manage data for ilMembershipCronNotifications cron job. 
 
getLikes(int $news_id, int $user_id)
Get likes for a news and user. 
 
getObjectsForRefId(int $a_ref_id)
Get subtree object IDs for ref id. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static queryNewsByIds(array $a_news_ids)
Query news data by news ids. 
 
__construct(int $last_run, string $cron_id)
 
checkMissingNews(int $user_id, int $ref_id, int $news_id)
Get missing news*. 
 
A news item can be created by different sources. 
 
array $user_news_aggr
news array (may include aggregated news which contains news as subitems) 
 
getAggregatedNews()
Get aggregated news. 
 
static getActiveUsersforAllObjects()
Get active notifications for all objects. 
 
loadMissingNews()
Load missing news (news for new likes and/or comments)