4require_once 
'Services/Object/classes/class.ilObject.php';
 
    5require_once 
'Modules/Forum/classes/class.ilForum.php';
 
    6require_once 
'Modules/Forum/classes/class.ilFileDataForum.php';
 
    7require_once 
'Modules/Forum/classes/class.ilForumProperties.php';
 
   65    public function __construct($a_id = 0, $a_call_by_reference = 
true)
 
   69        $this->rbac = 
$DIC->rbac();
 
   70        $this->db = 
$DIC->database();
 
   71        $this->ilBench = 
$DIC[
'ilBench'];
 
   72        $this->
user = $DIC->user();
 
   73        $this->logger = 
$DIC->logger()->root();
 
   76        parent::__construct($a_id, $a_call_by_reference);
 
   84        $new_deadline = time() - 60 * 60 * 24 * 7 * ($this->
settings->get(
'frm_store_new') ?
 
   85            $this->
settings->get(
'frm_store_new') :
 
   87        define(
'NEW_DEADLINE', $new_deadline);
 
   98        $id = parent::create();
 
  100        require_once 
'Modules/Forum/classes/class.ilForumProperties.php';
 
  102        $properties->setDefaultView(1);
 
  103        $properties->setAnonymisation(0);
 
  104        $properties->setStatisticsStatus(0);
 
  105        $properties->setPostActivation(0);
 
  106        $properties->setThreadSorting(0);
 
  107        $properties->insert();
 
  121        parent::setPermissions($a_ref_id);
 
  125        $this->rbac->admin()->assignUser($roles[0], $this->
getOwner(), 
'n');
 
  134        $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'));
 
  144        require_once(
"./Modules/File/classes/class.ilObjFileAccess.php");
 
  155                        SELECT thr_subject FROM frm_threads WHERE thr_pk = %s',
 
  161            return $row->thr_subject;
 
  169        $a_frm_id = $this->
getId();
 
  171        $this->ilBench->start(
"Forum", 
'getCountRead');
 
  174            $res = $this->db->queryf(
 
  176                                SELECT top_pk FROM frm_data WHERE top_frm_fk = %s',
 
  182            while (
$row = $this->db->fetchObject(
$res)) {
 
  183                $topic_id = 
$row->top_pk;
 
  187            $res = $this->db->queryf(
 
  189                                SELECT COUNT(pos_pk) num_posts FROM frm_posts  
  190                                WHERE pos_top_fk = %s',
 
  195            while (
$row = $this->db->fetchObject(
$res)) {
 
  196                $num_posts = 
$row->num_posts;
 
  199            $res = $this->db->queryf(
 
  201                                SELECT COUNT(post_id) count_read FROM frm_user_read 
  204                array(
'integer', 
'integer'),
 
  205                array($a_frm_id, $a_usr_id)
 
  208            while (
$row = $this->db->fetchObject(
$res)) {
 
  209                $count_read = 
$row->count_read;
 
  211            $unread = $num_posts - $count_read;
 
  213            $this->ilBench->stop(
"Forum", 
'getCountRead');
 
  214            return $unread > 0 ? $unread : 0;
 
  216            $res = $this->db->queryf(
 
  218                                SELECT COUNT(pos_pk) num_posts FROM frm_posts 
  219                                WHERE pos_thr_fk = %s',
 
  224            $row       = $this->db->fetchObject(
$res);
 
  225            $num_posts = 
$row->num_posts;
 
  227            $res = $this->db->queryf(
 
  229                                SELECT COUNT(post_id) count_read FROM frm_user_read  
  233                array(
'integer', 
'integer', 
'integer'),
 
  234                array($a_frm_id, $a_frm_id, $a_thread_id)
 
  237            $row        = $this->db->fetchObject(
$res);
 
  238            $count_read = 
$row->count_read;
 
  240            $unread = $num_posts - $count_read;
 
  242            $this->ilBench->stop(
"Forum", 
'getCountRead');
 
  243            return $unread > 0 ? $unread : 0;
 
  245        $this->ilBench->stop(
"Forum", 
'getCountRead');
 
  253        $res = $this->db->queryf(
 
  255                        SELECT * FROM frm_posts WHERE pos_thr_fk = %s',
 
  260        while (
$row = $this->db->fetchObject(
$res)) {
 
  268        $res = $this->db->queryf(
 
  270                        SELECT * FROM frm_data, frm_threads  
  271                        WHERE top_frm_fk = %s 
  272                        AND top_pk = thr_top_fk',
 
  274            array($this->
getId())
 
  277        while (
$row = $this->db->fetchObject(
$res)) {
 
  288        $res = $this->db->queryf(
 
  290                        SELECT * FROM frm_user_read  
  295            array(
'integer', 
'integer', 
'integer', 
'integer'),
 
  296            array($a_usr_id, $this->
getId(), $a_thread_id, $a_post_id)
 
  299        if ($this->db->numRows(
$res)) {
 
  303        $this->db->manipulateF(
 
  305                        INSERT INTO frm_user_read 
  311                        VALUES (%s,%s,%s,%s)',
 
  312            array(
'integer', 
'integer', 
'integer', 
'integer'),
 
  313            array($a_usr_id, $this->
getId(), $a_thread_id, $a_post_id)
 
  321        $this->db->manipulateF(
 
  323                        DELETE FROM frm_user_read 
  326            array(
'integer', 
'integer'),
 
  327            array($a_user_id, $a_post_id)
 
  331    public function isRead($a_usr_id, $a_post_id)
 
  333        $res = $this->db->queryf(
 
  335                        SELECT * FROM frm_user_read 
  338            array(
'integer', 
'integer'),
 
  339            array($a_usr_id, $a_post_id)
 
  342        return $this->db->numRows(
$res) ? true : 
false;
 
  347        $res = $this->db->queryf(
 
  349                        SELECT * FROM frm_thread_access  
  353            array(
'integer', 
'integer', 
'integer'),
 
  354            array($a_usr_id, $this->
getId(), $a_thread_id)
 
  361                'usr_id'    => array(
'integer', $a_usr_id),
 
  362                'obj_id'    => array(
'integer', $this->
getId()),
 
  363                'thread_id' => array(
'integer', $a_thread_id)
 
  366                'access_last'   => array(
'integer', time()),
 
  367                'access_old'    => array(
'integer', isset(
$data[
'access_old']) ? 
$data[
'access_old'] : 0),
 
  368                'access_old_ts' => array(
'timestamp', 
$data[
'access_old_ts'])
 
  386                        UPDATE frm_thread_access  
  387                        SET access_old = access_last 
  394            "SELECT * FROM frm_thread_access " .
 
  395                " WHERE usr_id = " . 
$ilDB->quote($a_usr_id, 
"integer")
 
  397        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  399                "UPDATE frm_thread_access SET " .
 
  400                    " access_old_ts = " . 
$ilDB->quote(
date(
'Y-m-d H:i:s', $rec[
"access_old"]), 
"timestamp") .
 
  401                    " WHERE usr_id = " . 
$ilDB->quote($rec[
"usr_id"], 
"integer") .
 
  402                    " AND obj_id = " . 
$ilDB->quote($rec[
"obj_id"], 
"integer") .
 
  403                    " AND thread_id = " . 
$ilDB->quote($rec[
"thread_id"], 
"integer")
 
  407        $new_deadline = time() - 60 * 60 * 24 * 7 * (
$DIC->settings()->get(
'frm_store_new') ?
 
  408            $DIC->settings()->get(
'frm_store_new') :
 
  413                        DELETE FROM frm_thread_access WHERE access_last < %s',
 
  424        $data = array($a_usr_id);
 
  428                        DELETE FROM frm_user_read WHERE usr_id = %s',
 
  435                        DELETE FROM frm_thread_access WHERE usr_id = %s',
 
  443                        DELETE FROM frm_notification WHERE user_id = %s',
 
  459                        DELETE FROM frm_user_read WHERE post_id = %s',
 
  473                        DELETE FROM frm_thread_access WHERE thread_id = %s',
 
  485    public function update($a_update_user_id = 0)
 
  487        if (!$a_update_user_id) {
 
  488            $a_update_user_id = $this->
user->getId();
 
  492            $this->db->manipulateF(
 
  496                                        top_description = %s, 
  499                                WHERE top_frm_fk =%s',
 
  500                array(
'text', 
'text', 
'timestamp', 
'integer', 
'integer'),
 
  505                    (
int) $a_update_user_id,
 
  522    public function cloneObject($a_target_id, $a_copy_id = 0, $a_omit_tree = 
false)
 
  525        $new_obj = parent::cloneObject($a_target_id, $a_copy_id, $a_omit_tree);
 
  529        $this->Forum->setMDB2WhereCondition(
'top_frm_fk = %s ', array(
'integer'), array($this->
getId()));
 
  530        $topData = $this->Forum->getOneTopic();
 
  532        $this->db->update(
'frm_data', array(
 
  533            'top_name'        => array(
'text', $topData[
'top_name']),
 
  534            'top_description' => array(
'text', $topData[
'top_description']),
 
  535            'top_num_posts'   => array(
'integer', $topData[
'top_num_posts']),
 
  536            'top_num_threads' => array(
'integer', $topData[
'top_num_threads']),
 
  537            'top_last_post'   => array(
'text', $topData[
'top_last_post']),
 
  538            'top_date'        => array(
'timestamp', $topData[
'top_date']),
 
  539            'visits'          => array(
'integer', $topData[
'visits']),
 
  540            'top_update'      => array(
'timestamp', $topData[
'top_update']),
 
  541            'update_user'     => array(
'integer', $topData[
'update_user']),
 
  542            'top_usr_id'      => array(
'integer', $topData[
'top_usr_id'])
 
  544            'top_frm_fk'      => array(
'integer', $new_obj->getId())
 
  548        include_once(
'Services/CopyWizard/classes/class.ilCopyWizardOptions.php');
 
  553        $options[
'threads'] = $this->Forum->_getThreads($this->
getId());
 
  556        include_once(
'Modules/Forum/classes/class.ilFileDataForum.php');
 
  558        $new_frm = $new_obj->Forum;
 
  559        $new_frm->setMDB2WhereCondition(
'top_frm_fk = %s ', array(
'integer'), array($new_obj->getId()));
 
  561        $new_frm->setForumId($new_obj->getId());
 
  562        $new_frm->setForumRefId($new_obj->getRefId());
 
  564        $new_topic = $new_frm->getOneTopic();
 
  565        foreach (
$options[
'threads'] as $thread_id => $thread_subject) {
 
  566            $this->Forum->setMDB2WhereCondition(
'thr_pk = %s ', array(
'integer'), array($thread_id));
 
  568            $old_thread = $this->Forum->getOneThread();
 
  570            $old_post_id = $this->Forum->getFirstPostByThread($old_thread[
'thr_pk']);
 
  571            $old_post    = $this->Forum->getOnePost($old_post_id);
 
  574            $newThread->setSticky($old_thread[
'is_sticky']);
 
  575            $newThread->setForumId($new_topic[
'top_pk']);
 
  576            $newThread->setThrAuthorId($old_thread[
'thr_author_id']);
 
  577            $newThread->setDisplayUserId($old_thread[
'thr_display_user_id']);
 
  578            $newThread->setSubject($old_thread[
'thr_subject']);
 
  579            $newThread->setUserAlias($old_thread[
'thr_usr_alias']);
 
  580            $newThread->setCreateDate($old_thread[
'thr_date']);
 
  582            $newPostId = $new_frm->generateThread(
 
  590            $old_forum_files->ilClone($new_obj->getId(), $newPostId);
 
  594        $targetRefId = $new_obj->getRefId();
 
  597            $sourceRefId > 0 && $targetRefId > 0 &&
 
  598            $this->tree->getParentId($sourceRefId) === $this->tree->getParentId($targetRefId)
 
  600            $grpRefId = $this->tree->checkForParentType($targetRefId, 
'grp');
 
  601            $crsRefId = $this->tree->checkForParentType($targetRefId, 
'crs');
 
  603            if ($grpRefId > 0 || $crsRefId > 0) {
 
  604                $notifications = new \ilForumNotification($targetRefId);
 
  605                $notifications->cloneFromSource((
int) $sourceRefId);
 
  623        if (!$moderator || !$new_moderator || !$this->
getRefId() || !$new_obj->getRefId()) {
 
  624            $this->logger->write(__METHOD__ . 
' : Error cloning auto generated role: il_frm_moderator');
 
  626        $this->rbac->admin()->copyRolePermissions($moderator, $this->
getRefId(), $new_obj->getRefId(), $new_moderator, 
true);
 
  627        $this->logger->write(__METHOD__ . 
' : Finished copying of role il_frm_moderator.');
 
  629        include_once 
'./Modules/Forum/classes/class.ilForumModerators.php';
 
  632        $old_mods = $obj_mods->getCurrentModerators();
 
  633        foreach ($old_mods as $user_id) {
 
  636            if ($this->
getOwner() != $user_id) {
 
  637                $this->rbac->admin()->assignUser($new_moderator, $user_id);
 
  647    public function delete()
 
  650        if (!parent::delete()) {
 
  656        $tmp_file_obj->delete();
 
  657        unset($tmp_file_obj);
 
  659        $this->Forum->setMDB2WhereCondition(
'top_frm_fk = %s ', array(
'integer'), array($this->
getId()));
 
  661        $topData = $this->Forum->getOneTopic();
 
  663        $threads = $this->Forum->getAllThreads($topData[
'top_pk']);
 
  664        foreach ($threads[
'items'] as $thread) {
 
  665            $thread_ids_to_delete[$thread->getId()] = $thread->getId();
 
  669        $this->db->manipulate(
'DELETE FROM frm_posts_tree WHERE ' . $this->db->in(
'thr_fk', $thread_ids_to_delete, 
false, 
'integer'));
 
  672        $this->db->manipulate(
'DELETE FROM frm_posts WHERE ' . $this->db->in(
'pos_thr_fk', $thread_ids_to_delete, 
false, 
'integer'));
 
  675        $this->db->manipulate(
'DELETE FROM frm_threads WHERE ' . $this->db->in(
'thr_pk', $thread_ids_to_delete, 
false, 
'integer'));
 
  677        $obj_id = array($this->
getId());
 
  679        $this->db->manipulateF(
 
  680            'DELETE FROM frm_data WHERE top_frm_fk = %s',
 
  686        $this->db->manipulateF(
 
  687            'DELETE FROM frm_settings WHERE obj_id = %s',
 
  693        $this->db->manipulateF(
 
  694            'DELETE FROM frm_user_read WHERE obj_id = %s',
 
  700        $this->db->manipulateF(
 
  701            'DELETE FROM frm_thread_access WHERE obj_id = %s',
 
  707        $this->db->manipulate(
'DELETE FROM frm_notification WHERE ' . $this->db->in(
'thread_id', $thread_ids_to_delete, 
false, 
'integer'));
 
  710        $this->db->manipulateF(
'DELETE FROM frm_notification WHERE  frm_id = %s', array(
'integer'), $obj_id);
 
  713        $this->db->manipulateF(
'DELETE FROM frm_posts_deleted WHERE obj_id = %s', array(
'integer'), $obj_id);
 
  726        $res = $this->db->queryF(
 
  727            'SELECT draft_id FROM frm_posts_drafts WHERE forum_id = %s',
 
  729            array((
int) $forum_id)
 
  732        $draft_ids = array();
 
  733        while (
$row = $this->db->fetchAssoc(
$res)) {
 
  734            $draft_ids[] = 
$row[
'draft_id'];
 
  737        if (count($draft_ids) > 0) {
 
  738            require_once 
'Modules/Forum/classes/class.ilForumDraftsHistory.php';
 
  740            $historyObj->deleteHistoryByDraftIds($draft_ids);
 
  742            require_once 
'Modules/Forum/classes/class.ilForumPostDraft.php';
 
  744            $draftObj->deleteDraftsByDraftIds($draft_ids);
 
  755        include_once 
'./Services/AccessControl/classes/class.ilObjRole.php';
 
  757            'il_frm_moderator_' . $this->
getRefId(),
 
  758            "Moderator of forum obj_no." . $this->
getId(),
 
  777        $mod_title = 
'il_frm_moderator_' . $a_ref_id;
 
  781                        SELECT * FROM object_data WHERE title = %s',
 
  796        include_once(
"./Services/News/classes/class.ilNewsItem.php");
 
  798        if ($default_visibility == 
"public") {
 
  807        $nextId = $this->db->nextId(
'frm_data');
 
  810            'top_frm_fk'           => $this->
getId(),
 
  813            'top_num_posts'        => 0,
 
  814            'top_num_threads'      => 0,
 
  815            'top_last_post'        => 
null,
 
  816            'top_mods'             => !is_numeric($a_roles[0]) ? 0 : $a_roles[0],
 
  817            'top_usr_id'           => $this->
user->getId(),
 
  821        $this->db->manipulateF(
 
  836                VALUES(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)',
 
  837            array(
'integer', 
'integer', 
'text', 
'text', 
'integer', 
'integer', 
'text', 
'integer', 
'timestamp', 
'integer'),
 
  840                $top_data[
'top_frm_fk'],
 
  841                $top_data[
'top_name'],
 
  842                $top_data[
'top_description'],
 
  843                $top_data[
'top_num_posts'],
 
  844                $top_data[
'top_num_threads'],
 
  845                $top_data[
'top_last_post'],
 
  846                $top_data[
'top_mods'],
 
  847                $top_data[
'top_date'],
 
  848                $top_data[
'top_usr_id']
 
  857            array(
'thread_sorting' => array(
'integer',$a_sorting_value)),
 
  858            array(
'thr_pk' => array(
'integer', $a_thr_pk))
 
  870        if (array_key_exists($obj_id, self::$obj_id_to_forum_id_cache)) {
 
  871            return (
int) self::$obj_id_to_forum_id_cache[$obj_id];
 
  876        return (
int) self::$obj_id_to_forum_id_cache[$obj_id];
 
  886        if (array_key_exists(
$ref_id, self::$ref_id_to_forum_id_cache)) {
 
  887            return (
int) self::$ref_id_to_forum_id_cache[
$ref_id];
 
  892        return (
int) self::$ref_id_to_forum_id_cache[
$ref_id];
 
  904        if (count($obj_ids) == 1) {
 
  905            $in = 
" objr.obj_id = " . 
$ilDB->quote(current($obj_ids), 
'integer') . 
" ";
 
  907            $in = 
$ilDB->in(
'objr.obj_id', $obj_ids, 
false, 
'integer');
 
  910                        SELECT frmd.top_pk, objr.ref_id, objr.obj_id 
  911                        FROM object_reference objr 
  912                        INNER JOIN frm_data frmd ON frmd.top_frm_fk = objr.obj_id 
  918        foreach ($obj_ids as $obj_id) {
 
  919            self::$obj_id_to_forum_id_cache[$obj_id] = 
null;
 
  923            self::$obj_id_to_forum_id_cache[
$row[
'obj_id']] = 
$row[
'top_pk'];
 
  924            self::$ref_id_to_forum_id_cache[
$row[
'ref_id']] = 
$row[
'top_pk'];
 
  937        if (count($ref_ids) == 1) {
 
  938            $in = 
" objr.ref_id = " . 
$ilDB->quote(current($ref_ids), 
'integer') . 
" ";
 
  940            $in = 
$ilDB->in(
'objr.ref_id', $ref_ids, 
false, 
'integer');
 
  943                        SELECT frmd.top_pk, objr.ref_id, objr.obj_id 
  944                        FROM object_reference objr 
  945                        INNER JOIN frm_data frmd ON frmd.top_frm_fk = objr.obj_id 
  951        foreach ($ref_ids as 
$ref_id) {
 
  952            self::$ref_id_to_forum_id_cache[
$ref_id] = 
null;
 
  956            self::$obj_id_to_forum_id_cache[
$row[
'obj_id']] = 
$row[
'top_pk'];
 
  957            self::$ref_id_to_forum_id_cache[
$row[
'ref_id']] = 
$row[
'top_pk'];
 
  969        $ilAccess = 
$DIC->access();
 
  974        if (isset(self::$forum_statistics_cache[
$ref_id])) {
 
  975            return self::$forum_statistics_cache[
$ref_id];
 
  980            'num_unread_posts' => 0,
 
  986            self::$forum_statistics_cache[
$ref_id] = $statistics;
 
  987            return self::$forum_statistics_cache[
$ref_id];
 
  991        $is_post_activation_enabled = $objProperties->isPostActivationEnabled();
 
  995        if ($is_post_activation_enabled && !$ilAccess->checkAccess(
'moderate_frm', 
'', 
$ref_id)) {
 
  996            $act_clause .= 
" AND (frm_posts.pos_status = " . 
$ilDB->quote(1, 
"integer") . 
" OR frm_posts.pos_author_id = " . 
$ilDB->quote(
$ilUser->getId(), 
"integer") . 
") ";
 
  999        $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));
 
 1001        if (!
$ilUser->isAnonymous()) {
 
 1003                                (SELECT COUNT(frm_posts.pos_pk) cnt 
 1005                                INNER JOIN frm_threads ON frm_posts.pos_thr_fk = frm_threads.thr_pk  
 1006                                WHERE frm_threads.thr_top_fk = %s $act_clause) 
 1010                                (SELECT COUNT(DISTINCT(frm_user_read.post_id)) cnt 
 1012                                INNER JOIN frm_posts ON frm_user_read.post_id = frm_posts.pos_pk 
 1013                                INNER JOIN frm_threads ON frm_threads.thr_pk = frm_posts.pos_thr_fk  
 1014                                WHERE frm_user_read.usr_id = %s AND frm_posts.pos_top_fk = %s $act_clause) 
 1017            $types  = array(
'integer', 
'integer', 
'integer');
 
 1018            $values = array($forumId, 
$ilUser->getId(), $forumId);
 
 1020            $forum_overview_setting = (int) $ilSetting::_lookupValue(
'frma', 
'forum_overview');
 
 1022                $news_types = array(
'integer', 
'integer', 
'integer', 
'timestamp', 
'integer');
 
 1023                $news_values = array(
$ilUser->getId(), 
$ilUser->getId(), $forumId,  $new_deadline, 
$ilUser->getId());
 
 1028                                (SELECT COUNT(frm_posts.pos_pk) cnt 
 1030                                LEFT JOIN frm_user_read ON (post_id = frm_posts.pos_pk AND frm_user_read.usr_id = %s) 
 1031                                LEFT JOIN frm_thread_access ON (frm_thread_access.thread_id = frm_posts.pos_thr_fk AND frm_thread_access.usr_id = %s) 
 1032                                WHERE frm_posts.pos_top_fk = %s 
 1033                                AND ( (frm_posts.pos_update > frm_thread_access.access_old_ts) 
 1034                                                OR (frm_thread_access.access_old IS NULL AND frm_posts.pos_update > %s) 
 1036                                AND frm_posts.pos_author_id != %s  
 1037                                AND frm_user_read.usr_id IS NULL $act_clause)";
 
 1039                $types  = array_merge($types, $news_types);
 
 1040                $values = array_merge($values, $news_values);
 
 1043            $mapping = array_keys($statistics);
 
 1049            for (
$i = 0; 
$i <= 2; 
$i++) {
 
 1052                $statistics[$mapping[
$i]] = (int) 
$row[
'cnt'];
 
 1056                    $statistics[$mapping[
$i]] = $statistics[$mapping[
$i - 1]] - $statistics[$mapping[
$i]];
 
 1061                                SELECT COUNT(frm_posts.pos_pk) cnt 
 1063                                INNER JOIN frm_threads ON frm_posts.pos_thr_fk = frm_threads.thr_pk  
 1064                                WHERE frm_threads.thr_top_fk = %s $act_clause 
 1066            $types  = array(
'integer');
 
 1067            $values = array($forumId);
 
 1075            $statistics = array(
 
 1076                'num_posts'        => 
$row[
'cnt'],
 
 1077                'num_unread_posts' => 
$row[
'cnt'],
 
 1078                'num_new_posts'    => 
$row[
'cnt']
 
 1082        self::$forum_statistics_cache[
$ref_id] = $statistics;
 
 1084        return self::$forum_statistics_cache[
$ref_id];
 
 1095        $ilAccess = 
$DIC->access();
 
 1099        if (isset(self::$forum_last_post_cache[
$ref_id])) {
 
 1100            return self::$forum_last_post_cache[
$ref_id];
 
 1105            self::$forum_last_post_cache[
$ref_id] = array();
 
 1106            return self::$forum_last_post_cache[
$ref_id];
 
 1110        if (!$ilAccess->checkAccess(
'moderate_frm', 
'', 
$ref_id)) {
 
 1111            $act_clause .= 
" AND (frm_posts.pos_status = " . 
$ilDB->quote(1, 
"integer") . 
" OR frm_posts.pos_author_id = " . 
$ilDB->quote(
$ilUser->getId(), 
"integer") . 
") ";
 
 1114        $ilDB->setLimit(1, 0);
 
 1118                        WHERE pos_top_fk = %s $act_clause 
 1119                        ORDER BY pos_date DESC 
 1131        return self::$forum_last_post_cache[
$ref_id];
 
 1143        $ilAccess = 
$DIC->access();
 
 1148        $act_inner_clause = 
'';
 
 1149        if (!$ilAccess->checkAccess(
'moderate_frm', 
'', 
$ref_id)) {
 
 1150            $act_clause .= 
" AND (t1.pos_status = " . 
$ilDB->quote(1, 
"integer") . 
" OR t1.pos_author_id = " . 
$ilDB->quote(
$ilUser->getId(), 
"integer") . 
") ";
 
 1151            $act_inner_clause .= 
" AND (t3.pos_status = " . 
$ilDB->quote(1, 
"integer") . 
" OR t3.pos_author_id = " . 
$ilDB->quote(
$ilUser->getId(), 
"integer") . 
") ";
 
 1154        $in       = 
$ilDB->in(
"t1.pos_thr_fk", $thread_ids, 
false, 
'integer');
 
 1155        $inner_in = 
$ilDB->in(
"t3.pos_thr_fk", $thread_ids, 
false, 
'integer');
 
 1158                        SELECT t1.pos_display_user_id, t1.update_user 
 1161                                SELECT t3.pos_thr_fk, MAX(t3.pos_date) pos_date 
 1163                                WHERE $inner_in $act_inner_clause 
 1164                                GROUP BY t3.pos_thr_fk 
 1165                        ) t2 ON t2.pos_thr_fk = t1.pos_thr_fk AND t2.pos_date = t1.pos_date 
 1166                        WHERE $in $act_clause 
 1167                        GROUP BY t1.pos_thr_fk, t1.pos_display_user_id, t1.update_user 
 1174            if ((
int) 
$row[
'pos_display_user_id']) {
 
 1175                $usr_ids[] = (int) 
$row[
'pos_display_user_id'];
 
 1177            if ((
int) 
$row[
'update_user']) {
 
 1178                $usr_ids[] = (int) 
$row[
'update_user'];
 
 1182        return array_unique($usr_ids);
 
 1192            array(
'thread_id' => array(
'integer', $merge_target_thread_id)),
 
 1193            array(
'thread_id' => array(
'integer',$merge_source_thread_id))
 
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
if(php_sapi_name() !='cli') $in
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
An exception for terminatinating execution or to throw for unit testing.
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 _lookupPostMessage($a_id)
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)
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)
getCountUnread($a_usr_id, $a_thread_id=0)
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.
update($pash, $contents, Config $config)
foreach($_POST as $key=> $value) $res