コード例 #1
0
 /**
  * @return array
  */
 public function getProperties()
 {
     /**
      * @var $lng	  ilLanguage
      * @var $ilUser   ilObjUser
      * @var $ilAccess ilAccessHandler
      */
     global $lng, $ilUser, $ilAccess;
     if (!$ilAccess->checkAccess('read', '', $this->ref_id)) {
         return array();
     }
     $lng->loadLanguageModule('forum');
     $props = array();
     include_once 'Modules/Forum/classes/class.ilObjForumAccess.php';
     $properties = ilObjForumAccess::getStatisticsByRefId($this->ref_id);
     $num_posts_total = $properties['num_posts'];
     $num_unread_total = $properties['num_unread_posts'];
     $num_new_total = $properties['num_new_posts'];
     $last_post = ilObjForumAccess::getLastPostByRefId($this->ref_id);
     if (!$ilUser->isAnonymous()) {
         if ($this->getDetailsLevel() == ilObjectListGUI::DETAILS_ALL) {
             $alert = $num_unread_total > 0 ? true : false;
             $props[] = array('alert' => $alert, 'property' => $lng->txt('forums_articles') . ' (' . $lng->txt('unread') . ')', 'value' => $num_posts_total . ' (' . $num_unread_total . ')');
             // New
             $alert = $num_new_total > 0 ? true : false;
             $props[] = array('alert' => $alert, 'property' => $lng->txt('forums_new_articles'), 'value' => $num_new_total);
         }
     } else {
         $props[] = array('alert' => false, 'property' => $lng->txt('forums_articles'), 'value' => $num_posts_total);
     }
     include_once 'Modules/Forum/classes/class.ilForumProperties.php';
     if ($this->getDetailsLevel() == ilObjectListGUI::DETAILS_ALL) {
         if (ilForumProperties::getInstance($this->obj_id)->isAnonymized()) {
             $props[] = array('alert' => false, 'newline' => false, 'property' => $lng->txt('forums_anonymized'), 'value' => $lng->txt('yes'));
         }
     }
     // Last Post
     if ((int) $last_post['pos_pk']) {
         $lpCont = "<a class=\"il_ItemProperty\" target=\"" . ilFrameTargetInfo::_getFrame('MainContent') . "\" href=\"ilias.php?baseClass=ilRepositoryGUI&amp;cmd=viewThread&amp;cmdClass=ilobjforumgui&amp;target=true&amp;pos_pk=" . $last_post['pos_pk'] . "&amp;thr_pk=" . $last_post['pos_thr_fk'] . "&amp;ref_id=" . $this->ref_id . "#" . $last_post["pos_pk"] . "\">" . ilObjForumAccess::prepareMessageForLists($last_post['pos_message']) . "</a> " . strtolower($lng->txt('from')) . "&nbsp;";
         require_once 'Modules/Forum/classes/class.ilForumAuthorInformation.php';
         $authorinfo = new ilForumAuthorInformation($last_post['pos_usr_id'], $last_post['pos_usr_alias'], $last_post['import_name'], array('class' => 'il_ItemProperty', 'href' => 'ilias.php?baseClass=ilRepositoryGUI&amp;cmd=showUser&amp;cmdClass=ilobjforumgui&amp;ref_id=' . $this->ref_id . '&amp;user='******'pos_usr_id'] . '&amp;offset=0&amp;backurl=' . urlencode('ilias.php?baseClass=ilRepositoryGUI&amp;ref_id=' . $_GET['ref_id'])));
         $lpCont .= $authorinfo->getLinkedAuthorName();
         $lpCont .= ', ' . ilDatePresentation::formatDate(new ilDateTime($last_post['pos_date'], IL_CAL_DATETIME));
         $props[] = array('alert' => false, 'newline' => true, 'property' => $lng->txt('forums_last_post'), 'value' => $lpCont);
     }
     return $props;
 }
