• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP forum_get_user_posts函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: forum_user_complete

/**
 *
 */
function forum_user_complete($course, $user, $mod, $forum)
{
    global $CFG;
    if ($posts = forum_get_user_posts($forum->id, $user->id)) {
        if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $course->id))) {
            error('Course Module ID was incorrect');
        }
        $discussions = forum_get_user_involved_discussions($forum->id, $user->id);
        foreach ($posts as $post) {
            if (!isset($discussions[$forum->discussion])) {
                continue;
            }
            $discussion = $discussions[$forum->discussion];
            forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false, false);
        }
    } else {
        echo "<p>" . get_string("noposts", "forum") . "</p>";
    }
}
开发者ID:r007,项目名称:PMoodle,代码行数:22,代码来源:lib.php


示例2: forum_user_complete

/**
 * @global object
 * @global object
 * @param object $coure
 * @param object $user
 * @param object $mod
 * @param object $forum
 */
function forum_user_complete($course, $user, $mod, $forum) {
    global $CFG,$USER, $OUTPUT;
    require_once("$CFG->libdir/gradelib.php");

    $grades = grade_get_grades($course->id, 'mod', 'forum', $forum->id, $user->id);
    if (!empty($grades->items[0]->grades)) {
        $grade = reset($grades->items[0]->grades);
        echo $OUTPUT->container(get_string('grade').': '.$grade->str_long_grade);
        if ($grade->str_feedback) {
            echo $OUTPUT->container(get_string('feedback').': '.$grade->str_feedback);
        }
    }

    if ($posts = forum_get_user_posts($forum->id, $user->id)) {

        if (!$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id)) {
            print_error('invalidcoursemodule');
        }
        $discussions = forum_get_user_involved_discussions($forum->id, $user->id);

        foreach ($posts as $post) {
            if (!isset($discussions[$post->discussion])) {
                continue;
            }
            $discussion = $discussions[$post->discussion];

            forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false);
        }
    } else {
        echo "<p>".get_string("noposts", "forum")."</p>";
    }
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:40,代码来源:lib.php


示例3: forum_user_complete

/**
 *
 */
function forum_user_complete($course, $user, $mod, $forum)
{
    global $CFG, $USER;
    require_once "{$CFG->libdir}/gradelib.php";
    $grades = grade_get_grades($course->id, 'mod', 'forum', $forum->id, $user->id);
    if (!empty($grades->items[0]->grades)) {
        $grade = reset($grades->items[0]->grades);
        echo '<p>' . get_string('grade') . ': ' . $grade->str_long_grade . '</p>';
        if ($grade->str_feedback) {
            echo '<p>' . get_string('feedback') . ': ' . $grade->str_feedback . '</p>';
        }
    }
    if ($posts = forum_get_user_posts($forum->id, $user->id)) {
        if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $course->id))) {
            error('Course Module ID was incorrect');
        }
        $discussions = forum_get_user_involved_discussions($forum->id, $user->id);
        // preload all user ratings for these discussions - one query only and minimal memory
        $cm->cache->ratings = array();
        $cm->cache->myratings = array();
        if ($postratings = forum_get_all_user_ratings($user->id, $discussions)) {
            foreach ($postratings as $pr) {
                if (!isset($cm->cache->ratings[$pr->postid])) {
                    $cm->cache->ratings[$pr->postid] = array();
                }
                $cm->cache->ratings[$pr->postid][$pr->id] = $pr->rating;
                if ($pr->userid == $USER->id) {
                    $cm->cache->myratings[$pr->postid] = $pr->rating;
                }
            }
            unset($postratings);
        }
        foreach ($posts as $post) {
            if (!isset($discussions[$post->discussion])) {
                continue;
            }
            $discussion = $discussions[$post->discussion];
            $ratings = null;
            if ($forum->assessed) {
                if ($scale = make_grades_menu($forum->scale)) {
                    $ratings = new object();
                    $ratings->scale = $scale;
                    $ratings->assesstimestart = $forum->assesstimestart;
                    $ratings->assesstimefinish = $forum->assesstimefinish;
                    $ratings->allow = false;
                }
            }
            forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false, $ratings);
        }
    } else {
        echo "<p>" . get_string("noposts", "forum") . "</p>";
    }
}
开发者ID:njorth,项目名称:marginalia,代码行数:56,代码来源:lib.php


示例4: forum_user_complete

/**
 *
 */
