ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilNewsItem.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4define("NEWS_NOTICE", 0);
5define("NEWS_MESSAGE", 1);
6define("NEWS_WARNING", 2);
7
8include_once("./Services/News/classes/class.ilNewsItemGen.php");
9
23{
24
25 private static $privFeedId = false;
26 private $limitation;
27
33 public function __construct($a_id = 0)
34 {
35 parent::__construct($a_id);
36 $this->limitation = true;
37 }
38
39
45 function setLimitation($a_limitation)
46 {
47 $this->limitation = $a_limitation;
48 }
49
55 function getLimitation()
56 {
57 return $this->limitation;
58 }
59
65 public function setContentTextIsLangVar($a_val = 0)
66 {
67 $this->content_text_is_lang_var = $a_val;
68 }
69
75 public function getContentTextIsLangVar()
76 {
77 return $this->content_text_is_lang_var;
78 }
79
85 function setMobPlayCounter($a_val)
86 {
87 $this->mob_cnt_play = $a_val;
88 }
89
96 {
97 return $this->mob_cnt_play;
98 }
99
105 function setMobDownloadCounter($a_val)
106 {
107 $this->mob_cnt_download = $a_val;
108 }
109
116 {
117 return $this->mob_cnt_download;
118 }
119
123 public function read()
124 {
125 global $ilDB;
126
127 $query = "SELECT * FROM il_news_item WHERE id = ".
128 $ilDB->quote($this->getId(), "integer");
129 $set = $ilDB->query($query);
130 $rec = $ilDB->fetchAssoc($set);
131
132 $this->setTitle($rec["title"]);
133 $this->setContent($rec["content"]);
134 $this->setContextObjId((int) $rec["context_obj_id"]);
135 $this->setContextObjType($rec["context_obj_type"]);
136 $this->setContextSubObjId((int) $rec["context_sub_obj_id"]);
137 $this->setContextSubObjType($rec["context_sub_obj_type"]);
138 $this->setContentType($rec["content_type"]);
139 $this->setCreationDate($rec["creation_date"]);
140 $this->setUpdateDate($rec["update_date"]);
141 $this->setUserId($rec["user_id"]);
142 $this->setVisibility($rec["visibility"]);
143 $this->setContentLong($rec["content_long"]);
144 $this->setPriority($rec["priority"]);
145 $this->setContentIsLangVar($rec["content_is_lang_var"]);
146 $this->setContentTextIsLangVar((int) $rec["content_text_is_lang_var"]);
147 $this->setMobId($rec["mob_id"]);
148 $this->setPlaytime($rec["playtime"]);
149 $this->setMobPlayCounter($rec["mob_cnt_play"]);
150 $this->setMobDownloadCounter($rec["mob_cnt_download"]);
151
152 }
153
157 function create()
158 {
159 global $ilDB;
160
161 // insert new record into db
162 $this->setId($ilDB->nextId("il_news_item"));
163 $ilDB->insert("il_news_item", array(
164 "id" => array("integer", $this->getId()),
165 "title" => array("text", $this->getTitle()),
166 "content" => array("clob", $this->getContent()),
167 "context_obj_id" => array("integer", (int) $this->getContextObjId()),
168 "context_obj_type" => array("text", $this->getContextObjType()),
169 "context_sub_obj_id" => array("integer", (int) $this->getContextSubObjId()),
170 "context_sub_obj_type" => array("text", $this->getContextSubObjType()),
171 "content_type" => array("text", $this->getContentType()),
172 "creation_date" => array("timestamp", ilUtil::now()),
173 "update_date" => array("timestamp", ilUtil::now()),
174 "user_id" => array("integer", $this->getUserId()),
175 "visibility" => array("text", $this->getVisibility()),
176 "content_long" => array("clob", $this->getContentLong()),
177 "priority" => array("integer", $this->getPriority()),
178 "content_is_lang_var" => array("integer", $this->getContentIsLangVar()),
179 "content_text_is_lang_var" => array("integer", (int) $this->getContentTextIsLangVar()),
180 "mob_id" => array("integer", $this->getMobId()),
181 "playtime" => array("text", $this->getPlaytime())
182 ));
183
184
185 $news_set = new ilSetting("news");
186 $max_items = $news_set->get("max_items");
187 if ($max_items <= 0)
188 {
189 $max_items = 50;
190 }
191
192 // limit number of news
193 if ($this->getLimitation())
194 {
195 // Determine how many rows should be deleted
196 $query = "SELECT count(*) cnt ".
197 "FROM il_news_item ".
198 "WHERE ".
199 "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
200 " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
201 " AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId(), "integer").
202 " AND ".$ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true)." ";
203
204 $set = $ilDB->query($query);
205 $rec = $ilDB->fetchAssoc($set);
206
207 // if we have more records than allowed, delete them
208 if (($rec["cnt"] > $max_items) && $this->getContextObjId() > 0)
209 {
210 $query = "SELECT * ".
211 "FROM il_news_item ".
212 "WHERE ".
213 "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
214 " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
215 " AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId(), "integer").
216 " AND ".$ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true).
217 " ORDER BY creation_date ASC";
218
219 $ilDB->setLimit($rec["cnt"] - $max_items);
220 $del_set = $ilDB->query($query);
221 while ($del_item = $ilDB->fetchAssoc($del_set))
222 {
223 $del_news = new ilNewsItem($del_item["id"]);
224 $del_news->delete();
225 }
226 }
227 }
228 }
229
235 public function update($a_as_new = false)
236 {
237 global $ilDB;
238
239 $fields = array(
240 "title" => array("text", $this->getTitle()),
241 "content" => array("clob", $this->getContent()),
242 "context_obj_id" => array("integer", $this->getContextObjId()),
243 "context_obj_type" => array("text", $this->getContextObjType()),
244 "context_sub_obj_id" => array("integer", $this->getContextSubObjId()),
245 "context_sub_obj_type" => array("text", $this->getContextSubObjType()),
246 "content_type" => array("text", $this->getContentType()),
247 "user_id" => array("integer", $this->getUserId()),
248 "visibility" => array("text", $this->getVisibility()),
249 "content_long" => array("clob", $this->getContentLong()),
250 "priority" => array("integer", $this->getPriority()),
251 "content_is_lang_var" => array("integer", $this->getContentIsLangVar()),
252 "content_text_is_lang_var" => array("integer", (int) $this->getContentTextIsLangVar()),
253 "mob_id" => array("integer", $this->getMobId()),
254 "mob_cnt_play" => array("integer", $this->getMobPlayCounter()),
255 "mob_cnt_download" => array("integer", $this->getMobDownloadCounter()),
256 "playtime" => array("text", $this->getPlaytime())
257 );
258
259 $now = ilUtil::now();
260 if ($a_as_new)
261 {
262 $fields["creation_date"] = array("timestamp", $now);
263 $fields["update_date"] = array("timestamp", $now);
264 }
265 else
266 {
267 $fields["update_date"] = array("timestamp", $now);
268 }
269
270 $ilDB->update("il_news_item", $fields, array(
271 "id" => array("integer", $this->getId())
272 ));
273
274 }
275
276
280 static function _getNewsItemsOfUser($a_user_id, $a_only_public = false,
281 $a_prevent_aggregation = false, $a_per = 0, &$a_cnt = NULL)
282 {
283 global $ilAccess;
284
285 $news_item = new ilNewsItem();
286 $news_set = new ilSetting("news");
287
288 $per = $a_per;
289
290 include_once("./Services/News/classes/class.ilNewsSubscription.php");
291 include_once("./Services/Block/classes/class.ilBlockSetting.php");
292
293 // this is currently not used
294 $ref_ids = ilNewsSubscription::_getSubscriptionsOfUser($a_user_id);
295
296 if (ilObjUser::_lookupPref($a_user_id, "pd_items_news") != "n")
297 {
298 // get all items of the personal desktop
299 $pd_items = ilObjUser::_lookupDesktopItems($a_user_id);
300 foreach($pd_items as $item)
301 {
302 if (!in_array($item["ref_id"], $ref_ids))
303 {
304 $ref_ids[] = $item["ref_id"];
305 }
306 }
307
308 // get all memberships
309 include_once 'Services/Membership/classes/class.ilParticipants.php';
310 $crs_mbs = ilParticipants::_getMembershipByType($a_user_id, 'crs');
311 $grp_mbs = ilParticipants::_getMembershipByType($a_user_id, 'grp');
312 $items = array_merge($crs_mbs, $grp_mbs);
313 foreach($items as $i)
314 {
315 $item_references = ilObject::_getAllReferences($i);
316 if(is_array($item_references) && count($item_references))
317 {
318 foreach($item_references as $ref_id)
319 {
320 if (!in_array($ref_id, $ref_ids))
321 {
322 $ref_ids[] = $ref_id;
323 }
324 }
325 }
326 }
327 }
328
329 $data = array();
330
331 foreach($ref_ids as $ref_id)
332 {
333 if (!$a_only_public)
334 {
335 // this loop should not cost too much performance
336 $acc = $ilAccess->checkAccessOfUser($a_user_id, "read", "", $ref_id);
337
338 if (!$acc)
339 {
340 continue;
341 }
342 }
343 if (ilNewsItem::getPrivateFeedId() != false) {
344 global $rbacsystem;
345 $acc = $rbacsystem->checkAccessOfUser(ilNewsItem::getPrivateFeedId(),"read", $ref_id);
346
347 if (!$acc)
348 {
349 continue;
350 }
351 }
352
354 $obj_type = ilObject::_lookupType($obj_id);
355 $news = $news_item->getNewsForRefId($ref_id, $a_only_public, false,
356 $per, $a_prevent_aggregation, false, false, false, $a_user_id);
357
358 // counter
359 if (!is_null($a_cnt))
360 {
361 $a_cnt[$ref_id] = count($news);
362 }
363
365 }
366
367 $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
368
369 return $data;
370 }
371
377 function getNewsForRefId($a_ref_id, $a_only_public = false, $a_stopnesting = false,
378 $a_time_period = 0, $a_prevent_aggregation = true, $a_forum_group_sequences = false,
379 $a_no_auto_generated = false, $a_ignore_date_filter = false, $a_user_id = null)
380 {
381 $obj_id = ilObject::_lookupObjId($a_ref_id);
382 $obj_type = ilObject::_lookupType($obj_id);
383
384 // get starting date
385 $starting_date = "";
386 if ($obj_type == "grp" || $obj_type == "crs" || $obj_type == "cat")
387 {
388 include_once("./Services/Block/classes/class.ilBlockSetting.php");
389 $hide_news_per_date = ilBlockSetting::_lookup("news", "hide_news_per_date",
390 0, $obj_id);
391 if ($hide_news_per_date && !$a_ignore_date_filter)
392 {
393 $starting_date = ilBlockSetting::_lookup("news", "hide_news_date",
394 0, $obj_id);
395 }
396 }
397
398 if ($obj_type == "cat" && !$a_stopnesting)
399 {
400 $news = $this->getAggregatedChildNewsData($a_ref_id, $a_only_public, $a_time_period,
401 $a_prevent_aggregation, $starting_date, $a_no_auto_generated);
402 }
403 else if (($obj_type == "grp" || $obj_type == "crs") &&
404 !$a_stopnesting)
405 {
406 $news = $this->getAggregatedNewsData($a_ref_id, $a_only_public, $a_time_period,
407 $a_prevent_aggregation, $starting_date, $a_no_auto_generated, $a_user_id);
408 }
409 else
410 {
411 $news_item = new ilNewsItem();
412 $news_item->setContextObjId($obj_id);
413 $news_item->setContextObjType($obj_type);
414 $news = $news_item->queryNewsForContext($a_only_public, $a_time_period,
415 $starting_date, $a_no_auto_generated);
416 $unset = array();
417 foreach ($news as $k => $v)
418 {
419 if (!$a_only_public || $v["visibility"] == NEWS_PUBLIC ||
420 ($v["priority"] == 0 &&
421 ilBlockSetting::_lookup("news", "public_notifications",
422 0, $obj_id)))
423 {
424 $news[$k]["ref_id"] = $a_ref_id;
425 }
426 else
427 {
428 $unset[] = $k;
429 }
430 }
431 foreach ($unset as $un)
432 {
433 unset($news[$un]);
434 }
435 }
436
437 if (!$a_prevent_aggregation)
438 {
439 $news = $this->aggregateForums($news);
440 }
441 else if ($a_forum_group_sequences)
442 {
443 $news = $this->aggregateForums($news, true);
444 }
445
446 return $news;
447 }
448
452 function getAggregatedNewsData($a_ref_id, $a_only_public = false, $a_time_period = 0,
453 $a_prevent_aggregation = false, $a_starting_date = "", $a_no_auto_generated = false,
454 $a_user_id = null)
455 {
456 global $tree, $ilAccess, $ilObjDataCache;
457
458 // get news of parent object
459
460 $data = array();
461
462 // get subtree
463 $cur_node = $tree->getNodeData($a_ref_id);
464
465 // do not check for lft (materialized path)
466 if($cur_node)
467 {
468 $nodes = (array) $tree->getSubTree($cur_node,true);
469 }
470 else
471 {
472 $nodes = array();
473 }
474
475 // preload object data cache
476 $ref_ids = array();
477 $obj_ids = array();
478 foreach($nodes as $node)
479 {
480 $ref_ids[] = $node["child"];
481 $obj_ids[] = $node["obj_id"];
482 }
483
484 $ilObjDataCache->preloadReferenceCache($ref_ids);
485 if (!$a_only_public)
486 {
487 include_once "Services/Object/classes/class.ilObjectActivation.php";
489 }
490
491 // no check, for which of the objects any news are available
492 $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
493 //$news_obj_ids = $obj_ids;
494
495 // get news for all subtree nodes
496 $contexts = array();
497 foreach($nodes as $node)
498 {
499 // only go on, if news are available
500 if (!in_array($node["obj_id"], $news_obj_ids))
501 {
502 continue;
503 }
504
505 if (!$a_only_public)
506 {
507 if(!$a_user_id)
508 {
509 $acc = $ilAccess->checkAccess("read", "", $node["child"]);
510 }
511 else
512 {
513 $acc = $ilAccess->checkAccessOfUser($a_user_id, "read", "",
514 $node["child"]);
515 }
516 if (!$acc)
517 {
518 continue;
519 }
520 }
521
522 $ref_id[$node["obj_id"]] = $node["child"];
523 $contexts[] = array("obj_id" => $node["obj_id"],
524 "obj_type" => $node["type"]);
525 }
526
527 // sort and return
528 $news = $this->queryNewsForMultipleContexts($contexts, $a_only_public, $a_time_period,
529 $a_starting_date, $a_no_auto_generated, $a_user_id);
530
531 $to_del = array();
532 foreach ($news as $k => $v)
533 {
534 $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
535 }
536
538 $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
539
540 if (!$a_prevent_aggregation)
541 {
542 $data = $this->aggregateFiles($data, $a_ref_id);
543 }
544
545 return $data;
546 }
547
548 function aggregateForums($news, $a_group_posting_sequence = false)
549 {
550 $to_del = array();
551 $forums = array();
552
553 // aggregate
554 foreach ($news as $k => $v)
555 {
556 if ($a_group_posting_sequence && $last_aggregation_forum > 0 &&
557 $last_aggregation_forum != $news[$k]["context_obj_id"])
558 {
559 $forums[$last_aggregation_forum] = "";
560 }
561
562 if ($news[$k]["context_obj_type"] == "frm")
563 {
564 if ($forums[$news[$k]["context_obj_id"]] == "")
565 {
566 // $forums[forum_id] = news_id;
567 $forums[$news[$k]["context_obj_id"]] = $k;
568 $last_aggregation_forum = $news[$k]["context_obj_id"];
569 }
570 else
571 {
572 $to_del[] = $k;
573 }
574
575 $news[$k]["no_context_title"] = true;
576
577 // aggregate every forum into it's "k" news
578 $news[$forums[$news[$k]["context_obj_id"]]]["aggregation"][$k]
579 = $news[$k];
580 $news[$k]["agg_ref_id"]
581 = $news[$k]["ref_id"];
582 $news[$k]["content"] = "";
583 $news[$k]["content_long"] = "";
584 }
585 }
586
587 // delete double entries
588 foreach($to_del as $k)
589 {
590 unset($news[$k]);
591 }
592//var_dump($news[14]["aggregation"]);
593
594
595 return $news;
596 }
597
598 function aggregateFiles($news, $a_ref_id)
599 {
600 $first_file = "";
601 $to_del = array();
602 foreach ($news as $k => $v)
603 {
604 // aggregate file related news
605 if ($news[$k]["context_obj_type"] == "file")
606 {
607 if ($first_file == "")
608 {
609 $first_file = $k;
610 }
611 else
612 {
613 $to_del[] = $k;
614 }
615 $news[$first_file]["aggregation"][$k] = $news[$k];
616 $news[$first_file]["agg_ref_id"] = $a_ref_id;
617 $news[$first_file]["ref_id"] = $a_ref_id;
618 }
619 }
620
621 foreach($to_del as $v)
622 {
623 unset($news[$v]);
624 }
625
626 return $news;
627 }
628
629
633 function getAggregatedChildNewsData($a_ref_id, $a_only_public = false,
634 $a_time_period = 0, $a_prevent_aggregation = false, $a_starting_date = "",
635 $a_no_auto_generated = false)
636 {
637 global $tree, $ilAccess;
638
639 // get news of parent object
640 $data = $this->getNewsForRefId($a_ref_id, $a_only_public, true, $a_time_period,
641 true, false, false, $a_no_auto_generated);
642 foreach ($data as $k => $v)
643 {
644 $data[$k]["ref_id"] = $a_ref_id;
645 }
646
647 // get childs
648 $nodes = $tree->getChilds($a_ref_id);
649
650 // no check, for which of the objects any news are available
651 $obj_ids = array();
652 foreach($nodes as $node)
653 {
654 $obj_ids[] = $node["obj_id"];
655 }
656 $news_obj_ids = ilNewsItem::filterObjIdsPerNews($obj_ids, $a_time_period, $a_starting_date);
657 //$news_obj_ids = $obj_ids;
658
659 // get news for all subtree nodes
660 $contexts = array();
661 foreach($nodes as $node)
662 {
663 // only go on, if news are available
664 if (!in_array($node["obj_id"], $news_obj_ids))
665 {
666 continue;
667 }
668
669 if (!$a_only_public && !$ilAccess->checkAccess("read", "", $node["child"]))
670 {
671 continue;
672 }
673 $ref_id[$node["obj_id"]] = $node["child"];
674 $contexts[] = array("obj_id" => $node["obj_id"],
675 "obj_type" => $node["type"]);
676 }
677
678 $news = $this->queryNewsForMultipleContexts($contexts, $a_only_public, $a_time_period,
679 $a_starting_date, $a_no_auto_generated);
680 foreach ($news as $k => $v)
681 {
682 $news[$k]["ref_id"] = $ref_id[$v["context_obj_id"]];
683 }
685
686 // sort and return
687 $data = ilUtil::sortArray($data, "creation_date", "desc", false, true);
688
689 if (!$a_prevent_aggregation)
690 {
691 $data = $this->aggregateFiles($data, $a_ref_id);
692 }
693
694 return $data;
695 }
696
700 function setContext($a_obj_id, $a_obj_type, $a_sub_obj_id = 0, $a_sub_obj_type = "")
701 {
702 $this->setContextObjId($a_obj_id);
703 $this->setContextObjType($a_obj_type);
704 $this->setContextSubObjId($a_sub_obj_id);
705 $this->setContextSubObjType($a_sub_obj_type);
706 }
707
714 protected static function handleTimePeriod($a_time_period)
715 {
716 // time period is number of days
717 if(is_numeric($a_time_period))
718 {
719 if($a_time_period > 0)
720 {
721 return date('Y-m-d H:i:s', time() - ($a_time_period * 24 * 60 * 60));
722 }
723 }
724 // time period is datetime
725 else if(preg_match("/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/", $a_time_period))
726 {
727 return $a_time_period;
728 }
729 // :TODO: what to return?
730 }
731
740 public function queryNewsForContext($a_for_rss_use = false, $a_time_period = 0,
741 $a_starting_date = "", $a_no_auto_generated = false, $a_oldest_first = false, $a_limit = 0)
742 {
743 global $ilDB, $ilUser, $lng;
744
745 $and = "";
746 if ($a_time_period > 0)
747 {
748 $limit_ts = self::handleTimePeriod($a_time_period);
749 $and = " AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp")." ";
750 }
751
752 if ($a_starting_date != "")
753 {
754 $and.= " AND creation_date > ".$ilDB->quote($a_starting_date, "timestamp")." ";
755 }
756
757 if ($a_no_auto_generated)
758 {
759 $and.= " AND priority = 1 AND content_type = ".$ilDB->quote("text", "text")." ";
760 }
761
762 // this is changed with 4.1 (news table for lm pages)
763 if ($this->getContextSubObjId() > 0)
764 {
765 $and.= " AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId(), "integer").
766 " AND context_sub_obj_type = ".$ilDB->quote($this->getContextSubObjType(), "text");
767 }
768
769 $ordering = ($a_oldest_first)
770 ? " creation_date ASC, id ASC "
771 : " creation_date DESC, id DESC ";
772
773 if ($a_for_rss_use && ilNewsItem::getPrivateFeedId() == false)
774 {
775 $query = "SELECT * ".
776 "FROM il_news_item ".
777 " WHERE ".
778 "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
779 " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
780 $and.
781 " ORDER BY ".$ordering;
782 }
783 elseif (ilNewsItem::getPrivateFeedId() != false)
784 {
785 $query = "SELECT il_news_item.* ".
786 ", il_news_read.user_id user_read ".
787 "FROM il_news_item LEFT JOIN il_news_read ".
788 "ON il_news_item.id = il_news_read.news_id AND ".
789 " il_news_read.user_id = ".$ilDB->quote(ilNewsItem::getPrivateFeedId(), "integer").
790 " WHERE ".
791 "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
792 " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
793 $and.
794 " ORDER BY ".$ordering;
795 }
796 else
797 {
798 $query = "SELECT il_news_item.* ".
799 ", il_news_read.user_id as user_read ".
800 "FROM il_news_item LEFT JOIN il_news_read ".
801 "ON il_news_item.id = il_news_read.news_id AND ".
802 " il_news_read.user_id = ".$ilDB->quote($ilUser->getId(), "integer").
803 " WHERE ".
804 "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
805 " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
806 $and.
807 " ORDER BY ".$ordering;
808 }
809//echo $query;
810 $set = $ilDB->query($query);
811 $result = array();
812 while($rec = $ilDB->fetchAssoc($set))
813 {
814 if ($a_limit > 0 && count($result) >= $a_limit)
815 {
816 continue;
817 }
818 if (!$a_for_rss_use || (ilNewsItem::getPrivateFeedId() != false) || ($rec["visibility"] == NEWS_PUBLIC ||
819 ($rec["priority"] == 0 &&
820 ilBlockSetting::_lookup("news", "public_notifications",
821 0, $rec["context_obj_id"]))))
822 {
823 $result[$rec["id"]] = $rec;
824 }
825 }
826
827 // do we get data for rss and may the time limit by an issue?
828 // do a second query without time limit.
829 // this is not very performant, but I do not have a better
830 // idea. The keep_rss_min setting is currently (Jul 2012) only set
831 // by mediacasts
832 if ($a_time_period != "" && $a_for_rss_use)
833 {
834 include_once("./Services/Block/classes/class.ilBlockSetting.php");
835 $keep_rss_min = ilBlockSetting::_lookup("news", "keep_rss_min",
836 0, $this->getContextObjId());
837 if ($keep_rss_min > 0)
838 {
839 return $this->queryNewsForContext(true, 0,
840 $a_starting_date, $a_no_auto_generated, $a_oldest_first, $keep_rss_min);
841 }
842 }
843
844 return $result;
845
846 }
847
855 public function checkNewsExistsForGroupCourse($a_ref_id, $a_time_period = 1)
856 {
857 global $tree, $ilDB;
858
859 $all = array();
860
861 if(!$tree->isDeleted($a_ref_id))
862 {
863 // parse repository branch of group
864 $nodes = array();
865 $node = $tree->getNodeData($a_ref_id);
866 foreach($tree->getSubTree($node) as $child)
867 {
868 if($child["type"] != "rolf")
869 {
870 $nodes[$child["obj_id"]] = $child["type"];
871 }
872 }
873
874 $limit_ts = self::handleTimePeriod($a_time_period);
875
876 // are there any news items for relevant objects and?
877 $query = $ilDB->query("SELECT id,context_obj_id,context_obj_type".
878 " FROM il_news_item".
879 " WHERE ".$ilDB->in("context_obj_id", array_keys($nodes), false, "integer").
880 " AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp"));
881 while($rec = $ilDB->fetchAssoc($query))
882 {
883 if ($nodes[$rec["context_obj_id"]] == $rec["context_obj_type"])
884 {
885 $all[] = $rec["id"];
886 }
887 }
888 }
889
890 return $all;
891 }
892
898 public function queryNewsForMultipleContexts($a_contexts, $a_for_rss_use = false,
899 $a_time_period = 0, $a_starting_date = "", $a_no_auto_generated = false,
900 $a_user_id = null)
901 {
902 global $ilDB, $ilUser, $lng, $ilCtrl;
903
904 $and = "";
905 if ($a_time_period > 0)
906 {
907 $limit_ts = self::handleTimePeriod($a_time_period);
908 $and = " AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp")." ";
909 }
910
911 if ($a_starting_date != "")
912 {
913 $and.= " AND creation_date > ".$ilDB->quote($a_starting_date, "timestamp")." ";
914 }
915
916 if ($a_no_auto_generated)
917 {
918 $and.= " AND priority = 1 AND content_type = ".$ilDB->quote("text", "text")." ";
919 }
920
921 $ids = array();
922 $type = array();
923 foreach($a_contexts as $cont)
924 {
925 $ids[] = $cont["obj_id"];
926 $type[$cont["obj_id"]] = $cont["obj_type"];
927 }
928
929 if ($a_for_rss_use && ilNewsItem::getPrivateFeedId() == false)
930 {
931 $query = "SELECT * ".
932 "FROM il_news_item ".
933 " WHERE ".
934 $ilDB->in("context_obj_id", $ids, false, "integer")." ".
935 $and.
936 " ORDER BY creation_date DESC ";
937 }
938 elseif (ilNewsItem::getPrivateFeedId() != false)
939 {
940 $query = "SELECT il_news_item.* ".
941 ", il_news_read.user_id as user_read ".
942 "FROM il_news_item LEFT JOIN il_news_read ".
943 "ON il_news_item.id = il_news_read.news_id AND ".
944 " il_news_read.user_id = ".$ilDB->quote(ilNewsItem::getPrivateFeedId(), "integer").
945 " WHERE ".
946 $ilDB->in("context_obj_id", $ids, false, "integer")." ".
947 $and.
948 " ORDER BY creation_date DESC ";
949 }
950 else
951 {
952 if($a_user_id)
953 {
954 $user_id = $a_user_id;
955 }
956 else
957 {
958 $user_id = $ilUser->getId();
959 }
960 $query = "SELECT il_news_item.* ".
961 ", il_news_read.user_id as user_read ".
962 "FROM il_news_item LEFT JOIN il_news_read ".
963 "ON il_news_item.id = il_news_read.news_id AND ".
964 " il_news_read.user_id = ".$ilDB->quote($user_id, "integer").
965 " WHERE ".
966 $ilDB->in("context_obj_id", $ids, false, "integer")." ".
967 $and.
968 " ORDER BY creation_date DESC ";
969 }
970
971 $set = $ilDB->query($query);
972 $result = array();
973 while($rec = $ilDB->fetchAssoc($set))
974 {
975 if ($type[$rec["context_obj_id"]] == $rec["context_obj_type"])
976 {
977 if (!$a_for_rss_use || ilNewsItem::getPrivateFeedId() != false || ($rec["visibility"] == NEWS_PUBLIC ||
978 ($rec["priority"] == 0 &&
979 ilBlockSetting::_lookup("news", "public_notifications",
980 0, $rec["context_obj_id"]))))
981 {
982 $result[$rec["id"]] = $rec;
983 }
984 }
985 }
986
987 return $result;
988
989 }
990
991
995 function _setRead($a_user_id, $a_news_id)
996 {
997 global $ilDB, $ilAppEventHandler;
998
999 $ilDB->replace("il_news_read",
1000 array(
1001 "user_id" => array("integer", $a_user_id),
1002 "news_id" => array("integer", $a_news_id)
1003 ),
1004 array()
1005 );
1006
1007 /*
1008 $ilDB->manipulate("DELETE FROM il_news_read WHERE ".
1009 "user_id = ".$ilDB->quote($a_user_id, "integer").
1010 " AND news_id = ".$ilDB->quote($a_news_id, "integer"));
1011 $ilDB->manipulate("INSERT INTO il_news_read (user_id, news_id) VALUES (".
1012 $ilDB->quote($a_user_id, "integer").",".
1013 $ilDB->quote($a_news_id, "integer").")");*/
1014
1015 $ilAppEventHandler->raise("Services/News", "readNews",
1016 array("user_id" => $a_user_id, "news_ids" => array($a_news_id)));
1017 }
1018
1022 function _setUnread($a_user_id, $a_news_id)
1023 {
1024 global $ilDB, $ilAppEventHandler;
1025
1026 $ilDB->manipulate("DELETE FROM il_news_read (user_id, news_id) VALUES (".
1027 " WHERE user_id = ".$ilDB->quote($a_user_id, "integer").
1028 " AND news_id = ".$ilDB->quote($a_news_id, "integer"));
1029
1030 $ilAppEventHandler->raise("Services/News", "unreadNews",
1031 array("user_id" => $a_user_id, "news_ids" => array($a_news_id)));
1032 }
1033
1042 function mergeNews($n1, $n2)
1043 {
1044 foreach($n2 as $id => $news)
1045 {
1046 $n1[$id] = $news;
1047 }
1048
1049 return $n1;
1050 }
1051
1057 static function _getDefaultVisibilityForRefId($a_ref_id)
1058 {
1059 global $tree, $ilSetting;
1060
1061 include_once("./Services/Block/classes/class.ilBlockSetting.php");
1062
1063 $news_set = new ilSetting("news");
1064 $default_visibility = ($news_set->get("default_visibility") != "")
1065 ? $news_set->get("default_visibility")
1066 : "users";
1067
1068 if ($tree->isInTree($a_ref_id))
1069 {
1070 $path = $tree->getPathFull($a_ref_id);
1071
1072 foreach ($path as $key => $row)
1073 {
1074 if (!in_array($row["type"], array("root", "cat","crs", "fold", "grp")))
1075 {
1076 continue;
1077 }
1078
1079 $visibility = ilBlockSetting::_lookup("news", "default_visibility",
1080 0, $row["obj_id"]);
1081
1082 if ($visibility != "")
1083 {
1084 $default_visibility = $visibility;
1085 }
1086 }
1087 }
1088
1089 return $default_visibility;
1090 }
1091
1092
1097 public function delete()
1098 {
1099 global $ilDB;
1100
1101 // delete il_news_read entries
1102 $ilDB->manipulate("DELETE FROM il_news_read ".
1103 " WHERE news_id = ".$ilDB->quote($this->getId(), "integer"));
1104
1105 // delete multimedia object
1106 $mob = $this->getMobId();
1107
1108 // delete
1109 parent::delete();
1110
1111 // delete mob after news, to have a "mob usage" of 0
1112 if ($mob > 0 and ilObject::_exists($mob))
1113 {
1114 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1115 $mob = new ilObjMediaObject($mob);
1116 $mob->delete();
1117 }
1118 }
1119
1124 static public function deleteNewsOfContext($a_context_obj_id,
1125 $a_context_obj_type, $a_context_sub_obj_id = 0, $a_context_sub_obj_type = "")
1126 {
1127 global $ilDB;
1128
1129 if ($a_context_obj_id == 0 || $a_context_obj_type == "")
1130 {
1131 return;
1132 }
1133
1134 if ($a_context_sub_obj_id > 0)
1135 {
1136 $and = " AND context_sub_obj_id = ".$ilDB->quote($a_context_sub_obj_id, "integer").
1137 " AND context_sub_obj_type = ".$ilDB->quote($a_context_sub_obj_type, "text");
1138 }
1139
1140 // get news records
1141 $query = "SELECT * FROM il_news_item".
1142 " WHERE context_obj_id = ".$ilDB->quote($a_context_obj_id, "integer").
1143 " AND context_obj_type = ".$ilDB->quote($a_context_obj_type, "text").
1144 $and;
1145
1146 $news_set = $ilDB->query($query);
1147
1148 while ($news = $ilDB->fetchAssoc($news_set))
1149 {
1150 $news_obj = new ilNewsItem($news["id"]);
1151 $news_obj->delete();
1152 }
1153 }
1154
1158 static function _lookupTitle($a_news_id)
1159 {
1160 global $ilDB;
1161
1162 $query = "SELECT title FROM il_news_item WHERE id = ".
1163 $ilDB->quote($a_news_id, "integer");
1164 $set = $ilDB->query($query);
1165 $rec = $ilDB->fetchAssoc($set);
1166 return $rec["title"];
1167 }
1168
1172 static function _lookupVisibility($a_news_id)
1173 {
1174 global $ilDB;
1175
1176 $query = "SELECT visibility FROM il_news_item WHERE id = ".
1177 $ilDB->quote($a_news_id, "integer");
1178 $set = $ilDB->query($query);
1179 $rec = $ilDB->fetchAssoc($set);
1180
1181 return $rec["visibility"];
1182 }
1183
1187 static function _lookupMobId($a_news_id)
1188 {
1189 global $ilDB;
1190
1191 $query = "SELECT mob_id FROM il_news_item WHERE id = ".
1192 $ilDB->quote($a_news_id, "integer");
1193 $set = $ilDB->query($query);
1194 $rec = $ilDB->fetchAssoc($set);
1195 return $rec["mob_id"];
1196 }
1197
1201 static function filterObjIdsPerNews($a_obj_ids, $a_time_period = 0, $a_starting_date = "",$a_ending_date = '', $ignore_period = false)
1202 {
1203 global $ilDB;
1204
1205 $and = "";
1206 if ($a_time_period > 0)
1207 {
1208 $limit_ts = self::handleTimePeriod($a_time_period);
1209 $and = " AND creation_date >= ".$ilDB->quote($limit_ts, "timestamp")." ";
1210 }
1211
1212 if ($a_starting_date != "")
1213 {
1214 $and.= " AND creation_date >= ".$ilDB->quote($a_starting_date, "timestamp");
1215 }
1216
1217 $query = "SELECT DISTINCT(context_obj_id) AS obj_id FROM il_news_item".
1218 " WHERE ".$ilDB->in("context_obj_id", $a_obj_ids, false, "integer")." ".$and;
1219 //" WHERE context_obj_id IN (".implode(ilUtil::quoteArray($a_obj_ids),",").")".$and;
1220
1221 $set = $ilDB->query($query);
1222 $objs = array();
1223 while($rec = $ilDB->fetchAssoc($set))
1224 {
1225 $objs[] = $rec["obj_id"];
1226 }
1227
1228 return $objs;
1229 }
1230
1234 static function determineNewsTitle($a_context_obj_type, $a_title, $a_content_is_lang_var,
1235 $a_agg_ref_id = 0, $a_aggregation = "")
1236 {
1237 global $lng;
1238
1239 if ($a_agg_ref_id > 0)
1240 {
1241 $cnt = count($a_aggregation);
1242
1243 // forums
1244 if ($a_context_obj_type == "frm")
1245 {
1246 if ($cnt > 1)
1247 {
1248 return sprintf($lng->txt("news_x_postings"), $cnt);
1249 }
1250 else
1251 {
1252 return $lng->txt("news_1_postings");
1253 }
1254 }
1255 else // files
1256 {
1257 $up_cnt = $cr_cnt = 0;
1258 foreach($a_aggregation as $item)
1259 {
1260 if ($item["title"] == "file_updated")
1261 {
1262 $up_cnt++;
1263 }
1264 else
1265 {
1266 $cr_cnt++;
1267 }
1268 }
1269 $sep = "";
1270 if ($cr_cnt == 1)
1271 {
1272 $tit = $lng->txt("news_1_file_created");
1273 $sep = "<br />";
1274 }
1275 else if ($cr_cnt > 1)
1276 {
1277 $tit = sprintf($lng->txt("news_x_files_created"), $cr_cnt);
1278 $sep = "<br />";
1279 }
1280 if ($up_cnt == 1)
1281 {
1282 $tit .= $sep.$lng->txt("news_1_file_updated");
1283 }
1284 else if ($up_cnt > 1)
1285 {
1286 $tit .= $sep.sprintf($lng->txt("news_x_files_updated"), $up_cnt);
1287 }
1288 return $tit;
1289 }
1290 }
1291 else
1292 {
1293 if ($a_content_is_lang_var)
1294 {
1295 return $lng->txt($a_title);
1296 }
1297 else
1298 {
1299 return $a_title;
1300 }
1301 }
1302
1303 return "";
1304 }
1305
1309 static function determineNewsContent($a_context_obj_type, $a_content, $a_is_lang_var)
1310 {
1311 global $lng;
1312
1313 if ($a_is_lang_var)
1314 {
1315 $lng->loadLanguageModule($a_context_obj_type);
1316 return $lng->txt($a_content);
1317 }
1318 else
1319 {
1320 return $a_content;
1321 }
1322 }
1323
1324
1325
1329 static function getFirstNewsIdForContext($a_context_obj_id,
1330 $a_context_obj_type, $a_context_sub_obj_id = "", $a_context_sub_obj_type = "")
1331 {
1332 global $ilDB;
1333
1334 // Determine how many rows should be deleted
1335 $query = "SELECT * ".
1336 "FROM il_news_item ".
1337 "WHERE ".
1338 "context_obj_id = ".$ilDB->quote($a_context_obj_id, "integer").
1339 " AND context_obj_type = ".$ilDB->quote($a_context_obj_type, "text").
1340 " AND context_sub_obj_id = ".$ilDB->quote($a_context_sub_obj_id, "integer").
1341 " AND ".$ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true);
1342
1343 $set = $ilDB->query($query);
1344 $rec = $ilDB->fetchAssoc($set);
1345
1346 return $rec["id"];
1347 }
1348
1352 static function getLastNewsIdForContext($a_context_obj_id,
1353 $a_context_obj_type, $a_context_sub_obj_id = "", $a_context_sub_obj_type = "",
1354 $a_only_today = false)
1355 {
1356 global $ilDB;
1357
1358 // Determine how many rows should be deleted
1359 $query = "SELECT id, update_date ".
1360 "FROM il_news_item ".
1361 "WHERE ".
1362 "context_obj_id = ".$ilDB->quote($a_context_obj_id, "integer").
1363 " AND context_obj_type = ".$ilDB->quote($a_context_obj_type, "text").
1364 " AND context_sub_obj_id = ".$ilDB->quote($a_context_sub_obj_id, "integer").
1365 " AND ".$ilDB->equals("context_sub_obj_type", $a_context_sub_obj_type, "text", true).
1366 " ORDER BY update_date DESC";
1367
1368 $ilDB->setLimit(1);
1369 $set = $ilDB->query($query);
1370 $rec = $ilDB->fetchAssoc($set);
1371
1372 $id = (int) $rec["id"];
1373 if ($a_only_today)
1374 {
1375 $now = ilUtil::now();
1376 if (substr($now, 0, 10) != substr($rec["update_date"], 0, 10))
1377 {
1378 $id = 0;
1379 }
1380 }
1381
1382 return $id;
1383 }
1384
1385
1389 static function _lookupMediaObjectUsages($a_mob_id)
1390 {
1391 global $ilDB;
1392
1393 $query = "SELECT * ".
1394 "FROM il_news_item ".
1395 "WHERE ".
1396 " mob_id = ".$ilDB->quote($a_mob_id, "integer");
1397
1398 $usages = array();
1399 $set = $ilDB->query($query);
1400 while ($rec = $ilDB->fetchAssoc($set))
1401 {
1402 $usages[$rec["id"]] = array("type" => "news", "id" => $rec["id"]);
1403 }
1404
1405 return $usages;
1406 }
1407
1411 static function _lookupContextObjId($a_news_id)
1412 {
1413 global $ilDB;
1414
1415 $query = "SELECT * ".
1416 "FROM il_news_item ".
1417 "WHERE ".
1418 " id = ".$ilDB->quote($a_news_id, "integer");
1419 $set = $ilDB->query($query);
1420 $rec = $ilDB->fetchAssoc($set);
1421
1422 return $rec["context_obj_id"];
1423 }
1424
1426 {
1427 $news_set = new ilSetting("news");
1428 $per = $news_set->get("pd_period");
1429 if ($per == 0)
1430 {
1431 $per = 30;
1432 }
1433
1434 return $per;
1435 }
1436
1437 function _lookupUserPDPeriod($a_user_id)
1438 {
1439 global $ilSetting;
1440
1441 $news_set = new ilSetting("news");
1442 $allow_shorter_periods = $news_set->get("allow_shorter_periods");
1443 $allow_longer_periods = $news_set->get("allow_longer_periods");
1444 $default_per = ilNewsItem::_lookupDefaultPDPeriod();
1445
1446 include_once("./Services/Block/classes/class.ilBlockSetting.php");
1447 $per = ilBlockSetting::_lookup("pdnews", "news_pd_period",
1448 $a_user_id, 0);
1449
1450 // news period information
1451 if ($per <= 0 ||
1452 (!$allow_shorter_periods && ($per < $default_per)) ||
1453 (!$allow_longer_periods && ($per > $default_per))
1454 )
1455 {
1456 $per = $default_per;
1457 }
1458
1459 return $per;
1460 }
1461
1463 {
1464 $news_set = new ilSetting("news");
1465 $rss_period = $news_set->get("rss_period");
1466 if ($rss_period == 0) // default to two weeks
1467 {
1468 $rss_period = 14;
1469 }
1470 return $rss_period;
1471 }
1472 function setPrivateFeedId ($a_userId)
1473 {
1474 ilNewsItem::$privFeedId = $a_userId;
1475 }
1476
1477 function getPrivateFeedId () {
1478
1480 }
1481
1488 function deliverMobFile($a_purpose = "Standard", $a_increase_download_cnt = false)
1489 {
1490 $mob = $this->getMobId();
1491 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1492 $mob = new ilObjMediaObject($mob);
1493 $mob_dir = ilObjMediaObject::_getDirectory($mob->getId());
1494
1495 // check purpose
1496 if (!$mob->hasPurposeItem($a_purpose))
1497 {
1498 return false;
1499 }
1500
1501 $m_item = $mob->getMediaItem($a_purpose);
1502 if ($m_item->getLocationType() != "Reference")
1503 {
1504 $file = $mob_dir."/".$m_item->getLocation();
1505 if (file_exists($file) && is_file($file))
1506 {
1507 if ($a_increase_download_cnt)
1508 {
1509 $this->increaseDownloadCounter();
1510 }
1511 ilUtil::deliverFile($file, $m_item->getLocation(), "", false, false, false);
1512 return true;
1513 }
1514 else
1515 {
1516 ilUtil::sendFailure("File not found!",true);
1517 return false;
1518 }
1519 }
1520 else
1521 {
1522 if ($a_increase_download_cnt)
1523 {
1524 $this->increaseDownloadCounter();
1525 }
1526 ilUtil::redirect($m_item->getLocation());
1527 }
1528 }
1529
1537 {
1538 global $ilDB;
1539
1540 $cnt = $this->getMobDownloadCounter();
1541 $cnt++;
1542 $this->setMobDownloadCounter($cnt);
1543 $ilDB->manipulate("UPDATE il_news_item SET ".
1544 " mob_cnt_download = ".$ilDB->quote($cnt, "integer").
1545 " WHERE id = ".$ilDB->quote($this->getId(), "integer")
1546 );
1547 }
1548
1556 {
1557 global $ilDB;
1558
1559 $cnt = $this->getMobPlayCounter();
1560 $cnt++;
1561 $this->setMobPlayCounter($cnt);
1562 $ilDB->manipulate("UPDATE il_news_item SET ".
1563 " mob_cnt_play = ".$ilDB->quote($cnt, "integer").
1564 " WHERE id = ".$ilDB->quote($this->getId(), "integer")
1565 );
1566 }
1567
1574 static function prepareNewsDataFromCache($a_cres)
1575 {
1576 global $ilDB;
1577
1578 $data = unserialize($a_cres);
1579 $news_ids = array_keys($data);
1580 $set = $ilDB->query("SELECT id FROM il_news_item ".
1581 " WHERE ".$ilDB->in("id", $news_ids, false, "integer"));
1582 $existing_ids = array();
1583 while ($rec = $ilDB->fetchAssoc($set))
1584 {
1585 $existing_ids[] = $rec["id"];
1586 }
1587 //var_dump($existing_ids);
1588 $existing_news = array();
1589 foreach ($data as $k => $v)
1590 {
1591 if (in_array($k, $existing_ids))
1592 {
1593 $existing_news[$k] = $v;
1594 }
1595 }
1596
1597 //var_dump($data);
1598 //var_dump($existing_news);
1599
1600 return $existing_news;
1601 }
1602
1603}
1604?>
$result
print $file
const NEWS_PUBLIC
static _lookup($a_type, $a_setting, $a_user=0, $a_block_id=0)
Lookup setting from database.
A news item can be created by different sources.
getContextObjId()
Get ContextObjId.
setTitle($a_title)
Set Title.
setContentType($a_content_type="text")
Set ContentType.
getContent()
Get Content.
setCreationDate($a_creation_date)
Set CreationDate.
setVisibility($a_visibility="users")
Set Visibility.
setContextSubObjType($a_context_sub_obj_type)
Set ContextSubObjType.
setPlaytime($a_playtime)
Set Playtime.
setContentIsLangVar($a_content_is_lang_var=0)
Set ContentIsLangVar.
setUserId($a_user_id)
Set UserId.
setContextObjType($a_context_obj_type)
Set ContextObjType.
getPriority()
Get Priority.
setContextObjId($a_context_obj_id)
Set ContextObjId.
getContentType()
Get ContentType.
setContextSubObjId($a_context_sub_obj_id)
Set ContextSubObjId.
setContent($a_content)
Set Content.
setPriority($a_priority=1)
Set Priority.
setUpdateDate($a_update_date)
Set UpdateDate.
getUserId()
Get UserId.
getContextObjType()
Get ContextObjType.
setMobId($a_mob_id)
Set MobId.
getContextSubObjId()
Get ContextSubObjId.
setId($a_id)
Set Id.
getContentIsLangVar()
Get ContentIsLangVar.
getPlaytime()
Get Playtime.
getContextSubObjType()
Get ContextSubObjType.
queryNewsForContext()
Query NewsForContext.
getContentLong()
Get ContentLong.
setContentLong($a_content_long)
Set ContentLong.
getVisibility()
Get Visibility.
getAggregatedChildNewsData($a_ref_id, $a_only_public=false, $a_time_period=0, $a_prevent_aggregation=false, $a_starting_date="", $a_no_auto_generated=false)
Get news aggregation for child objects (e.g.
update($a_as_new=false)
Update item in database.
deliverMobFile($a_purpose="Standard", $a_increase_download_cnt=false)
Deliver mob file.
static _getDefaultVisibilityForRefId($a_ref_id)
Get default visibility for reference id.
static _lookupVisibility($a_news_id)
Lookup News Visibility.
static _lookupTitle($a_news_id)
Lookup News Title.
static _getNewsItemsOfUser($a_user_id, $a_only_public=false, $a_prevent_aggregation=false, $a_per=0, &$a_cnt=NULL)
Get all news items for a user.
__construct($a_id=0)
Constructor.
static getFirstNewsIdForContext($a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id="", $a_context_sub_obj_type="")
Get first new id of news set related to a certain context.
static _lookupMobId($a_news_id)
Lookup mob id.
setContext($a_obj_id, $a_obj_type, $a_sub_obj_id=0, $a_sub_obj_type="")
Convenient function to set the whole context information.
read()
Read item from database.
setMobPlayCounter($a_val)
Set mob play counter.
queryNewsForMultipleContexts($a_contexts, $a_for_rss_use=false, $a_time_period=0, $a_starting_date="", $a_no_auto_generated=false, $a_user_id=null)
Query News for multiple Contexts.
static handleTimePeriod($a_time_period)
Convert time period for DB-queries.
aggregateForums($news, $a_group_posting_sequence=false)
increasePlayCounter()
Increase play counter.
setLimitation($a_limitation)
Set Limitation for number of items.
increaseDownloadCounter()
Increase download counter.
static filterObjIdsPerNews($a_obj_ids, $a_time_period=0, $a_starting_date="", $a_ending_date='', $ignore_period=false)
Checks whether news are available for.
static determineNewsContent($a_context_obj_type, $a_content, $a_is_lang_var)
Determine new content.
_setRead($a_user_id, $a_news_id)
Set item read.
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.
checkNewsExistsForGroupCourse($a_ref_id, $a_time_period=1)
_setUnread($a_user_id, $a_news_id)
Set item unread.
static prepareNewsDataFromCache($a_cres)
Prepare news data from cache.
static deleteNewsOfContext($a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id=0, $a_context_sub_obj_type="")
Delete all news of a context.
getLimitation()
Get Limitation for number of items.
_lookupUserPDPeriod($a_user_id)
mergeNews($n1, $n2)
Merges two sets of news.
static $privFeedId
getAggregatedNewsData($a_ref_id, $a_only_public=false, $a_time_period=0, $a_prevent_aggregation=false, $a_starting_date="", $a_no_auto_generated=false, $a_user_id=null)
Get news aggregation (e.g.
setContentTextIsLangVar($a_val=0)
Set content text ist lang var.
static getLastNewsIdForContext($a_context_obj_id, $a_context_obj_type, $a_context_sub_obj_id="", $a_context_sub_obj_type="", $a_only_today=false)
Get last news id of news set related to a certain context.
getNewsForRefId($a_ref_id, $a_only_public=false, $a_stopnesting=false, $a_time_period=0, $a_prevent_aggregation=true, $a_forum_group_sequences=false, $a_no_auto_generated=false, $a_ignore_date_filter=false, $a_user_id=null)
Get News For Ref Id.
getMobPlayCounter()
Get mob play counter.
getMobDownloadCounter()
Get mob download counter.
setMobDownloadCounter($a_val)
Set mob download counter.
getContentTextIsLangVar()
Get content text ist lang var.
aggregateFiles($news, $a_ref_id)
queryNewsForContext($a_for_rss_use=false, $a_time_period=0, $a_starting_date="", $a_no_auto_generated=false, $a_oldest_first=false, $a_limit=0)
static _lookupContextObjId($a_news_id)
Context Object ID.
setPrivateFeedId($a_userId)
static _lookupMediaObjectUsages($a_mob_id)
Lookup media object usage(s)
static _getSubscriptionsOfUser($a_user_id)
Get subscriptions of user.
Class ilObjMediaObject.
_getDirectory($a_mob_id)
get directory for files of media object (static)
static _lookupDesktopItems($user_id, $a_types="")
get all desktop items of user and specified type
_lookupPref($a_usr_id, $a_keyword)
static preloadData(array $a_ref_ids)
Preload data to internal cache.
static _lookupObjId($a_id)
static _getAllReferences($a_id)
get all reference ids of object
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getMembershipByType($a_usr_id, $a_type, $a_only_member_role=false)
get membership by type Get course or group membership
ILIAS Setting Class.
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static redirect($a_script)
http redirect to other script
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static now()
Return current timestamp in Y-m-d H:i:s format.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
$data
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40
$ref_id
Definition: sahs_server.php:39
$path
Definition: index.php:22
global $ilDB
global $ilUser
Definition: imgupload.php:15