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


PHP get_recent_enrolments函数代码示例

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


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

示例1: get_recent_enrolments

 /**
  * Returns all recent enrollments
  *
  * @todo MDL-36993 this function always return empty array
  * @return array array of entries from {user} table
  */
 protected function get_recent_enrolments()
 {
     return get_recent_enrolments($this->page->course->id, $this->get_timestart());
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:10,代码来源:block_recent_activity.php

示例2: print_recent_activity

/**
 * This function trawls through the logs looking for
 * anything new since the user's last login
 */
function print_recent_activity($course)
{
    // $course is an object
    global $CFG, $USER, $SESSION, $DB, $OUTPUT;
    $context = get_context_instance(CONTEXT_COURSE, $course->id);
    $viewfullnames = has_capability('moodle/site:viewfullnames', $context);
    $timestart = round(time() - COURSE_MAX_RECENT_PERIOD, -2);
    // better db caching for guests - 100 seconds
    if (!isguestuser()) {
        if (!empty($USER->lastcourseaccess[$course->id])) {
            if ($USER->lastcourseaccess[$course->id] > $timestart) {
                $timestart = $USER->lastcourseaccess[$course->id];
            }
        }
    }
    echo '<div class="activitydate">';
    echo get_string('activitysince', '', userdate($timestart));
    echo '</div>';
    echo '<div class="activityhead">';
    echo '<a href="' . $CFG->wwwroot . '/course/recent.php?id=' . $course->id . '">' . get_string('recentactivityreport') . '</a>';
    echo "</div>\n";
    $content = false;
    /// Firstly, have there been any new enrolments?
    $users = get_recent_enrolments($course->id, $timestart);
    //Accessibility: new users now appear in an <OL> list.
    if ($users) {
        echo '<div class="newusers">';
        echo $OUTPUT->heading(get_string("newusers") . ':', 3);
        $content = true;
        echo "<ol class=\"list\">\n";
        foreach ($users as $user) {
            $fullname = fullname($user, $viewfullnames);
            echo '<li class="name"><a href="' . "{$CFG->wwwroot}/user/view.php?id={$user->id}&amp;course={$course->id}\">{$fullname}</a></li>\n";
        }
        echo "</ol>\n</div>\n";
    }
    /// Next, have there been any modifications to the course structure?
    $modinfo = get_fast_modinfo($course);
    $changelist = array();
    $logs = $DB->get_records_select('log', "time > ? AND course = ? AND\n                                            module = 'course' AND\n                                            (action = 'add mod' OR action = 'update mod' OR action = 'delete mod')", array($timestart, $course->id), "id ASC");
    if ($logs) {
        $actions = array('add mod', 'update mod', 'delete mod');
        $newgones = array();
        // added and later deleted items
        foreach ($logs as $key => $log) {
            if (!in_array($log->action, $actions)) {
                continue;
            }
            $info = explode(' ', $log->info);
            // note: in most cases I replaced hardcoding of label with use of
            // $cm->has_view() but it was not possible to do this here because
            // we don't necessarily have the $cm for it
            if ($info[0] == 'label') {
                // Labels are ignored in recent activity
                continue;
            }
            if (count($info) != 2) {
                debugging("Incorrect log entry info: id = " . $log->id, DEBUG_DEVELOPER);
                continue;
            }
            $modname = $info[0];
            $instanceid = $info[1];
            if ($log->action == 'delete mod') {
                // unfortunately we do not know if the mod was visible
                if (!array_key_exists($log->info, $newgones)) {
                    $strdeleted = get_string('deletedactivity', 'moodle', get_string('modulename', $modname));
                    $changelist[$log->info] = array('operation' => 'delete', 'text' => $strdeleted);
                }
            } else {
                if (!isset($modinfo->instances[$modname][$instanceid])) {
                    if ($log->action == 'add mod') {
                        // do not display added and later deleted activities
                        $newgones[$log->info] = true;
                    }
                    continue;
                }
                $cm = $modinfo->instances[$modname][$instanceid];
                if (!$cm->uservisible) {
                    continue;
                }
                if ($log->action == 'add mod') {
                    $stradded = get_string('added', 'moodle', get_string('modulename', $modname));
                    $changelist[$log->info] = array('operation' => 'add', 'text' => "{$stradded}:<br /><a href=\"{$CFG->wwwroot}/mod/{$cm->modname}/view.php?id={$cm->id}\">" . format_string($cm->name, true) . "</a>");
                } else {
                    if ($log->action == 'update mod' and empty($changelist[$log->info])) {
                        $strupdated = get_string('updated', 'moodle', get_string('modulename', $modname));
                        $changelist[$log->info] = array('operation' => 'update', 'text' => "{$strupdated}:<br /><a href=\"{$CFG->wwwroot}/mod/{$cm->modname}/view.php?id={$cm->id}\">" . format_string($cm->name, true) . "</a>");
                    }
                }
            }
        }
    }
    if (!empty($changelist)) {
        echo $OUTPUT->heading(get_string("courseupdates") . ':', 3);
        $content = true;
        foreach ($changelist as $changeinfo => $change) {
//.........这里部分代码省略.........
开发者ID:numbas,项目名称:moodle,代码行数:101,代码来源:lib.php


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