当前位置: 首页>>代码示例>>PHP>>正文


PHP forum_tp_is_post_read函数代码示例

本文整理汇总了PHP中forum_tp_is_post_read函数的典型用法代码示例。如果您正苦于以下问题:PHP forum_tp_is_post_read函数的具体用法?PHP forum_tp_is_post_read怎么用?PHP forum_tp_is_post_read使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了forum_tp_is_post_read函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: forum_print_post

/**
 * Print a forum post
 *
 * @global object
 * @global object
 * @uses FORUM_MODE_THREADED
 * @uses PORTFOLIO_FORMAT_PLAINHTML
 * @uses PORTFOLIO_FORMAT_FILE
 * @uses PORTFOLIO_FORMAT_RICHHTML
 * @uses PORTFOLIO_ADD_TEXT_LINK
 * @uses CONTEXT_MODULE
 * @param object $post The post to print.
 * @param object $discussion
 * @param object $forum
 * @param object $cm
 * @param object $course
 * @param boolean $ownpost Whether this post belongs to the current user.
 * @param boolean $reply Whether to print a 'reply' link at the bottom of the message.
 * @param boolean $link Just print a shortened version of the post as a link to the full post.
 * @param string $footer Extra stuff to print after the message.
 * @param string $highlight Space-separated list of terms to highlight.
 * @param int $post_read true, false or -99. If we already know whether this user
 *          has read this post, pass that in, otherwise, pass in -99, and this
 *          function will work it out.
 * @param boolean $dummyifcantsee When forum_user_can_see_post says that
 *          the current user can't see this post, if this argument is true
 *          (the default) then print a dummy 'you can't see this post' post.
 *          If false, don't output anything at all.
 * @param bool|null $istracked
 * @return void
 */