コード例 #2
0
 /**
  * @param ilForumTopic $thread
  */
 public function fillRow(ilForumTopic $thread)
 {
     /**
      * @var $ilUser ilObjUser
      */
     global $ilUser;
     $this->ctrl->setParameter($this->getParentObject(), 'thr_pk', $thread->getId());
     if ('mergeThreads' == $this->parent_cmd) {
         $checked = $this->max_count == 1 || isset($_POST['thread_ids']) && in_array($thread->getId(), $_POST['thread_ids']);
         $this->tpl->setVariable('VAL_CHECK', ilUtil::formRadioButton($checked, 'thread_ids[]', $thread->getId()));
     } else {
         if ('showThreads' == $this->parent_cmd) {
             $this->tpl->setVariable('VAL_CHECK', ilUtil::formCheckbox(isset($_POST['thread_ids']) && in_array($thread->getId(), $_POST['thread_ids']) ? true : false, 'thread_ids[]', $thread->getId()));
         } else {
             if ($thread->isSticky()) {
                 $this->tpl->setVariable('VAL_SORTING_NAME', 'thread_sorting[' . $thread->getId() . ']');
                 $this->tpl->setVariable('VAL_SORTING', (int) $this->position * 10);
             } else {
                 $this->tpl->setVariable('VAL_CHECK', '');
             }
             $this->position++;
         }
     }
     $subject = '';
     if ($thread->isSticky()) {
         $subject .= '<span class="light">[' . $this->lng->txt('sticky') . ']</span> ';
     }
     if ($thread->isClosed()) {
         $subject .= '<span class="light">[' . $this->lng->txt('topic_close') . ']</span> ';
     }
     if (!$ilUser->isAnonymous() && $this->ilias->getSetting('forum_notification') != 0 && $thread->getUserNotificationEnabled()) {
         $subject .= '<span class="light">[' . $this->lng->txt('forums_notification_enabled') . ']</span> ';
     }
     $num_posts = $thread->getNumPosts();
     $num_unread = $thread->getNumUnreadPosts();
     $num_new = $thread->getNumNewPosts();
     if ($num_posts > 0) {
         $subject = '<div><a href="' . $this->ctrl->getLinkTarget($this->getParentObject(), 'viewThread') . '">' . $thread->getSubject() . '</a></div>' . $subject;
     } else {
         $subject = $thread->getSubject() . $subject;
     }
     $this->tpl->setVariable('VAL_SUBJECT', $subject);
     // Author
     $this->ctrl->setParameter($this->getParentObject(), 'backurl', urlencode($this->ctrl->getLinkTargetByClass("ilrepositorygui", "")));
     $this->ctrl->setParameter($this->getParentObject(), 'user', $thread->getUserId());
     $authorinfo = new ilForumAuthorInformation($thread->getUserId(), $thread->getUserAlias(), $thread->getImportName(), array('class' => 'il_ItemProperty', 'href' => $this->ctrl->getLinkTarget($this->getParentObject(), 'showUser')));
     $this->tpl->setVariable('VAL_AUTHOR', $authorinfo->getLinkedAuthorName());
     $topicStats = $num_posts;
     if (!$ilUser->isAnonymous()) {
         if ($num_unread > 0) {
             $topicStats .= '<br /><span class="alert ilWhiteSpaceNowrap">' . $this->lng->txt('unread') . ': ' . $num_unread . '</span>';
         }
         if ($num_new > 0 && $this->getOverviewSetting() == 0) {
             $topicStats .= '<br /><span class="alert ilWhiteSpaceNowrap">' . $this->lng->txt('new') . ': ' . $num_new . '</span>';
         }
     }
     $this->tpl->setVariable('VAL_ARTICLE_STATS', $topicStats);
     $this->tpl->setVariable('VAL_NUM_VISIT', $thread->getVisits());
     // Last posting
     if ($num_posts > 0) {
         if ($this->getIsModerator()) {
             $objLastPost = $thread->getLastPost();
         } else {
             $objLastPost = $thread->getLastActivePost();
         }
         if (is_object($objLastPost)) {
             $authorinfo = new ilForumAuthorInformation($objLastPost->getUserId(), $objLastPost->getUserAlias(), $objLastPost->getImportName(), array('href' => $this->ctrl->getLinkTarget($this->getParentObject(), 'viewThread') . '#' . $objLastPost->getId()));
             $this->tpl->setVariable('VAL_LP_DATE', '<div class="ilWhiteSpaceNowrap">' . ilDatePresentation::formatDate(new ilDateTime($objLastPost->getCreateDate(), IL_CAL_DATETIME)) . '</div>' . '<div class="ilWhiteSpaceNowrap">' . $this->lng->txt('from') . ' ' . $authorinfo->getLinkedAuthorName() . '</div>');
         }
     }
     // Row style
     $css_row = $this->css_row;
     if ($thread->isSticky()) {
         $css_row = $css_row == 'tblrow1' ? 'tblstickyrow1' : 'tblstickyrow2';
     }
     $this->tpl->setVariable('CSS_ROW', $css_row);
     $this->ctrl->setParameter($this->getParentObject(), 'thr_pk', '');
     $this->ctrl->setParameter($this->getParentObject(), 'user', '');
     $this->ctrl->setParameter($this->getParentObject(), 'backurl', '');
 }