ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
35 public $ilias;
36 public $lng;
37
44 private $dbTable;
45
51 private $className="ilForum";
52
59 private $orderField;
60
61 private $mdb2Query;
64
65 private $txtQuote1 = "[quote]";
66 private $txtQuote2 = "[/quote]";
67 private $replQuote1 = '<blockquote class="ilForumQuote">';
68 private $replQuote2 = '</blockquote>';
69
70 // max. datasets per page
72
73 // object id
74 private $id;
75
80 public function __construct()
81 {
82 global $ilias,$lng;
83
84 $this->ilias = $ilias;
85 $this->lng = $lng;
86 }
87
88 public function setLanguage($lng)
89 {
90 $this->lng = $lng;
91 }
92
103 public static function _getLanguageInstanceByUsrId($usr_id)
104 {
105 static $lngCache = array();
106
107 $languageShorthandle = ilObjUser::_lookupLanguage($usr_id);
108
109 // lookup in cache array
110 if(!isset($lngCache[$languageShorthandle]))
111 {
112 $lngCache[$languageShorthandle] = new ilLanguage($languageShorthandle);
113 $lngCache[$languageShorthandle]->loadLanguageModule('forum');
114 }
115
116 return $lngCache[$languageShorthandle];
117 }
118
124 public function setForumId($a_obj_id)
125 {
126
127 if (!isset($a_obj_id))
128 {
129 $message = get_class($this)."::setForumId(): No obj_id given!";
130 $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
131 }
132
133 $this->id = $a_obj_id;
134 }
135
141 public function setForumRefId($a_ref_id)
142 {
143 if (!isset($a_ref_id))
144 {
145 $message = get_class($this)."::setForumRefId(): No ref_id given!";
146 $this->ilias->raiseError($message,$this->ilias->error_obj->WARNING);
147 }
148
149 $this->ref_id = $a_ref_id;
150 }
151
157 public function getForumId()
158 {
159 return $this->id;
160 }
161
167 public function getForumRefId()
168 {
169 return $this->ref_id;
170 }
171
178 private function setOrderField($orderField)
179 {
180 if ($orderField == "")
181 {
182 die($this->className . "::setOrderField(): No orderField given.");
183 }
184 else
185 {
186 $this->orderField = $orderField;
187 }
188 }
189
196 public function getOrderField()
197 {
198 return $this->orderField;
199 }
200
207 public function setDbTable($dbTable)
208 {
209 if ($dbTable == "")
210 {
211 die($this->className . "::setDbTable(): No database table given.");
212 }
213 else
214 {
215 $this->dbTable = $dbTable;
216 }
217 }
218
225 public function getDbTable()
226 {
227 return $this->dbTable;
228 }
229
230
240 public function setMDB2WhereCondition($query_string, $data_type, $data_value)
241 {
242 $this->mdb2Query = $query_string;
243 $this->mdb2DataValue = $data_value;
244 $this->mdb2DataType = $data_type;
245
246 return true;
247 }
248
249
255 public function getMDB2Query()
256 {
257 if($this->mdb2Query != '')
258 {
259 return $this->mdb2Query;
260 }
261
262 }
263
269 public function getMDB2DataValue()
270 {
271 if($this->mdb2DataValue != '')
272 {
274 }
275 }
276
282 public function getMDB2DataType()
283 {
284 if($this->mdb2DataType != '')
285 {
286 return $this->mdb2DataType;
287 }
288 }
289
294 public function setPageHits($pageHits)
295 {
296 if($pageHits < 1 || !is_numeric($pageHits))
297 {
298 $pageHits = 1;
299 }
300
301 $this->pageHits = (int)$pageHits;
302 return true;
303 }
304
311 public function getPageHits()
312 {
313 return $this->pageHits;
314 }
315
316 // *******************************************************************************
317
323 public function getOneTopic()
324 {
325 global $ilDB;
326
327 $data_type = array();
328 $data_value = array();
329
330 $query = 'SELECT * FROM frm_data WHERE ';
331
332 if($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '')
333 {
334 $query .= ''.$this->getMDB2Query().'';
335 $data_type = $data_type + $this->getMDB2DataType();
336 $data_value = $data_value + $this->getMDB2DataValue();
337
338 $res = $ilDB->queryf($query, $data_type, $data_value);
339 $row = $ilDB->fetchAssoc($res);
340
341 if(is_null($row)) return NULL;
342
343 $row["top_name"] = trim($row["top_name"]);
344 $row["top_description"] = nl2br($row["top_description"]);
345
346 return $row;
347
348 }
349 else
350 {
351 $query .= '1 = 1';
352
353 $res = $ilDB->query($query);
354 $row = $ilDB->fetchAssoc($res);
355
356 if(!is_array($row) || !count($row)) return null;
357
358 $row['top_name'] = trim($row['top_name']);
359 $row['top_description'] = nl2br($row['top_description']);
360
361 return $row;
362 }
363 }
364
370 public function getOneThread()
371 {
372 global $ilDB;
373
374 $data_type = array();
375 $data_value = array();
376
377 $query = 'SELECT * FROM frm_threads WHERE ';
378
379 if($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '')
380 {
381 $query .= $this->getMDB2Query();
382 $data_type = $data_type + $this->getMDB2DataType();
383 $data_value = $data_value + $this->getMDB2DataValue();
384
385 $sql_res = $ilDB->queryf($query, $data_type, $data_value);
386 $result = $ilDB->fetchAssoc($sql_res);
387 $result["thr_subject"] = trim($result["thr_subject"]);
388 }
389
390 return $result;
391 }
392
399 public function getOnePost($post)
400 {
401 global $ilDB;
402
403 $res = $ilDB->queryf('
404 SELECT frm_posts.*, usr_data.lastname FROM frm_posts, usr_data
405 WHERE pos_pk = %s
406 AND pos_display_user_id = usr_id',
407 array('integer'), array($post));
408
409 $row = $ilDB->fetchAssoc($res);
410
411
412 $row["pos_date"] = $this->convertDate($row["pos_date"]);
413 $row["pos_message"] = nl2br($row["pos_message"]);
414
415 return $row;
416 }
417
418 public static function _lookupPostMessage($a_id)
419 {
420 global $ilDB;
421
422 $res = $ilDB->queryf('
423 SELECT * FROM frm_posts WHERE pos_pk = %s',
424 array('integer'), array($a_id));
425
426 while($row = $ilDB->fetchObject($res))
427 {
428 return $row->pos_message;
429 }
430 return '';
431 }
432
448 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)
449 {
450 global $ilDB;
451
452 $objNewPost = new ilForumPost();
453 $objNewPost->setForumId($forum_id);
454 $objNewPost->setThreadId($thread_id);
455 $objNewPost->setSubject($subject);
456 $objNewPost->setMessage($message);
457 $objNewPost->setDisplayUserId($display_user_id);
458 $objNewPost->setUserAlias($alias);
459 $objNewPost->setPosAuthorId($author_id);
460
461 $frm_settings = ilForumProperties::getInstance($this->getForumId());
462
463 if($frm_settings->getMarkModeratorPosts() == 1)
464 {
465 self::_isModerator($this->getForumRefId(), $author_id) ? $is_moderator = true : $is_moderator = false;
466 }
467 else
468 {
469 $is_moderator = false;
470 }
471 $objNewPost->setIsAuthorModerator($is_moderator);
472
473 if ($date == "")
474 {
475 $objNewPost->setCreateDate(date("Y-m-d H:i:s"));
476 }
477 else
478 {
479 if (strpos($date, "-") > 0) // in mysql format
480 {
481 $objNewPost->setCreateDate($date);
482 }
483 else // a timestamp
484 {
485 $objNewPost->setCreateDate(date("Y-m-d H:i:s", $date));
486 }
487 }
488 if($status == 1)
489 {
490 $objNewPost->setPostActivationDate($objNewPost->getCreateDate());
491 }
492
493 $objNewPost->setImportName($this->getImportName());
494 $objNewPost->setNotification($notify);
495 $objNewPost->setStatus($status);
496 $objNewPost->insert();
497
498 // entry in tree-table
499 if ($parent_pos == 0)
500 {
501 $this->addPostTree($objNewPost->getThreadId(), $objNewPost->getId(), $objNewPost->getCreateDate());
502 }
503 else
504 {
505 $this->insertPostNode($objNewPost->getId(), $parent_pos, $objNewPost->getThreadId(), $objNewPost->getCreateDate());
506 }
507
508 // string last post
509 $lastPost = $objNewPost->getForumId()."#".$objNewPost->getThreadId()."#".$objNewPost->getId();
510
511 // update thread
512 $result = $ilDB->manipulateF('
513 UPDATE frm_threads
514 SET thr_num_posts = thr_num_posts + 1,
515 thr_last_post = %s
516 WHERE thr_pk = %s',
517 array('text', 'integer'),
518 array($lastPost, $objNewPost->getThreadId()));
519
520 // update forum
521 $result = $ilDB->manipulateF('
522 UPDATE frm_data
523 SET top_num_posts = top_num_posts + 1,
524 top_last_post = %s
525 WHERE top_pk = %s',
526 array('text', 'integer'),
527 array($lastPost, $objNewPost->getForumId()));
528
529 // MARK READ
531 $forum_obj->markPostRead($objNewPost->getPosAuthorId(), $objNewPost->getThreadId(), $objNewPost->getId());
532
533 // Add Notification to news
534 if($status)
535 {
536 require_once 'Services/RTE/classes/class.ilRTE.php';
537 include_once("./Services/News/classes/class.ilNewsItem.php");
538 $news_item = new ilNewsItem();
539 $news_item->setContext($forum_obj->getId(), 'frm', $objNewPost->getId(), 'pos');
540 $news_item->setPriority(NEWS_NOTICE);
541 $news_item->setTitle($objNewPost->getSubject());
542 $news_item->setContent(ilRTE::_replaceMediaObjectImageSrc($this->prepareText($objNewPost->getMessage(), 0), 1));
543 if($objNewPost->getMessage() != strip_tags($objNewPost->getMessage()))
544 {
545 $news_item->setContentHtml(true);
546 }
547
548 $news_item->setUserId($display_user_id);
549 $news_item->setVisibility(NEWS_USERS);
550 $news_item->create();
551 }
552
553 return $objNewPost->getId();
554 }
555
564 public function generateThread(ilForumTopic $thread, $message, $notify, $notify_posts, $status = 1)
565 {
566 global $ilDB;
567
568 if(!$thread->getCreateDate())
569 {
570 $thread->setCreateDate(date('Y-m-d H:i:s'));
571 }
572
573 $thread->setImportName($this->getImportName());
574 $thread->insert();
575
576 if($notify_posts == 1)
577 {
578 $thread->enableNotification($thread->getThrAuthorId());
579 }
580
581 $ilDB->manipulateF('
582 UPDATE frm_data
583 SET top_num_threads = top_num_threads + 1
584 WHERE top_pk = %s',
585 array('integer'), array($thread->getForumId()));
586
587 return $this->generatePost(
588 $thread->getForumId(),
589 $thread->getId(),
590 $thread->getThrAuthorId(),
591 $thread->getDisplayUserId(),
592 $message, 0, $notify,
593 $thread->getSubject(),
594 $thread->getUserAlias(),
595 $thread->getCreateDate(),
596 $status,
597 0
598 );
599 }
600
609 public function moveThreads($thread_ids = array(), $src_ref_id = 0, $dest_top_frm_fk = 0)
610 {
611 global $ilDB;
612
613 $src_top_frm_fk = ilObject::_lookupObjectId($src_ref_id);
614
615 if (is_numeric($src_top_frm_fk) && $src_top_frm_fk > 0 && is_numeric($dest_top_frm_fk) && $dest_top_frm_fk > 0)
616 {
617
618 $this->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($src_top_frm_fk));
619
620 $oldFrmData = $this->getOneTopic();
621
622 $this->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($dest_top_frm_fk));
623
624 $newFrmData = $this->getOneTopic();
625
626 if ($oldFrmData['top_pk'] && $newFrmData['top_pk'])
627 {
628 $moved_posts = 0;
629 $moved_threads = 0;
630 $visits = 0;
631 foreach ($thread_ids as $id)
632 {
633 $objTmpThread = new ilForumTopic($id);
634
635 $numPosts = $objTmpThread->movePosts($src_top_frm_fk, $oldFrmData['top_pk'], $dest_top_frm_fk, $newFrmData['top_pk']);
636 if (($last_post_string = $objTmpThread->getLastPostString()) != '')
637 {
638 $last_post_string = explode('#', $last_post_string);
639 $last_post_string[0] = $newFrmData['top_pk'];
640 $last_post_string = implode('#', $last_post_string);
641 $objTmpThread->setLastPostString($last_post_string);
642 }
643
644 $visits += $objTmpThread->getVisits();
645
646 $moved_posts += $numPosts;
647 ++$moved_threads;
648
649 $objTmpThread->setForumId($newFrmData['top_pk']);
650 $objTmpThread->update();
651
652 unset($objTmpThread);
653 }
654
655 // update frm_data source forum
656 $ilDB->setLimit(1);
657 $res = $ilDB->queryf('
658 SELECT pos_thr_fk, pos_pk
659 FROM frm_posts
660 WHERE pos_top_fk = %s
661 ORDER BY pos_date DESC',
662 array('integer'), array($oldFrmData['top_pk']));
663
664 $row = $ilDB->fetchObject($res);
665 $last_post_src = $oldFrmData['top_pk'] . '#' . $row->pos_thr_fk . '#' . $row->pos_pk;
666
667 $statement = $ilDB->manipulateF('
668 UPDATE frm_data
669 SET top_num_posts = top_num_posts - %s,
670 top_num_threads = top_num_threads - %s,
671 visits = visits - %s,
672 top_last_post = %s
673 WHERE top_pk = %s',
674 array('integer', 'integer', 'integer', 'text', 'integer'),
675 array( $moved_posts,
676 $moved_threads,
677 $visits,
678 $last_post_src,
679 $oldFrmData['top_pk']));
680
681 // update frm_data destination forum
682
683 $ilDB->setLimit(1);
684 $res = $ilDB->queryf('
685 SELECT pos_thr_fk, pos_pk
686 FROM frm_posts
687 WHERE pos_top_fk = %s
688 ORDER BY pos_date DESC',
689 array('integer'), array($newFrmData['top_kp']));
690
691 $row = $ilDB->fetchObject($res);
692 $last_post_dest = $newFrmData['top_pk'] . '#' . $row->pos_thr_fk . '#' . $row->pos_pk;
693
694 $statement = $ilDB->manipulateF('
695 UPDATE frm_data
696 SET top_num_posts = top_num_posts + %s,
697 top_num_threads = top_num_threads + %s,
698 visits = visits + %s,
699 top_last_post = %s
700 WHERE top_pk = %s',
701 array('integer', 'integer', 'integer', 'text', 'integer'),
702 array($moved_posts, $moved_threads, $visits, $last_post_dest, $newFrmData['top_pk']));
703
704 /*
705 // update news items
706 include_once("./Services/News/classes/class.ilNewsItem.php");
707 $objNewsItem = new ilNewsItem();
708 $news_items = $objNewsItem->getNewsForRefId($src_ref_id);
709 foreach ($news_items as $news_item)
710 {
711 $tmpObjNewsItem = new ilNewsItem($news_item['id']);
712 if ($tmpObjNewsItem->getContextObjId() == $src_top_frm_fk)
713 {
714 $tmpObjNewsItem->setContextObjId($dest_top_frm_fk);
715 $tmpObjNewsItem->update();
716 }
717 unset($tmpObjNewsItem);
718 }
719 */
720 }
721 }
722}
723
724
732 public function postCensorship($message, $pos_pk, $cens = 0)
733 {
734 global $ilDB;
735
736 $cens_date = date("Y-m-d H:i:s");
737
738 $ilDB->manipulateF('
739 UPDATE frm_posts
740 SET pos_cens_com = %s,
741 pos_cens_date = %s,
742 pos_cens = %s,
743 update_user = %s
744 WHERE pos_pk = %s',
745 array('text', 'timestamp', 'integer', 'integer', 'integer'),
746 array($message, $cens_date, $cens, $GLOBALS['DIC']['ilUser']->getId(), $pos_pk));
747
748 // Change news item accordingly
749 include_once("./Services/News/classes/class.ilNewsItem.php");
750 $news_id = ilNewsItem::getFirstNewsIdForContext($this->id,
751 "frm", $pos_pk, "pos");
752 if ($news_id > 0)
753 {
754 if ($cens > 0) // censor
755 {
756 $news_item = new ilNewsItem($news_id);
757 //$news_item->setTitle($subject);
758 $news_item->setContent(nl2br($this->prepareText($message, 0)));
759 if($message != strip_tags($message))
760 {
761 $news_item->setContentHtml(true);
762 }
763 else
764 {
765 $news_item->setContentHtml(false);
766 }
767
768 $news_item->update();
769 }
770 else // revoke censorship
771 {
772 // get original message
773 $res = $ilDB->queryf('
774 SELECT * FROM frm_posts
775 WHERE pos_pk = %s',
776 array('integer'), array($pos_pk));
777
778 $rec = $ilDB->fetchAssoc($res);
779
780 $news_item = new ilNewsItem($news_id);
781 //$news_item->setTitle($subject);
782 $news_item->setContent(nl2br($this->prepareText($rec["pos_message"], 0)));
783 if($rec["pos_message"] != strip_tags($rec["pos_message"]))
784 {
785 $news_item->setContentHtml(true);
786 }
787 else
788 {
789 $news_item->setContentHtml(false);
790 }
791
792 $news_item->update();
793 }
794 }
795
796 require_once 'Modules/Forum/classes/class.ilForumPost.php';
797 $GLOBALS['ilAppEventHandler']->raise(
798 'Modules/Forum',
799 'censoredPost',
800 array(
801 'ref_id' => $this->getForumRefId(),
802 'post' => new ilForumPost($pos_pk)
803 )
804 );
805
806 return true;
807 }
808
815 public function deletePost($post)
816 {
817 global $ilDB;
818
819 include_once "./Modules/Forum/classes/class.ilObjForum.php";
820
821 $p_node = $this->getPostNode($post);
822
823 $GLOBALS['ilAppEventHandler']->raise(
824 'Modules/Forum',
825 'deletedPost',
826 array(
827 'ref_id' => $this->getForumRefId(),
828 'post' => new ilForumPost($post),
829 'thread_deleted' => ($p_node["parent"] == 0)? true : false
830 )
831 );
832
833 // delete tree and get id's of all posts to delete
834 $del_id = $this->deletePostTree($p_node);
835
836 // delete drafts_history
837 $obj_history = new ilForumDraftsHistory();
838 $draft_ids = $obj_history->deleteHistoryByPostIds($del_id);
839 // delete all drafts
840 $obj_draft = new ilForumPostDraft();
841 $obj_draft->deleteDraftsByDraftIds($draft_ids);
842
843 // Delete User read entries
844 foreach($del_id as $post_id)
845 {
846 ilObjForum::_deleteReadEntries($post_id);
847 }
848
849 // DELETE ATTACHMENTS ASSIGNED TO POST
850 $this->__deletePostFiles($del_id);
851
852 $dead_pos = count($del_id);
853 $dead_thr = 0;
854
855 // if deletePost is thread opener ...
856 if ($p_node["parent"] == 0)
857 {
858 // delete thread access data
859 include_once './Modules/Forum/classes/class.ilObjForum.php';
860
861 ilObjForum::_deleteAccessEntries($p_node['tree']);
862
863 // delete thread
864 $dead_thr = $p_node["tree"];
865
866 $statement = $ilDB->manipulateF('
867 DELETE FROM frm_threads
868 WHERE thr_pk = %s',
869 array('integer'), array($p_node['tree']));
870
871 // update num_threads
872 $statement = $ilDB->manipulateF('
873 UPDATE frm_data
874 SET top_num_threads = top_num_threads - 1
875 WHERE top_frm_fk = %s',
876 array('integer'), array($this->id));
877
878 // delete all related news
879 $posset = $ilDB->queryf('
880 SELECT * FROM frm_posts
881 WHERE pos_thr_fk = %s',
882 array('integer'), array($p_node['tree']));
883
884 while ($posrec = $ilDB->fetchAssoc($posset))
885 {
886 include_once("./Services/News/classes/class.ilNewsItem.php");
887 $news_id = ilNewsItem::getFirstNewsIdForContext($this->id,
888 "frm", $posrec["pos_pk"], "pos");
889 if ($news_id > 0)
890 {
891 $news_item = new ilNewsItem($news_id);
892 $news_item->delete();
893 }
894
895 try
896 {
897 include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
898 $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $posrec['pos_pk']);
899 foreach($mobs as $mob)
900 {
902 {
903 ilObjMediaObject::_removeUsage($mob, 'frm:html', $posrec['pos_pk']);
904 $mob_obj = new ilObjMediaObject($mob);
905 $mob_obj->delete();
906 }
907 }
908 }
909 catch(Exception $e)
910 {
911 }
912 }
913
914
915 // delete all posts of this thread
916 $statement = $ilDB->manipulateF('
917 DELETE FROM frm_posts
918 WHERE pos_thr_fk = %s',
919 array('integer'), array($p_node['tree']));
920
921 }
922 else
923 {
924
925 // delete this post and its sub-posts
926 for ($i = 0; $i < $dead_pos; $i++)
927 {
928 $statement = $ilDB->manipulateF('
929 DELETE FROM frm_posts
930 WHERE pos_pk = %s',
931 array('integer'), array($del_id[$i]));
932
933 // delete related news item
934 include_once("./Services/News/classes/class.ilNewsItem.php");
935 $news_id = ilNewsItem::getFirstNewsIdForContext($this->id,
936 "frm", $del_id[$i], "pos");
937 if ($news_id > 0)
938 {
939 $news_item = new ilNewsItem($news_id);
940 $news_item->delete();
941 }
942
943 try
944 {
945 include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
946 $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $del_id[$i]);
947 foreach($mobs as $mob)
948 {
950 {
951 ilObjMediaObject::_removeUsage($mob, 'frm:html', $del_id[$i]);
952 $mob_obj = new ilObjMediaObject($mob);
953 $mob_obj->delete();
954 }
955 }
956 }
957 catch(Exception $e)
958 {
959 }
960 }
961
962 // update num_posts in frm_threads
963 $statement = $ilDB->manipulateF('
964 UPDATE frm_threads
965 SET thr_num_posts = thr_num_posts - %s
966 WHERE thr_pk = %s',
967 array('integer', 'integer'),
968 array($dead_pos, $p_node['tree']));
969
970
971 // get latest post of thread and update last_post
972 $res1 = $ilDB->queryf('
973 SELECT * FROM frm_posts
974 WHERE pos_thr_fk = %s
975 ORDER BY pos_date DESC',
976 array('integer'), array($p_node['tree']));
977
978 if ($res1->numRows() == 0)
979 {
980 $lastPost_thr = "";
981 }
982 else
983 {
984 $z = 0;
985
986 while ($selData = $ilDB->fetchAssoc($res1))
987 {
988 if ($z > 0)
989 {
990 break;
991 }
992
993 $lastPost_thr = $selData["pos_top_fk"]."#".$selData["pos_thr_fk"]."#".$selData["pos_pk"];
994 $z ++;
995 }
996 }
997
998 $statement = $ilDB->manipulateF('
999 UPDATE frm_threads
1000 SET thr_last_post = %s
1001 WHERE thr_pk = %s',
1002 array('text', 'integer'), array($lastPost_thr, $p_node['tree']));
1003 }
1004
1005 // update num_posts in frm_data
1006 $statement = $ilDB->manipulateF('
1007 UPDATE frm_data
1008 SET top_num_posts = top_num_posts - %s
1009 WHERE top_frm_fk = %s',
1010 array('integer', 'integer'), array($dead_pos, $this->id));
1011
1012
1013 // get latest post of forum and update last_post
1014 $res2 = $ilDB->queryf('
1015 SELECT * FROM frm_posts, frm_data
1016 WHERE pos_top_fk = top_pk
1017 AND top_frm_fk = %s
1018 ORDER BY pos_date DESC',
1019 array('integer'), array($this->id));
1020
1021 if ($res2->numRows() == 0)
1022 {
1023 $lastPost_top = "";
1024 }
1025 else
1026 {
1027 $z = 0;
1028
1029 while ($selData = $ilDB->fetchAssoc($res2))
1030 {
1031 if ($z > 0)
1032 {
1033 break;
1034 }
1035
1036 $lastPost_top = $selData["pos_top_fk"]."#".$selData["pos_thr_fk"]."#".$selData["pos_pk"];
1037 $z ++;
1038 }
1039 }
1040
1041 $statement = $ilDB->manipulateF('
1042 UPDATE frm_data
1043 SET top_last_post = %s
1044 WHERE top_frm_fk = %s',
1045 array('text', 'integer'), array($lastPost_top, $this->id));
1046
1047 return $dead_thr;
1048 }
1049
1057 public function getAllThreads($a_topic_id, array $params = array(), $limit = 0, $offset = 0)
1058 {
1064 global $ilDB, $ilUser, $ilSetting;
1065
1066 $frm_overview_setting = (int)$ilSetting::_lookupValue('frma', 'forum_overview');
1067 $frm_props = ilForumProperties::getInstance($this->getForumId());
1068 $is_post_activation_enabled = $frm_props->isPostActivationEnabled();
1069
1070 $excluded_ids_condition = '';
1071 if(isset($params['excluded_ids']) && is_array($params['excluded_ids']) && $params['excluded_ids'])
1072 {
1073 $excluded_ids_condition = ' AND ' . $ilDB->in('thr_pk', $params['excluded_ids'], true, 'integer') . ' ';
1074 }
1075
1076 if(!in_array(strtolower($params['order_column']), array('lp_date', 'rating', 'thr_subject', 'num_posts', 'num_visit')))
1077 {
1078 $params['order_column'] = 'post_date';
1079 }
1080 if(!in_array(strtolower($params['order_direction']), array('asc', 'desc')))
1081 {
1082 $params['order_direction'] = 'desc';
1083 }
1084
1085 $cnt_active_pos_query = '';
1086 $cnt_join_type = 'LEFT';
1087 if($is_post_activation_enabled && !$params['is_moderator'])
1088 {
1089 $cnt_active_pos_query = " AND (pos_status = {$ilDB->quote(1, 'integer')} OR pos_author_id = {$ilDB->quote($ilUser->getId(), 'integer')}) ";
1090 $cnt_join_type = "INNER";
1091 }
1092 $query =
1093 "SELECT COUNT(DISTINCT(thr_pk)) cnt
1094 FROM frm_threads
1095 {$cnt_join_type} JOIN frm_posts
1096 ON pos_thr_fk = thr_pk {$cnt_active_pos_query}
1097 WHERE thr_top_fk = %s {$excluded_ids_condition}
1098 ";
1099 $res = $ilDB->queryF($query, array('integer'), array($a_topic_id));
1100 $cntData = $ilDB->fetchAssoc($res);
1101 $cnt = (int)$cntData['cnt'];
1102
1103 $active_query = '';
1104 $active_inner_query = '';
1105 $having = '';
1106 if($is_post_activation_enabled && !$params['is_moderator'])
1107 {
1108 $active_query = ' AND (pos_status = %s OR pos_author_id = %s) ';
1109 $active_inner_query = ' AND (ipos.pos_status = %s OR ipos.pos_author_id = %s) ';
1110 $having = ' HAVING num_posts > 0';
1111 }
1112
1113 $threads = array();
1114 $data = array();
1115 $data_types = array();
1116
1117 $optional_fields = '';
1118 if($frm_props->isIsThreadRatingEnabled())
1119 {
1120 $optional_fields = ',avg_rating';
1121 }
1122 if($frm_props->getThreadSorting() == 1)
1123 {
1124 $optional_fields = ',thread_sorting';
1125 }
1126
1127 $additional_sort = '';
1128 if($frm_props->getThreadSorting())
1129 {
1130 $additional_sort .= ' , thread_sorting ASC ';
1131 }
1132
1133 if($params['order_column'] == 'thr_subject')
1134 {
1135 $dynamic_columns = array(', thr_subject ' . $params['order_direction']);
1136 }
1137 else if($params['order_column'] == 'num_posts')
1138 {
1139 $dynamic_columns = array(', thr_num_posts ' . $params['order_direction']);
1140 }
1141 else if($params['order_column'] == 'num_visit')
1142 {
1143 $dynamic_columns = array(', visits ' . $params['order_direction']);
1144 }
1145 else
1146 {
1147 $dynamic_columns = array(', post_date ' . $params['order_direction']);
1148 }
1149
1150 if($frm_props->isIsThreadRatingEnabled())
1151 {
1152 $dynamic_columns[] = ' ,avg_rating ' . $params['order_direction'];
1153 }
1154 if('rating' == strtolower($params['order_column']))
1155 {
1156 $dynamic_columns = array_reverse($dynamic_columns);
1157 }
1158 $additional_sort .= implode(' ', $dynamic_columns);
1159
1160 if(!$ilUser->isAnonymous())
1161 {
1162 $query = "SELECT
1163 (CASE WHEN COUNT(DISTINCT(notification_id)) > 0 THEN 1 ELSE 0 END) usr_notification_is_enabled,
1164 MAX(pos_date) post_date,
1165 COUNT(DISTINCT(pos_pk)) num_posts,
1166 COUNT(DISTINCT(pos_pk)) - COUNT(DISTINCT(postread.post_id)) num_unread_posts, ";
1167
1168 // new posts query
1169 if($frm_overview_setting == ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS)
1170 {
1171 $query .= "
1172 (SELECT COUNT(DISTINCT(ipos.pos_pk))
1173 FROM frm_posts ipos
1174 LEFT JOIN frm_user_read iread ON iread.post_id = ipos.pos_pk AND iread.usr_id = %s
1175 LEFT JOIN frm_thread_access iacc ON (iacc.thread_id = ipos.pos_thr_fk AND iacc.usr_id = %s)
1176 WHERE ipos.pos_thr_fk = thr_pk
1177
1178 AND (ipos.pos_update > iacc.access_old_ts
1179 OR
1180 (iacc.access_old IS NULL AND (ipos.pos_update > " . $ilDB->quote(date('Y-m-d H:i:s', NEW_DEADLINE), 'timestamp') . "))
1181 )
1182
1183 AND ipos.pos_author_id != %s
1184 AND iread.usr_id IS NULL $active_inner_query
1185 ) num_new_posts, ";
1186 }
1187
1188 $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
1189 {$optional_fields}
1190 FROM frm_threads
1191
1192 LEFT JOIN frm_notification
1193 ON frm_notification.thread_id = thr_pk
1194 AND frm_notification.user_id = %s
1195
1196 LEFT JOIN frm_posts
1197 ON pos_thr_fk = thr_pk $active_query
1198
1199 LEFT JOIN frm_user_read postread
1200 ON postread.post_id = pos_pk
1201 AND postread.usr_id = %s";
1202
1203 $query .= " WHERE thr_top_fk = %s
1204 {$excluded_ids_condition}
1205 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
1206 {$optional_fields}
1207 {$having}
1208 ORDER BY is_sticky DESC {$additional_sort}, thr_date DESC";
1209
1210
1211 // data_types for new posts query and $active_inner_query
1212 if($frm_overview_setting == ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS)
1213 {
1214 $data_types[] = 'integer';
1215 $data_types[] = 'integer';
1216 $data_types[] = 'integer';
1217 if($is_post_activation_enabled && !$params['is_moderator'])
1218 {
1219 array_push($data_types, 'integer', 'integer');
1220 }
1221 }
1222 $data_types[] = 'integer';
1223 if($is_post_activation_enabled && !$params['is_moderator'])
1224 {
1225 array_push($data_types, 'integer', 'integer');
1226 }
1227 $data_types[] = 'integer';
1228 $data_types[] = 'integer';
1229
1230 // data_values for new posts query and $active_inner_query
1231 if($frm_overview_setting == ilForumProperties::FORUM_OVERVIEW_WITH_NEW_POSTS)
1232 {
1233 $data[] = $ilUser->getId();
1234 $data[] = $ilUser->getId();
1235 $data[] = $ilUser->getId();
1236 if($is_post_activation_enabled && !$params['is_moderator'])
1237 {
1238 array_push($data, '1', $ilUser->getId());
1239 }
1240 }
1241 $data[] = $ilUser->getId();
1242 if($is_post_activation_enabled && !$params['is_moderator'])
1243 {
1244 array_push($data, '1', $ilUser->getId());
1245 }
1246 $data[] = $ilUser->getId();
1247 $data[] = $a_topic_id;
1248 }
1249 else
1250 {
1251 $query = "SELECT
1252 0 usr_notification_is_enabled,
1253 MAX(pos_date) post_date,
1254 COUNT(DISTINCT(pos_pk)) num_posts,
1255 COUNT(DISTINCT(pos_pk)) num_unread_posts,
1256 COUNT(DISTINCT(pos_pk)) num_new_posts,
1257 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
1258 {$optional_fields}
1259 FROM frm_threads
1260
1261 LEFT JOIN frm_posts
1262 ON pos_thr_fk = thr_pk $active_query";
1263
1264 $query .= " WHERE thr_top_fk = %s
1265 {$excluded_ids_condition}
1266 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
1267 {$optional_fields}
1268 {$having}
1269 ORDER BY is_sticky DESC {$additional_sort}, thr_date DESC";
1270
1271 if($is_post_activation_enabled && !$params['is_moderator'])
1272 {
1273 array_push($data_types, 'integer', 'integer');
1274 }
1275 $data_types[] = 'integer';
1276 if($is_post_activation_enabled && !$params['is_moderator'])
1277 {
1278 array_push($data, '1', $ilUser->getId());
1279 }
1280 $data[] = $a_topic_id;
1281 }
1282
1283 if($limit || $offset)
1284 {
1285 $ilDB->setLimit($limit, $offset);
1286 }
1287 $res = $ilDB->queryF($query, $data_types, $data);
1288 while($row = $ilDB->fetchAssoc($res))
1289 {
1290 $thread = new ilForumTopic($row['thr_pk'], $params['is_moderator'], true);
1291 $thread->assignData($row);
1292 $threads[] = $thread;
1293 }
1294
1295 return array(
1296 'items' => $threads,
1297 'cnt' => $cnt
1298 );
1299 }
1300
1301 public function getUserStatistic($is_moderator = false)
1302 {
1303 global $ilDB, $ilUser;
1304
1305 $statistic = array();
1306
1307 $data_types = array();
1308 $data = array();
1309
1310 $query = "SELECT COUNT(f.pos_display_user_id) ranking, u.login, p.value, u.lastname, u.firstname
1311 FROM frm_posts f
1312 INNER JOIN frm_posts_tree t
1313 ON f.pos_pk = t.pos_fk
1314 INNER JOIN frm_threads th
1315 ON t.thr_fk = th.thr_pk
1316 INNER JOIN usr_data u
1317 ON u.usr_id = f.pos_display_user_id
1318 INNER JOIN frm_data d
1319 ON d.top_pk = f.pos_top_fk
1320 LEFT JOIN usr_pref p
1321 ON p.usr_id = u.usr_id AND p.keyword = %s
1322 WHERE 1 = 1";
1323
1324 array_push($data_types, 'text');
1325 array_push($data, 'public_profile');
1326
1327 if (!$is_moderator)
1328 {
1329 $query .= ' AND (pos_status = %s
1330 OR (pos_status = %s
1331 AND pos_author_id = %s ))';
1332
1333 array_push($data_types,'integer', 'integer', 'integer');
1334 array_push($data, '1', '0', $ilUser->getId());
1335 }
1336
1337 $query .= ' AND d.top_frm_fk = %s
1338 GROUP BY pos_display_user_id, u.login, p.value,u.lastname, u.firstname';
1339
1340 array_push($data_types,'integer');
1341 array_push($data, $this->getForumId());
1342
1343
1344
1345 $res = $ilDB->queryf($query, $data_types, $data);
1346
1347 $counter = 0;
1348 while ($row = $ilDB->fetchAssoc($res))
1349 {
1350 $statistic[$counter][] = $row['ranking'];
1351 $statistic[$counter][] = $row['login'];
1352
1353 $lastname ='';
1354 $firstname = '';
1355 if(!$ilUser->isAnonymous() && in_array($row['value'], array('y', 'g')) ||
1356 $ilUser->isAnonymous() && 'g' == $row['value'])
1357 {
1358 $lastname = $row['lastname'];
1359 $firstname = $row['firstname'];
1360 }
1361
1362 $statistic[$counter][] = $lastname;
1363 $statistic[$counter][] = $firstname;
1364
1365 ++$counter;
1366 }
1367
1368 return is_array($statistic) ? $statistic : array();
1369 }
1370
1371
1379 public function getFirstPostByThread($a_thread_id)
1380 {
1381 global $ilDB;
1382
1383 $res = $ilDB->queryf('
1384 SELECT * FROM frm_posts_tree
1385 WHERE thr_fk = %s
1386 AND parent_pos = %s',
1387 array('integer', 'integer'), array($a_thread_id, '0'));
1388
1389 $row = $ilDB->fetchObject($res);
1390
1391 return $row->pos_fk ? $row->pos_fk : 0;
1392 }
1393
1400 public function getModerators()
1401 {
1402 return self::_getModerators($this->getForumRefId());
1403 }
1404
1412 public static function _getModerators($a_ref_id)
1413 {
1414 global $rbacreview;
1415
1416 $role_arr = $rbacreview->getRolesOfRoleFolder($a_ref_id);
1417 foreach($role_arr as $role_id)
1418 {
1419 if(ilObject::_lookupTitle($role_id) == 'il_frm_moderator_' . $a_ref_id)
1420 {
1421 return $rbacreview->assignedUsers($role_id);
1422 }
1423 }
1424
1425 return array();
1426 }
1427
1436 public static function _isModerator($a_ref_id, $a_usr_id)
1437 {
1438 if(!self::$moderators_by_ref_id_map[$a_ref_id])
1439 {
1440 self::$moderators_by_ref_id_map[$a_ref_id] = self::_getModerators($a_ref_id);
1441 }
1442 return in_array($a_usr_id, self::$moderators_by_ref_id_map[$a_ref_id]);
1443 }
1444
1452 public function countUserArticles($a_user_id)
1453 {
1454 global $ilDB;
1455
1456 $res = $ilDB->queryf('
1457 SELECT * FROM frm_data
1458 INNER JOIN frm_posts ON pos_top_fk = top_pk
1459 WHERE top_frm_fk = %s
1460 AND pos_author_id = %s',
1461 array('integer', 'integer'),
1462 array($this->getForumId(), $a_user_id));
1463
1464 return $res->numRows();
1465 }
1466
1467 public function countActiveUserArticles($a_user_id)
1468 {
1469 global $ilDB, $ilUser;
1470
1471 $res = $ilDB->queryf('
1472 SELECT * FROM frm_data
1473 INNER JOIN frm_posts ON pos_top_fk = top_pk
1474 WHERE top_frm_fk = %s
1475 AND (pos_status = %s
1476 OR (pos_status = %s
1477 AND pos_author_id = %s
1478 )
1479 )
1480 AND pos_author_id = %s',
1481 array('integer', 'integer', 'integer', 'integer', 'integer'),
1482 array($this->getForumId(),'1', '0', $ilUser->getId(), $a_user_id));
1483
1484 return $res->numRows();
1485 }
1486
1493 public function convertDate($date)
1494 {
1496 }
1497
1505 public function addPostTree($a_tree_id, $a_node_id = -1, $a_date = '')
1506 {
1507 global $ilDB;
1508
1509 $a_date = $a_date ? $a_date : date("Y-m-d H:i:s");
1510
1511 if ($a_node_id <= 0)
1512 {
1513 $a_node_id = $a_tree_id;
1514 }
1515
1516 $nextId = $ilDB->nextId('frm_posts_tree');
1517
1518 $statement = $ilDB->manipulateF('
1519 INSERT INTO frm_posts_tree
1520 ( fpt_pk,
1521 thr_fk,
1522 pos_fk,
1523 parent_pos,
1524 lft,
1525 rgt,
1526 depth,
1527 fpt_date
1528 )
1529 VALUES(%s, %s, %s, %s, %s, %s, %s, %s )',
1530 array('integer','integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'timestamp'),
1531 array($nextId, $a_tree_id, $a_node_id, '0', '1', '2', '1', $a_date));
1532
1533 return true;
1534 }
1535
1543 public function insertPostNode($a_node_id, $a_parent_id, $tree_id, $a_date = '')
1544 {
1545 global $ilDB;
1546
1547 $a_date = $a_date ? $a_date : date("Y-m-d H:i:s");
1548
1549 // get left value
1550 $sql_res = $ilDB->queryf('
1551 SELECT * FROM frm_posts_tree
1552 WHERE pos_fk = %s
1553 AND thr_fk = %s',
1554 array('integer', 'integer'),
1555 array($a_parent_id, $tree_id));
1556
1557 $res = $ilDB->fetchObject($sql_res);
1558
1559 $left = $res->lft;
1560
1561 $lft = $left + 1;
1562 $rgt = $left + 2;
1563
1564 // spread tree
1565 $statement = $ilDB->manipulateF('
1566 UPDATE frm_posts_tree
1567 SET lft = CASE
1568 WHEN lft > %s
1569 THEN lft + 2
1570 ELSE lft
1571 END,
1572 rgt = CASE
1573 WHEN rgt > %s
1574 THEN rgt + 2
1575 ELSE rgt
1576 END
1577 WHERE thr_fk = %s',
1578 array('integer', 'integer', 'integer'),
1579 array($left, $left, $tree_id));
1580
1581 $depth = $this->getPostDepth($a_parent_id, $tree_id) + 1;
1582
1583 // insert node
1584 $nextId = $ilDB->nextId('frm_posts_tree');
1585 $statement = $ilDB->manipulateF('
1586 INSERT INTO frm_posts_tree
1587 ( fpt_pk,
1588 thr_fk,
1589 pos_fk,
1590 parent_pos,
1591 lft,
1592 rgt,
1593 depth,
1594 fpt_date
1595 )
1596 VALUES(%s,%s,%s, %s, %s, %s,%s, %s)',
1597 array('integer','integer', 'integer', 'integer', 'integer', 'integer', 'integer', 'timestamp'),
1598 array( $nextId,
1599 $tree_id,
1600 $a_node_id,
1601 $a_parent_id,
1602 $lft,
1603 $rgt,
1604 $depth,
1605 $a_date)
1606 );
1607
1608 }
1609
1617 public function getPostDepth($a_node_id, $tree_id)
1618 {
1619 global $ilDB;
1620
1621 if ($tree_id)
1622 {
1623 $sql_res = $ilDB->queryf('
1624 SELECT depth FROM frm_posts_tree
1625 WHERE pos_fk = %s
1626 AND thr_fk = %s',
1627 array('integer', 'integer'),
1628 array($a_node_id, $tree_id));
1629
1630 $res = $ilDB->fetchObject($sql_res);
1631
1632 return $res->depth;
1633 }
1634 else
1635 {
1636 return 0;
1637 }
1638 }
1639
1646 public function getFirstPostNode($tree_id)
1647 {
1648 global $ilDB;
1649
1650 $res = $ilDB->queryf('
1651 SELECT * FROM frm_posts, frm_posts_tree
1652 WHERE pos_pk = pos_fk
1653 AND parent_pos = %s
1654 AND thr_fk = %s',
1655 array('integer', 'integer'),
1656 array('0', $tree_id));
1657
1658 $row = $ilDB->fetchObject($res);
1659
1660 return $this->fetchPostNodeData($row);
1661 }
1662
1669 public function getPostNode($post_id)
1670 {
1671 global $ilDB;
1672
1673 $res = $ilDB->queryf('
1674 SELECT * FROM frm_posts, frm_posts_tree
1675 WHERE pos_pk = pos_fk
1676 AND pos_pk = %s',
1677 array('integer'),
1678 array($post_id));
1679
1680 $row = $ilDB->fetchObject($res);
1681
1682 return $this->fetchPostNodeData($row);
1683 }
1684
1691 public function fetchPostNodeData($a_row)
1692 {
1693 global $lng;
1694
1695 require_once('./Services/User/classes/class.ilObjUser.php');
1696
1697 if (ilObject::_exists($a_row->pos_display_user_id))
1698 {
1699 $tmp_user = new ilObjUser($a_row->pos_display_user_id);
1700 $fullname = $tmp_user->getFullname();
1701 $loginname = $tmp_user->getLogin();
1702 }
1703
1704 $fullname = $fullname ? $fullname : ($a_row->import_name ? $a_row->import_name : $lng->txt("unknown"));
1705
1706 $data = array(
1707 "pos_pk" => $a_row->pos_pk,
1708 "child" => $a_row->pos_pk,
1709 "author" => $a_row->pos_display_user_id,
1710 "alias" => $a_row->pos_usr_alias,
1711 "title" => $fullname,
1712 "loginname" => $loginname,
1713 "type" => "post",
1714 "message" => $a_row->pos_message,
1715 "subject" => $a_row->pos_subject,
1716 "pos_cens_com" => $a_row->pos_cens_com,
1717 "pos_cens" => $a_row->pos_cens,
1718 // "date" => $a_row->date,
1719 "date" => $a_row->fpt_date,
1720 "create_date" => $a_row->pos_date,
1721 "update" => $a_row->pos_update,
1722 "update_user" => $a_row->update_user,
1723 "tree" => $a_row->thr_fk,
1724 "parent" => $a_row->parent_pos,
1725 "lft" => $a_row->lft,
1726 "rgt" => $a_row->rgt,
1727 "depth" => $a_row->depth,
1728 "id" => $a_row->fpt_pk,
1729 "notify" => $a_row->notify,
1730 "import_name" => $a_row->import_name,
1731 "pos_status" => $a_row->pos_status
1732 );
1733
1734 // why this line? data should be stored without slashes in db
1735 //$data["message"] = stripslashes($data["message"]);
1736
1737 return $data ? $data : array();
1738 }
1739
1746 public function deletePostTree($a_node)
1747 {
1748 global $ilDB;
1749
1750 // GET LEFT AND RIGHT VALUES
1751 $res = $ilDB->queryf('
1752 SELECT * FROM frm_posts_tree
1753 WHERE thr_fk = %s
1754 AND pos_fk = %s
1755 AND parent_pos = %s',
1756 array('integer', 'integer', 'integer'),
1757 array($a_node['tree'], $a_node['pos_pk'], $a_node['parent']));
1758
1759 while($row = $ilDB->fetchObject($res))
1760 {
1761 $a_node["lft"] = $row->lft;
1762 $a_node["rgt"] = $row->rgt;
1763 }
1764
1765 $diff = $a_node["rgt"] - $a_node["lft"] + 1;
1766
1767 // get data of posts
1768 $result = $ilDB->queryf('
1769 SELECT * FROM frm_posts_tree
1770 WHERE lft BETWEEN %s AND %s
1771 AND thr_fk = %s',
1772 array('integer', 'integer', 'integer'),
1773 array($a_node['lft'], $a_node['rgt'], $a_node['tree']));
1774
1775 $del_id = array();
1776
1777 while ($treeData = $ilDB->fetchAssoc($result))
1778 {
1779 $del_id[] = $treeData["pos_fk"];
1780 }
1781
1782 // delete subtree
1783 $statement = $ilDB->manipulateF('
1784 DELETE FROM frm_posts_tree
1785 WHERE lft BETWEEN %s AND %s
1786 AND thr_fk = %s',
1787 array('integer', 'integer', 'integer'),
1788 array($a_node['lft'], $a_node['rgt'], $a_node['tree']));
1789
1790
1791 // close gaps
1792 $statement = $ilDB->manipulateF('
1793 UPDATE frm_posts_tree
1794 SET lft = CASE
1795 WHEN lft > %s
1796 THEN lft - %s
1797 ELSE lft
1798 END,
1799 rgt = CASE
1800 WHEN rgt > %s
1801 THEN rgt - %s
1802 ELSE rgt
1803 END
1804 WHERE thr_fk = %s',
1805 array('integer', 'integer', 'integer', 'integer', 'integer'),
1806 array($a_node['lft'], $diff, $a_node['lft'], $diff, $a_node['tree']));
1807
1808 return $del_id;
1809
1810 }
1811
1817 public function updateVisits($ID)
1818 {
1819
1820 global $ilDB;
1821
1822 $checkTime = time() - (60*60);
1823
1824 if ($_SESSION["frm_visit_".$this->dbTable."_".$ID] < $checkTime)
1825 {
1826
1827 $_SESSION["frm_visit_".$this->dbTable."_".$ID] = time();
1828 $query = 'UPDATE '.$this->dbTable.' SET visits = visits + 1 WHERE ';
1829
1830 $data_type = array();
1831 $data_value = array();
1832
1833 if($this->getMDB2Query() != '' && $this->getMDB2DataType() != '' && $this->getMDB2DataValue() != '')
1834 {
1835 $query .= $this->getMDB2Query();
1836 $data_type = $data_type + $this->getMDB2DataType();
1837 $data_value = $data_value + $this->getMDB2DataValue();
1838
1839 $res = $ilDB->queryf($query, $data_type, $data_value);
1840 }
1841 }
1842 }
1843
1851 public function prepareText($text, $edit=0, $quote_user = '', $type = '')
1852 {
1853 global $lng;
1854
1855 if($type == 'export')
1856 {
1857 $this->replQuote1 = "<blockquote class=\"quote\"><hr size=\"1\" color=\"#000000\">";
1858 $this->replQuote2 = "<hr size=\"1\" color=\"#000000\"/></blockquote>";
1859 }
1860
1861 if($edit == 1)
1862 {
1863 // add login name of quoted users
1864 $lname = ($quote_user != "")
1865 ? '="'.$quote_user.'"'
1866 : "";
1867
1868 $text = "[quote$lname]".$text."[/quote]";
1869 }
1870 else
1871 {
1872 // check for quotation
1873 $startZ = substr_count ($text, "[quote"); // also count [quote="..."]
1874 $endZ = substr_count ($text, "[/quote]");
1875
1876 if ($startZ > 0 || $endZ > 0)
1877 {
1878 // add missing opening and closing tags
1879 if ($startZ > $endZ)
1880 {
1881 $diff = $startZ - $endZ;
1882
1883 for ($i = 0; $i < $diff; $i++)
1884 {
1885 if ($type == 'export') $text .= $this->txtQuote2;
1886 else $text .= "[/quote]";
1887 }
1888 }
1889 elseif ($startZ < $endZ)
1890 {
1891 $diff = $endZ - $startZ;
1892
1893 for ($i = 0; $i < $diff; $i++)
1894 {
1895 if ($type == 'export') $text = $this->txtQuote1.$text;
1896 else $text = "[quote]".$text;
1897 }
1898 }
1899
1900 if($edit == 0)
1901 {
1902 $text = preg_replace(
1903 '@\[(quote\s*?=\s*?"([^"]*?)"\s*?)\]@i',
1904 $this->replQuote1 . '<div class="ilForumQuoteHead">' . $lng->txt('quote'). ' ($2)</div>',
1905 $text
1906 );
1907
1908 $text = str_replace("[quote]",
1909 $this->replQuote1.'<div class="ilForumQuoteHead">'.$lng->txt("quote").'</div>', $text);
1910
1911 $text = str_replace("[/quote]", $this->replQuote2, $text);
1912 }
1913 }
1914 }
1915
1916 if($type != 'export')
1917 {
1918 if($edit == 0)
1919 {
1920 include_once './Services/MathJax/classes/class.ilMathJax.php';
1921 $text = ilMathJax::getInstance()->insertLatexImages($text, "<span class\=\"latex\">", "<\/span>");
1922 $text = ilMathJax::getInstance()->insertLatexImages($text, "\[tex\]", "\[\/tex\]");
1923 }
1924
1925 // workaround for preventing template engine
1926 // from hiding text that is enclosed
1927 // in curly brackets (e.g. "{a}")
1928 $text = str_replace("{", "&#123;", $text);
1929 $text = str_replace("}", "&#125;", $text);
1930 }
1931
1932 return $text;
1933 }
1934
1935
1942 public function getModeratorFromPost($pos_pk)
1943 {
1944 global $ilDB;
1945
1946 $res = $ilDB->queryf('
1947 SELECT frm_data.* FROM frm_data, frm_posts
1948 WHERE pos_pk = %s
1949 AND pos_top_fk = top_pk',
1950 array('integer'), array($pos_pk));
1951
1952 $row = $ilDB->fetchAssoc($res);
1953
1954 return $row;
1955
1956 }
1957
1958 function __deletePostFiles($a_ids)
1959 {
1960 if(!is_array($a_ids))
1961 {
1962 return false;
1963 }
1964 include_once "./Modules/Forum/classes/class.ilFileDataForum.php";
1965
1966 $tmp_file_obj = new ilFileDataForum($this->getForumId());
1967 foreach($a_ids as $pos_id)
1968 {
1969 $tmp_file_obj->setPosId($pos_id);
1970 $files = $tmp_file_obj->getFilesOfPost();
1971 foreach($files as $file)
1972 {
1973 $tmp_file_obj->unlinkFile($file["name"]);
1974 }
1975 }
1976 unset($tmp_file_obj);
1977 return true;
1978 }
1979
1980 function getImportName()
1981 {
1982 return $this->import_name;
1983 }
1984 function setImportName($a_import_name)
1985 {
1986 $this->import_name = $a_import_name;
1987 }
1988
1995 function enableForumNotification($user_id)
1996 {
1997 global $ilDB;
1998
1999 if (!$this->isForumNotificationEnabled($user_id))
2000 {
2001 /* Remove all notifications of threads that belong to the forum */
2002
2003 $res = $ilDB->queryf('
2004 SELECT frm_notification.thread_id FROM frm_data, frm_notification, frm_threads
2005 WHERE frm_notification.user_id = %s
2006 AND frm_notification.thread_id = frm_threads.thr_pk
2007 AND frm_threads.thr_top_fk = frm_data.top_pk
2008 AND frm_data.top_frm_fk = %s
2009 GROUP BY frm_notification.thread_id',
2010 array('integer', 'integer'),
2011 array($user_id, $this->id));
2012
2013 if (is_object($res) && $res->numRows() > 0)
2014 {
2015 $thread_data = array();
2016 $thread_data_types = array();
2017
2018 $query = ' DELETE FROM frm_notification
2019 WHERE user_id = %s
2020 AND thread_id IN (';
2021
2022 array_push($thread_data, $user_id);
2023 array_push($thread_data_types, 'integer');
2024
2025 $counter = 1;
2026
2027 while($row = $ilDB->fetchAssoc($res))
2028 {
2029 if($counter < $res->numRows())
2030 {
2031 $query .= '%s, ';
2032 array_push($thread_data, $row['thread_id']);
2033 array_push($thread_data_types, 'integer');
2034 }
2035
2036 if($counter == $res->numRows())
2037 {
2038 $query .= '%s)';
2039 array_push($thread_data, $row['thread_id']);
2040 array_push($thread_data_types, 'integer');
2041
2042 }
2043 $counter++;
2044 }
2045
2046 $statement = $ilDB->manipulateF($query, $thread_data_types, $thread_data);
2047 }
2048
2049 /* Insert forum notification */
2050
2051 $nextId = $ilDB->nextId('frm_notification');
2052
2053 $statement = $ilDB->manipulateF('
2054 INSERT INTO frm_notification
2055 ( notification_id,
2056 user_id,
2057 frm_id
2058 )
2059 VALUES(%s, %s, %s)',
2060 array('integer','integer', 'integer'),
2061 array($nextId, $user_id, $this->id));
2062
2063 }
2064
2065 return true;
2066 }
2067
2074 function disableForumNotification($user_id)
2075 {
2076 global $ilDB;
2077
2078 $statement = $ilDB->manipulateF('
2079 DELETE FROM frm_notification
2080 WHERE user_id = %s
2081 AND frm_id = %s',
2082 array('integer', 'integer'),
2083 array($user_id, $this->id));
2084
2085 return true;
2086 }
2087
2095 {
2096 global $ilDB;
2097
2098 $result = $ilDB->queryf('SELECT COUNT(*) cnt FROM frm_notification WHERE user_id = %s AND frm_id = %s',
2099 array('integer', 'integer'), array($user_id, $this->id));
2100
2101 while($record = $ilDB->fetchAssoc($result))
2102 {
2103 return (bool)$record['cnt'];
2104 }
2105
2106 return false;
2107 }
2108
2116 function enableThreadNotification($user_id, $thread_id)
2117 {
2118 global $ilDB;
2119
2120 if (!$this->isThreadNotificationEnabled($user_id, $thread_id))
2121 {
2122 $nextId = $ilDB->nextId('frm_notification');
2123 $statement = $ilDB->manipulateF('
2124 INSERT INTO frm_notification
2125 ( notification_id,
2126 user_id,
2127 thread_id
2128 )
2129 VALUES (%s, %s, %s)',
2130 array('integer', 'integer', 'integer'), array($nextId, $user_id, $thread_id));
2131
2132 }
2133
2134 return true;
2135 }
2136
2144 function isThreadNotificationEnabled($user_id, $thread_id)
2145 {
2146 global $ilDB;
2147
2148 $result = $ilDB->queryf('
2149 SELECT COUNT(*) cnt FROM frm_notification
2150 WHERE user_id = %s
2151 AND thread_id = %s',
2152 array('integer', 'integer'),
2153 array($user_id, $thread_id));
2154
2155
2156 while($record = $ilDB->fetchAssoc($result))
2157 {
2158 return (bool)$record['cnt'];
2159 }
2160
2161 return false;
2162 }
2163
2173 public static function _getThreads($a_obj_id,$a_sort_mode = self::SORT_DATE)
2174 {
2175 global $ilDB;
2176
2177 switch($a_sort_mode)
2178 {
2179 case self::SORT_DATE:
2180 $sort = 'thr_date';
2181 break;
2182
2183 case self::SORT_TITLE:
2184 default:
2185 $sort = 'thr_subject';
2186 break;
2187 }
2188
2189 $res = $ilDB->queryf('
2190 SELECT * FROM frm_threads
2191 JOIN frm_data ON top_pk = thr_top_fk
2192 WHERE top_frm_fk = %s
2193 ORDER BY %s',
2194 array('integer', 'text'), array($a_obj_id, $sort));
2195
2196 while($row = $ilDB->fetchObject($res))
2197 {
2198 $threads[$row->thr_pk] = $row->thr_subject;
2199 }
2200 return $threads ? $threads : array();
2201 }
2202
2203 public static function _lookupObjIdForForumId($a_for_id)
2204 {
2205 global $ilDB;
2206
2207 $res = $ilDB->queryf('
2208 SELECT top_frm_fk FROM frm_data
2209 WHERE top_pk = %s',
2210 array('integer'), array($a_for_id));
2211
2212 if ($fdata = $ilDB->fetchAssoc($res))
2213 {
2214 return $fdata["top_frm_fk"];
2215 }
2216 return false;
2217 }
2218
2219 public static function updateLastPostByObjId($a_obj_id)
2220 {
2221 global $ilDB;
2222 // get latest post of forum and update last_post
2223 $ilDB->setLimit(1);
2224 $res2 = $ilDB->queryf('
2225 SELECT pos_top_fk, pos_thr_fk, pos_pk FROM frm_posts, frm_data
2226 WHERE pos_top_fk = top_pk
2227 AND top_frm_fk = %s
2228 ORDER BY pos_date DESC',
2229 array('integer'), array($a_obj_id));
2230
2231 if ($res2->numRows() == 0)
2232 {
2233 $lastPost_top = "";
2234 }
2235 else
2236 {
2237 $z = 0;
2238
2239 while ($selData = $ilDB->fetchAssoc($res2))
2240 {
2241 if ($z > 0)
2242 {
2243 break;
2244 }
2245
2246 $lastPost_top = $selData["pos_top_fk"]."#".$selData["pos_thr_fk"]."#".$selData["pos_pk"];
2247 $z ++;
2248 }
2249 }
2250
2251 $ilDB->update('frm_data',
2252 array('top_last_post' => array('text', $lastPost_top)),
2253 array('top_frm_fk' => array('integer', $a_obj_id))
2254 );
2255
2256 }
2257
2264 public static function mergeThreads($obj_id, $source_id, $target_id)
2265 {
2266 // selected source & target objects
2267 $source_thread_obj = new ilForumTopic((int)$source_id);
2268 $target_thread_obj = new ilForumTopic((int)$target_id);
2269
2270 if($source_thread_obj->getForumId() != $target_thread_obj->getForumId())
2271 {
2272 throw new ilException('not_allowed_to_merge_into_another_forum');
2273 }
2274 // use the "older" thread as target
2275 if($source_thread_obj->getCreateDate() > $target_thread_obj->getCreateDate())
2276 {
2277 $merge_thread_source = $source_thread_obj;
2278 $merge_thread_target = $target_thread_obj;
2279 }
2280 else
2281 {
2282 $merge_thread_source = $target_thread_obj;
2283 $merge_thread_target = $source_thread_obj;
2284 }
2285
2286 $thread_subject = $target_thread_obj->getSubject();
2287
2288 // remember if the threads are open or closed and then close both threads !
2289 $targed_was_closed = $merge_thread_target->isClosed();
2290
2291 $merge_thread_source->close();
2292
2293 if($targed_was_closed == false)
2294 {
2295 $merge_thread_target->close();
2296 }
2297
2298 $source_all_posts = $merge_thread_source->getAllPosts();
2299 $source_root_node = $merge_thread_source->getFirstPostNode();
2300 $target_root_node = $merge_thread_target->getFirstPostNode();
2301
2302 $add_difference = $target_root_node->getRgt();
2303
2304// update target root node rgt
2305 include_once 'Modules/Forum/classes/class.ilForumPostsTree.php';
2306// $new_target_rgt = ($target_root_node->getRgt() + $source_root_node->getRgt() + 1);
2307 $new_target_rgt = ($target_root_node->getRgt() + $source_root_node->getRgt());
2308 ilForumPostsTree::updateTargetRootRgt($target_root_node->getId(), $new_target_rgt);
2309
2310 $new_target_root = $target_root_node->getId();
2311
2312 // get source post tree and update posts tree
2313 foreach($source_all_posts as $post)
2314 {
2315 $post_obj = new ilForumPost($post->pos_pk);
2316
2317 $posts_tree_obj = new ilForumPostsTree();
2318 $posts_tree_obj->setPosFk($post->pos_pk);
2319
2320 if($post_obj->getParentId() == 0)
2321 {
2322 $posts_tree_obj->setParentPos($new_target_root);
2323
2324 //$posts_tree_obj->setRgt(($post_obj->getRgt() + $add_difference));
2325 $posts_tree_obj->setRgt(($post_obj->getRgt() + $add_difference) - 1);
2326 $posts_tree_obj->setLft($target_root_node->getRgt());
2327
2328 $posts_tree_obj->setDepth(($post_obj->getDepth() + 1));
2329 $posts_tree_obj->setSourceThreadId($merge_thread_source->getId());
2330
2331 $posts_tree_obj->setTargetThreadId($merge_thread_target->getId());
2332
2333 $posts_tree_obj->mergeParentPos();
2334 }
2335 else
2336 {
2337 $posts_tree_obj->setRgt(($post_obj->getRgt() + $add_difference) - 1);
2338 $posts_tree_obj->setLft(($post_obj->getLft() + $add_difference) - 1);
2339
2340 $posts_tree_obj->setDepth(($post_obj->getDepth() + 1));
2341 $posts_tree_obj->setSourceThreadId($merge_thread_source->getId());
2342
2343 $posts_tree_obj->setParentPos($post_obj->getParentId());
2344 $posts_tree_obj->setTargetThreadId($merge_thread_target->getId());
2345
2346 $posts_tree_obj->merge();
2347 }
2348 }
2349
2350// update frm_posts pos_thr_fk = target_thr_id
2351 include_once 'Modules/Forum/classes/class.ilForumPost.php';
2352 ilForumPost::mergePosts($merge_thread_source->getId(), $merge_thread_target->getId());
2353
2354// check notifications
2355 include_once 'Modules/Forum/classes/class.ilForumNotification.php';
2356 ilForumNotification::mergeThreadNotificiations($merge_thread_source->getId(), $merge_thread_target->getId());
2357
2358// delete frm_thread_access entries
2359 include_once './Modules/Forum/classes/class.ilObjForum.php';
2360 ilObjForum::_deleteAccessEntries($merge_thread_source->getId());
2361
2362// update frm_user_read
2363 ilObjForum::mergeForumUserRead($merge_thread_source->getId(), $merge_thread_target->getId());
2364
2365// update visits, thr_num_posts, last_post, subject
2366 $post_date_source = $merge_thread_source->getLastPost()->getCreateDate();
2367 $post_date_target = $merge_thread_target->getLastPost()->getCreateDate();
2368
2369 $target_last_post = $merge_thread_target->getLastPostString();
2370 $exp = explode('#', $target_last_post);
2371
2372 if($post_date_source > $post_date_target)
2373 {
2374 $exp[2] = $merge_thread_source->getLastPost()->getId();
2375 }
2376 else
2377 {
2378 $exp[2] = $merge_thread_target->getLastPost()->getId();
2379 }
2380 $new_thr_last_post = implode('#', $exp);
2381
2382 $num_posts_source = (int)$merge_thread_source->getNumPosts();
2383 $num_visits_source = (int)$merge_thread_source->getVisits();
2384 $num_posts_target = (int)$merge_thread_target->getNumPosts();
2385 $num_visits_target = (int)$merge_thread_source->getVisits();
2386
2387 $frm_topic_obj = new ilForumTopic(0, false, true);
2388 $frm_topic_obj->setNumPosts(($num_posts_source + $num_posts_target));
2389 $frm_topic_obj->setVisits(($num_visits_source + $num_visits_target));
2390 $frm_topic_obj->setLastPostString($new_thr_last_post);
2391 $frm_topic_obj->setSubject($thread_subject);
2392 $frm_topic_obj->setId($merge_thread_target->getId());
2393
2394 $frm_topic_obj->updateMergedThread();
2395
2396// update frm_data: top_last_post , top_num_threads
2398
2399// reopen target if was not "closed" before merging
2400 if(!$targed_was_closed)
2401 {
2402 $merge_thread_target->reopen();
2403 }
2404 // raise event for updating existing drafts
2405 $GLOBALS['ilAppEventHandler']->raise('Modules/Forum', 'mergedThreads',
2406 array( 'source_thread_id' => $merge_thread_source->getId(),
2407 'target_thread_id' => $merge_thread_target->getId())
2408 );
2409
2410// delete source thread
2411 ilForumTopic::deleteByThreadId($merge_thread_source->getId());
2412 }
2413} // END class.Forum
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$result
$files
Definition: add-vimline.php:18
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_DATETIME
const NEWS_USERS
const NEWS_NOTICE
static formatDate(ilDateTime $date)
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 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)
Enable a user's notification about new posts in a thread.
__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
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.
getModeratorFromPost($pos_pk)
get one post-dataset
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 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
$text
$params
Definition: example_049.php:96
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$target_id
Definition: goto.php:51
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:17
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
$ref_id
Definition: sahs_server.php:39
global $ilDB
$mobs
$ilUser
Definition: imgupload.php:18