function forum_print_post($post, $discussion, $forum, &$cm, $course, $ownpost=false, $reply=false, $link=false,
                          $footer="", $highlight="", $postisread=null, $dummyifcantsee=true, $istracked=null, $return=false) {
    global $USER, $CFG, $OUTPUT;

    require_once($CFG->libdir . '/filelib.php');

    // String cache
    static $str;

    $modcontext = context_module::instance($cm->id);

    $post->course = $course->id;
    $post->forum  = $forum->id;
    $post->message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php', $modcontext->id, 'mod_forum', 'post', $post->id);
    if (!empty($CFG->enableplagiarism)) {
        require_once($CFG->libdir.'/plagiarismlib.php');
        $post->message .= plagiarism_get_links(array('userid' => $post->userid,
            'content' => $post->message,
            'cmid' => $cm->id,
            'course' => $post->course,
            'forum' => $post->forum));
    }

    // caching
    if (!isset($cm->cache)) {
        $cm->cache = new stdClass;
    }

    if (!isset($cm->cache->caps)) {
        $cm->cache->caps = array();
        $cm->cache->caps['mod/forum:viewdiscussion']   = has_capability('mod/forum:viewdiscussion', $modcontext);
        $cm->cache->caps['moodle/site:viewfullnames']  = has_capability('moodle/site:viewfullnames', $modcontext);
        $cm->cache->caps['mod/forum:editanypost']      = has_capability('mod/forum:editanypost', $modcontext);
        $cm->cache->caps['mod/forum:splitdiscussions'] = has_capability('mod/forum:splitdiscussions', $modcontext);
        $cm->cache->caps['mod/forum:deleteownpost']    = has_capability('mod/forum:deleteownpost', $modcontext);
        $cm->cache->caps['mod/forum:deleteanypost']    = has_capability('mod/forum:deleteanypost', $modcontext);
        $cm->cache->caps['mod/forum:viewanyrating']    = has_capability('mod/forum:viewanyrating', $modcontext);
        $cm->cache->caps['mod/forum:exportpost']       = has_capability('mod/forum:exportpost', $modcontext);
        $cm->cache->caps['mod/forum:exportownpost']    = has_capability('mod/forum:exportownpost', $modcontext);
    }

    if (!isset($cm->uservisible)) {
        $cm->uservisible = coursemodule_visible_for_user($cm);
    }

    if ($istracked && is_null($postisread)) {
        $postisread = forum_tp_is_post_read($USER->id, $post);
    }

    if (!forum_user_can_see_post($forum, $discussion, $post, NULL, $cm)) {
        $output = '';
        if (!$dummyifcantsee) {
            if ($return) {
                return $output;
            }
            echo $output;
            return;
        }
        $output .= html_writer::tag('a', '', array('id'=>'p'.$post->id));
        $output .= html_writer::start_tag('div', array('class'=>'forumpost clearfix'));
        $output .= html_writer::start_tag('div', array('class'=>'row header'));
        $output .= html_writer::tag('div', '', array('class'=>'left picture')); // Picture
        if ($post->parent) {
            $output .= html_writer::start_tag('div', array('class'=>'topic'));
        } else {
            $output .= html_writer::start_tag('div', array('class'=>'topic starter'));
        }
        $output .= html_writer::tag('div', get_string('forumsubjecthidden','forum'), array('class'=>'subject')); // Subject
        $output .= html_writer::tag('div', get_string('forumauthorhidden','forum'), array('class'=>'author')); // author
//.........这里部分代码省略.........
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:lib.php

示例2: forum_print_post

/**
 * Print a forum post
 *
 * @global object
 * @global object
 * @uses FORUM_MODE_THREADED
 * @uses PORTFOLIO_FORMAT_PLAINHTML
 * @uses PORTFOLIO_FORMAT_FILE
 * @uses PORTFOLIO_FORMAT_RICHHTML
 * @uses PORTFOLIO_ADD_TEXT_LINK
 * @uses CONTEXT_MODULE
 * @param object $post The post to print.
 * @param object $discussion
 * @param object $forum
 * @param object $cm
 * @param object $course
 * @param boolean $ownpost Whether this post belongs to the current user.
 * @param boolean $reply Whether to print a 'reply' link at the bottom of the message.
 * @param boolean $link Just print a shortened version of the post as a link to the full post.
 * @param string $footer Extra stuff to print after the message.
 * @param string $highlight Space-separated list of terms to highlight.
 * @param int $post_read true, false or -99. If we already know whether this user
 *          has read this post, pass that in, otherwise, pass in -99, and this
 *          function will work it out.
 * @param boolean $dummyifcantsee When forum_user_can_see_post says that
 *          the current user can't see this post, if this argument is true
 *          (the default) then print a dummy 'you can't see this post' post.
 *          If false, don't output anything at all.
 * @param bool|null $istracked
 * @return void
 */
function forum_print_post($post, $discussion, $forum, &$cm, $course, $ownpost = false, $reply = false, $link = false, $footer = "", $highlight = "", $postisread = null, $dummyifcantsee = true, $istracked = null, $return = false)
{
    global $USER, $CFG, $OUTPUT;
    require_once $CFG->libdir . '/filelib.php';
    // String cache
    static $str;
    // This is an extremely hacky way to ensure we only print the 'unread' anchor
    // the first time we encounter an unread post on a page. Ideally this would
    // be moved into the caller somehow, and be better testable. But at the time
    // of dealing with this bug, this static workaround was the most surgical and
    // it fits together with only printing th unread anchor id once on a given page.
    static $firstunreadanchorprinted = false;
    $modcontext = context_module::instance($cm->id);
    $post->course = $course->id;
    $post->forum = $forum->id;
    $post->message = file_rewrite_pluginfile_urls($post->message, 'pluginfile.php', $modcontext->id, 'mod_forum', 'post', $post->id);
    if (!empty($CFG->enableplagiarism)) {
        require_once $CFG->libdir . '/plagiarismlib.php';
        $post->message .= plagiarism_get_links(array('userid' => $post->userid, 'content' => $post->message, 'cmid' => $cm->id, 'course' => $post->course, 'forum' => $post->forum));
    }
    // caching
    if (!isset($cm->cache)) {
        $cm->cache = new stdClass();
    }
    if (!isset($cm->cache->caps)) {
        $cm->cache->caps = array();
        $cm->cache->caps['mod/forum:viewdiscussion'] = has_capability('mod/forum:viewdiscussion', $modcontext);
        $cm->cache->caps['moodle/site:viewfullnames'] = has_capability('moodle/site:viewfullnames', $modcontext);
        $cm->cache->caps['mod/forum:editanypost'] = has_capability('mod/forum:editanypost', $modcontext);
        $cm->cache->caps['mod/forum:splitdiscussions'] = has_capability('mod/forum:splitdiscussions', $modcontext);
        $cm->cache->caps['mod/forum:deleteownpost'] = has_capability('mod/forum:deleteownpost', $modcontext);
        $cm->cache->caps['mod/forum:deleteanypost'] = has_capability('mod/forum:deleteanypost', $modcontext);
        $cm->cache->caps['mod/forum:viewanyrating'] = has_capability('mod/forum:viewanyrating', $modcontext);
        $cm->cache->caps['mod/forum:exportpost'] = has_capability('mod/forum:exportpost', $modcontext);
        $cm->cache->caps['mod/forum:exportownpost'] = has_capability('mod/forum:exportownpost', $modcontext);
    }
    if (!isset($cm->uservisible)) {
        $cm->uservisible = \core_availability\info_module::is_user_visible($cm, 0, false);
    }
    if ($istracked && is_null($postisread)) {
        $postisread = forum_tp_is_post_read($USER->id, $post);
    }
    if (!forum_user_can_see_post($forum, $discussion, $post, NULL, $cm)) {
        $output = '';
        if (!$dummyifcantsee) {
            if ($return) {
                return $output;
            }
            echo $output;
            return;
        }
        $output .= html_writer::tag('a', '', array('id' => 'p' . $post->id));
        $output .= html_writer::start_tag('div', array('class' => 'forumpost clearfix', 'role' => 'region', 'aria-label' => get_string('hiddenforumpost', 'forum')));
        $output .= html_writer::start_tag('div', array('class' => 'row header'));
        $output .= html_writer::tag('div', '', array('class' => 'left picture'));
        // Picture
        if ($post->parent) {
            $output .= html_writer::start_tag('div', array('class' => 'topic'));
        } else {
            $output .= html_writer::start_tag('div', array('class' => 'topic starter'));
        }
        $output .= html_writer::tag('div', get_string('forumsubjecthidden', 'forum'), array('class' => 'subject', 'role' => 'header'));
        // Subject.
        $output .= html_writer::tag('div', get_string('forumauthorhidden', 'forum'), array('class' => 'author', 'role' => 'header'));
        // Author.
        $output .= html_writer::end_tag('div');
        $output .= html_writer::end_tag('div');
        // row
        $output .= html_writer::start_tag('div', array('class' => 'row'));
//.........这里部分代码省略.........
开发者ID:rezaies,项目名称:moodle,代码行数:101,代码来源:lib.php

示例3: forum_print_post

/**
 * Print a forum post
 *
 * @param object $post The post to print.
 * @param integer $courseid The course this post belongs to.
 * @param boolean $ownpost Whether this post belongs to the current user.
 * @param boolean $reply Whether to print a 'reply' link at the bottom of the message.
 * @param boolean $link Just print a shortened version of the post as a link to the full post.
 * @param object $ratings -- I don't really know --
 * @param string $footer Extra stuff to print after the message.
 * @param string $highlight Space-separated list of terms to highlight.
 * @param int $post_read true, false or -99. If we already know whether this user
 *          has read this post, pass that in, otherwise, pass in -99, and this
 *          function will work it out.
 * @param boolean $dummyifcantsee When forum_user_can_see_post says that
 *          the current user can't see this post, if this argument is true
 *          (the default) then print a dummy 'you can't see this post' post.
 *          If false, don't output anything at all.
 */
function forum_print_post($post, $discussion, $forum, &$cm, $course, $ownpost = false, $reply = false, $link = false, $ratings = NULL, $footer = "", $highlight = "", $post_read = null, $dummyifcantsee = true, $istracked = null)
{
    global $USER, $CFG;
    static $stredit, $strdelete, $strreply, $strparent, $strprune;
    static $strpruneheading, $displaymode;
    static $strmarkread, $strmarkunread;
    $post->course = $course->id;
    $post->forum = $forum->id;
    // caching
    if (!isset($cm->cache)) {
        $cm->cache = new object();
    }
    if (!isset($cm->cache->caps)) {
        $cm->cache->caps = array();
        $modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
        $cm->cache->caps['mod/forum:viewdiscussion'] = has_capability('mod/forum:viewdiscussion', $modcontext);
        $cm->cache->caps['moodle/site:viewfullnames'] = has_capability('moodle/site:viewfullnames', $modcontext);
        $cm->cache->caps['mod/forum:editanypost'] = has_capability('mod/forum:editanypost', $modcontext);
        $cm->cache->caps['mod/forum:splitdiscussions'] = has_capability('mod/forum:splitdiscussions', $modcontext);
        $cm->cache->caps['mod/forum:deleteownpost'] = has_capability('mod/forum:deleteownpost', $modcontext);
        $cm->cache->caps['mod/forum:deleteanypost'] = has_capability('mod/forum:deleteanypost', $modcontext);
        $cm->cache->caps['mod/forum:viewanyrating'] = has_capability('mod/forum:viewanyrating', $modcontext);
    }
    if (!isset($cm->uservisible)) {
        $cm->uservisible = coursemodule_visible_for_user($cm);
    }
    if (!forum_user_can_see_post($forum, $discussion, $post, NULL, $cm)) {
        if (!$dummyifcantsee) {
            return;
        }
        echo '<a id="p' . $post->id . '"></a>';
        echo '<table cellspacing="0" class="forumpost">';
        echo '<tr class="header"><td class="picture left">';
        //        print_user_picture($post->userid, $courseid, $post->picture);
        echo '</td>';
        if ($post->parent) {
            echo '<td class="topic">';
        } else {
            echo '<td class="topic starter">';
        }
        echo '<div class="subject">' . get_string('forumsubjecthidden', 'forum') . '</div>';
        echo '<div class="author">';
        print_string('forumauthorhidden', 'forum');
        echo '</div></td></tr>';
        echo '<tr><td class="left side">';
        echo '&nbsp;';
        // Actual content
        echo '</td><td class="content">' . "\n";
        echo get_string('forumbodyhidden', 'forum');
        echo '</td></tr></table>';
        return;
    }
    if (empty($stredit)) {
        $stredit = get_string('edit', 'forum');
        $strdelete = get_string('delete', 'forum');
        $strreply = get_string('reply', 'forum');
        $strparent = get_string('parent', 'forum');
        $strpruneheading = get_string('pruneheading', 'forum');
        $strprune = get_string('prune', 'forum');
        $displaymode = get_user_preferences('forum_displaymode', $CFG->forum_displaymode);
        $strmarkread = get_string('markread', 'forum');
        $strmarkunread = get_string('markunread', 'forum');
    }
    $read_style = '';
    // ignore trackign status if not tracked or tracked param missing
    if ($istracked) {
        if (is_null($post_read)) {
            debugging('fetching post_read info');
            $post_read = forum_tp_is_post_read($USER->id, $post);
        }
        if ($post_read) {
            $read_style = ' read';
        } else {
            $read_style = ' unread';
            echo '<a name="unread"></a>';
        }
    }
    echo '<a id="p' . $post->id . '"></a>';
    echo '<table cellspacing="0" class="forumpost' . $read_style . '">';
    // Picture
    $postuser = new object();
//.........这里部分代码省略.........
开发者ID:r007,项目名称:PMoodle,代码行数:101,代码来源:lib.php

示例4: forum_print_post

/**
 * TODO document
 */
function forum_print_post(&$post, $courseid, $ownpost = false, $reply = false, $link = false, $ratings = NULL, $footer = "", $highlight = "", $post_read = -99)
{
    global $USER, $CFG, $SESSION;
    static $stredit, $strdelete, $strreply, $strparent, $strprune;
    static $strpruneheading, $threadedmode;
    static $strmarkread, $strmarkunread, $istracked;
    if (empty($post->modcontext)) {
        // Have to generate it, which is expensive!  Should always be set.
        if (empty($post->forum)) {
            $discussion = get_record('forum_discussions', 'id', $post->discussion);
            $post->forum = $discussion->forum;
        }
        if (!($cm = get_coursemodule_from_instance('forum', $post->forum))) {
            error('Course Module ID was incorrect');
        }
        $post->modcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
    }
    if (!forum_user_can_see_post($post->forum, $post->discussion, $post)) {
        if (empty($SESSION->forum_search)) {
            // just viewing, return
            return;
        }
        echo '<a id="p' . $post->id . '"></a>';
        echo '<table cellspacing="0" class="forumpost">';
        echo '<tr class="header"><td class="picture left">';
        //        print_user_picture($post->userid, $courseid, $post->picture);
        echo '</td>';
        if ($post->parent) {
            echo '<td class="topic">';
        } else {
            echo '<td class="topic starter">';
        }
        echo '<div class="subject">' . get_string('forumsubjecthidden', 'forum') . '</div>';
        echo '<div class="author">';
        print_string('forumauthorhidden', 'forum');
        echo '</div></td></tr>';
        echo '<tr><td class="left side">';
        echo '&nbsp;';
        // Actual content
        echo '</td><td class="content">' . "\n";
        echo get_string('forumbodyhidden', 'forum');
        echo '</td></tr></table>';
        return;
    }
    if (empty($stredit)) {
        $stredit = get_string('edit', 'forum');
        $strdelete = get_string('delete', 'forum');
        $strreply = get_string('reply', 'forum');
        $strparent = get_string('parent', 'forum');
        $strpruneheading = get_string('pruneheading', 'forum');
        $strprune = get_string('prune', 'forum');
        $threadedmode = (!empty($USER->mode) and $USER->mode == FORUM_MODE_THREADED);
        $strmarkread = get_string('markread', 'forum');
        $strmarkunread = get_string('markunread', 'forum');
        if (!empty($post->forum)) {
            $istracked = forum_tp_can_track_forums($post->forum) && forum_tp_is_tracked($post->forum);
        } else {
            $istracked = false;
        }
    }
    if ($istracked) {
        if ($post_read == -99) {
            // If we don't know yet...
            // The front page can display a news item post to non-logged in users. This should
            // always appear as 'read'.
            $post_read = empty($USER) || forum_tp_is_post_read($USER->id, $post);
        }
        if ($post_read) {
            $read_style = ' read';
        } else {
            $read_style = ' unread';
            echo '<a name="unread"></a>';
        }
    } else {
        $read_style = '';
    }
    echo '<a id="p' . $post->id . '"></a>';
    echo '<table cellspacing="0" class="forumpost' . $read_style . ' ' . PM_POST_CLASS . '" id="m' . $post->id . '">';
    // Picture
    $postuser = new object();
    $postuser->id = $post->userid;
    $postuser->firstname = $post->firstname;
    $postuser->lastname = $post->lastname;
    $postuser->imagealt = $post->imagealt;
    $postuser->picture = $post->picture;
    echo '<tr class="header"><td class="picture left">';
    print_user_picture($postuser, $courseid);
    echo '</td>';
    if ($post->parent) {
        echo '<td class="topic" colspan="3">';
    } else {
        echo '<td class="topic starter" colspan="3">';
    }
    echo '<div class="subject ' . PM_TITLE_CLASS . '">' . format_string($post->subject) . '</div>';
    // #GEOF# Annotations must use a unique value for the user ID
    // This should be a string, and it should be human-readable and suitable for
    // outside consumption.  I'm therefore using username rather than ID.
//.........这里部分代码省略.........
开发者ID:njorth,项目名称:marginalia,代码行数:101,代码来源:lib.php


注:本文中的forum_tp_is_post_read函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。