function forum_user_complete($course, $user, $mod, $forum)
{
    global $CFG, $USER;
    if ($posts = forum_get_user_posts($forum->id, $user->id)) {
        if (!($cm = get_coursemodule_from_instance('forum', $forum->id, $course->id))) {
            print_error('invalidcoursemodule');
        }
        $discussions = forum_get_user_involved_discussions($forum->id, $user->id);
        // preload all user ratings for these discussions - one query only and minimal memory
        $cm->cache->ratings = array();
        $cm->cache->myratings = array();
        if ($postratings = forum_get_all_user_ratings($user->id, $discussions)) {
            foreach ($postratings as $pr) {
                if (!isset($cm->cache->ratings[$pr->postid])) {
                    $cm->cache->ratings[$pr->postid] = array();
                }
                $cm->cache->ratings[$pr->postid][$pr->id] = $pr->rating;
                if ($pr->userid == $USER->id) {
                    $cm->cache->myratings[$pr->postid] = $pr->rating;
                }
            }
            unset($postratings);
        }
        foreach ($posts as $post) {
            if (!isset($discussions[$post->discussion])) {
                continue;
            }
            $discussion = $discussions[$post->discussion];
            $ratings = null;
            if ($forum->assessed) {
                if ($scale = make_grades_menu($forum->scale)) {
                    $ratings = new object();
                    $ratings->scale = $scale;
                    $ratings->assesstimestart = $forum->assesstimestart;
                    $ratings->assesstimefinish = $forum->assesstimefinish;
                    $ratings->allow = false;
                }
            }
            forum_print_post($post, $discussion, $forum, $cm, $course, false, false, false, $ratings);
        }
    } else {
        echo "<p>" . get_string("noposts", "forum") . "</p>";
    }
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:47,代码来源:lib.php


示例5: plagiarism_urkund_get_file_object

function plagiarism_urkund_get_file_object($plagiarismfile)
{
    global $CFG, $DB;
    if (strpos($plagiarismfile->identifier, $CFG->tempdir) === true) {
        // This is a stored text file in temp dir.
        $file = new stdclass();
        if (file_exists($plagiarismfile->identifier)) {
            $file->type = "tempurkund";
            $file->filename = basename($plagiarismfile->identifier);
            $file->timestamp = time();
            $file->identifier = sha1(file_get_contents($plagiarismfile->identifier));
            $file->filepath = $plagiarismfile->identifier;
            // Sanity check to see if the Sha1 for this file has already been sent to urkund using a different record.
            if ($DB->record_exists('plagiarism_urkund_files', array('identifier' => $file->identifier, 'cm' => $plagiarismfile->cm, 'userid' => $plagiarismfile->userid))) {
                // This file has already been sent and multiple records for this file were created
                // Delete plagiarism record and file.
                $DB->delete_records('plagiarism_urkund_files', array('id' => $plagiarismfile->id));
                debugging("This file has been duplicated, deleting the duplicate record. Identifier:" . $file->identifier);
                unlink($plagiarismfile->identifier);
                // Delete temp file as we don't need it anymore.
                return false;
            }
            return $file;
        } else {
            debugging("The local version of this file has been deleted, and this file cannot be sent");
            return false;
        }
    } else {
        $cm = get_coursemodule_from_id('', $plagiarismfile->cm);
        $modulecontext = context_module::instance($plagiarismfile->cm);
        $fs = get_file_storage();
        if ($cm->modname == 'assign') {
            require_once $CFG->dirroot . '/mod/assign/locallib.php';
            $assign = new assign($modulecontext, null, null);
            if ($assign->get_instance()->teamsubmission) {
                $submission = $assign->get_group_submission($plagiarismfile->userid, 0, false);
            } else {
                $submission = $assign->get_user_submission($plagiarismfile->userid, false);
            }
            $submissionplugins = $assign->get_submission_plugins();
            foreach ($submissionplugins as $submissionplugin) {
                $component = $submissionplugin->get_subtype() . '_' . $submissionplugin->get_type();
                $fileareas = $submissionplugin->get_file_areas();
                foreach ($fileareas as $filearea => $name) {
                    $files = $fs->get_area_files($assign->get_context()->id, $component, $filearea, $submission->id, "timemodified", false);
                    foreach ($files as $file) {
                        if ($file->get_contenthash() == $plagiarismfile->identifier) {
                            return $file;
                        }
                    }
                }
            }
        } else {
            if ($cm->modname == 'workshop') {
                require_once $CFG->dirroot . '/mod/workshop/locallib.php';
                $cm = get_coursemodule_from_id('workshop', $plagiarismfile->cm, 0, false, MUST_EXIST);
                $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
                $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
                $workshop = new workshop($workshop, $cm, $course);
                $submissions = $workshop->get_submissions($plagiarismfile->userid);
                foreach ($submissions as $submission) {
                    $files = $fs->get_area_files($workshop->context->id, 'mod_workshop', 'submission_attachment', $submission->id);
                    foreach ($files as $file) {
                        if ($file->get_contenthash() == $plagiarismfile->identifier) {
                            return $file;
                        }
                    }
                }
            } else {
                if ($cm->modname == 'forum') {
                    require_once $CFG->dirroot . '/mod/forum/lib.php';
                    $cm = get_coursemodule_from_id('forum', $plagiarismfile->cm, 0, false, MUST_EXIST);
                    $posts = forum_get_user_posts($cm->instance, $plagiarismfile->userid);
                    foreach ($posts as $post) {
                        $files = $fs->get_area_files($modulecontext->id, 'mod_forum', 'attachment', $post->id, "timemodified", false);
                        foreach ($files as $file) {
                            if ($file->get_contenthash() == $plagiarismfile->identifier) {
                                return $file;
                            }
                        }
                    }
                }
            }
        }
    }
}
开发者ID:henrikthorn,项目名称:moodle-plagiarism_urkund,代码行数:86,代码来源:lib.php


示例6: urkund_reset_file

function urkund_reset_file($id)
{
    global $DB, $CFG;
    $plagiarismfile = $DB->get_record('plagiarism_urkund_files', array('id' => $id), '*', MUST_EXIST);
    if ($plagiarismfile->statuscode == 'Analyzed' || $plagiarismfile->statuscode == URKUND_STATUSCODE_ACCEPTED) {
        // Sanity Check.
        return true;
    }
    // Set some new values.
    $plagiarismfile->statuscode = 'pending';
    $plagiarismfile->attempt = 0;
    $plagiarismfile->timesubmitted = time();
    $cm = get_coursemodule_from_id('', $plagiarismfile->cm);
    $modulecontext = context_module::instance($plagiarismfile->cm);
    $fs = get_file_storage();
    if ($cm->modname == 'assignment') {
        $submission = $DB->get_record('assignment_submissions', array('assignment' => $cm->instance, 'userid' => $plagiarismfile->userid));
        $files = $fs->get_area_files($modulecontext->id, 'mod_assignment', 'submission', $submission->id);
        foreach ($files as $file) {
            if ($file->get_contenthash() == $plagiarismfile->identifier) {
                $DB->update_record('plagiarism_urkund_files', $plagiarismfile);
                // Update before trying to send again.
                return urkund_send_file($plagiarismfile->cm, $plagiarismfile->userid, $file, plagiarism_plugin_urkund::get_settings());
            }
        }
    } else {
        if ($cm->modname == 'assign') {
            require_once $CFG->dirroot . '/mod/assign/locallib.php';
            $assign = new assign($modulecontext, null, null);
            $submissionplugins = $assign->get_submission_plugins();
            $dbparams = array('assignment' => $assign->get_instance()->id, 'userid' => $plagiarismfile->userid);
            $submissions = $DB->get_records('assign_submission', $dbparams);
            foreach ($submissions as $submission) {
                foreach ($submissionplugins as $submissionplugin) {
                    $component = $submissionplugin->get_subtype() . '_' . $submissionplugin->get_type();
                    $fileareas = $submissionplugin->get_file_areas();
                    foreach ($fileareas as $filearea => $name) {
                        $files = $fs->get_area_files($assign->get_context()->id, $component, $filearea, $submission->id, "timemodified", false);
                        foreach ($files as $file) {
                            if ($file->get_contenthash() == $plagiarismfile->identifier) {
                                $DB->update_record('plagiarism_urkund_files', $plagiarismfile);
                                // Update before trying to send again.
                                return urkund_send_file($plagiarismfile->cm, $plagiarismfile->userid, $file, plagiarism_plugin_urkund::get_settings());
                            }
                        }
                    }
                }
            }
        } else {
            if ($cm->modname == 'workshop') {
                require_once $CFG->dirroot . '/mod/workshop/locallib.php';
                $cm = get_coursemodule_from_id('workshop', $plagiarismfile->cm, 0, false, MUST_EXIST);
                $workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
                $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
                $workshop = new workshop($workshop, $cm, $course);
                $submissions = $workshop->get_submissions($plagiarismfile->userid);
                foreach ($submissions as $submission) {
                    $files = $fs->get_area_files($workshop->context->id, 'mod_workshop', 'submission_attachment', $submission->id);
                    foreach ($files as $file) {
                        if ($file->get_contenthash() == $plagiarismfile->identifier) {
                            $DB->update_record('plagiarism_urkund_files', $plagiarismfile);
                            // Update before trying to send again.
                            return urkund_send_file($plagiarismfile->cm, $plagiarismfile->userid, $file, plagiarism_plugin_urkund::get_settings());
                        }
                    }
                }
            } else {
                if ($cm->modname == 'forum') {
                    require_once $CFG->dirroot . '/mod/forum/lib.php';
                    $cm = get_coursemodule_from_id('forum', $plagiarismfile->cm, 0, false, MUST_EXIST);
                    $posts = forum_get_user_posts($cm->instance, $plagiarismfile->userid);
                    foreach ($posts as $post) {
                        $files = $fs->get_area_files($modulecontext->id, 'mod_forum', 'attachment', $post->id, "timemodified", false);
                        foreach ($files as $file) {
                            if ($file->get_contenthash() == $plagiarismfile->identifier) {
                                $DB->update_record('plagiarism_urkund_files', $plagiarismfile);
                                // Update before trying to send again.
                                return urkund_send_file($plagiarismfile->cm, $plagiarismfile->userid, $file, plagiarism_plugin_urkund::get_settings());
                            }
                        }
                    }
                }
            }
        }
    }
}
开发者ID:edmiranda,项目名称:moodle-plagiarism_urkund,代码行数:86,代码来源:lib.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP forum_go_back_to函数代码示例发布时间:2022-05-15
下一篇:
PHP forum_get_user_posted_time函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap