ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilForum.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once './Modules/Forum/classes/class.ilForumProperties.php';
5require_once './Modules/Forum/classes/class.ilObjForum.php';
6require_once './Modules/Forum/classes/class.ilForumTopic.php';
7require_once './Modules/Forum/classes/class.ilForumPost.php';
8
19{
20 const SORT_TITLE = 1;
21 const SORT_DATE = 2;
22
24
28 protected static $moderators_by_ref_id_map = array();
29
30 public $lng;
31 public $error;
32 public $db;
33 public $user;
34 public $settings;
35
42 private $dbTable;
43
49 private $className="ilForum";
50
57 private $orderField;
58
59 private $mdb2Query;
62
63 private $txtQuote1 = "[quote]";
64 private $txtQuote2 = "[/quote]";
65 private $replQuote1 = '<blockquote class="ilForumQuote">';
66 private $replQuote2 = '</blockquote>';
67
68 // max. datasets per page
70
71 // object id
72 private $id;
73
78 public function __construct()
79 {
80 global $DIC;
81
82 $this->error = $DIC['ilErr'];
83 $this->lng = $DIC->language();
84 $this->db = $DIC->database();
85 $this->user = $DIC->user();
86 $this->settings = $DIC->settings();
87 }
88
89 // no usage?
90 public function setLanguage($lng)
91 {
92 $this->lng = $lng;
93 }
94
105 public static function _getLanguageInstanceByUsrId($usr_id)
106 {
107 static $lngCache = array();
108
109 $languageShorthandle = ilObjUser::_lookupLanguage($usr_id);
110
111 // lookup in cache array
112 if (!isset($lngCache[$languageShorthandle])) {
113 $lngCache[$languageShorthandle] = new ilLanguage($languageShorthandle);
114 $lngCache[$languageShorthandle]->loadLanguageModule('forum');
115 }
116
117 return $lngCache[$languageShorthandle];
118 }
119
125 public function setForumId($a_obj_id)
126 {
127 if (!isset($a_obj_id)) {
128 $message = get_class($this) . "::setForumId(): No obj_id given!";
129 $this->error->raiseError($message, $this->error->WARNING);
130 }
131
132 $this->id = $a_obj_id;
133 }
134
140 public function setForumRefId($a_ref_id)
141 {
142 if (!isset($a_ref_id)) {
143 $message = get_class($this) . "::setForumRefId(): No ref_id given!";
144 $this->error->raiseError($message, $this->error->WARNING);
145 }
146
147 $this->ref_id = $a_ref_id;
148 }
149
155 public function getForumId()
156 {
157 return $this->id;
158 }
159
165 public function getForumRefId()
166 {
167 return $this->ref_id;
168 }
169
176 private function setOrderField($orderField)
177 {
178 if ($orderField == "") {
179 die($this->className . "::setOrderField(): No orderField given.");
180 } else {
181 $this->orderField = $orderField;
182 }
183 }
184
191 public function getOrderField()
192 {
193 return $this->orderField;
194 }
195
202 public function setDbTable($dbTable)
203 {
204 if ($dbTable == "") {
205 die($this->className . "::setDbTable(): No database table given.");
206 } else {
207 $this->dbTable = $dbTable;
208 }
209 }
210
217 public function getDbTable()
218 {
219 return $this->dbTable;
220 }
221
230 public function setMDB2WhereCondition($query_string, $data_type, $data_value)
231 {
232 $this->mdb2Query = $query_string;
233 $this->mdb2DataValue = $data_value;
234 $this->mdb2DataType = $data_type;
235
236 return true;
237 }
238
243 public function getMDB2Query()
244 {
245 if ($this->mdb2Query != '') {
246 return $this->mdb2Query;
247 }
248 }
249
254 public function getMDB2DataValue()
255 {
256 if ($this->mdb2DataValue != '') {
258 }
259 }
260
265 public function getMDB2DataType()
266 {
267 if ($this->mdb2DataType != '') {
268 return $this->mdb2DataType;
269 }
270 }
271
276 public function setPageHits($pageHits)
277 {
278 if ($pageHits < 1 || !is_numeric($pageHits)) {
279 $pageHits = 1;
280 }
281
282 $this->pageHits = (int) $pageHits;
283 return true;
284 }
285
292 public function getPageHits()
293 {
294 return $this->pageHits;
295 }
296
302 public function getOneTopic()
303 {
304 $data_type = array();
305 $data_value = array();
306
307 $query = 'SELECT * FROM frm_data WHERE ';
308
309 if ($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '') {
310 $query .= '' . $this->getMDB2Query() . '';
311 $data_type = $data_type + $this->getMDB2DataType();
312 $data_value = $data_value + $this->getMDB2DataValue();
313
314 $res = $this->db->queryf($query, $data_type, $data_value);
315 $row = $this->db->fetchAssoc($res);
316
317 if (is_null($row)) {
318 return null;
319 }
320
321 $row["top_name"] = trim($row["top_name"]);
322 $row["top_description"] = nl2br($row["top_description"]);
323
324 return $row;
325 } else {
326 $query .= '1 = 1';
327
328 $res = $this->db->query($query);
329 $row = $this->db->fetchAssoc($res);
330
331 if (!is_array($row) || !count($row)) {
332 return null;
333 }
334
335 $row['top_name'] = trim($row['top_name']);
336 $row['top_description'] = nl2br($row['top_description']);
337
338 return $row;
339 }
340 }
341
347 public function getOneThread()
348 {
349 $data_type = array();
350 $data_value = array();
351
352 $query = 'SELECT * FROM frm_threads WHERE ';
353
354 if ($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '') {
355 $query .= $this->getMDB2Query();
356 $data_type = $data_type + $this->getMDB2DataType();
357 $data_value = $data_value + $this->getMDB2DataValue();
358
359 $sql_res = $this->db->queryf($query, $data_type, $data_value);
360 $result = $this->db->fetchAssoc($sql_res);
361 $result["thr_subject"] = trim($result["thr_subject"]);
362 }
363
364 return $result;
365 }
366
373 public function getOnePost($post)
374 {
375 $res = $this->db->queryf(
376 '
377 SELECT frm_posts.*, usr_data.lastname FROM frm_posts, usr_data
378 WHERE pos_pk = %s
379 AND pos_display_user_id = usr_id',
380 array('integer'),
381 array($post)
382 );
383
384 $row = $this->db->fetchAssoc($res);
385
386 $row["pos_date"] = $this->convertDate($row["pos_date"]);
387 $row["pos_message"] = nl2br($row["pos_message"]);
388
389 return $row;
390 }
391
392 public static function _lookupPostMessage($a_id)
393 {
394 global $DIC;
395 $ilDB = $DIC->database();
396
397 $res = $ilDB->queryf(
398 '
399 SELECT * FROM frm_posts WHERE pos_pk = %s',
400 array('integer'),
401 array($a_id)
402 );
403
404 while ($row = $ilDB->fetchObject($res)) {
405 return $row->pos_message;
406 }
407 return '';
408 }
409
426 public function generatePost($forum_id, $thread_id, $author_id, $display_user_id, $message, $parent_pos, $notify, $subject = '', $alias = '', $date = '', $status = 1, $send_activation_mail = 0)
427 {
428 $objNewPost = new ilForumPost();
429 $objNewPost->setForumId($forum_id);
430 $objNewPost->setThreadId($thread_id);
431 $objNewPost->setSubject($subject);
432 $objNewPost->setMessage($message);
433 $objNewPost->setDisplayUserId($display_user_id);
434 $objNewPost->setUserAlias($alias);
435 $objNewPost->setPosAuthorId($author_id);
436
437 $frm_settings = ilForumProperties::getInstance($this->getForumId());
438
439 if ($frm_settings->getMarkModeratorPosts() == 1) {
440 self::_isModerator($this->getForumRefId(), $author_id) ? $is_moderator = true : $is_moderator = false;
441 } else {
442 $is_moderator = false;
443 }
444 $objNewPost->setIsAuthorModerator($is_moderator);
445
446 if ($date == "") {
447 $objNewPost->setCreateDate(date("Y-m-d H:i:s"));
448 } else {
449 if (strpos($date, "-") > 0) { // in mysql format
450 $objNewPost->setCreateDate($date);
451 } else { // a timestamp
452 $objNewPost->setCreateDate(date("Y-m-d H:i:s", $date));
453 }
454 }
455 if ($status == 1) {
456 $objNewPost->setPostActivationDate($objNewPost->getCreateDate());
457 }
458
459 $objNewPost->setImportName($this->getImportName());
460 $objNewPost->setNotification($notify);
461 $objNewPost->setStatus($status);
462 $objNewPost->insert();
463
464 // entry in tree-table
465 if ($parent_pos == 0) {
466 $this->addPostTree($objNewPost->getThreadId(), $objNewPost->getId(), $objNewPost->getCreateDate());
467 } else {
468 $this->insertPostNode($objNewPost->getId(), $parent_pos, $objNewPost->getThreadId(), $objNewPost->getCreateDate());
469 }
470
471 // string last post
472 $lastPost = $objNewPost->getForumId() . "#" . $objNewPost->getThreadId() . "#" . $objNewPost->getId();
473
474 // update thread
475 $this->db->manipulateF(
476 '
477 UPDATE frm_threads
478 SET thr_num_posts = thr_num_posts + 1,
479 thr_last_post = %s
480 WHERE thr_pk = %s',
481 array('text', 'integer'),
482 array($lastPost, $objNewPost->getThreadId())
483 );
484
485 // update forum
486 $this->db->manipulateF(
487 '
488 UPDATE frm_data
489 SET top_num_posts = top_num_posts + 1,
490 top_last_post = %s
491 WHERE top_pk = %s',
492 array('text', 'integer'),
493 array($lastPost, $objNewPost->getForumId())
494 );
495
496 // MARK READ
498 $forum_obj->markPostRead($objNewPost->getPosAuthorId(), $objNewPost->getThreadId(), $objNewPost->getId());
499
500 // Add Notification to news
501 if ($status) {
502 require_once 'Services/RTE/classes/class.ilRTE.php';
503 include_once("./Services/News/classes/class.ilNewsItem.php");
504 $news_item = new ilNewsItem();
505 $news_item->setContext($forum_obj->getId(), 'frm', $objNewPost->getId(), 'pos');
506 $news_item->setPriority(NEWS_NOTICE);
507 $news_item->setTitle($objNewPost->getSubject());
508 $news_item->setContent(ilRTE::_replaceMediaObjectImageSrc($this->prepareText($objNewPost->getMessage(), 0), 1));
509 if ($objNewPost->getMessage() != strip_tags($objNewPost->getMessage())) {
510 $news_item->setContentHtml(true);
511 }
512
513 $news_item->setUserId($display_user_id);
514 $news_item->setVisibility(NEWS_USERS);
515 $news_item->create();
516 }
517
518 return $objNewPost->getId();
519 }
520
529 public function generateThread(ilForumTopic $thread, $message, $notify, $notify_posts, $status = 1)
530 {
531 if (!$thread->getCreateDate()) {
532 $thread->setCreateDate(date('Y-m-d H:i:s'));
533 }
534
535 $thread->setImportName($this->getImportName());
536 $thread->insert();
537
538 if ($notify_posts == 1) {
539 $thread->enableNotification($thread->getThrAuthorId());
540 }
541
542 $this->db->manipulateF(
543 '
544 UPDATE frm_data
545 SET top_num_threads = top_num_threads + 1
546 WHERE top_pk = %s',
547 array('integer'),
548 array($thread->getForumId())
549 );
550
551 return $this->generatePost(
552 $thread->getForumId(),
553 $thread->getId(),
554 $thread->getThrAuthorId(),
555 $thread->getDisplayUserId(),
556 $message,
557 0,
558 $notify,
559 $thread->getSubject(),
560 $thread->getUserAlias(),
561 $thread->getCreateDate(),
562 $status,
563 0
564 );
565 }
566
576 public function moveThreads($thread_ids = array(), $src_ref_id = 0, $dest_top_frm_fk = 0)
577 {
578 $src_top_frm_fk = ilObject::_lookupObjectId($src_ref_id);
579
580 $errorMessages = array();
581
582 if (is_numeric($src_top_frm_fk) && $src_top_frm_fk > 0 && is_numeric($dest_top_frm_fk) && $dest_top_frm_fk > 0) {
583 $this->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($src_top_frm_fk));
584
585 $oldFrmData = $this->getOneTopic();
586
587 $this->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($dest_top_frm_fk));
588
589 $newFrmData = $this->getOneTopic();
590
591 if ($oldFrmData['top_pk'] && $newFrmData['top_pk']) {
592 $moved_posts = 0;
593 $moved_threads = 0;
594 $visits = 0;
595
596 foreach ($thread_ids as $id) {
597 $objTmpThread = new ilForumTopic($id);
598
599 try {
600 $numPosts = $objTmpThread->movePosts(
601 $src_top_frm_fk,
602 $oldFrmData['top_pk'],
603 $dest_top_frm_fk,
604 $newFrmData['top_pk']
605 );
606
607 if (($last_post_string = $objTmpThread->getLastPostString()) != '') {
608 $last_post_string = explode('#', $last_post_string);
609 $last_post_string[0] = $newFrmData['top_pk'];
610 $last_post_string = implode('#', $last_post_string);
611 $objTmpThread->setLastPostString($last_post_string);
612 }
613
614 $visits += $objTmpThread->getVisits();
615
616 $moved_posts += $numPosts;
617 ++$moved_threads;
618
619 $objTmpThread->setForumId($newFrmData['top_pk']);
620 $objTmpThread->update();
621
622 unset($objTmpThread);
623 } catch (\ilFileUtilsException $exception) {
624 $errorMessages[] = sprintf($this->lng->txt('frm_move_invalid_file_type'), $objTmpThread->getSubject());
625 continue;
626 }
627 }
628
629 if ($moved_threads > 0 || $moved_posts > 0 || $visits > 0) {
630 // update frm_data source forum
631 $this->db->setLimit(1);
632 $res = $this->db->queryf(
633 '
634 SELECT pos_thr_fk, pos_pk
635 FROM frm_posts
636 WHERE pos_top_fk = %s
637 ORDER BY pos_date DESC',
638 array('integer'),
639 array($oldFrmData['top_pk'])
640 );
641
642 $row = $this->db->fetchObject($res);
643 $last_post_src = $oldFrmData['top_pk'] . '#' . $row->pos_thr_fk . '#' . $row->pos_pk;
644
645 $this->db->manipulateF(
646 '
647 UPDATE frm_data
648 SET top_num_posts = top_num_posts - %s,
649 top_num_threads = top_num_threads - %s,
650 visits = visits - %s,
651 top_last_post = %s
652 WHERE top_pk = %s',
653 array('integer', 'integer', 'integer', 'text', 'integer'),
654 array( $moved_posts,
655 $moved_threads,
656 $visits,
657 $last_post_src,
658 $oldFrmData['top_pk'])
659 );
660
661 // update frm_data destination forum
662 $this->db->setLimit(1);
663 $res = $this->db->queryf(
664 '
665 SELECT pos_thr_fk, pos_pk
666 FROM frm_posts
667 WHERE pos_top_fk = %s
668 ORDER BY pos_date DESC',
669 array('integer'),
670 array($newFrmData['top_kp'])
671 );
672
673 $row = $this->db->fetchObject($res);
674 $last_post_dest = $newFrmData['top_pk'] . '#' . $row->pos_thr_fk . '#' . $row->pos_pk;
675
676 $this->db->manipulateF(
677 '
678 UPDATE frm_data
679 SET top_num_posts = top_num_posts + %s,
680 top_num_threads = top_num_threads + %s,
681 visits = visits + %s,
682 top_last_post = %s
683 WHERE top_pk = %s',
684 array('integer', 'integer', 'integer', 'text', 'integer'),
685 array($moved_posts, $moved_threads, $visits, $last_post_dest, $newFrmData['top_pk'])
686 );
687 }
688 }
689
690 return $errorMessages;
691 }
692 }
693
694
702 public function postCensorship($message, $pos_pk, $cens = 0)
703 {
704 $cens_date = date("Y-m-d H:i:s");
705
706 $this->db->manipulateF(
707 '
708 UPDATE frm_posts
709 SET pos_cens_com = %s,
710 pos_cens_date = %s,
711 pos_cens = %s,
712 update_user = %s
713 WHERE pos_pk = %s',
714 array('text', 'timestamp', 'integer', 'integer', 'integer'),
715 array($message, $cens_date, $cens, $GLOBALS['DIC']['ilUser']->getId(), $pos_pk)
716 );
717
718 // Change news item accordingly
719 include_once("./Services/News/classes/class.ilNewsItem.php");
721 $this->id,
722 "frm",
723 $pos_pk,
724 "pos"
725 );
726 if ($news_id > 0) {
727 if ($cens > 0) { // censor
728 $news_item = new ilNewsItem($news_id);
729 //$news_item->setTitle($subject);
730 $news_item->setContent(nl2br($this->prepareText($message, 0)));
731 if ($message != strip_tags($message)) {
732 $news_item->setContentHtml(true);
733 } else {
734 $news_item->setContentHtml(false);
735 }
736
737 $news_item->update();
738 } else { // revoke censorship
739 // get original message
740 $res = $this->db->queryf(
741 '
742 SELECT * FROM frm_posts
743 WHERE pos_pk = %s',
744 array('integer'),
745 array($pos_pk)
746 );
747
748 $rec = $this->db->fetchAssoc($res);
749
750 $news_item = new ilNewsItem($news_id);
751 //$news_item->setTitle($subject);
752 $news_item->setContent(nl2br($this->prepareText($rec["pos_message"], 0)));
753 if ($rec["pos_message"] != strip_tags($rec["pos_message"])) {
754 $news_item->setContentHtml(true);
755 } else {
756 $news_item->setContentHtml(false);
757 }
758
759 $news_item->update();
760 }
761 }
762
763 require_once 'Modules/Forum/classes/class.ilForumPost.php';
764 $GLOBALS['ilAppEventHandler']->raise(
765 'Modules/Forum',
766 'censoredPost',
767 array(
768 'ref_id' => $this->getForumRefId(),
769 'post' => new ilForumPost($pos_pk)
770 )
771 );
772
773 return true;
774 }
775
782 public function deletePost($post)
783 {
784 include_once "./Modules/Forum/classes/class.ilObjForum.php";
785
786 $p_node = $this->getPostNode($post);
787
788 $GLOBALS['ilAppEventHandler']->raise(
789 'Modules/Forum',
790 'deletedPost',
791 array(
792 'ref_id' => $this->getForumRefId(),
793 'post' => new ilForumPost($post),
794 'thread_deleted' => ($p_node["parent"] == 0)? true : false
795 )
796 );
797
798 // delete tree and get id's of all posts to delete
799 $del_id = $this->deletePostTree($p_node);
800
801 // delete drafts_history
802 $obj_history = new ilForumDraftsHistory();
803 $obj_history->deleteHistoryByPostIds($del_id);
804 // delete all drafts
805 $obj_draft = new ilForumPostDraft();
806 $obj_draft->deleteDraftsByPostIds($del_id);
807
808 // Delete User read entries
809 foreach ($del_id as $post_id) {
811 }
812
813 // DELETE ATTACHMENTS ASSIGNED TO POST
814 $this->__deletePostFiles($del_id);
815
816 $dead_pos = count($del_id);
817 $dead_thr = 0;
818
819 // if deletePost is thread opener ...
820 if ($p_node["parent"] == 0) {
821 // delete thread access data
822 include_once './Modules/Forum/classes/class.ilObjForum.php';
823
824 ilObjForum::_deleteAccessEntries($p_node['tree']);
825
826 // delete thread
827 $dead_thr = $p_node["tree"];
828
829 $this->db->manipulateF(
830 '
831 DELETE FROM frm_threads
832 WHERE thr_pk = %s',
833 array('integer'),
834 array($p_node['tree'])
835 );
836
837 // update num_threads
838 $this->db->manipulateF(
839 '
840 UPDATE frm_data
841 SET top_num_threads = top_num_threads - 1
842 WHERE top_frm_fk = %s',
843 array('integer'),
844 array($this->id)
845 );
846
847 // delete all related news
848 $posset = $this->db->queryf(
849 '
850 SELECT * FROM frm_posts
851 WHERE pos_thr_fk = %s',
852 array('integer'),
853 array($p_node['tree'])
854 );
855
856 while ($posrec = $this->db->fetchAssoc($posset)) {
857 include_once("./Services/News/classes/class.ilNewsItem.php");
859 $this->id,
860 "frm",
861 $posrec["pos_pk"],
862 "pos"
863 );
864 if ($news_id > 0) {
865 $news_item = new ilNewsItem($news_id);
866 $news_item->delete();
867 }
868
869 try {
870 include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
871 $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $posrec['pos_pk']);
872 foreach ($mobs as $mob) {
873 if (ilObjMediaObject::_exists($mob)) {
874 ilObjMediaObject::_removeUsage($mob, 'frm:html', $posrec['pos_pk']);
875 $mob_obj = new ilObjMediaObject($mob);
876 $mob_obj->delete();
877 }
878 }
879 } catch (Exception $e) {
880 }
881 }
882
883 // delete all posts of this thread
884 $this->db->manipulateF(
885 '
886 DELETE FROM frm_posts
887 WHERE pos_thr_fk = %s',
888 array('integer'),
889 array($p_node['tree'])
890 );
891 } else {
892 // delete this post and its sub-posts
893 for ($i = 0; $i < $dead_pos; $i++) {
894 $this->db->manipulateF(
895 '
896 DELETE FROM frm_posts
897 WHERE pos_pk = %s',
898 array('integer'),
899 array($del_id[$i])
900 );
901
902 // delete related news item
903 include_once("./Services/News/classes/class.ilNewsItem.php");
905 $this->id,
906 "frm",
907 $del_id[$i],
908 "pos"
909 );
910 if ($news_id > 0) {
911 $news_item = new ilNewsItem($news_id);
912 $news_item->delete();
913 }
914
915 try {
916 include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
917 $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $del_id[$i]);
918 foreach ($mobs as $mob) {
919 if (ilObjMediaObject::_exists($mob)) {
920 ilObjMediaObject::_removeUsage($mob, 'frm:html', $del_id[$i]);
921 $mob_obj = new ilObjMediaObject($mob);
922 $mob_obj->delete();
923 }
924 }
925 } catch (Exception $e) {
926 }
927 }
928
929 // update num_posts in frm_threads
930 $this->db->manipulateF(
931 '
932 UPDATE frm_threads
933 SET thr_num_posts = thr_num_posts - %s
934 WHERE thr_pk = %s',
935 array('integer', 'integer'),
936 array($dead_pos, $p_node['tree'])
937 );
938
939 // get latest post of thread and update last_post
940 $res1 = $this->db->queryf(
941 '
942 SELECT * FROM frm_posts
943 WHERE pos_thr_fk = %s
944 ORDER BY pos_date DESC',
945 array('integer'),
946 array($p_node['tree'])
947 );
948
949 if ($res1->numRows() == 0) {
950 $lastPost_thr = "";
951 } else {
952 $z = 0;
953
954 while ($selData = $this->db->fetchAssoc($res1)) {
955 if ($z > 0) {
956 break;
957 }
958
959 $lastPost_thr = $selData["pos_top_fk"] . "#" . $selData["pos_thr_fk"] . "#" . $selData["pos_pk"];
960 $z++;
961 }
962 }
963
964 $this->db->manipulateF(
965 '
966 UPDATE frm_threads
967 SET thr_last_post = %s
968 WHERE thr_pk = %s',
969 array('text', 'integer'),
970 array($lastPost_thr, $p_node['tree'])
971 );
972 }
973
974 // update num_posts in frm_data
975 $this->db->manipulateF(
976 '
977 UPDATE frm_data
978 SET top_num_posts = top_num_posts - %s
979 WHERE top_frm_fk = %s',
980 array('integer', 'integer'),
981 array($dead_pos, $this->id)
982 );
983
984 // get latest post of forum and update last_post
985 $res2 = $this->db->queryf(
986 '
987 SELECT * FROM frm_posts, frm_data
988 WHERE pos_top_fk = top_pk
989 AND top_frm_fk = %s
990 ORDER BY pos_date DESC',
991 array('integer'),
992 array($this->id)
993 );
994
995 if ($res2->numRows() == 0) {
996 $lastPost_top = "";
997 } else {
998 $z = 0;
999
1000 while ($selData = $this->db->fetchAssoc($res2)) {
1001 if ($z > 0) {
1002 break;
1003 }
1004
1005 $lastPost_top = $selData["pos_top_fk"] . "#" . $selData["pos_thr_fk"] . "#" . $selData["pos_pk"];
1006 $z++;
1007 }
1008 }
1009
1010 $this->db->manipulateF(
1011 '
1012 UPDATE frm_data
1013 SET top_last_post = %s
1014 WHERE top_frm_fk = %s',
1015 array('text', 'integer'),
1016 array($lastPost_top, $this->id)
1017 );
1018
1019 return $dead_thr;
1020 }
1021
1029 public function getAllThreads($a_topic_id, array $params = array(), $limit = 0, $offset = 0)
1030 {
1031 $frm_overview_setting = (int) $this->settings->get('forum_overview');
1032 $frm_props = ilForumProperties::getInstance($this->getForumId());
1033 $is_post_activation_enabled = $frm_props->isPostActivationEnabled();
1034
1035 $user_id = $this->user->getId();
1036
1037 $excluded_ids_condition = '';
1038 if (isset($params['excluded_ids']) && is_array($params['excluded_ids']) && $params['excluded_ids']) {
1039 $excluded_ids_condition = ' AND ' . $this->db->in('thr_pk', $params['excluded_ids'], true, 'integer') . ' ';
1040 }
1041
1042 if (!in_array(strtolower($params['order_column']), array('lp_date', 'rating', 'thr_subject', 'num_posts', 'num_visit'))) {
1043 $params['order_column'] = 'post_date';
1044 }
1045 if (!in_array(strtolower($params['order_direction']), array('asc', 'desc'))) {
1046 $params['order_direction'] = 'desc';
1047 }
1048
1049 $cnt_active_pos_query = '';
1050 $cnt_join_type = 'LEFT';
1051 if ($is_post_activation_enabled && !$params['is_moderator']) {
1052 $cnt_active_pos_query = " AND (pos_status = {$this->db->quote(1, 'integer')} OR pos_author_id = {$this->db->quote($user_id, 'integer')}) ";
1053 $cnt_join_type = "INNER";
1054 }
1055 $query =
1056 "SELECT COUNT(DISTINCT(thr_pk)) cnt
1057 FROM frm_threads
1058 {$cnt_join_type} JOIN frm_posts
1059 ON pos_thr_fk = thr_pk {$cnt_active_pos_query}
1060 WHERE thr_top_fk = %s {$excluded_ids_condition}
1061 ";
1062 $res = $this->db->queryF($query, array('integer'), array($a_topic_id));
1063 $cntData = $this->db->fetchAssoc($res);
1064 $cnt = (int) $cntData['cnt'];
1065
1066 $active_query = '';
1067 $active_inner_query = '';
1068 $having = '';
1069 if ($is_post_activation_enabled && !$params['is_moderator']) {
1070 $active_query = ' AND (pos_status = %s OR pos_author_id = %s) ';
1071 $active_inner_query = ' AND (ipos.pos_status = %s OR ipos.pos_author_id = %s) ';
1072 $having = ' HAVING num_posts > 0';
1073 }
1074
1075 $threads = array();
1076 $data = array();
1077 $data_types = array();
1078
1079 $optional_fields = '';
1080 if ($frm_props->isIsThreadRatingEnabled()) {
1081 $optional_fields = ',avg_rating';
1082 }
1083 if ($frm_props->getThreadSorting() == 1) {
1084 $optional_fields = ',thread_sorting';
1085 }
1086
1087 $additional_sort = '';
1088 if ($frm_props->getThreadSorting()) {
1089 $additional_sort .= ' , thread_sorting ASC ';
1090 }
1091
1092 if ($params['order_column'] == 'thr_subject') {
1093 $dynamic_columns = array(', thr_subject ' . $params['order_direction']);
1094 } elseif ($params['order_column'] == 'num_posts') {
1095 $dynamic_columns = array(', thr_num_posts ' . $params['order_direction']);
1096 } elseif ($params['order_column'] == 'num_visit') {
1097 $dynamic_columns = array(', visits ' . $params['order_direction']);
1098 } else {
1099 $dynamic_columns = array(', post_date ' . $params['order_direction']);
1100 }
1101
1102 if ($frm_props->isIsThreadRatingEnabled()) {
1103 $dynamic_columns[] = ' ,avg_rating ' . $params['order_direction'];
1104 }
1105 if ('rating' == strtolower($params['order_column'])) {
1106 $dynamic_columns = array_reverse($dynamic_columns);
1107 }
1108 $additional_sort .= implode(' ', $dynamic_columns);
1109
1110 if (!$this->user->isAnonymous()) {
1111 $query = "SELECT
1112 (CASE WHEN COUNT(DISTINCT(notification_id)) > 0 THEN 1 ELSE 0 END) usr_notification_is_enabled,
1113 MAX(pos_date) post_date,
1114 COUNT(DISTINCT(pos_pk)) num_posts,
1115 COUNT(DISTINCT(pos_pk)) - COUNT(DISTINCT(postread.post_id)) num_unread_posts, ";
1116
1117 // new posts query
1118 if ($frm_overview_setting == ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS) {
1119 $query .= "
1120 (SELECT COUNT(DISTINCT(ipos.pos_pk))
1121 FROM frm_posts ipos
1122 LEFT JOIN frm_user_read iread ON iread.post_id = ipos.pos_pk AND iread.usr_id = %s
1123 LEFT JOIN frm_thread_access iacc ON (iacc.thread_id = ipos.pos_thr_fk AND iacc.usr_id = %s)
1124 WHERE ipos.pos_thr_fk = thr_pk
1125
1126 AND (ipos.pos_update > iacc.access_old_ts
1127 OR
1128 (iacc.access_old IS NULL AND (ipos.pos_update > " . $this->db->quote(date('Y-m-d H:i:s', NEW_DEADLINE), 'timestamp') . "))
1129 )
1130
1131 AND ipos.pos_author_id != %s
1132 AND iread.usr_id IS NULL $active_inner_query
1133 ) num_new_posts, ";
1134 }
1135
1136 $query .= " thr_pk, thr_top_fk, thr_subject, thr_author_id, thr_display_user_id, thr_usr_alias, thr_num_posts, thr_last_post, thr_date, thr_update, visits, frm_threads.import_name, is_sticky, is_closed
1137 {$optional_fields}
1138 FROM frm_threads
1139
1140 LEFT JOIN frm_notification
1141 ON frm_notification.thread_id = thr_pk
1142 AND frm_notification.user_id = %s
1143
1144 LEFT JOIN frm_posts
1145 ON pos_thr_fk = thr_pk $active_query
1146
1147 LEFT JOIN frm_user_read postread
1148 ON postread.post_id = pos_pk
1149 AND postread.usr_id = %s";
1150
1151 $query .= " WHERE thr_top_fk = %s
1152 {$excluded_ids_condition}
1153 GROUP BY thr_pk, thr_top_fk, thr_subject, thr_author_id, thr_display_user_id, thr_usr_alias, thr_num_posts, thr_last_post, thr_date, thr_update, visits, frm_threads.import_name, is_sticky, is_closed
1154 {$optional_fields}
1155 {$having}
1156 ORDER BY is_sticky DESC {$additional_sort}, thr_date DESC";
1157
1158
1159 // data_types for new posts query and $active_inner_query
1160 if ($frm_overview_setting == ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS) {
1161 $data_types[] = 'integer';
1162 $data_types[] = 'integer';
1163 $data_types[] = 'integer';
1164 if ($is_post_activation_enabled && !$params['is_moderator']) {
1165 array_push($data_types, 'integer', 'integer');
1166 }
1167 }
1168 $data_types[] = 'integer';
1169 if ($is_post_activation_enabled && !$params['is_moderator']) {
1170 array_push($data_types, 'integer', 'integer');
1171 }
1172 $data_types[] = 'integer';
1173 $data_types[] = 'integer';
1174
1175 // data_values for new posts query and $active_inner_query
1176 if ($frm_overview_setting == ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS) {
1177 $data[] = $user_id;
1178 $data[] = $user_id;
1179 $data[] = $user_id;
1180 if ($is_post_activation_enabled && !$params['is_moderator']) {
1181 array_push($data, '1', $user_id);
1182 }
1183 }
1184 $data[] = $user_id;
1185 if ($is_post_activation_enabled && !$params['is_moderator']) {
1186 array_push($data, '1', $user_id);
1187 }
1188 $data[] = $user_id;
1189 $data[] = $a_topic_id;
1190 } else {
1191 $query = "SELECT
1192 0 usr_notification_is_enabled,
1193 MAX(pos_date) post_date,
1194 COUNT(DISTINCT(pos_pk)) num_posts,
1195 COUNT(DISTINCT(pos_pk)) num_unread_posts,
1196 COUNT(DISTINCT(pos_pk)) num_new_posts,
1197 thr_pk, thr_top_fk, thr_subject, thr_author_id, thr_display_user_id, thr_usr_alias, thr_num_posts, thr_last_post, thr_date, thr_update, visits, frm_threads.import_name, is_sticky, is_closed
1198 {$optional_fields}
1199 FROM frm_threads
1200
1201 LEFT JOIN frm_posts
1202 ON pos_thr_fk = thr_pk $active_query";
1203
1204 $query .= " WHERE thr_top_fk = %s
1205 {$excluded_ids_condition}
1206 GROUP BY thr_pk, thr_top_fk, thr_subject, thr_author_id, thr_display_user_id, thr_usr_alias, thr_num_posts, thr_last_post, thr_date, thr_update, visits, frm_threads.import_name, is_sticky, is_closed
1207 {$optional_fields}
1208 {$having}
1209 ORDER BY is_sticky DESC {$additional_sort}, thr_date DESC";
1210
1211 if ($is_post_activation_enabled && !$params['is_moderator']) {
1212 array_push($data_types, 'integer', 'integer');
1213 }
1214 $data_types[] = 'integer';
1215 if ($is_post_activation_enabled && !$params['is_moderator']) {
1216 array_push($data, '1', $user_id);
1217 }
1218 $data[] = $a_topic_id;
1219 }
1220
1221 if ($limit || $offset) {
1222 $this->db->setLimit($limit, $offset);
1223 }
1224 $res = $this->db->queryF($query, $data_types, $data);
1225
1226 $threadIds = [];
1227 while ($row = $this->db->fetchAssoc($res)) {
1228 $thread = new ilForumTopic($row['thr_pk'], $params['is_moderator'], true);
1229 $thread->assignData($row);
1230 $threads[$row['thr_pk']] = $thread;
1231
1232 $threadIds[] = $row['thr_pk'];
1233 }
1234
1235 $inner_last_active_post_condition = '';
1236 if ($params['is_moderator'] == false) {
1237 $inner_last_active_post_condition = "
1238 AND ( iposts.pos_status = " . $this->db->quote(1, 'integer') . "
1239 OR ( iposts.pos_status = " . $this->db->quote(0, 'integer') . "
1240 AND iposts.pos_author_id = " . $this->db->quote($this->user->getId(), 'integer') . "))";
1241 }
1242
1243 $post_res = $this->db->query(
1244 '
1245 SELECT frm_posts.*
1246 FROM frm_posts
1247 INNER JOIN (
1248 SELECT pos_thr_fk, MAX(iposts.pos_date) i_pos_date
1249 FROM frm_posts iposts
1250 WHERE ' . $this->db->in('iposts.pos_thr_fk', $threadIds, false, 'integer') . '
1251 ' . $inner_last_active_post_condition . '
1252 GROUP BY pos_thr_fk
1253 ) opost ON frm_posts.pos_thr_fk = opost.pos_thr_fk AND frm_posts.pos_date = opost.i_pos_date'
1254 );
1255
1256 while ($post_row = $this->db->fetchAssoc($post_res)) {
1257 $tmp_obj = new ilForumPost($post_row['pos_pk'], $params['is_moderator'], true);
1258
1259 $tmp_obj->setPosAuthorId($post_row['pos_author_id']);
1260 $tmp_obj->setDisplayUserId($post_row['pos_display_user_id']);
1261 $tmp_obj->setUserAlias($post_row['pos_usr_alias']);
1262 $tmp_obj->setImportName($post_row['import_name']);
1263 $tmp_obj->setId($post_row['pos_pk']);
1264 $tmp_obj->setCreateDate($post_row['pos_date']);
1265
1266 $threads[$post_row['pos_thr_fk']]->setLastPostForThreadOverview($tmp_obj);
1267 }
1268
1269 return array('items' => $threads,'cnt' => $cnt);
1270 }
1271
1276 public function getUserStatistic($is_moderator = false)
1277 {
1278 $statistic = array();
1279
1280 $data_types = array();
1281 $data = array();
1282
1283 $query = "SELECT COUNT(f.pos_display_user_id) ranking, u.login, p.value, u.lastname, u.firstname
1284 FROM frm_posts f
1285 INNER JOIN frm_posts_tree t
1286 ON f.pos_pk = t.pos_fk
1287 INNER JOIN frm_threads th
1288 ON t.thr_fk = th.thr_pk
1289 INNER JOIN usr_data u
1290 ON u.usr_id = f.pos_display_user_id
1291 INNER JOIN frm_data d
1292 ON d.top_pk = f.pos_top_fk
1293 LEFT JOIN usr_pref p
1294 ON p.usr_id = u.usr_id AND p.keyword = %s
1295 WHERE 1 = 1";
1296
1297 array_push($data_types, 'text');
1298 array_push($data, 'public_profile');
1299
1300 if (!$is_moderator) {
1301 $query .= ' AND (pos_status = %s
1302 OR (pos_status = %s
1303 AND pos_author_id = %s ))';
1304
1305 array_push($data_types, 'integer', 'integer', 'integer');
1306 array_push($data, '1', '0', $this->user->getId());
1307 }
1308
1309 $query .= ' AND d.top_frm_fk = %s
1310 GROUP BY pos_display_user_id, u.login, p.value,u.lastname, u.firstname';
1311
1312 array_push($data_types, 'integer');
1313 array_push($data, $this->getForumId());
1314
1315 $res = $this->db->queryf($query, $data_types, $data);
1316
1317 $counter = 0;
1318 while ($row = $this->db->fetchAssoc($res)) {
1319 $statistic[$counter][] = $row['ranking'];
1320 $statistic[$counter][] = $row['login'];
1321
1322 $lastname ='';
1323 $firstname = '';
1324 if (!$this->user->isAnonymous() && in_array($row['value'], array('y', 'g')) ||
1325 $this->user->isAnonymous() && 'g' == $row['value']) {
1326 $lastname = $row['lastname'];
1327 $firstname = $row['firstname'];
1328 }
1329
1330 $statistic[$counter][] = $lastname;
1331 $statistic[$counter][] = $firstname;
1332
1333 ++$counter;
1334 }
1335
1336 return is_array($statistic) ? $statistic : array();
1337 }
1338
1346 public function getFirstPostByThread($a_thread_id)
1347 {
1348 $res = $this->db->queryf(
1349 '
1350 SELECT * FROM frm_posts_tree
1351 WHERE thr_fk = %s
1352 AND parent_pos = %s',
1353 array('integer', 'integer'),
1354 array($a_thread_id, '0')
1355 );
1356
1357 $row = $this->db->fetchObject($res);
1358
1359 return $row->pos_fk ? $row->pos_fk : 0;
1360 }
1361
1368 public function getModerators()
1369 {
1370 return self::_getModerators($this->getForumRefId());
1371 }
1372
1380 public static function _getModerators($a_ref_id)
1381 {
1382 global $DIC;
1383 $rbacreview = $DIC->rbac()->review();
1384
1385 $role_arr = $rbacreview->getRolesOfRoleFolder($a_ref_id);
1386 foreach ($role_arr as $role_id) {
1387 if (ilObject::_lookupTitle($role_id) == 'il_frm_moderator_' . $a_ref_id) {
1388 return $rbacreview->assignedUsers($role_id);
1389 }
1390 }
1391
1392 return array();
1393 }
1394
1403 public static function _isModerator($a_ref_id, $a_usr_id)
1404 {
1405 if (!self::$moderators_by_ref_id_map[$a_ref_id]) {
1406 self::$moderators_by_ref_id_map[$a_ref_id] = self::_getModerators($a_ref_id);
1407 }
1408 return in_array($a_usr_id, self::$moderators_by_ref_id_map[$a_ref_id]);
1409 }
1410
1418 public function countUserArticles($a_user_id)
1419 {
1420 $res = $this->db->queryf(
1421 '
1422 SELECT * FROM frm_data
1423 INNER JOIN frm_posts ON pos_top_fk = top_pk
1424 WHERE top_frm_fk = %s
1425 AND pos_author_id = %s',
1426 array('integer', 'integer'),
1427 array($this->getForumId(), $a_user_id)
1428 );
1429
1430 return $res->numRows();
1431 }
1432
1433 public function countActiveUserArticles($a_user_id)
1434 {
1435 $res = $this->db->queryf(
1436 '
1437 SELECT * FROM frm_data
1438 INNER JOIN frm_posts ON pos_top_fk = top_pk
1439 WHERE top_frm_fk = %s
1440 AND (pos_status = %s
1441 OR (pos_status = %s
1442 AND pos_author_id = %s
1443 )
1444 )
1445 AND pos_author_id = %s',
1446 array('integer', 'integer', 'integer', 'integer', 'integer'),
1447 array($this->getForumId(),'1', '0', $this->user->getId(), $a_user_id)
1448 );
1449
1450 return $res->numRows();
1451 }
1452
1459 public function convertDate($date)
1460 {
1462 }
1463
1471 public function addPostTree($a_tree_id, $a_node_id = -1, $a_date = '')
1472 {
1473 $a_date = $a_date ? $a_date : date("Y-m-d H:i:s");
1474
1475 if ($a_node_id <= 0) {
1476 $a_node_id = $a_tree_id;
1477 }
1478
1479 $nextId = $this->db->nextId('frm_posts_tree');
1480
1481 $this->db->manipulateF(
1482 '
1483 INSERT INTO frm_posts_tree
1484 ( fpt_pk,
1485 thr_fk,
1486 pos_fk,
1487 parent_pos,
1488 lft,
1489 rgt,
1490 depth,
1491 fpt_date
1492 )
1493 VALUES(%s, %s, %s, %s, %s, %s, %s, %s )',
1494 array('integer','integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'timestamp'),
1495 array($nextId, $a_tree_id, $a_node_id, '0', '1', '2', '1', $a_date)
1496 );
1497
1498 return true;
1499 }
1500
1508 public function insertPostNode($a_node_id, $a_parent_id, $tree_id, $a_date = '')
1509 {
1510 $a_date = $a_date ? $a_date : date("Y-m-d H:i:s");
1511
1512 // get left value
1513 $sql_res = $this->db->queryf(
1514 '
1515 SELECT * FROM frm_posts_tree
1516 WHERE pos_fk = %s
1517 AND thr_fk = %s',
1518 array('integer', 'integer'),
1519 array($a_parent_id, $tree_id)
1520 );
1521
1522 $res = $this->db->fetchObject($sql_res);
1523
1524 $left = $res->lft;
1525
1526 $lft = $left + 1;
1527 $rgt = $left + 2;
1528
1529 // spread tree
1530 $this->db->manipulateF(
1531 '
1532 UPDATE frm_posts_tree
1533 SET lft = CASE
1534 WHEN lft > %s
1535 THEN lft + 2
1536 ELSE lft
1537 END,
1538 rgt = CASE
1539 WHEN rgt > %s
1540 THEN rgt + 2
1541 ELSE rgt
1542 END
1543 WHERE thr_fk = %s',
1544 array('integer', 'integer', 'integer'),
1545 array($left, $left, $tree_id)
1546 );
1547
1548 $depth = $this->getPostDepth($a_parent_id, $tree_id) + 1;
1549
1550 // insert node
1551 $nextId = $this->db->nextId('frm_posts_tree');
1552 $this->db->manipulateF(
1553 '
1554 INSERT INTO frm_posts_tree
1555 ( fpt_pk,
1556 thr_fk,
1557 pos_fk,
1558 parent_pos,
1559 lft,
1560 rgt,
1561 depth,
1562 fpt_date
1563 )
1564 VALUES(%s,%s,%s, %s, %s, %s,%s, %s)',
1565 array('integer','integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'timestamp'),
1566 array( $nextId,
1567 $tree_id,
1568 $a_node_id,
1569 $a_parent_id,
1570 $lft,
1571 $rgt,
1572 $depth,
1573 $a_date)
1574 );
1575 }
1576
1584 public function getPostDepth($a_node_id, $tree_id)
1585 {
1586 if ($tree_id) {
1587 $sql_res = $this->db->queryf(
1588 '
1589 SELECT depth FROM frm_posts_tree
1590 WHERE pos_fk = %s
1591 AND thr_fk = %s',
1592 array('integer', 'integer'),
1593 array($a_node_id, $tree_id)
1594 );
1595
1596 $res = $this->db->fetchObject($sql_res);
1597
1598 return $res->depth;
1599 } else {
1600 return 0;
1601 }
1602 }
1603
1610 public function getFirstPostNode($tree_id)
1611 {
1612 $res = $this->db->queryf(
1613 '
1614 SELECT * FROM frm_posts, frm_posts_tree
1615 WHERE pos_pk = pos_fk
1616 AND parent_pos = %s
1617 AND thr_fk = %s',
1618 array('integer', 'integer'),
1619 array('0', $tree_id)
1620 );
1621
1622 $row = $this->db->fetchObject($res);
1623
1624 return $this->fetchPostNodeData($row);
1625 }
1626
1633 public function getPostNode($post_id)
1634 {
1635 $res = $this->db->queryf(
1636 '
1637 SELECT * FROM frm_posts, frm_posts_tree
1638 WHERE pos_pk = pos_fk
1639 AND pos_pk = %s',
1640 array('integer'),
1641 array($post_id)
1642 );
1643
1644 $row = $this->db->fetchObject($res);
1645
1646 return $this->fetchPostNodeData($row);
1647 }
1648
1655 public function fetchPostNodeData($a_row)
1656 {
1657 require_once('./Services/User/classes/class.ilObjUser.php');
1658
1659 if (ilObject::_exists($a_row->pos_display_user_id)) {
1660 $tmp_user = new ilObjUser($a_row->pos_display_user_id);
1661 $fullname = $tmp_user->getFullname();
1662 $loginname = $tmp_user->getLogin();
1663 }
1664
1665 $fullname = $fullname ? $fullname : ($a_row->import_name ? $a_row->import_name : $this->lng->txt("unknown"));
1666
1667 $data = array(
1668 "pos_pk" => $a_row->pos_pk,
1669 "child" => $a_row->pos_pk,
1670 "author" => $a_row->pos_display_user_id,
1671 "alias" => $a_row->pos_usr_alias,
1672 "title" => $fullname,
1673 "loginname" => $loginname,
1674 "type" => "post",
1675 "message" => $a_row->pos_message,
1676 "subject" => $a_row->pos_subject,
1677 "pos_cens_com" => $a_row->pos_cens_com,
1678 "pos_cens" => $a_row->pos_cens,
1679 // "date" => $a_row->date,
1680 "date" => $a_row->fpt_date,
1681 "create_date" => $a_row->pos_date,
1682 "update" => $a_row->pos_update,
1683 "update_user" => $a_row->update_user,
1684 "tree" => $a_row->thr_fk,
1685 "parent" => $a_row->parent_pos,
1686 "lft" => $a_row->lft,
1687 "rgt" => $a_row->rgt,
1688 "depth" => $a_row->depth,
1689 "id" => $a_row->fpt_pk,
1690 "notify" => $a_row->notify,
1691 "import_name" => $a_row->import_name,
1692 "pos_status" => $a_row->pos_status
1693 );
1694
1695 return $data ? $data : array();
1696 }
1697
1704 public function deletePostTree($a_node)
1705 {
1706 // GET LEFT AND RIGHT VALUES
1707 $res = $this->db->queryf(
1708 '
1709 SELECT * FROM frm_posts_tree
1710 WHERE thr_fk = %s
1711 AND pos_fk = %s
1712 AND parent_pos = %s',
1713 array('integer', 'integer', 'integer'),
1714 array($a_node['tree'], $a_node['pos_pk'], $a_node['parent'])
1715 );
1716
1717 while ($row = $this->db->fetchObject($res)) {
1718 $a_node["lft"] = $row->lft;
1719 $a_node["rgt"] = $row->rgt;
1720 }
1721
1722 $diff = $a_node["rgt"] - $a_node["lft"] + 1;
1723
1724 // get data of posts
1725 $result = $this->db->queryf(
1726 '
1727 SELECT * FROM frm_posts_tree
1728 WHERE lft BETWEEN %s AND %s
1729 AND thr_fk = %s',
1730 array('integer', 'integer', 'integer'),
1731 array($a_node['lft'], $a_node['rgt'], $a_node['tree'])
1732 );
1733
1734 $del_id = array();
1735
1736 while ($treeData = $this->db->fetchAssoc($result)) {
1737 $del_id[] = $treeData["pos_fk"];
1738 }
1739
1740 // delete subtree
1741 $this->db->manipulateF(
1742 '
1743 DELETE FROM frm_posts_tree
1744 WHERE lft BETWEEN %s AND %s
1745 AND thr_fk = %s',
1746 array('integer', 'integer', 'integer'),
1747 array($a_node['lft'], $a_node['rgt'], $a_node['tree'])
1748 );
1749
1750 // close gaps
1751 $this->db->manipulateF(
1752 '
1753 UPDATE frm_posts_tree
1754 SET lft = CASE
1755 WHEN lft > %s
1756 THEN lft - %s
1757 ELSE lft
1758 END,
1759 rgt = CASE
1760 WHEN rgt > %s
1761 THEN rgt - %s
1762 ELSE rgt
1763 END
1764 WHERE thr_fk = %s',
1765 array('integer', 'integer', 'integer', 'integer', 'integer'),
1766 array($a_node['lft'], $diff, $a_node['lft'], $diff, $a_node['tree'])
1767 );
1768
1769 return $del_id;
1770 }
1771
1777 public function updateVisits($ID)
1778 {
1779 $checkTime = time() - (60*60);
1780
1781 if ($_SESSION["frm_visit_" . $this->dbTable . "_" . $ID] < $checkTime) {
1782 $_SESSION["frm_visit_" . $this->dbTable . "_" . $ID] = time();
1783 $query = 'UPDATE ' . $this->dbTable . ' SET visits = visits + 1 WHERE ';
1784
1785 $data_type = array();
1786 $data_value = array();
1787
1788 if ($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '') {
1789 $query .= $this->getMDB2Query();
1790 $data_type = $data_type + $this->getMDB2DataType();
1791 $data_value = $data_value + $this->getMDB2DataValue();
1792
1793 $res = $this->db->queryf($query, $data_type, $data_value);
1794 }
1795 }
1796 }
1797
1805 public function prepareText($text, $edit=0, $quote_user = '', $type = '')
1806 {
1807 if ($type == 'export') {
1808 $this->replQuote1 = "<blockquote class=\"quote\"><hr size=\"1\" color=\"#000000\">";
1809 $this->replQuote2 = "<hr size=\"1\" color=\"#000000\"/></blockquote>";
1810 }
1811
1812 if ($edit == 1) {
1813 // add login name of quoted users
1814 $lname = ($quote_user != "")
1815 ? '="' . $quote_user . '"'
1816 : "";
1817
1818 $text = "[quote$lname]" . $text . "[/quote]";
1819 } else {
1820 // check for quotation
1821 $startZ = substr_count($text, "[quote"); // also count [quote="..."]
1822 $endZ = substr_count($text, "[/quote]");
1823
1824 if ($startZ > 0 || $endZ > 0) {
1825 // add missing opening and closing tags
1826 if ($startZ > $endZ) {
1827 $diff = $startZ - $endZ;
1828
1829 for ($i = 0; $i < $diff; $i++) {
1830 if ($type == 'export') {
1832 } else {
1833 $text .= "[/quote]";
1834 }
1835 }
1836 } elseif ($startZ < $endZ) {
1837 $diff = $endZ - $startZ;
1838
1839 for ($i = 0; $i < $diff; $i++) {
1840 if ($type == 'export') {
1841 $text = $this->txtQuote1 . $text;
1842 } else {
1843 $text = "[quote]" . $text;
1844 }
1845 }
1846 }
1847
1848 if ($edit == 0) {
1849 $text = preg_replace(
1850 '@\[(quote\s*?=\s*?"([^"]*?)"\s*?)\]@i',
1851 $this->replQuote1 . '<div class="ilForumQuoteHead">' . $this->lng->txt('quote') . ' ($2)</div>',
1852 $text
1853 );
1854
1855 $text = str_replace(
1856 "[quote]",
1857 $this->replQuote1 . '<div class="ilForumQuoteHead">' . $this->lng->txt("quote") . '</div>',
1858 $text
1859 );
1860
1861 $text = str_replace("[/quote]", $this->replQuote2, $text);
1862 }
1863 }
1864 }
1865
1866 if ($type != 'export') {
1867 if ($edit == 0) {
1868 include_once './Services/MathJax/classes/class.ilMathJax.php';
1869 $text = ilMathJax::getInstance()->insertLatexImages($text, "<span class\=\"latex\">", "<\/span>");
1870 $text = ilMathJax::getInstance()->insertLatexImages($text, "\[tex\]", "\[\/tex\]");
1871 }
1872
1873 // workaround for preventing template engine
1874 // from hiding text that is enclosed
1875 // in curly brackets (e.g. "{a}")
1876 $text = str_replace("{", "&#123;", $text);
1877 $text = str_replace("}", "&#125;", $text);
1878 }
1879
1880 return $text;
1881 }
1882
1883 public function __deletePostFiles($a_ids)
1884 {
1885 if (!is_array($a_ids)) {
1886 return false;
1887 }
1888 include_once "./Modules/Forum/classes/class.ilFileDataForum.php";
1889
1890 $tmp_file_obj = new ilFileDataForum($this->getForumId());
1891 foreach ($a_ids as $pos_id) {
1892 $tmp_file_obj->setPosId($pos_id);
1893 $files = $tmp_file_obj->getFilesOfPost();
1894 foreach ($files as $file) {
1895 $tmp_file_obj->unlinkFile($file["name"]);
1896 }
1897 }
1898 unset($tmp_file_obj);
1899 return true;
1900 }
1901
1902 public function getImportName()
1903 {
1904 return $this->import_name;
1905 }
1906 public function setImportName($a_import_name)
1907 {
1908 $this->import_name = $a_import_name;
1909 }
1910
1917 public function enableForumNotification($user_id)
1918 {
1919 if (!$this->isForumNotificationEnabled($user_id)) {
1920 /* Remove all notifications of threads that belong to the forum */
1921
1922 $res = $this->db->queryf(
1923 '
1924 SELECT frm_notification.thread_id FROM frm_data, frm_notification, frm_threads
1925 WHERE frm_notification.user_id = %s
1926 AND frm_notification.thread_id = frm_threads.thr_pk
1927 AND frm_threads.thr_top_fk = frm_data.top_pk
1928 AND frm_data.top_frm_fk = %s
1929 GROUP BY frm_notification.thread_id',
1930 array('integer', 'integer'),
1931 array($user_id, $this->id)
1932 );
1933
1934 if (is_object($res) && $res->numRows() > 0) {
1935 $thread_data = array();
1936 $thread_data_types = array();
1937
1938 $query = ' DELETE FROM frm_notification
1939 WHERE user_id = %s
1940 AND thread_id IN (';
1941
1942 array_push($thread_data, $user_id);
1943 array_push($thread_data_types, 'integer');
1944
1945 $counter = 1;
1946
1947 while ($row = $this->db->fetchAssoc($res)) {
1948 if ($counter < $res->numRows()) {
1949 $query .= '%s, ';
1950 array_push($thread_data, $row['thread_id']);
1951 array_push($thread_data_types, 'integer');
1952 }
1953
1954 if ($counter == $res->numRows()) {
1955 $query .= '%s)';
1956 array_push($thread_data, $row['thread_id']);
1957 array_push($thread_data_types, 'integer');
1958 }
1959 $counter++;
1960 }
1961
1962 $this->db->manipulateF($query, $thread_data_types, $thread_data);
1963 }
1964
1965 /* Insert forum notification */
1966
1967 $nextId = $this->db->nextId('frm_notification');
1968
1969 $this->db->manipulateF(
1970 '
1971 INSERT INTO frm_notification
1972 ( notification_id,
1973 user_id,
1974 frm_id
1975 )
1976 VALUES(%s, %s, %s)',
1977 array('integer','integer', 'integer'),
1978 array($nextId, $user_id, $this->id)
1979 );
1980 }
1981 return true;
1982 }
1983
1990 public function disableForumNotification($user_id)
1991 {
1992 $this->db->manipulateF(
1993 '
1994 DELETE FROM frm_notification
1995 WHERE user_id = %s
1996 AND frm_id = %s',
1997 array('integer', 'integer'),
1998 array($user_id, $this->id)
1999 );
2000
2001 return true;
2002 }
2003
2009 public function isForumNotificationEnabled($user_id)
2010 {
2011 $result = $this->db->queryf(
2012 'SELECT COUNT(*) cnt FROM frm_notification WHERE user_id = %s AND frm_id = %s',
2013 array('integer', 'integer'),
2014 array($user_id, $this->id)
2015 );
2016
2017 while ($record = $this->db->fetchAssoc($result)) {
2018 return (bool) $record['cnt'];
2019 }
2020
2021 return false;
2022 }
2023
2034 public function enableThreadNotification($user_id, $thread_id)
2035 {
2036 if (!$this->isThreadNotificationEnabled($user_id, $thread_id)) {
2037 $nextId = $this->db->nextId('frm_notification');
2038 $this->db->manipulateF(
2039 '
2040 INSERT INTO frm_notification
2041 ( notification_id,
2042 user_id,
2043 thread_id
2044 )
2045 VALUES (%s, %s, %s)',
2046 array('integer', 'integer', 'integer'),
2047 array($nextId, $user_id, $thread_id)
2048 );
2049 }
2050
2051 return true;
2052 }
2053
2060 public function isThreadNotificationEnabled($user_id, $thread_id)
2061 {
2062 $result = $this->db->queryf(
2063 '
2064 SELECT COUNT(*) cnt FROM frm_notification
2065 WHERE user_id = %s
2066 AND thread_id = %s',
2067 array('integer', 'integer'),
2068 array($user_id, $thread_id)
2069 );
2070
2071
2072 while ($record = $this->db->fetchAssoc($result)) {
2073 return (bool) $record['cnt'];
2074 }
2075
2076 return false;
2077 }
2078
2085 public static function _getThreads($a_obj_id, $a_sort_mode = self::SORT_DATE)
2086 {
2087 global $DIC;
2088 $ilDB = $DIC->database();
2089
2090 switch ($a_sort_mode) {
2091 case self::SORT_DATE:
2092 $sort = 'thr_date';
2093 break;
2094
2095 case self::SORT_TITLE:
2096 default:
2097 $sort = 'thr_subject';
2098 break;
2099 }
2100
2101 $res = $ilDB->queryf(
2102 '
2103 SELECT * FROM frm_threads
2104 JOIN frm_data ON top_pk = thr_top_fk
2105 WHERE top_frm_fk = %s
2106 ORDER BY %s',
2107 array('integer', 'text'),
2108 array($a_obj_id, $sort)
2109 );
2110
2111 while ($row = $ilDB->fetchObject($res)) {
2112 $threads[$row->thr_pk] = $row->thr_subject;
2113 }
2114 return $threads ? $threads : array();
2115 }
2116
2117 public static function _lookupObjIdForForumId($a_for_id)
2118 {
2119 global $DIC;
2120 $ilDB = $DIC->database();
2121
2122 $res = $ilDB->queryf(
2123 '
2124 SELECT top_frm_fk FROM frm_data
2125 WHERE top_pk = %s',
2126 array('integer'),
2127 array($a_for_id)
2128 );
2129
2130 if ($fdata = $ilDB->fetchAssoc($res)) {
2131 return $fdata["top_frm_fk"];
2132 }
2133 return false;
2134 }
2135
2136 public static function updateLastPostByObjId($a_obj_id)
2137 {
2138 global $DIC;
2139 $ilDB = $DIC->database();
2140 // get latest post of forum and update last_post
2141 $ilDB->setLimit(1);
2142 $res2 = $ilDB->queryf(
2143 '
2144 SELECT pos_top_fk, pos_thr_fk, pos_pk FROM frm_posts, frm_data
2145 WHERE pos_top_fk = top_pk
2146 AND top_frm_fk = %s
2147 ORDER BY pos_date DESC',
2148 array('integer'),
2149 array($a_obj_id)
2150 );
2151
2152 if ($res2->numRows() == 0) {
2153 $lastPost_top = "";
2154 } else {
2155 $z = 0;
2156
2157 while ($selData = $ilDB->fetchAssoc($res2)) {
2158 if ($z > 0) {
2159 break;
2160 }
2161
2162 $lastPost_top = $selData["pos_top_fk"] . "#" . $selData["pos_thr_fk"] . "#" . $selData["pos_pk"];
2163 $z++;
2164 }
2165 }
2166
2167 $ilDB->update(
2168 'frm_data',
2169 array('top_last_post' => array('text', $lastPost_top)),
2170 array('top_frm_fk' => array('integer', $a_obj_id))
2171 );
2172 }
2173
2180 public static function mergeThreads($obj_id, $source_id, $target_id)
2181 {
2182 // selected source & target objects
2183 $source_thread_obj = new ilForumTopic((int) $source_id);
2184 $target_thread_obj = new ilForumTopic((int) $target_id);
2185
2186 if ($source_thread_obj->getForumId() != $target_thread_obj->getForumId()) {
2187 throw new ilException('not_allowed_to_merge_into_another_forum');
2188 }
2189 // use the "older" thread as target
2190 if ($source_thread_obj->getCreateDate() > $target_thread_obj->getCreateDate()) {
2191 $merge_thread_source = $source_thread_obj;
2192 $merge_thread_target = $target_thread_obj;
2193 } else {
2194 $merge_thread_source = $target_thread_obj;
2195 $merge_thread_target = $source_thread_obj;
2196 }
2197
2198 $thread_subject = $target_thread_obj->getSubject();
2199
2200 // remember if the threads are open or closed and then close both threads !
2201 $targed_was_closed = $merge_thread_target->isClosed();
2202
2203 $merge_thread_source->close();
2204
2205 if ($targed_was_closed == false) {
2206 $merge_thread_target->close();
2207 }
2208
2209 $source_all_posts = $merge_thread_source->getAllPosts();
2210 $source_root_node = $merge_thread_source->getFirstPostNode();
2211 $target_root_node = $merge_thread_target->getFirstPostNode();
2212
2213 $add_difference = $target_root_node->getRgt();
2214
2215 // update target root node rgt
2216 include_once 'Modules/Forum/classes/class.ilForumPostsTree.php';
2217 // $new_target_rgt = ($target_root_node->getRgt() + $source_root_node->getRgt() + 1);
2218 $new_target_rgt = ($target_root_node->getRgt() + $source_root_node->getRgt());
2219 ilForumPostsTree::updateTargetRootRgt($target_root_node->getId(), $new_target_rgt);
2220
2221 $new_target_root = $target_root_node->getId();
2222
2223 // get source post tree and update posts tree
2224 foreach ($source_all_posts as $post) {
2225 $post_obj = new ilForumPost($post->pos_pk);
2226
2227 $posts_tree_obj = new ilForumPostsTree();
2228 $posts_tree_obj->setPosFk($post->pos_pk);
2229
2230 if ($post_obj->getParentId() == 0) {
2231 $posts_tree_obj->setParentPos($new_target_root);
2232
2233 //$posts_tree_obj->setRgt(($post_obj->getRgt() + $add_difference));
2234 $posts_tree_obj->setRgt(($post_obj->getRgt() + $add_difference) - 1);
2235 $posts_tree_obj->setLft($target_root_node->getRgt());
2236
2237 $posts_tree_obj->setDepth(($post_obj->getDepth() + 1));
2238 $posts_tree_obj->setSourceThreadId($merge_thread_source->getId());
2239
2240 $posts_tree_obj->setTargetThreadId($merge_thread_target->getId());
2241
2242 $posts_tree_obj->mergeParentPos();
2243 } else {
2244 $posts_tree_obj->setRgt(($post_obj->getRgt() + $add_difference) - 1);
2245 $posts_tree_obj->setLft(($post_obj->getLft() + $add_difference) - 1);
2246
2247 $posts_tree_obj->setDepth(($post_obj->getDepth() + 1));
2248 $posts_tree_obj->setSourceThreadId($merge_thread_source->getId());
2249
2250 $posts_tree_obj->setParentPos($post_obj->getParentId());
2251 $posts_tree_obj->setTargetThreadId($merge_thread_target->getId());
2252
2253 $posts_tree_obj->merge();
2254 }
2255 }
2256
2257 // update frm_posts pos_thr_fk = target_thr_id
2258 include_once 'Modules/Forum/classes/class.ilForumPost.php';
2259 ilForumPost::mergePosts($merge_thread_source->getId(), $merge_thread_target->getId());
2260
2261 // check notifications
2262 include_once 'Modules/Forum/classes/class.ilForumNotification.php';
2263 ilForumNotification::mergeThreadNotificiations($merge_thread_source->getId(), $merge_thread_target->getId());
2264
2265 // delete frm_thread_access entries
2266 include_once './Modules/Forum/classes/class.ilObjForum.php';
2267 ilObjForum::_deleteAccessEntries($merge_thread_source->getId());
2268
2269 // update frm_user_read
2270 ilObjForum::mergeForumUserRead($merge_thread_source->getId(), $merge_thread_target->getId());
2271
2272 // update visits, thr_num_posts, last_post, subject
2273 $post_date_source = $merge_thread_source->getLastPost()->getCreateDate();
2274 $post_date_target = $merge_thread_target->getLastPost()->getCreateDate();
2275
2276 $target_last_post = $merge_thread_target->getLastPostString();
2277 $exp = explode('#', $target_last_post);
2278
2279 if ($post_date_source > $post_date_target) {
2280 $exp[2] = $merge_thread_source->getLastPost()->getId();
2281 } else {
2282 $exp[2] = $merge_thread_target->getLastPost()->getId();
2283 }
2284 $new_thr_last_post = implode('#', $exp);
2285
2286 $num_posts_source = (int) $merge_thread_source->getNumPosts();
2287 $num_visits_source = (int) $merge_thread_source->getVisits();
2288 $num_posts_target = (int) $merge_thread_target->getNumPosts();
2289 $num_visits_target = (int) $merge_thread_source->getVisits();
2290
2291 $frm_topic_obj = new ilForumTopic(0, false, true);
2292 $frm_topic_obj->setNumPosts(($num_posts_source + $num_posts_target));
2293 $frm_topic_obj->setVisits(($num_visits_source + $num_visits_target));
2294 $frm_topic_obj->setLastPostString($new_thr_last_post);
2295 $frm_topic_obj->setSubject($thread_subject);
2296 $frm_topic_obj->setId($merge_thread_target->getId());
2297
2298 $frm_topic_obj->updateMergedThread();
2299
2300 // update frm_data: top_last_post , top_num_threads
2302
2303 // reopen target if was not "closed" before merging
2304 if (!$targed_was_closed) {
2305 $merge_thread_target->reopen();
2306 }
2307 // raise event for updating existing drafts
2308 $GLOBALS['ilAppEventHandler']->raise(
2309 'Modules/Forum',
2310 'mergedThreads',
2311 array( 'source_thread_id' => $merge_thread_source->getId(),
2312 'target_thread_id' => $merge_thread_target->getId())
2313 );
2314
2315 // delete source thread
2316 ilForumTopic::deleteByThreadId($merge_thread_source->getId());
2317 }
2318} // END class.Forum
sprintf('%.4f', $callTime)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$result
user()
Definition: user.php:4
$files
Definition: add-vimline.php:18
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
error($a_errmsg)
set error message @access public
const NEWS_USERS
const NEWS_NOTICE
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date @access public.
@classDescription Date and time handling
Base class for ILIAS Exception handling.
This class handles all operations on files for the forum object.
Class to report exception.
Class ilForumDraftHistory.
static mergeThreadNotificiations($merge_source_thread_id, $merge_target_thread_id)
Class ilForumPostDraft.
static mergePosts($source_thread_id, $target_thread_id)
static updateTargetRootRgt($root_node_id, $rgt)
static getInstance($a_obj_id=0)
static deleteByThreadId($thr_id)
insert()
Inserts the object data into database.
setImportName($a_import_name)
enableNotification($a_user_id)
Enable a user's notification about new posts in a thread.
setCreateDate($a_createdate)
Class Forum core functions for forum.
countUserArticles($a_user_id)
get number of articles from given user-ID
getOnePost($post)
get one post-dataset
disableForumNotification($user_id)
Disable a user's notification about new posts in this forum.
getFirstPostNode($tree_id)
get data of the first node from frm_posts_tree and frm_posts @access public
fetchPostNodeData($a_row)
get data of parent node from frm_posts_tree and frm_posts @access private
static _lookupPostMessage($a_id)
countActiveUserArticles($a_user_id)
deletePostTree($a_node)
delete node and the whole subtree under this node @access public
__deletePostFiles($a_ids)
const SORT_DATE
addPostTree($a_tree_id, $a_node_id=-1, $a_date='')
create a new post-tree
enableThreadNotification($user_id, $thread_id)
no usage? ..delete .
__construct()
Constructor @access public.
setForumId($a_obj_id)
set object id which refers to ILIAS obj_id
updateVisits($ID)
update page hits of given forum- or thread-ID @access public
getPostNode($post_id)
get data of given node from frm_posts_tree and frm_posts @access public
static $moderators_by_ref_id_map
setImportName($a_import_name)
getPostDepth($a_node_id, $tree_id)
Return depth of an object @access private.
static _isModerator($a_ref_id, $a_usr_id)
checks whether a user is moderator of a given forum object
getOneTopic()
get one topic-dataset by WhereCondition
generateThread(ilForumTopic $thread, $message, $notify, $notify_posts, $status=1)
prepareText($text, $edit=0, $quote_user='', $type='')
prepares given string @access public
getForumId()
get forum id @access public
postCensorship($message, $pos_pk, $cens=0)
update dataset in frm_posts with censorship info
const SORT_TITLE
generatePost($forum_id, $thread_id, $author_id, $display_user_id, $message, $parent_pos, $notify, $subject='', $alias='', $date='', $status=1, $send_activation_mail=0)
generate new dataset in frm_posts
static updateLastPostByObjId($a_obj_id)
static _getLanguageInstanceByUsrId($usr_id)
Get the ilLanguage instance for the passed user id.
convertDate($date)
converts the date format
getAllThreads($a_topic_id, array $params=array(), $limit=0, $offset=0)
setPageHits($pageHits)
isThreadNotificationEnabled($user_id, $thread_id)
Check whether a user's notification about new posts in a thread is enabled (result > 0) or not (resul...
moveThreads($thread_ids=array(), $src_ref_id=0, $dest_top_frm_fk=0)
Moves all chosen threads and their posts to a new forum.
getMDB2Query()
get content of additional condition
deletePost($post)
delete post and sub-posts
getOneThread()
get one thread-dataset by WhereCondition
setOrderField($orderField)
set database field for sorting results
getDbTable()
get name of database table
getPageHits()
get number of max.
setMDB2WhereCondition($query_string, $data_type, $data_value)
set content for additional condition
const DEFAULT_PAGE_HITS
static _getThreads($a_obj_id, $a_sort_mode=self::SORT_DATE)
Get thread infos of object.
getUserStatistic($is_moderator=false)
static mergeThreads($obj_id, $source_id, $target_id)
isForumNotificationEnabled($user_id)
Check whether a user's notification about new posts in this forum is enabled (result > 0) or not (res...
getMDB2DataType()
get content of additional condition
static _lookupObjIdForForumId($a_for_id)
getFirstPostByThread($a_thread_id)
Get first post of thread.
setForumRefId($a_ref_id)
set reference id which refers to ILIAS obj_id
static _getModerators($a_ref_id)
get all users assigned to local role il_frm_moderator_<frm_ref_id> (static)
enableForumNotification($user_id)
Enable a user's notification about new posts in this forum.
setLanguage($lng)
getMDB2DataValue()
get content of additional condition
getModerators()
get all users assigned to local role il_frm_moderator_<frm_ref_id>
getForumRefId()
get forum ref_id @access public
setDbTable($dbTable)
set database table
getOrderField()
get name of orderField
insertPostNode($a_node_id, $a_parent_id, $tree_id, $a_date='')
insert node under parent node @access public
language handling
static getInstance()
Singleton: get instance.
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 _deleteReadEntries($a_post_id)
static _deleteAccessEntries($a_thread_id)
static mergeForumUserRead($merge_source_thread_id, $merge_target_thread_id)
Class ilObjMediaObject.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _removeUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Remove usage of mob in another container.
static _exists($a_id, $a_reference=false, $a_type=null)
checks wether a lm content object with specified id exists or not
static _lookupLanguage($a_usr_id)
static getInstanceByRefId($a_ref_id, $stop_on_error=true)
get an instance of an Ilias object by reference id
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
Replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
$counter
$i
Definition: disco.tpl.php:19
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$target_id
Definition: goto.php:49
catch(Exception $e) $message
$post
Definition: post.php:34
$query
$type
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
settings()
Definition: settings.php:2
global $ilDB
$mobs
$params
Definition: disable.php:11
$text
Definition: errorreport.php:18