60    public function __construct($a_id = 0, $a_call_by_reference = 
true)
 
   64        $this->rbac = 
$DIC->rbac();
 
   65        $this->db = 
$DIC->database();
 
   66        $this->ilBench = 
$DIC[
'ilBench'];
 
   67        $this->
user = $DIC->user();
 
   68        $this->logger = 
$DIC->logger()->root();
 
   79        $new_deadline = time() - 60 * 60 * 24 * 7 * ($this->
settings->get(
'frm_store_new') ?
 
   80            $this->
settings->get(
'frm_store_new') :
 
   82        define(
'NEW_DEADLINE', $new_deadline);
 
   93        $id = parent::create();
 
   97        $properties->setAnonymisation(0);
 
   98        $properties->setStatisticsStatus(0);
 
   99        $properties->setPostActivation(0);
 
  100        $properties->setThreadSorting(0);
 
  101        $properties->insert();
 
  115        parent::setPermissions($a_ref_id);
 
  119        $this->rbac->admin()->assignUser($roles[0], $this->
getOwner(), 
'n');
 
  128        $this->db->manipulate(
'UPDATE frm_data SET top_mods = ' . $this->db->quote($role_id, 
'integer') . 
' WHERE top_frm_fk = ' . $this->db->quote($this->getId(), 
'integer'));
 
  148                        SELECT thr_subject FROM frm_threads WHERE thr_pk = %s',
 
  153        while ($row = 
$ilDB->fetchObject(
$res)) {
 
  154            return $row->thr_subject;
 
  162        $a_frm_id = $this->
getId();
 
  164        $this->ilBench->start(
"Forum", 
'getCountRead');
 
  167            $res = $this->db->queryf(
 
  169                                SELECT top_pk FROM frm_data WHERE top_frm_fk = %s',
 
  175            while ($row = $this->db->fetchObject(
$res)) {
 
  176                $topic_id = $row->top_pk;
 
  180            $res = $this->db->queryf(
 
  182                                SELECT COUNT(pos_pk) num_posts 
  184                                LEFT JOIN frm_posts_tree ON frm_posts_tree.pos_fk = pos_pk 
  185                                WHERE pos_top_fk = %s' . ($ignoreRoot ? 
' AND parent_pos != 0 ' : 
''),
 
  190            while ($row = $this->db->fetchObject(
$res)) {
 
  191                $num_posts = $row->num_posts;
 
  194            $res = $this->db->queryf(
 
  196                                SELECT COUNT(post_id) count_read FROM frm_user_read 
  199                array(
'integer', 
'integer'),
 
  200                array($a_frm_id, $a_usr_id)
 
  203            while ($row = $this->db->fetchObject(
$res)) {
 
  204                $count_read = $row->count_read;
 
  206            $unread = $num_posts - $count_read;
 
  208            $this->ilBench->stop(
"Forum", 
'getCountRead');
 
  209            return $unread > 0 ? $unread : 0;
 
  211            $res = $this->db->queryf(
 
  213                                SELECT COUNT(pos_pk) num_posts FROM frm_posts 
  214                                LEFT JOIN frm_posts_tree ON frm_posts_tree.pos_fk = pos_pk 
  215                                WHERE pos_thr_fk = %s' . ($ignoreRoot ? 
' AND parent_pos != 0 ' : 
''),
 
  220            $row = $this->db->fetchObject(
$res);
 
  221            $num_posts = $row->num_posts;
 
  223            $res = $this->db->queryf(
 
  225                                SELECT COUNT(post_id) count_read FROM frm_user_read  
  229                array(
'integer', 
'integer', 
'integer'),
 
  230                array($a_frm_id, $a_frm_id, $a_thread_id)
 
  233            $row = $this->db->fetchObject(
$res);
 
  234            $count_read = $row->count_read;
 
  236            $unread = $num_posts - $count_read;
 
  238            $this->ilBench->stop(
"Forum", 
'getCountRead');
 
  239            return $unread > 0 ? $unread : 0;
 
  241        $this->ilBench->stop(
"Forum", 
'getCountRead');
 
  249        $res = $this->db->queryf(
 
  251                        SELECT * FROM frm_posts WHERE pos_thr_fk = %s',
 
  256        while ($row = $this->db->fetchObject(
$res)) {
 
  257            $this->
markPostRead($a_usr_id, $a_thread_id, $row->pos_pk);
 
  264        $res = $this->db->queryf(
 
  266                        SELECT * FROM frm_data, frm_threads  
  267                        WHERE top_frm_fk = %s 
  268                        AND top_pk = thr_top_fk',
 
  270            array($this->
getId())
 
  273        while ($row = $this->db->fetchObject(
$res)) {
 
  284        $res = $this->db->queryf(
 
  286                        SELECT * FROM frm_user_read  
  291            array(
'integer', 
'integer', 
'integer', 
'integer'),
 
  292            array($a_usr_id, $this->
getId(), $a_thread_id, $a_post_id)
 
  295        if ($this->db->numRows(
$res)) {
 
  299        $this->db->manipulateF(
 
  301                        INSERT INTO frm_user_read 
  307                        VALUES (%s,%s,%s,%s)',
 
  308            array(
'integer', 
'integer', 
'integer', 
'integer'),
 
  309            array($a_usr_id, $this->
getId(), $a_thread_id, $a_post_id)
 
  317        $this->db->manipulateF(
 
  319                        DELETE FROM frm_user_read 
  322            array(
'integer', 
'integer'),
 
  323            array($a_user_id, $a_post_id)
 
  327    public function isRead($a_usr_id, $a_post_id)
 
  329        $res = $this->db->queryf(
 
  331                        SELECT * FROM frm_user_read 
  334            array(
'integer', 
'integer'),
 
  335            array($a_usr_id, $a_post_id)
 
  338        return $this->db->numRows(
$res) ? 
true : 
false;
 
  343        $res = $this->db->queryf(
 
  345                        SELECT * FROM frm_thread_access  
  349            array(
'integer', 
'integer', 
'integer'),
 
  350            array($a_usr_id, $this->
getId(), $a_thread_id)
 
  357                'usr_id' => array(
'integer', $a_usr_id),
 
  358                'obj_id' => array(
'integer', $this->
getId()),
 
  359                'thread_id' => array(
'integer', $a_thread_id)
 
  362                'access_last' => array(
'integer', time()),
 
  363                'access_old' => array(
'integer', isset(
$data[
'access_old']) ? 
$data[
'access_old'] : 0),
 
  364                'access_old_ts' => array(
'timestamp', 
$data[
'access_old_ts'])
 
  382                        UPDATE frm_thread_access  
  383                        SET access_old = access_last 
  390            "SELECT * FROM frm_thread_access " .
 
  391                " WHERE usr_id = " . 
$ilDB->quote($a_usr_id, 
"integer")
 
  393        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  395                "UPDATE frm_thread_access SET " .
 
  396                    " access_old_ts = " . 
$ilDB->quote(date(
'Y-m-d H:i:s', $rec[
"access_old"]), 
"timestamp") .
 
  397                    " WHERE usr_id = " . 
$ilDB->quote($rec[
"usr_id"], 
"integer") .
 
  398                    " AND obj_id = " . 
$ilDB->quote($rec[
"obj_id"], 
"integer") .
 
  399                    " AND thread_id = " . 
$ilDB->quote($rec[
"thread_id"], 
"integer")
 
  403        $new_deadline = time() - 60 * 60 * 24 * 7 * (
$DIC->settings()->get(
'frm_store_new') ?
 
  404            $DIC->settings()->get(
'frm_store_new') :
 
  409                        DELETE FROM frm_thread_access WHERE access_last < %s',
 
  420        $data = array($a_usr_id);
 
  424                        DELETE FROM frm_user_read WHERE usr_id = %s',
 
  431                        DELETE FROM frm_thread_access WHERE usr_id = %s',
 
  439                        DELETE FROM frm_notification WHERE user_id = %s',
 
  455                        DELETE FROM frm_user_read WHERE post_id = %s',
 
  469                        DELETE FROM frm_thread_access WHERE thread_id = %s',
 
  481    public function update($a_update_user_id = 0)
 
  483        if (!$a_update_user_id) {
 
  484            $a_update_user_id = $this->
user->getId();
 
  487        if (parent::update()) {
 
  488            $this->db->manipulateF(
 
  492                                        top_description = %s, 
  495                                WHERE top_frm_fk =%s',
 
  496                array(
'text', 
'text', 
'timestamp', 
'integer', 
'integer'),
 
  501                    (
int) $a_update_user_id,
 
  518    public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = 
false)
 
  521        $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
 
  525        $this->Forum->setMDB2WhereCondition(
'top_frm_fk = %s ', array(
'integer'), array($this->
getId()));
 
  526        $topData = $this->Forum->getOneTopic();
 
  528        $this->db->update(
'frm_data', array(
 
  529            'top_name' => array(
'text', $topData[
'top_name']),
 
  530            'top_description' => array(
'text', $topData[
'top_description']),
 
  531            'top_num_posts' => array(
'integer', $topData[
'top_num_posts']),
 
  532            'top_num_threads' => array(
'integer', $topData[
'top_num_threads']),
 
  533            'top_last_post' => array(
'text', $topData[
'top_last_post']),
 
  534            'top_date' => array(
'timestamp', $topData[
'top_date']),
 
  535            'visits' => array(
'integer', $topData[
'visits']),
 
  536            'top_update' => array(
'timestamp', $topData[
'top_update']),
 
  537            'update_user' => array(
'integer', $topData[
'update_user']),
 
  538            'top_usr_id' => array(
'integer', $topData[
'top_usr_id'])
 
  540            'top_frm_fk' => array(
'integer', $new_obj->getId())
 
  545        $options = $cwo->getOptions($this->
getRefId());
 
  547        $options[
'threads'] = $this->Forum->_getThreads($this->
getId());
 
  550        $new_frm = $new_obj->Forum;
 
  551        $new_frm->setMDB2WhereCondition(
'top_frm_fk = %s ', array(
'integer'), array($new_obj->getId()));
 
  553        $new_frm->setForumId($new_obj->getId());
 
  554        $new_frm->setForumRefId($new_obj->getRefId());
 
  556        $new_topic = $new_frm->getOneTopic();
 
  557        foreach ($options[
'threads'] as $thread_id => $thread_subject) {
 
  558            $this->Forum->setMDB2WhereCondition(
'thr_pk = %s ', array(
'integer'), array($thread_id));
 
  560            $old_thread = $this->Forum->getOneThread();
 
  562            $old_post_id = $this->Forum->getFirstPostByThread($old_thread[
'thr_pk']);
 
  563            $old_post = $this->Forum->getOnePost($old_post_id);
 
  566            $newThread->setSticky($old_thread[
'is_sticky']);
 
  567            $newThread->setForumId($new_topic[
'top_pk']);
 
  568            $newThread->setThrAuthorId($old_thread[
'thr_author_id']);
 
  569            $newThread->setDisplayUserId($old_thread[
'thr_display_user_id']);
 
  570            $newThread->setSubject($old_thread[
'thr_subject']);
 
  571            $newThread->setUserAlias($old_thread[
'thr_usr_alias']);
 
  572            $newThread->setCreateDate($old_thread[
'thr_date']);
 
  574            $old_thread_obj = 
new ilForumTopic($old_thread[
'thr_pk']);
 
  575            $top_pos_pk = $old_thread_obj->getFirstPostId() ?: $old_post_id;
 
  578            $newPostId = $new_frm->generateThread(
 
  580                $top_pos->getMessage(),
 
  581                (
int) $top_pos->isNotificationEnabled(),
 
  584                (
bool) ($old_thread_obj->getNumPosts() - 1)
 
  588            $old_forum_files->ilClone($new_obj->getId(), $newPostId);
 
  592        $targetRefId = $new_obj->getRefId();
 
  595            $sourceRefId > 0 && $targetRefId > 0 &&
 
  596            $this->tree->getParentId($sourceRefId) === $this->tree->getParentId($targetRefId)
 
  598            $grpRefId = $this->tree->checkForParentType($targetRefId, 
'grp');
 
  599            $crsRefId = $this->tree->checkForParentType($targetRefId, 
'crs');
 
  601            if ($grpRefId > 0 || $crsRefId > 0) {
 
  602                $notifications = new \ilForumNotification($targetRefId);
 
  603                $notifications->cloneFromSource((
int) $sourceRefId);
 
  621        if (!$moderator || !$new_moderator || !$this->
getRefId() || !$new_obj->getRefId()) {
 
  622            $this->logger->write(__METHOD__ . 
' : Error cloning auto generated role: il_frm_moderator');
 
  624        $this->rbac->admin()->copyRolePermissions($moderator, $this->
getRefId(), $new_obj->getRefId(), $new_moderator, 
true);
 
  625        $this->logger->write(__METHOD__ . 
' : Finished copying of role il_frm_moderator.');
 
  629        $old_mods = $obj_mods->getCurrentModerators();
 
  630        foreach ($old_mods as $user_id) {
 
  633            if ($this->
getOwner() != $user_id) {
 
  634                $this->rbac->admin()->assignUser($new_moderator, $user_id);
 
  644    public function delete()
 
  647        if (!parent::delete()) {
 
  653        $tmp_file_obj->delete();
 
  654        unset($tmp_file_obj);
 
  656        $this->Forum->setMDB2WhereCondition(
'top_frm_fk = %s ', array(
'integer'), array($this->
getId()));
 
  658        $topData = $this->Forum->getOneTopic();
 
  660        $threads = $this->Forum->getAllThreads($topData[
'top_pk']);
 
  661        foreach ($threads[
'items'] as $thread) {
 
  662            $thread_ids_to_delete[$thread->getId()] = $thread->getId();
 
  666        $this->db->manipulate(
'DELETE FROM frm_posts_tree WHERE ' . $this->db->in(
'thr_fk', $thread_ids_to_delete, 
false, 
'integer'));
 
  669        $this->db->manipulate(
'DELETE FROM frm_posts WHERE ' . $this->db->in(
'pos_thr_fk', $thread_ids_to_delete, 
false, 
'integer'));
 
  672        $this->db->manipulate(
'DELETE FROM frm_threads WHERE ' . $this->db->in(
'thr_pk', $thread_ids_to_delete, 
false, 
'integer'));
 
  674        $obj_id = array($this->
getId());
 
  676        $this->db->manipulateF(
 
  677            'DELETE FROM frm_data WHERE top_frm_fk = %s',
 
  683        $this->db->manipulateF(
 
  684            'DELETE FROM frm_settings WHERE obj_id = %s',
 
  690        $this->db->manipulateF(
 
  691            'DELETE FROM frm_user_read WHERE obj_id = %s',
 
  697        $this->db->manipulateF(
 
  698            'DELETE FROM frm_thread_access WHERE obj_id = %s',
 
  704        $this->db->manipulate(
'DELETE FROM frm_notification WHERE ' . $this->db->in(
'thread_id', $thread_ids_to_delete, 
false, 
'integer'));
 
  707        $this->db->manipulateF(
'DELETE FROM frm_notification WHERE  frm_id = %s', array(
'integer'), $obj_id);
 
  710        $this->db->manipulateF(
'DELETE FROM frm_posts_deleted WHERE obj_id = %s', array(
'integer'), $obj_id);
 
  723        $res = $this->db->queryF(
 
  724            'SELECT draft_id FROM frm_posts_drafts WHERE forum_id = %s',
 
  726            array((
int) $forum_id)
 
  729        $draft_ids = array();
 
  730        while ($row = $this->db->fetchAssoc(
$res)) {
 
  731            $draft_ids[] = $row[
'draft_id'];
 
  734        if (count($draft_ids) > 0) {
 
  736            $historyObj->deleteHistoryByDraftIds($draft_ids);
 
  739            $draftObj->deleteDraftsByDraftIds($draft_ids);
 
  751            'il_frm_moderator_' . $this->
getRefId(),
 
  752            "Moderator of forum obj_no." . $this->
getId(),
 
  771        $mod_title = 
'il_frm_moderator_' . $a_ref_id;
 
  775                        SELECT * FROM object_data WHERE title = %s',
 
  780        while ($row = 
$ilDB->fetchObject(
$res)) {
 
  791        if ($default_visibility == 
"public") {
 
  800        $nextId = $this->db->nextId(
'frm_data');
 
  803            'top_frm_fk' => $this->
getId(),
 
  806            'top_num_posts' => 0,
 
  807            'top_num_threads' => 0,
 
  808            'top_last_post' => 
null,
 
  809            'top_mods' => !is_numeric($a_roles[0]) ? 0 : $a_roles[0],
 
  810            'top_usr_id' => $this->
user->getId(),
 
  814        $this->db->manipulateF(
 
  829                VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)',
 
  830            array(
'integer', 
'integer', 
'text', 
'text', 
'integer', 
'integer', 
'text', 
'integer', 
'timestamp', 
'integer'),
 
  833                $top_data[
'top_frm_fk'],
 
  834                $top_data[
'top_name'],
 
  835                $top_data[
'top_description'],
 
  836                $top_data[
'top_num_posts'],
 
  837                $top_data[
'top_num_threads'],
 
  838                $top_data[
'top_last_post'],
 
  839                $top_data[
'top_mods'],
 
  840                $top_data[
'top_date'],
 
  841                $top_data[
'top_usr_id']
 
  850            array(
'thread_sorting' => array(
'integer',$a_sorting_value)),
 
  851            array(
'thr_pk' => array(
'integer', $a_thr_pk))
 
  863        if (array_key_exists($obj_id, self::$obj_id_to_forum_id_cache)) {
 
  864            return (
int) self::$obj_id_to_forum_id_cache[$obj_id];
 
  869        return (
int) self::$obj_id_to_forum_id_cache[$obj_id];
 
  879        if (array_key_exists(
$ref_id, self::$ref_id_to_forum_id_cache)) {
 
  880            return (
int) self::$ref_id_to_forum_id_cache[
$ref_id];
 
  885        return (
int) self::$ref_id_to_forum_id_cache[
$ref_id];
 
  897        if (count($obj_ids) == 1) {
 
  898            $in = 
" objr.obj_id = " . 
$ilDB->quote(current($obj_ids), 
'integer') . 
" ";
 
  900            $in = 
$ilDB->in(
'objr.obj_id', $obj_ids, 
false, 
'integer');
 
  903                        SELECT frmd.top_pk, objr.ref_id, objr.obj_id 
  904                        FROM object_reference objr 
  905                        INNER JOIN frm_data frmd ON frmd.top_frm_fk = objr.obj_id 
  911        foreach ($obj_ids as $obj_id) {
 
  912            self::$obj_id_to_forum_id_cache[$obj_id] = 
null;
 
  916            self::$obj_id_to_forum_id_cache[$row[
'obj_id']] = $row[
'top_pk'];
 
  917            self::$ref_id_to_forum_id_cache[$row[
'ref_id']] = $row[
'top_pk'];
 
  930        if (count($ref_ids) == 1) {
 
  931            $in = 
" objr.ref_id = " . 
$ilDB->quote(current($ref_ids), 
'integer') . 
" ";
 
  933            $in = 
$ilDB->in(
'objr.ref_id', $ref_ids, 
false, 
'integer');
 
  936                        SELECT frmd.top_pk, objr.ref_id, objr.obj_id 
  937                        FROM object_reference objr 
  938                        INNER JOIN frm_data frmd ON frmd.top_frm_fk = objr.obj_id 
  944        foreach ($ref_ids as 
$ref_id) {
 
  945            self::$ref_id_to_forum_id_cache[
$ref_id] = 
null;
 
  949            self::$obj_id_to_forum_id_cache[$row[
'obj_id']] = $row[
'top_pk'];
 
  950            self::$ref_id_to_forum_id_cache[$row[
'ref_id']] = $row[
'top_pk'];
 
  962        $ilAccess = 
$DIC->access();
 
  967        if (isset(self::$forum_statistics_cache[
$ref_id])) {
 
  968            return self::$forum_statistics_cache[
$ref_id];
 
  973            'num_unread_posts' => 0,
 
  979            self::$forum_statistics_cache[
$ref_id] = $statistics;
 
  980            return self::$forum_statistics_cache[
$ref_id];
 
  984        $is_post_activation_enabled = $objProperties->isPostActivationEnabled();
 
  988        if ($is_post_activation_enabled && !$ilAccess->checkAccess(
'moderate_frm', 
'', 
$ref_id)) {
 
  989            $act_clause .= 
" AND (frm_posts.pos_status = " . 
$ilDB->quote(1, 
"integer") . 
" OR frm_posts.pos_author_id = " . 
$ilDB->quote(
$ilUser->getId(), 
"integer") . 
") ";
 
  992        $new_deadline = date(
'Y-m-d H:i:s', time() - 60 * 60 * 24 * 7 * (
$ilSetting->get(
'frm_store_new') ? 
$ilSetting->get(
'frm_store_new') : 8));
 
  996                                (SELECT COUNT(frm_posts.pos_pk) cnt 
  998                                INNER JOIN frm_posts_tree tree1 
  999                                        ON tree1.pos_fk = frm_posts.pos_pk 
 1000                                        AND tree1.parent_pos != 0 
 1001                                INNER JOIN frm_threads ON frm_posts.pos_thr_fk = frm_threads.thr_pk  
 1002                                WHERE frm_threads.thr_top_fk = %s $act_clause) 
 1006                                (SELECT COUNT(DISTINCT(frm_user_read.post_id)) cnt 
 1008                                INNER JOIN frm_posts ON frm_user_read.post_id = frm_posts.pos_pk 
 1009                                INNER JOIN frm_posts_tree tree1 
 1010                                        ON tree1.pos_fk = frm_posts.pos_pk 
 1011                                        AND tree1.parent_pos != 0 
 1012                                INNER JOIN frm_threads ON frm_threads.thr_pk = frm_posts.pos_thr_fk  
 1013                                WHERE frm_user_read.usr_id = %s AND frm_posts.pos_top_fk = %s $act_clause) 
 1016            $types = array(
'integer', 
'integer', 
'integer');
 
 1017            $values = array($forumId, 
$ilUser->getId(), $forumId);
 
 1019            $forum_overview_setting = (int) $ilSetting::_lookupValue(
'frma', 
'forum_overview');
 
 1021                $news_types = array(
'integer', 
'integer', 
'integer', 
'timestamp', 
'integer');
 
 1022                $news_values = array(
$ilUser->getId(), 
$ilUser->getId(), $forumId,  $new_deadline, 
$ilUser->getId());
 
 1027                                (SELECT COUNT(frm_posts.pos_pk) cnt 
 1029                                INNER JOIN frm_posts_tree tree1 
 1030                                        ON tree1.pos_fk = frm_posts.pos_pk 
 1031                                        AND tree1.parent_pos != 0 
 1032                                LEFT JOIN frm_user_read ON (post_id = frm_posts.pos_pk AND frm_user_read.usr_id = %s) 
 1033                                LEFT JOIN frm_thread_access ON (frm_thread_access.thread_id = frm_posts.pos_thr_fk AND frm_thread_access.usr_id = %s) 
 1034                                WHERE frm_posts.pos_top_fk = %s 
 1035                                AND ( (frm_posts.pos_update > frm_thread_access.access_old_ts) 
 1036                                                OR (frm_thread_access.access_old IS NULL AND frm_posts.pos_update > %s) 
 1038                                AND frm_posts.pos_author_id != %s  
 1039                                AND frm_user_read.usr_id IS NULL $act_clause)";
 
 1041                $types = array_merge($types, $news_types);
 
 1042                $values = array_merge($values, $news_values);
 
 1045            $mapping = array_keys($statistics);
 
 1051            for (
$i = 0; 
$i <= 2; 
$i++) {
 
 1054                $statistics[$mapping[
$i]] = (int) ((is_array($row) ? $row[
'cnt'] : 0));
 
 1058                    $statistics[$mapping[
$i]] = $statistics[$mapping[
$i - 1]] - $statistics[$mapping[
$i]];
 
 1063                                SELECT COUNT(frm_posts.pos_pk) cnt 
 1065                                INNER JOIN frm_posts_tree tree1 
 1066                                        ON tree1.pos_fk = frm_posts.pos_pk 
 1067                                        AND tree1.parent_pos != 0 
 1068                                INNER JOIN frm_threads ON frm_posts.pos_thr_fk = frm_threads.thr_pk  
 1069                                WHERE frm_threads.thr_top_fk = %s $act_clause 
 1071            $types = array(
'integer');
 
 1072            $values = array($forumId);
 
 1080            $statistics = array(
 
 1081                'num_posts' => $row[
'cnt'],
 
 1082                'num_unread_posts' => $row[
'cnt'],
 
 1083                'num_new_posts' => $row[
'cnt']
 
 1087        self::$forum_statistics_cache[
$ref_id] = $statistics;
 
 1089        return self::$forum_statistics_cache[
$ref_id];
 
 1100        $ilAccess = 
$DIC->access();
 
 1104        if (isset(self::$forum_last_post_cache[
$ref_id])) {
 
 1105            return self::$forum_last_post_cache[
$ref_id];
 
 1110            self::$forum_last_post_cache[
$ref_id] = array();
 
 1111            return self::$forum_last_post_cache[
$ref_id];
 
 1115        if (!$ilAccess->checkAccess(
'moderate_frm', 
'', 
$ref_id)) {
 
 1116            $act_clause .= 
" AND (frm_posts.pos_status = " . 
$ilDB->quote(1, 
"integer") . 
" OR frm_posts.pos_author_id = " . 
$ilDB->quote(
$ilUser->getId(), 
"integer") . 
") ";
 
 1119        $ilDB->setLimit(1, 0);
 
 1123                        INNER JOIN frm_posts_tree tree1 
 1124                                        ON tree1.pos_fk = frm_posts.pos_pk 
 1125                                        AND tree1.parent_pos != 0 
 1126                        WHERE pos_top_fk = %s $act_clause 
 1127                        ORDER BY pos_date DESC 
 1139        return self::$forum_last_post_cache[
$ref_id];
 
 1151        $ilAccess = 
$DIC->access();
 
 1156        $act_inner_clause = 
'';
 
 1157        if (!$ilAccess->checkAccess(
'moderate_frm', 
'', 
$ref_id)) {
 
 1158            $act_clause .= 
" AND (t1.pos_status = " . 
$ilDB->quote(1, 
"integer") . 
" OR t1.pos_author_id = " . 
$ilDB->quote(
$ilUser->getId(), 
"integer") . 
") ";
 
 1159            $act_inner_clause .= 
" AND (t3.pos_status = " . 
$ilDB->quote(1, 
"integer") . 
" OR t3.pos_author_id = " . 
$ilDB->quote(
$ilUser->getId(), 
"integer") . 
") ";
 
 1162        $in = 
$ilDB->in(
"t1.pos_thr_fk", $thread_ids, 
false, 
'integer');
 
 1163        $inner_in = 
$ilDB->in(
"t3.pos_thr_fk", $thread_ids, 
false, 
'integer');
 
 1166                        SELECT t1.pos_display_user_id, t1.update_user 
 1168                        INNER JOIN frm_posts_tree tree1 ON tree1.pos_fk = t1.pos_pk AND tree1.parent_pos != 0  
 1170                                SELECT t3.pos_thr_fk, MAX(t3.pos_date) pos_date 
 1172                                INNER JOIN frm_posts_tree tree2 ON tree2.pos_fk = t3.pos_pk AND tree2.parent_pos != 0  
 1173                                WHERE $inner_in $act_inner_clause 
 1174                                GROUP BY t3.pos_thr_fk 
 1175                        ) t2 ON t2.pos_thr_fk = t1.pos_thr_fk AND t2.pos_date = t1.pos_date 
 1176                        WHERE $in $act_clause 
 1177                        GROUP BY t1.pos_thr_fk, t1.pos_display_user_id, t1.update_user 
 1183        while ($row = 
$ilDB->fetchAssoc(
$res)) {
 
 1184            if ((
int) $row[
'pos_display_user_id']) {
 
 1185                $usr_ids[] = (int) $row[
'pos_display_user_id'];
 
 1187            if ((
int) $row[
'update_user']) {
 
 1188                $usr_ids[] = (int) $row[
'update_user'];
 
 1192        return array_unique($usr_ids);
 
 1202            array(
'thread_id' => array(
'integer', $merge_target_thread_id)),
 
 1203            array(
'thread_id' => array(
'integer',$merge_source_thread_id))
 
 1209        $res = $this->db->query(
 
 1210            'SELECT COUNT(is_sticky) num_sticky FROM frm_threads 
 1211            INNER JOIN frm_data ON top_pk = thr_top_fk 
 1212            WHERE frm_data.top_frm_fk = ' . $this->db->quote($this->getId(), 
'integer') . 
' 
 1213            AND is_sticky = ' . $this->db->quote(1, 
'integer')
 
 1215        if ($row = $this->db->fetchAssoc(
$res)) {
 
 1216            return (
int) $row[
'num_sticky'];
 
if(php_sapi_name() !='cli') $in
An exception for terminatinating execution or to throw for unit testing.
return true
Flag indicating whether or not HTTP headers will be sent when outputting captcha image/audio.
static _write($a_type, $a_setting, $a_value, $a_user=0, $a_block_id=0)
Write setting to database.
static _getInstance($a_copy_id)
Get instance of copy wizard options.
This class handles all operations on files for the forum object.
Class ilForumDraftHistory.
const FORUM_OVERVIEW_WITH_NEW_POSTS
static getInstance($a_obj_id=0)
Class Forum core functions for forum.
static _getDefaultVisibilityForRefId($a_ref_id)
Get default visibility for reference id.
static _lookupDiskUsage($a_obj_id)
Returns the number of bytes used on the harddisk by the specified forum.
static $obj_id_to_forum_id_cache
markPostRead($a_usr_id, $a_thread_id, $a_post_id)
__construct($a_id=0, $a_call_by_reference=true)
Constructor @access public.
static _lookupThreadSubject($a_thread_id)
getCountUnread($a_usr_id, $a_thread_id=0, $ignoreRoot=false)
markAllThreadsRead($a_usr_id)
update($a_update_user_id=0)
update forum data @access public
deleteDraftsByForumId($forum_id)
static $forum_last_post_cache
initDefaultRoles()
init default roles settings @access public
saveData($a_roles=array())
setPermissions($a_ref_id)
updateModeratorRole($role_id)
static _deleteReadEntries($a_post_id)
static $forum_statistics_cache
static preloadForumIdsByRefIds(array $ref_ids)
static lookupStatisticsByRefId($ref_id)
updateLastAccess($a_usr_id, $a_thread_id)
setThreadSorting($a_thr_pk, $a_sorting_value)
getDiskUsage()
Gets the disk usage of the object in bytes.
static lookupForumIdByRefId($ref_id)
isRead($a_usr_id, $a_post_id)
static _deleteUser($a_usr_id)
static _deleteAccessEntries($a_thread_id)
markPostUnread($a_user_id, $a_post_id)
static lookupLastPostByRefId($ref_id)
markThreadRead($a_usr_id, $a_thread_id)
cloneAutoGeneratedRoles($new_obj)
Clone forum moderator role @access public.
static getUserIdsOfLastPostsByRefIdAndThreadIds($ref_id, array $thread_ids)
static $ref_id_to_forum_id_cache
static preloadForumIdsByObjIds(array $obj_ids)
static _lookupModeratorRole($a_ref_id)
Lookup moderator role @access public.
static _updateOldAccess($a_usr_id)
static mergeForumUserRead($merge_source_thread_id, $merge_target_thread_id)
static lookupForumIdByObjId($obj_id)
static createDefaultRole($a_title, $a_description, $a_tpl_name, $a_ref_id)
Class ilObject Basic functions for all objects.
getOwner()
get object owner
static _lookupObjectId($a_ref_id)
lookup object id
getRefId()
get reference id @access public
getDescription()
get object description
getId()
get object id @access public
getTitle()
get object title @access public
static now()
Return current timestamp in Y-m-d H:i:s format.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
foreach($_POST as $key=> $value) $res