Beispiel #1
0
function wiki_print_recent_activity($course, $isteacher, $timestart)
{
    /// Given a course and a time, this module should find recent activity
    /// that has occurred in wiki activities and print it out.
    /// Return true if there was output, or false is there was none.
    global $CFG;
    $sql = "SELECT l.*, cm.instance FROM {$CFG->prefix}log l \n                INNER JOIN {$CFG->prefix}course_modules cm ON l.cmid = cm.id \n            WHERE l.time > '{$timestart}' AND l.course = {$course->id} \n                AND l.module = 'wiki' AND action LIKE 'edit%'\n            ORDER BY l.time ASC";
    if (!($logs = get_records_sql($sql))) {
        return false;
    }
    $modinfo = get_fast_modinfo($course);
    $wikis = array();
    foreach ($logs as $log) {
        $cm = $modinfo->instances['wiki'][$log->instance];
        if (!$cm->uservisible) {
            continue;
        }
        /// Process log->url and rebuild it here to properly clean the pagename - MDL-15896
        $extractedpage = preg_replace('/^.*&page=/', '', $log->url);
        $log->url = preg_replace('/page=.*$/', 'page=' . urlencode($extractedpage), $log->url);
        $wikis[$log->info] = wiki_log_info($log);
        $wikis[$log->info]->pagename = $log->info;
        $wikis[$log->info]->time = $log->time;
        $wikis[$log->info]->url = str_replace('&', '&', $log->url);
    }
    if (!$wikis) {
        return false;
    }
    print_headline(get_string('updatedwikipages', 'wiki') . ':', 3);
    foreach ($wikis as $wiki) {
        print_recent_activity_note($wiki->time, $wiki, $wiki->pagename, $CFG->wwwroot . '/mod/wiki/' . $wiki->url);
    }
    return false;
}
Beispiel #2
0
/**
 * Print recent activity from all assignments in a given course
 *
 * This is used by the recent activity block
 */
function assignment_print_recent_activity($course, $isteacher, $timestart)
{
    global $CFG;
    $content = false;
    $assignments = array();
    if (!($logs = get_records_select('log', 'time > \'' . $timestart . '\' AND ' . 'course = \'' . $course->id . '\' AND ' . 'module = \'assignment\' AND ' . 'action = \'upload\' ', 'time ASC'))) {
        return false;
    }
    foreach ($logs as $log) {
        //Create a temp valid module structure (course,id)
        $tempmod = new object();
        $tempmod->course = $log->course;
        $tempmod->id = $log->info;
        //Obtain the visible property from the instance
        $modvisible = instance_is_visible($log->module, $tempmod);
        //Only if the mod is visible
        if ($modvisible) {
            if ($info = assignment_log_info($log)) {
                $assignments[$log->info] = $info;
                $assignments[$log->info]->time = $log->time;
                $assignments[$log->info]->url = str_replace('&', '&', $log->url);
            }
        }
    }
    if (!empty($assignments)) {
        print_headline(get_string('newsubmissions', 'assignment') . ':');
        foreach ($assignments as $assignment) {
            print_recent_activity_note($assignment->time, $assignment, $assignment->name, $CFG->wwwroot . '/mod/assignment/' . $assignment->url);
        }
        $content = true;
    }
    return $content;
}
Beispiel #3
0
function workshop_print_recent_activity($course, $isteacher, $timestart)
{
    global $CFG;
    // have a look for agreed assessments for this user (agree)
    $agreecontent = false;
    if (!$isteacher) {
        // teachers only need to see submissions
        if ($logs = workshop_get_agree_logs($course, $timestart)) {
            // got some, see if any belong to a visible module
            foreach ($logs as $log) {
                // Create a temp valid module structure (only need courseid, moduleid)
                $tempmod->course = $course->id;
                $tempmod->id = $log->workshopid;
                //Obtain the visible property from the instance
                if (instance_is_visible("workshop", $tempmod)) {
                    $agreecontent = true;
                    break;
                }
            }
            // if we got some "live" ones then output them
            if ($agreecontent) {
                print_headline(get_string("workshopagreedassessments", "workshop") . ":");
                foreach ($logs as $log) {
                    //Create a temp valid module structure (only need courseid, moduleid)
                    $tempmod->course = $course->id;
                    $tempmod->id = $log->workshopid;
                    //Obtain the visible property from the instance
                    if (instance_is_visible("workshop", $tempmod)) {
                        if (!workshop_is_teacher($workshop, $log->userid)) {
                            // don't break anonymous rule
                            $log->firstname = $course->student;
                            $log->lastname = '';
                        }
                        print_recent_activity_note($log->time, $log, $log->name, $CFG->wwwroot . '/mod/workshop/' . $log->url);
                    }
                }
            }
        }
    }
    // have a look for new assessments for this user (assess)
    $assesscontent = false;
    if (!$isteacher) {
        // teachers only need to see submissions
        if ($logs = workshop_get_assess_logs($course, $timestart)) {
            // got some, see if any belong to a visible module
            foreach ($logs as $log) {
                // Create a temp valid module structure (only need courseid, moduleid)
                $tempmod->course = $course->id;
                $tempmod->id = $log->workshopid;
                //Obtain the visible property from the instance
                if (instance_is_visible("workshop", $tempmod)) {
                    $assesscontent = true;
                    break;
                }
            }
            // if we got some "live" ones then output them
            if ($assesscontent) {
                print_headline(get_string("workshopassessments", "workshop") . ":");
                foreach ($logs as $log) {
                    //Create a temp valid module structure (only need courseid, moduleid)
                    $tempmod->course = $course->id;
                    $tempmod->id = $log->workshopid;
                    //Obtain the visible property from the instance
                    if (instance_is_visible("workshop", $tempmod)) {
                        if (!workshop_is_teacher($tempmod->id, $log->userid)) {
                            // don't break anonymous rule
                            $log->firstname = $course->student;
                            $log->lastname = '';
                        }
                        print_recent_activity_note($log->time, $log, $log->name, $CFG->wwwroot . '/mod/workshop/' . $log->url);
                    }
                }
            }
        }
    }
    // have a look for new comments for this user (comment)
    $commentcontent = false;
    if (!$isteacher) {
        // teachers only need to see submissions
        if ($logs = workshop_get_comment_logs($course, $timestart)) {
            // got some, see if any belong to a visible module
            foreach ($logs as $log) {
                // Create a temp valid module structure (only need courseid, moduleid)
                $tempmod->course = $course->id;
                $tempmod->id = $log->workshopid;
                //Obtain the visible property from the instance
                if (instance_is_visible("workshop", $tempmod)) {
                    $commentcontent = true;
                    break;
                }
            }
            // if we got some "live" ones then output them
            if ($commentcontent) {
                print_headline(get_string("workshopcomments", "workshop") . ":");
                foreach ($logs as $log) {
                    //Create a temp valid module structure (only need courseid, moduleid)
                    $tempmod->course = $course->id;
                    $tempmod->id = $log->workshopid;
                    //Obtain the visible property from the instance
                    if (instance_is_visible("workshop", $tempmod)) {
                        $log->firstname = $course->student;
                        // Keep anonymous
                        $log->lastname = '';
                        print_recent_activity_note($log->time, $log, $log->name, $CFG->wwwroot . '/mod/workshop/' . $log->url);
                    }
                }
            }
        }
    }
    // have a look for new assessment gradings for this user (grade)
    $gradecontent = false;
    if ($logs = workshop_get_grade_logs($course, $timestart)) {
        // got some, see if any belong to a visible module
        foreach ($logs as $log) {
            // Create a temp valid module structure (only need courseid, moduleid)
            $tempmod->course = $course->id;
            $tempmod->id = $log->workshopid;
            //Obtain the visible property from the instance
            if (instance_is_visible("workshop", $tempmod)) {
                $gradecontent = true;
                break;
            }
        }
        // if we got some "live" ones then output them
        if ($gradecontent) {
            print_headline(get_string("workshopfeedback", "workshop") . ":");
            foreach ($logs as $log) {
                //Create a temp valid module structure (only need courseid, moduleid)
                $tempmod->course = $course->id;
                $tempmod->id = $log->workshopid;
                //Obtain the visible property from the instance
                if (instance_is_visible("workshop", $tempmod)) {
                    $log->firstname = $course->teacher;
                    // Keep anonymous
                    $log->lastname = '';
                    print_recent_activity_note($log->time, $log, $log->name, $CFG->wwwroot . '/mod/workshop/' . $log->url);
                }
            }
        }
    }
    // have a look for new submissions (only show to teachers) (submit)
    $submitcontent = false;
    if ($isteacher) {
        if ($logs = workshop_get_submit_logs($course, $timestart)) {
            // got some, see if any belong to a visible module
            foreach ($logs as $log) {
                // Create a temp valid module structure (only need courseid, moduleid)
                $tempmod->course = $course->id;
                $tempmod->id = $log->workshopid;
                //Obtain the visible property from the instance
                if (instance_is_visible("workshop", $tempmod)) {
                    $submitcontent = true;
                    break;
                }
            }
            // if we got some "live" ones then output them
            if ($submitcontent) {
                print_headline(get_string("workshopsubmissions", "workshop") . ":");
                foreach ($logs as $log) {
                    //Create a temp valid module structure (only need courseid, moduleid)
                    $tempmod->course = $course->id;
                    $tempmod->id = $log->workshopid;
                    //Obtain the visible property from the instance
                    if (instance_is_visible("workshop", $tempmod)) {
                        print_recent_activity_note($log->time, $log, $log->name, $CFG->wwwroot . '/mod/workshop/' . $log->url);
                    }
                }
            }
        }
    }
    return $agreecontent or $assesscontent or $commentcontent or $gradecontent or $submitcontent;
}
Beispiel #4
0
function hotpot_print_recent_activity($course, $isteacher, $timestart)
{
    /// Given a course and a time, this module should find recent activity
    /// that has occurred in hotpot activities and print it out.
    /// Return true if there was output, or false is there was none.
    global $CFG;
    $result = false;
    $records = get_records_sql("\n        SELECT\n            h.id AS id,\n            h.name AS name,\n            COUNT(*) AS count_attempts\n        FROM\n            {$CFG->prefix}hotpot h,\n            {$CFG->prefix}hotpot_attempts a\n        WHERE\n            h.course = {$course->id}\n            AND h.id = a.hotpot\n            AND a.id = a.clickreportid\n            AND a.starttime > {$timestart}\n        GROUP BY\n            h.id, h.name\n    ");
    // note that PostGreSQL requires h.name in the GROUP BY clause
    if ($records) {
        $names = array();
        foreach ($records as $id => $record) {
            if ($cm = get_coursemodule_from_instance('hotpot', $record->id, $course->id)) {
                $context = get_context_instance(CONTEXT_MODULE, $cm->id);
                if (has_capability('mod/hotpot:viewreport', $context)) {
                    $href = "{$CFG->wwwroot}/mod/hotpot/view.php?hp={$id}";
                    $name = '&nbsp;<a href="' . $href . '">' . $record->name . '</a>';
                    if ($record->count_attempts > 1) {
                        $name .= " ({$record->count_attempts})";
                    }
                    $names[] = $name;
                }
            }
        }
        if (count($names) > 0) {
            print_headline(get_string('modulenameplural', 'hotpot') . ':');
            if ($CFG->version >= 2005050500) {
                // Moodle 1.5+
                echo '<div class="head"><div class="name">' . implode('<br />', $names) . '</div></div>';
            } else {
                // Moodle 1.4.x (or less)
                echo '<font size="1">' . implode('<br />', $names) . '</font>';
            }
            $result = true;
        }
    }
    return $result;
    //  True if anything was printed, otherwise false
}
Beispiel #5
0
/**
 * Print recent activity from all assignments in a given course
 *
 * This is used by the recent activity block
 */
function assignment_print_recent_activity($course, $viewfullnames, $timestart)
{
    global $CFG, $USER;
    // do not use log table if possible, it may be huge
    if (!($submissions = get_records_sql("SELECT asb.id, asb.timemodified, cm.id AS cmid, asb.userid,\n                                                u.firstname, u.lastname, u.email, u.picture\n                                           FROM {$CFG->prefix}assignment_submissions asb\n                                                JOIN {$CFG->prefix}assignment a      ON a.id = asb.assignment\n                                                JOIN {$CFG->prefix}course_modules cm ON cm.instance = a.id\n                                                JOIN {$CFG->prefix}modules md        ON md.id = cm.module\n                                                JOIN {$CFG->prefix}user u            ON u.id = asb.userid\n                                          WHERE asb.timemodified > {$timestart} AND\n                                                a.course = {$course->id} AND\n                                                md.name = 'assignment'\n                                       ORDER BY asb.timemodified ASC"))) {
        return false;
    }
    $modinfo =& get_fast_modinfo($course);
    // reference needed because we might load the groups
    $show = array();
    $grader = array();
    foreach ($submissions as $submission) {
        if (!array_key_exists($submission->cmid, $modinfo->cms)) {
            continue;
        }
        $cm = $modinfo->cms[$submission->cmid];
        if (!$cm->uservisible) {
            continue;
        }
        if ($submission->userid == $USER->id) {
            $show[] = $submission;
            continue;
        }
        // the act of sumbitting of assignment may be considered private - only graders will see it if specified
        if (empty($CFG->assignment_showrecentsubmissions)) {
            if (!array_key_exists($cm->id, $grader)) {
                $grader[$cm->id] = has_capability('moodle/grade:viewall', get_context_instance(CONTEXT_MODULE, $cm->id));
            }
            if (!$grader[$cm->id]) {
                continue;
            }
        }
        $groupmode = groups_get_activity_groupmode($cm, $course);
        if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id))) {
            if (isguestuser()) {
                // shortcut - guest user does not belong into any group
                continue;
            }
            if (is_null($modinfo->groups)) {
                $modinfo->groups = groups_get_user_groups($course->id);
                // load all my groups and cache it in modinfo
            }
            // this will be slow - show only users that share group with me in this cm
            if (empty($modinfo->groups[$cm->id])) {
                continue;
            }
            $usersgroups = groups_get_all_groups($course->id, $cm->userid, $cm->groupingid);
            if (is_array($usersgroups)) {
                $usersgroups = array_keys($usersgroups);
                $interset = array_intersect($usersgroups, $modinfo->groups[$cm->id]);
                if (empty($intersect)) {
                    continue;
                }
            }
        }
        $show[] = $submission;
    }
    if (empty($show)) {
        return false;
    }
    print_headline(get_string('newsubmissions', 'assignment') . ':');
    foreach ($show as $submission) {
        $cm = $modinfo->cms[$submission->cmid];
        $link = $CFG->wwwroot . '/mod/assignment/view.php?id=' . $cm->id;
        print_recent_activity_note($submission->timemodified, $submission, $cm->name, $link, false, $viewfullnames);
    }
    return true;
}
function elluminate_print_recent_activity($course, $isteacher, $timestart)
{
    /// Given a course and a time, this module should find recent activity
    /// that has occurred in Blackboard Collaborate activities and print it out.
    /// Return true if there was output, or false is there was none.
    global $CFG;
    global $DB;
    $content = false;
    $meetings = NULL;
    $select = "time > {$timestart} AND course = {$course->id} AND " . "module = 'elluminate' AND action = 'view.meeting'";
    if (!($logs = $DB->get_records_select('log', $select, null, 'time ASC'))) {
        return false;
    }
    foreach ($logs as $log) {
        //Create a temp valid module structure (course,id)
        $tempmod = new stdClass();
        $tempmod->course = $log->course;
        $tempmod->id = $log->info;
        //Obtain the visible property from the instance
        $modvisible = instance_is_visible($log->module, $tempmod);
        //Only if the mod is visible
        if ($modvisible) {
            $sql = "SELECT e.name, u.firstname, u.lastname\n\t\t            FROM {elluminate} e,\n\t\t            {user} u" . "WHERE e.id = :elluminate\n            \t\tAND u.id = :log";
            $sql_params = array('elluminate' => $log->info, 'log' => $log->userid);
            $meetings[$log->info] = $DB->get_record_sql($sql, $sql_params);
            $meetings[$log->info]->time = $log->time;
            $meetings[$log->info]->url = str_replace('&', '&amp;', $log->url);
        }
    }
    if ($meetings) {
        print_headline(get_string('newsubmissions', 'assignment') . ':');
        foreach ($meetings as $meeting) {
            print_recent_activity_note($meeting->time, $meeting, $isteacher, stripslashes($meeting->name), $CFG->wwwroot . '/mod/elluminate/' . $meeting->url);
        }
        $content = true;
    }
    return $content;
}
Beispiel #7
0
/**
 * Given a course and a date, prints a summary of all the new
 * messages posted in the course since that date
 * @param object $course
 * @param bool $viewfullnames capability
 * @param int $timestart
 * @return bool success
 */
function forum_print_recent_activity($course, $viewfullnames, $timestart)
{
    global $CFG, $USER;
    // do not use log table if possible, it may be huge and is expensive to join with other tables
    if (!($posts = get_records_sql("SELECT p.*, f.type AS forumtype, d.forum, d.groupid,\n                                          d.timestart, d.timeend, d.userid AS duserid,\n                                          u.firstname, u.lastname, u.email, u.picture\n                                     FROM {$CFG->prefix}forum_posts p\n                                          JOIN {$CFG->prefix}forum_discussions d ON d.id = p.discussion\n                                          JOIN {$CFG->prefix}forum f             ON f.id = d.forum\n                                          JOIN {$CFG->prefix}user u              ON u.id = p.userid\n                                    WHERE p.created > {$timestart} AND f.course = {$course->id}\n                                 ORDER BY p.id ASC"))) {
        // order by initial posting date
        return false;
    }
    $modinfo =& get_fast_modinfo($course);
    $groupmodes = array();
    $cms = array();
    $strftimerecent = get_string('strftimerecent');
    $printposts = array();
    foreach ($posts as $post) {
        if (!isset($modinfo->instances['forum'][$post->forum])) {
            // not visible
            continue;
        }
        $cm = $modinfo->instances['forum'][$post->forum];
        if (!$cm->uservisible) {
            continue;
        }
        $context = get_context_instance(CONTEXT_MODULE, $cm->id);
        if (!has_capability('mod/forum:viewdiscussion', $context)) {
            continue;
        }
        if (!empty($CFG->forum_enabletimedposts) and $USER->id != $post->duserid and ($post->timestart > 0 and $post->timestart > time() or $post->timeend > 0 and $post->timeend < time())) {
            if (!has_capability('mod/forum:viewhiddentimedposts', $context)) {
                continue;
            }
        }
        $groupmode = groups_get_activity_groupmode($cm, $course);
        if ($groupmode) {
            if ($post->groupid == -1 or $groupmode == VISIBLEGROUPS or has_capability('moodle/site:accessallgroups', $context)) {
                // oki (Open discussions have groupid -1)
            } else {
                // separate mode
                if (isguestuser()) {
                    // shortcut
                    continue;
                }
                if (is_null($modinfo->groups)) {
                    $modinfo->groups = groups_get_user_groups($course->id);
                    // load all my groups and cache it in modinfo
                }
                if (!array_key_exists($post->groupid, $modinfo->groups[0])) {
                    continue;
                }
            }
        }
        $printposts[] = $post;
    }
    unset($posts);
    if (!$printposts) {
        return false;
    }
    print_headline(get_string('newforumposts', 'forum') . ':', 3);
    echo "\n<ul class='unlist'>\n";
    foreach ($printposts as $post) {
        $subjectclass = empty($post->parent) ? ' bold' : '';
        echo '<li><div class="head">' . '<div class="date">' . userdate($post->modified, $strftimerecent) . '</div>' . '<div class="name">' . fullname($post, $viewfullnames) . '</div>' . '</div>';
        echo '<div class="info' . $subjectclass . '">';
        if (empty($post->parent)) {
            echo '"<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '">';
        } else {
            echo '"<a href="' . $CFG->wwwroot . '/mod/forum/discuss.php?d=' . $post->discussion . '&amp;parent=' . $post->parent . '#p' . $post->id . '">';
        }
        $post->subject = break_up_long_words(format_string($post->subject, true));
        echo $post->subject;
        echo "</a>\"</div></li>\n";
    }
    echo "</ul>\n";
    return true;
}
Beispiel #8
0
function wiki_print_recent_activity($course, $isteacher, $timestart)
{
    /// Given a course and a time, this module should find recent activity
    /// that has occurred in wiki activities and print it out.
    /// Return true if there was output, or false is there was none.
    global $CFG;
    if (!($logs = get_records_select('log', 'time > \'' . $timestart . '\' AND ' . 'course = \'' . $course->id . '\' AND ' . 'module = \'wiki\' AND ' . 'action LIKE \'edit%\' ', 'time ASC'))) {
        return false;
    }
    foreach ($logs as $log) {
        //Create a temp valid module structure (course,id)
        $tempmod = new Object();
        $tempmod->course = $log->course;
        $tempmod->id = $log->cmid;
        //Obtain the visible property from the instance
        $modvisible = instance_is_visible($log->module, $tempmod);
        /// Process log->url and rebuild it here to properly clean the pagename - MDL-15896
        $extractedpage = preg_replace('/^.*&page=/', '', $log->url);
        $log->url = preg_replace('/page=.*$/', 'page=' . urlencode($extractedpage), $log->url);
        //Only if the mod is visible
        if ($modvisible) {
            $wikis[$log->info] = wiki_log_info($log);
            $wikis[$log->info]->pagename = $log->info;
            $wikis[$log->info]->time = $log->time;
            $wikis[$log->info]->url = str_replace('&', '&amp;', $log->url);
        }
    }
    if ($wikis) {
        $content = true;
        print_headline(get_string('updatedwikipages', 'wiki') . ':', 3);
        foreach ($wikis as $wiki) {
            print_recent_activity_note($wiki->time, $wiki, $wiki->pagename, $CFG->wwwroot . '/mod/wiki/' . $wiki->url);
        }
    }
    return true;
    //  True if anything was printed, otherwise false
}
Beispiel #9
0
function survey_print_recent_activity($course, $isteacher, $timestart)
{
    global $CFG;
    $content = false;
    $surveys = NULL;
    if (!($logs = get_records_select('log', 'time > \'' . $timestart . '\' AND ' . 'course = \'' . $course->id . '\' AND ' . 'module = \'survey\' AND ' . 'action = \'submit\' ', 'time ASC'))) {
        return false;
    }
    foreach ($logs as $log) {
        //Create a temp valid module structure (course,id)
        $tempmod->course = $log->course;
        $tempmod->id = $log->info;
        //Obtain the visible property from the instance
        $modvisible = instance_is_visible($log->module, $tempmod);
        //Only if the mod is visible
        if ($modvisible) {
            $surveys[$log->id] = survey_log_info($log);
            $surveys[$log->id]->time = $log->time;
            $surveys[$log->id]->url = str_replace('&', '&amp;', $log->url);
        }
    }
    if ($surveys) {
        $content = true;
        print_headline(get_string('newsurveyresponses', 'survey') . ':');
        foreach ($surveys as $survey) {
            print_recent_activity_note($survey->time, $survey, $survey->name, $CFG->wwwroot . '/mod/survey/' . $survey->url);
        }
    }
    return $content;
}
Beispiel #10
0
function journal_print_recent_activity($course, $isteacher, $timestart)
{
    global $CFG;
    if (!empty($CFG->journal_showrecentactivity)) {
        // Don't even bother
        return false;
    }
    $content = false;
    $journals = NULL;
    if (!($logs = get_records_select('log', 'time > \'' . $timestart . '\' AND ' . 'course = \'' . $course->id . '\' AND ' . 'module = \'journal\' AND ' . '(action = \'add entry\' OR action = \'update entry\')', 'time ASC'))) {
        return false;
    }
    foreach ($logs as $log) {
        ///Get journal info.  I'll need it later
        $j_log_info = journal_log_info($log);
        //Create a temp valid module structure (course,id)
        $tempmod->course = $log->course;
        $tempmod->id = $j_log_info->id;
        //Obtain the visible property from the instance
        $modvisible = instance_is_visible($log->module, $tempmod);
        //Only if the mod is visible
        if ($modvisible) {
            if (!isset($journals[$log->info])) {
                $journals[$log->info] = $j_log_info;
                $journals[$log->info]->time = $log->time;
                $journals[$log->info]->url = str_replace('&', '&amp;', $log->url);
            }
        }
    }
    if ($journals) {
        $content = true;
        print_headline(get_string('newjournalentries', 'journal') . ':');
        foreach ($journals as $journal) {
            print_recent_activity_note($journal->time, $journal, $journal->name, $CFG->wwwroot . '/mod/journal/' . $journal->url);
        }
    }
    return $content;
}
Beispiel #11
0
function chat_print_recent_activity($course, $viewfullnames, $timestart)
{
    /// Given a course and a date, prints a summary of all chat rooms past and present
    /// This function is called from course/lib.php: print_recent_activity()
    global $CFG, $USER;
    // this is approximate only, but it is really fast ;-)
    $timeout = $CFG->chat_old_ping * 10;
    if (!($mcms = get_records_sql("SELECT cm.id, MAX(chm.timestamp) AS lasttime\n                                    FROM {$CFG->prefix}course_modules cm\n                                         JOIN {$CFG->prefix}modules md        ON md.id = cm.module\n                                         JOIN {$CFG->prefix}chat ch           ON ch.id = cm.instance\n                                         JOIN {$CFG->prefix}chat_messages chm ON chm.chatid = ch.id\n                                   WHERE chm.timestamp > {$timestart} AND ch.course = {$course->id} AND md.name = 'chat'\n                                GROUP BY cm.id\n                                ORDER BY lasttime ASC"))) {
        return false;
    }
    $past = array();
    $current = array();
    $modinfo =& get_fast_modinfo($course);
    // reference needed because we might load the groups
    foreach ($mcms as $cmid => $mcm) {
        if (!array_key_exists($cmid, $modinfo->cms)) {
            continue;
        }
        $cm = $modinfo->cms[$cmid];
        $cm->lasttime = $mcm->lasttime;
        if (!$modinfo->cms[$cm->id]->uservisible) {
            continue;
        }
        if (groups_get_activity_groupmode($cm) != SEPARATEGROUPS or has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id))) {
            if ($timeout > time() - $cm->lasttime) {
                $current[] = $cm;
            } else {
                $past[] = $cm;
            }
            continue;
        }
        if (is_null($modinfo->groups)) {
            $modinfo->groups = groups_get_user_groups($course->id);
            // load all my groups and cache it in modinfo
        }
        // verify groups in separate mode
        if (!($mygroupids = $modinfo->groups[$cm->groupingid])) {
            continue;
        }
        // ok, last post was not for my group - we have to query db to get last message from one of my groups
        // only minor problem is that the order will not be correct
        $mygroupids = implode(',', $mygroupids);
        $cm->mygroupids = $mygroupids;
        if (!($mcm = get_record_sql("SELECT cm.id, MAX(chm.timestamp) AS lasttime\n                                      FROM {$CFG->prefix}course_modules cm\n                                           JOIN {$CFG->prefix}chat ch           ON ch.id = cm.instance\n                                           JOIN {$CFG->prefix}chat_messages chm ON chm.chatid = ch.id\n                                     WHERE chm.timestamp > {$timestart} AND cm.id = {$cm->id} AND\n                                           (chm.groupid IN ({$mygroupids}) OR chm.groupid = 0)\n                                  GROUP BY cm.id"))) {
            continue;
        }
        $cm->lasttime = $mcm->lasttime;
        if ($timeout > time() - $cm->lasttime) {
            $current[] = $cm;
        } else {
            $past[] = $cm;
        }
    }
    if (!$past and !$current) {
        return false;
    }
    $strftimerecent = get_string('strftimerecent');
    if ($past) {
        print_headline(get_string('pastchats', 'chat') . ':');
        foreach ($past as $cm) {
            $link = $CFG->wwwroot . '/mod/chat/view.php?id=' . $cm->id;
            $date = userdate($cm->lasttime, $strftimerecent);
            echo '<div class="head"><div class="date">' . $date . '</div></div>';
            echo '<div class="info"><a href="' . $link . '">' . format_string($cm->name, true) . '</a></div>';
        }
    }
    if ($current) {
        print_headline(get_string('currentchats', 'chat') . ':');
        $oldest = floor((time() - $CFG->chat_old_ping) / 10) * 10;
        // better db caching
        $timeold = time() - $CFG->chat_old_ping;
        $timeold = floor($timeold / 10) * 10;
        // better db caching
        $timeoldext = time() - $CFG->chat_old_ping * 10;
        // JSless gui_basic needs much longer timeouts
        $timeoldext = floor($timeoldext / 10) * 10;
        // better db caching
        $timeout = "AND (chu.version<>'basic' AND chu.lastping>{$timeold}) OR (chu.version='basic' AND chu.lastping>{$timeoldext})";
        foreach ($current as $cm) {
            //count users first
            if (isset($cm->mygroupids)) {
                $groupselect = "AND (chu.groupid IN ({$cm->mygroupids}) OR chu.groupid = 0)";
            } else {
                $groupselect = "";
            }
            if (!($users = get_records_sql("SELECT u.id, u.firstname, u.lastname, u.email, u.picture\n                                             FROM {$CFG->prefix}course_modules cm\n                                             JOIN {$CFG->prefix}chat ch        ON ch.id = cm.instance\n                                             JOIN {$CFG->prefix}chat_users chu ON chu.chatid = ch.id\n                                             JOIN {$CFG->prefix}user u         ON u.id = chu.userid\n                                            WHERE cm.id = {$cm->id} {$timeout} {$groupselect}\n                                         GROUP BY u.id, u.firstname, u.lastname, u.email, u.picture"))) {
            }
            $link = $CFG->wwwroot . '/mod/chat/view.php?id=' . $cm->id;
            $date = userdate($cm->lasttime, $strftimerecent);
            echo '<div class="head"><div class="date">' . $date . '</div></div>';
            echo '<div class="info"><a href="' . $link . '">' . format_string($cm->name, true) . '</a></div>';
            echo '<div class="userlist">';
            if ($users) {
                echo '<ul>';
                foreach ($users as $user) {
                    echo '<li>' . fullname($user, $viewfullnames) . '</li>';
                }
                echo '</ul>';
            }
            echo '</div>';
        }
    }
    return true;
}
Beispiel #12
0
function print_recent_activity($course)
{
    // $course is an object
    // This function trawls through the logs looking for
    // anything new since the user's last login
    global $CFG, $USER, $SESSION;
    $context = get_context_instance(CONTEXT_COURSE, $course->id);
    $timestart = time() - COURSE_MAX_RECENT_PERIOD;
    if (!has_capability('moodle/legacy:guest', $context, NULL, false)) {
        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";
    // Firstly, have there been any new enrolments?
    $heading = false;
    $content = false;
    $users = get_recent_enrolments($course->id, $timestart);
    //Accessibility: new users now appear in an <OL> list.
    if ($users) {
        echo '<div class="newusers">';
        if (!$heading) {
            print_headline(get_string("newusers") . ':', 3);
            $heading = true;
            $content = true;
        }
        echo "<ol class=\"list\">\n";
        foreach ($users as $user) {
            $fullname = fullname($user, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id)));
            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?
    $logs = get_records_select('log', "time > '{$timestart}' AND course = '{$course->id}' AND\n                                       module = 'course' AND action LIKE '% mod'", "time ASC");
    if ($logs) {
        foreach ($logs as $key => $log) {
            $info = split(' ', $log->info);
            if ($info[0] == 'label') {
                // Labels are special activities
                continue;
            }
            $modname = get_field($info[0], 'name', 'id', $info[1]);
            //Create a temp valid module structure (course,id)
            $tempmod->course = $log->course;
            $tempmod->id = $info[1];
            //Obtain the visible property from the instance
            $modvisible = instance_is_visible($info[0], $tempmod);
            //Only if the mod is visible
            if ($modvisible) {
                switch ($log->action) {
                    case 'add mod':
                        $stradded = get_string('added', 'moodle', get_string('modulename', $info[0]));
                        $changelist[$log->info] = array('operation' => 'add', 'text' => "{$stradded}:<br /><a href=\"{$CFG->wwwroot}/course/{$log->url}\">" . format_string($modname, true) . "</a>");
                        break;
                    case 'update mod':
                        $strupdated = get_string('updated', 'moodle', get_string('modulename', $info[0]));
                        if (empty($changelist[$log->info])) {
                            $changelist[$log->info] = array('operation' => 'update', 'text' => "{$strupdated}:<br /><a href=\"{$CFG->wwwroot}/course/{$log->url}\">" . format_string($modname, true) . "</a>");
                        }
                        break;
                    case 'delete mod':
                        if (!empty($changelist[$log->info]['operation']) and $changelist[$log->info]['operation'] == 'add') {
                            $changelist[$log->info] = NULL;
                        } else {
                            $strdeleted = get_string('deletedactivity', 'moodle', get_string('modulename', $info[0]));
                            $changelist[$log->info] = array('operation' => 'delete', 'text' => $strdeleted);
                        }
                        break;
                }
            }
        }
    }
    if (!empty($changelist)) {
        foreach ($changelist as $changeinfo => $change) {
            if ($change) {
                $changes[$changeinfo] = $change;
            }
        }
        if (isset($changes)) {
            if (count($changes) > 0) {
                print_headline(get_string('courseupdates') . ':', 3);
                $content = true;
                foreach ($changes as $changeinfo => $change) {
                    echo '<p class="activity">' . $change['text'] . '</p>';
                }
            }
        }
    }
    // Now display new things from each module
    $mods = get_records('modules', 'visible', '1', 'name', 'id, name');
    $viewfullnames = has_capability('moodle/site:viewfullnames', $context);
    foreach ($mods as $mod) {
        // Each module gets it's own logs and prints them
        if (file_exists($CFG->dirroot . '/mod/' . $mod->name . '/lib.php')) {
            include_once $CFG->dirroot . '/mod/' . $mod->name . '/lib.php';
            $print_recent_activity = $mod->name . '_print_recent_activity';
            if (function_exists($print_recent_activity)) {
                //
                // NOTE:
                //   $isteacher (second parameter below) is to be deprecated!
                //
                // TODO:
                //   1) Make sure that all _print_recent_activity functions are
                //      not using the $isteacher value.
                //   2) Eventually, remove the $isteacher parameter from the
                //      function calls.
                //
                $modcontent = $print_recent_activity($course, $viewfullnames, $timestart);
                if ($modcontent) {
                    $content = true;
                }
            }
        } else {
            /// Really need to indicate an error here to admins. Is there a way to do this?
        }
    }
    if (!$content) {
        echo '<p class="message">' . get_string('nothingnew') . '</p>';
    }
}
Beispiel #13
0
function glossary_print_recent_activity($course, $isteacher, $timestart)
{
    /// Given a course and a time, this module should find recent activity
    /// that has occurred in glossary activities and print it out.
    /// Return true if there was output, or false is there was none.
    global $CFG;
    if (!($logs = get_records_select('log', 'time > \'' . $timestart . '\' AND ' . 'course = \'' . $course->id . '\' AND ' . 'module = \'glossary\' AND ' . '(action = \'add entry\' OR ' . ' action  = \'approve entry\')', 'time ASC'))) {
        return false;
    }
    $entries = array();
    foreach ($logs as $log) {
        //Create a temp valid module structure (course,id)
        $tempmod = new object();
        $tempmod->course = $log->course;
        $entry = get_record('glossary_entries', 'id', $log->info);
        if (!$entry) {
            continue;
        }
        $tempmod->id = $entry->glossaryid;
        //Obtain the visible property from the instance
        $modvisible = instance_is_visible($log->module, $tempmod);
        //Only if the mod is visible
        if ($modvisible and $entry->approved) {
            $entries[$log->info] = glossary_log_info($log);
            $entries[$log->info]->time = $log->time;
            $entries[$log->info]->url = str_replace('&', '&amp;', $log->url);
        }
    }
    $content = false;
    if ($entries) {
        $content = true;
        print_headline(get_string('newentries', 'glossary') . ':');
        foreach ($entries as $entry) {
            $user = get_record('user', 'id', $entry->userid, '', '', '', '', 'firstname,lastname');
            print_recent_activity_note($entry->timemodified, $user, $entry->concept, $CFG->wwwroot . '/mod/glossary/view.php?g=' . $entry->glossaryid . '&amp;mode=entry&amp;hook=' . $entry->id);
        }
    }
    return $content;
}
/**
 * Given a course and a time, this module should find recent activity
 * that has occurred in newmodule activities and print it out.
 * Return true if there was output, or false is there was none.
 *
 * @param object $course
 * @param bool $isteacher
 * @param int $timestart
 * @return boolean true on success, false on failure.
 **/
function oublog_print_recent_activity($course, $isteacher, $timestart)
{
    global $CFG;
    include_once 'locallib.php';
    $sql = "SELECT i.oublogid, p.id AS postid, p.*, u.firstname, u.lastname, u.email, u.idnumber, i.userid\r\n            FROM {$CFG->prefix}oublog_posts p\r\n                INNER JOIN {$CFG->prefix}oublog_instances i ON p.oubloginstancesid = i.id\r\n                INNER JOIN {$CFG->prefix}oublog b ON i.oublogid = b.id\r\n                INNER JOIN {$CFG->prefix}user u ON i.userid = u.id\r\n            WHERE b.course = {$course->id} AND p.deletedby IS NULL AND p.timeposted >= {$timestart} ";
    if (!($rs = get_recordset_sql($sql))) {
        return true;
    }
    $modinfo =& get_fast_modinfo($course);
    $strftimerecent = get_string('strftimerecent');
    print_headline(get_string('newblogposts', 'oublog') . ':', 3);
    echo "\n<ul class='unlist'>\n";
    while ($blog = rs_fetch_next_record($rs)) {
        if (!isset($modinfo->instances['oublog'][$blog->oublogid])) {
            // not visible
            continue;
        }
        $cm = $modinfo->instances['oublog'][$blog->oublogid];
        if (!$cm->uservisible) {
            continue;
        }
        if (!has_capability('mod/oublog:view', get_context_instance(CONTEXT_MODULE, $cm->id))) {
            continue;
        }
        if (!has_capability('mod/oublog:view', get_context_instance(CONTEXT_USER, $blog->userid))) {
            continue;
        }
        $groupmode = oublog_get_activity_groupmode($cm, $course);
        if ($groupmode) {
            if ($blog->groupid && $groupmode != VISIBLEGROUPS) {
                // separate mode
                if (isguestuser()) {
                    // shortcut
                    continue;
                }
                if (is_null($modinfo->groups)) {
                    $modinfo->groups = groups_get_user_groups($course->id);
                    // load all my groups and cache it in modinfo
                }
                if (!array_key_exists($blog->groupid, $modinfo->groups[0])) {
                    continue;
                }
            }
        }
        echo '<li><div class="head">' . '<div class="date">' . oublog_date($blog->timeposted, $strftimerecent) . '</div>' . '<div class="name">' . fullname($blog) . '</div>' . '</div>';
        echo '<div class="info">';
        echo "<a href=\"{$CFG->wwwroot}/mod/oublog/viewpost.php?post={$blog->postid}\">";
        echo break_up_long_words(format_string(empty($blog->title) ? $blog->message : $blog->title));
        echo '</a>';
        echo '</div>';
    }
    echo "</ul>\n";
    rs_close($rs);
}
Beispiel #15
0
function lightboxgallery_print_recent_activity($course, $viewfullnames, $timestart)
{
    global $CFG;
    $sql = "SELECT c.*, l.name, u.firstname, u.lastname\n              FROM {$CFG->prefix}lightboxgallery_comments c\n                   JOIN {$CFG->prefix}lightboxgallery l ON l.id = c.gallery\n                   JOIN {$CFG->prefix}user            u ON u.id = c.userid\n             WHERE c.timemodified > {$timestart} AND l.course = {$course->id}\n          ORDER BY c.timemodified ASC";
    if ($comments = get_records_sql($sql)) {
        print_headline(get_string('newgallerycomments', 'lightboxgallery') . ':', 3);
        echo '<ul class="unlist">';
        $strftimerecent = get_string('strftimerecent');
        foreach ($comments as $comment) {
            $display = lightboxgallery_resize_text(trim(strip_tags($comment->comment)), MAX_COMMENT_PREVIEW);
            echo '<li>' . ' <div class="head">' . '  <div class="date">' . userdate($comment->timemodified, $strftimerecent) . '</div>' . '  <div class="name">' . fullname($comment, $viewfullnames) . ' - ' . format_string($comment->name) . '</div>' . ' </div>' . ' <div class="info">' . '  "<a href="' . $CFG->wwwroot . '/mod/lightboxgallery/view.php?l=' . $comment->gallery . '#c' . $comment->id . '">' . $display . '</a>"' . ' </div>' . '</li>';
        }
        echo '</ul>';
    }
    return true;
}
Beispiel #16
0
function wiki_print_recent_activity($course, $isteacher, $timestart)
{
    /// Given a course and a time, this module should find recent activity
    /// that has occurred in wiki activities and print it out.
    /// Return true if there was output, or false is there was none.
    global $CFG;
    $sql = "SELECT l.*, cm.instance FROM {$CFG->prefix}log l \n                INNER JOIN {$CFG->prefix}course_modules cm ON l.cmid = cm.id \n            WHERE l.time > '{$timestart}' AND l.course = {$course->id} \n                AND l.module = 'wiki' AND action LIKE 'edit%'\n            ORDER BY l.time ASC";
    if (!($logs = get_records_sql($sql))) {
        return false;
    }
    foreach ($logs as $log) {
        //Create a temp valid module structure (course,id)
        $tempmod = new Object();
        $tempmod->course = $log->course;
        $tempmod->id = $log->instance;
        //Obtain the visible property from the instance
        $modvisible = instance_is_visible($log->module, $tempmod);
        //Only if the mod is visible
        if ($modvisible) {
            $wikis[$log->info] = wiki_log_info($log);
            $wikis[$log->info]->pagename = $log->info;
            $wikis[$log->info]->time = $log->time;
            $wikis[$log->info]->url = str_replace('&', '&amp;', $log->url);
        }
    }
    if (isset($wikis)) {
        $content = true;
        print_headline(get_string('updatedwikipages', 'wiki') . ':', 3);
        foreach ($wikis as $wiki) {
            print_recent_activity_note($wiki->time, $wiki, $wiki->pagename, $CFG->wwwroot . '/mod/wiki/' . $wiki->url);
        }
    }
    return true;
    //  True if anything was printed, otherwise false
}
Beispiel #17
0
function dimdim_print_recent_activity($course, $isteacher, $timestart)
{
    /// Given a course and a date, prints a summary of all dimdim rooms
    /// that currently have people in them.
    /// This function is called from course/lib.php: print_recent_activity()
    global $CFG;
    $timeold = time() - $CFG->dimdim_old_ping;
    $lastpingsearch = $CFG->dimdim_method == 'sockets' ? '' : 'AND cu.lastping > \'' . $timeold . '\'';
    if (!($dimdimusers = get_records_sql("SELECT u.id, cu.dimdimid, u.firstname, u.lastname\n                                        FROM {$CFG->prefix}dimdim_users as cu,\n                                             {$CFG->prefix}dimdim as ch,\n                                             {$CFG->prefix}user as u\n                                       WHERE cu.userid = u.id\n                                         AND cu.dimdimid = ch.id {$lastpingsearch}\n                                         AND ch.course = '{$course->id}'\n                                       ORDER BY cu.dimdimid ASC"))) {
        return false;
    }
    $isteacher = isteacher($course->id);
    $outputstarted = false;
    $current = 0;
    foreach ($dimdimusers as $dimdimuser) {
        if ($current != $dimdimuser->dimdimid) {
            if ($current) {
                echo '</ul></div>';
                // room
                $current = 0;
            }
            if ($dimdim = get_record('dimdim', 'id', $dimdimuser->dimdimid)) {
                if (!($isteacher or instance_is_visible('dimdim', $dimdim))) {
                    // dimdim hidden to students
                    continue;
                }
                if (!$outputstarted) {
                    print_headline(get_string('currentdimdims', 'dimdim') . ':');
                    $outputstarted = true;
                }
                echo '<div class="room"><p class="head"><a href="' . $CFG->wwwroot . '/mod/dimdim/view.php?c=' . $dimdim->id . '">' . format_string($dimdim->name, true) . '</a></p><ul>';
            }
            $current = $dimdimuser->dimdimid;
        }
        $fullname = fullname($dimdimuser, $isteacher);
        echo '<li class="info name">' . $fullname . '</li>';
    }
    if ($current) {
        echo '</ul></div>';
        // room
    }
    return true;
}
Beispiel #18
0
function exercise_print_recent_activity($course, $viewfullanmes, $timestart)
{
    global $CFG;
    $isteacher = has_capability('mod/exercise:assess', get_context_instance(CONTEXT_COURSE, $course->id));
    $modinfo = get_fast_modinfo($course);
    // have a look for new submissions (only show to teachers)
    $submitcontent = false;
    if ($isteacher) {
        if ($logs = exercise_get_submit_logs($course, $timestart)) {
            // if we got some 'live' ones then output them
            $submitcontent = true;
            print_headline(get_string('exercisesubmissions', 'exercise') . ':');
            foreach ($logs as $log) {
                print_recent_activity_note($log->time, $log, $log->name, $CFG->wwwroot . '/mod/exercise/' . str_replace('&', '&amp;', $log->url));
            }
        }
    }
    // have a look for new assessment gradings for this user
    $gradecontent = false;
    if ($logs = exercise_get_grade_logs($course, $timestart)) {
        // got some, see if any belong to a visible module
        foreach ($logs as $id => $log) {
            $cm = $modinfo->instances['exercise'][$log->exerciseid];
            if (!$cm->uservisible) {
                unset($logs[$id]);
                continue;
            }
        }
        // if we got some "live" ones then output them
        if ($logs) {
            $gradecontent = true;
            print_headline(get_string('exercisefeedback', 'exercise') . ':');
            foreach ($logs as $log) {
                print_recent_activity_note($log->time, $log, $log->name, $CFG->wwwroot . '/mod/exercise/' . str_replace('&', '&amp;', $log->url));
            }
        }
    }
    // have a look for new assessments for this user
    $assesscontent = false;
    if (!$isteacher) {
        // teachers only need to see submissions
        if ($logs = exercise_get_assess_logs($course, $timestart)) {
            // got some, see if any belong to a visible module
            foreach ($logs as $id => $log) {
                $cm = $modinfo->instances['exercise'][$log->exerciseid];
                if (!$cm->uservisible) {
                    unset($logs[$id]);
                    continue;
                }
            }
            // if we got some "live" ones then output them
            if ($logs) {
                $assesscontent = true;
                print_headline(get_string('exerciseassessments', 'exercise') . ':');
                foreach ($logs as $log) {
                    print_recent_activity_note($log->time, $log, $log->name, $CFG->wwwroot . '/mod/exercise/' . str_replace('&', '&amp;', $log->url));
                }
            }
        }
    }
    return $submitcontent or $gradecontent or $assesscontent;
}
Beispiel #19
0
/**
 * Prints any recent dialogue activity since a given time
 * @param   object  $course
 * @param   bool    $viewfullnames capability
 * @param   timestamp   $timestart
 * @return  bool    success
 */
function dialogue_print_recent_activity($course, $viewfullnames, $timestart)
{
    global $CFG;
    // have a look for new entries
    $addentrycontent = false;
    $tempmod = new object();
    // Create a temp valid module structure (only need courseid, moduleid)
    $tempmod->course = $course->id;
    if ($logs = dialogue_get_add_entry_logs($course, $timestart)) {
        // got some, see if any belong to a visible module
        foreach ($logs as $log) {
            $tempmod->id = $log->dialogueid;
            //Obtain the visible property from the instance
            if (instance_is_visible('dialogue', $tempmod)) {
                $addentrycontent = true;
                break;
            }
        }
        // if we got some "live" ones then output them
        if ($addentrycontent) {
            print_headline(get_string('newdialogueentries', 'dialogue') . ':');
            foreach ($logs as $log) {
                $tempmod->id = $log->dialogueid;
                $user = get_record('user', 'id', $log->userid);
                //Obtain the visible property from the instance
                if (instance_is_visible('dialogue', $tempmod)) {
                    print_recent_activity_note($log->time, $user, $log->subject, $CFG->wwwroot . '/mod/dialogue/' . str_replace('&', '&amp;', $log->url));
                }
            }
        }
    }
    // have a look for open conversations
    $opencontent = false;
    if ($logs = dialogue_get_open_conversations($course)) {
        // got some, see if any belong to a visible module
        foreach ($logs as $log) {
            // Create a temp valid module structure (only need courseid, moduleid)
            $tempmod->id = $log->dialogueid;
            //Obtain the visible property from the instance
            if (instance_is_visible('dialogue', $tempmod)) {
                $opencontent = true;
                break;
            }
        }
        // if we got some 'live' ones then output them
        if ($opencontent) {
            print_headline(get_string('opendialogueentries', 'dialogue') . ':');
            foreach ($logs as $log) {
                //Create a temp valid module structure (only need courseid, moduleid)
                $tempmod->id = $log->dialogueid;
                $user = get_record('user', 'id', $log->userid);
                //Obtain the visible property from the instance
                if (instance_is_visible('dialogue', $tempmod)) {
                    print_recent_activity_note($log->time, $user, $log->name, $CFG->wwwroot . '/mod/dialogue/' . str_replace('&', '&amp;', $log->url));
                }
            }
        }
    }
    return $addentrycontent or $opencontent;
}
Beispiel #20
0
function glossary_print_recent_activity($course, $viewfullnames, $timestart)
{
    /// Given a course and a time, this module should find recent activity
    /// that has occurred in glossary activities and print it out.
    /// Return true if there was output, or false is there was none.
    global $CFG, $USER;
    //TODO: use timestamp in approved field instead of changing timemodified when approving in 2.0
    $modinfo = get_fast_modinfo($course);
    $ids = array();
    foreach ($modinfo->cms as $cm) {
        if ($cm->modname != 'glossary') {
            continue;
        }
        if (!$cm->uservisible) {
            continue;
        }
        $ids[$cm->instance] = $cm->instance;
    }
    if (!$ids) {
        return false;
    }
    $glist = implode(',', $ids);
    // there should not be hundreds of glossaries in one course, right?
    if (!($entries = get_records_sql("SELECT ge.id, ge.concept, ge.approved, ge.timemodified, ge.glossaryid,\n                                            ge.userid, u.firstname, u.lastname, u.email, u.picture\n                                       FROM {$CFG->prefix}glossary_entries ge\n                                            JOIN {$CFG->prefix}user u ON u.id = ge.userid\n                                      WHERE ge.glossaryid IN ({$glist}) AND ge.timemodified > {$timestart}\n                                   ORDER BY ge.timemodified ASC"))) {
        return false;
    }
    $editor = array();
    foreach ($entries as $entryid => $entry) {
        if ($entry->approved) {
            continue;
        }
        if (!isset($editor[$entry->glossaryid])) {
            $editor[$entry->glossaryid] = has_capability('mod/glossary:approve', get_context_instance(CONTEXT_MODULE, $modinfo->instances['glossary'][$entry->glossaryid]->id));
        }
        if (!$editor[$entry->glossaryid]) {
            unset($entries[$entryid]);
        }
    }
    if (!$entries) {
        return false;
    }
    print_headline(get_string('newentries', 'glossary') . ':');
    $strftimerecent = get_string('strftimerecent');
    foreach ($entries as $entry) {
        $link = $CFG->wwwroot . '/mod/glossary/view.php?g=' . $entry->glossaryid . '&amp;mode=entry&amp;hook=' . $entry->id;
        if ($entry->approved) {
            $dimmed = '';
        } else {
            $dimmed = ' dimmed_text';
        }
        echo '<div class="head' . $dimmed . '">';
        echo '<div class="date">' . userdate($entry->timemodified, $strftimerecent) . '</div>';
        echo '<div class="name">' . fullname($entry, $viewfullnames) . '</div>';
        echo '</div>';
        echo '<div class="info"><a href="' . $link . '">' . format_text($entry->concept, true) . '</a></div>';
    }
    return true;
}
Beispiel #21
0
function print_recent_activity($course)
{
    // $course is an object
    // This function trawls through the logs looking for
    // anything new since the user's last login
    global $CFG, $USER, $SESSION;
    $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 (!has_capability('moodle/legacy:guest', $context, NULL, false)) {
        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">';
        print_headline(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 = get_records_select('log', "time > {$timestart} AND course = {$course->id} AND\n                                       module = 'course' AND\n                                       (action = 'add mod' OR action = 'update mod' OR action = 'delete mod')", "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 = split(' ', $log->info);
            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)) {
        print_headline(get_string('courseupdates') . ':', 3);
        $content = true;
        foreach ($changelist as $changeinfo => $change) {
            echo '<p class="activity">' . $change['text'] . '</p>';
        }
    }
    /// Now display new things from each module
    $usedmodules = array();
    foreach ($modinfo->cms as $cm) {
        if (isset($usedmodules[$cm->modname])) {
            continue;
        }
        if (!$cm->uservisible) {
            continue;
        }
        $usedmodules[$cm->modname] = $cm->modname;
    }
    foreach ($usedmodules as $modname) {
        // Each module gets it's own logs and prints them
        if (file_exists($CFG->dirroot . '/mod/' . $modname . '/lib.php')) {
            include_once $CFG->dirroot . '/mod/' . $modname . '/lib.php';
            $print_recent_activity = $modname . '_print_recent_activity';
            if (function_exists($print_recent_activity)) {
                // NOTE: original $isteacher (second parameter below) was replaced with $viewfullnames!
                $content = $print_recent_activity($course, $viewfullnames, $timestart) || $content;
            }
        } else {
            debugging("Missing lib.php in lib/{$modname} - please reinstall files or uninstall the module");
        }
    }
    if (!$content) {
        echo '<p class="message">' . get_string('nothingnew') . '</p>';
    }
}
Beispiel #22
0
/**
 * Given a course and a date, prints a summary of all the new
 * messages posted in the course since that date
 */
function forum_print_recent_activity($course, $isteacher, $timestart)
{
    global $CFG;
    $LIKE = sql_ilike();
    $heading = false;
    $content = false;
    if (!($logs = get_records_select('log', 'time > \'' . $timestart . '\' AND ' . 'course = \'' . $course->id . '\' AND ' . 'module = \'forum\' AND ' . 'action ' . $LIKE . ' \'add %\' ', 'time ASC'))) {
        return false;
    }
    $strftimerecent = get_string('strftimerecent');
    $mygroupid = mygroupid($course->id);
    $groupmode = array();
    // To cache group modes
    $count = 0;
    foreach ($logs as $log) {
        //Get post info, I'll need it later
        if ($post = forum_get_post_from_log($log)) {
            //Create a temp valid module structure (course,id)
            $tempmod = new object();
            $tempmod->course = $log->course;
            $tempmod->id = $post->forum;
            //Obtain the visible property from the instance
            $coursecontext = get_context_instance(CONTEXT_COURSE, $tempmod->course);
            $modvisible = instance_is_visible('forum', $tempmod) || has_capability('moodle/course:viewhiddenactivities', $coursecontext);
        }
        //Only if the post exists and mod is visible
        if ($post && $modvisible) {
            if (!isset($cm[$post->forum])) {
                $cm[$post->forum] = get_coursemodule_from_instance('forum', $post->forum, $course->id);
            }
            $modcontext = get_context_instance(CONTEXT_MODULE, $cm[$post->forum]->id);
            // Check whether this is belongs to a discussion in a group that
            // should NOT be accessible to the current user
            if (!has_capability('moodle/site:accessallgroups', $modcontext) && $post->groupid != -1) {
                // Open discussions have groupid -1
                $groupmode[$post->forum] = groups_get_activity_groupmode($cm[$post->forum]);
                if ($groupmode[$post->forum]) {
                    //hope i didn't break anything
                    if (!@in_array($mygroupid, $post->groupid)) {
                        continue;
                    }
                }
            }
            if (!$heading) {
                print_headline(get_string('newforumposts', 'forum') . ':', 3);
                $heading = true;
                $content = true;
            }
            $date = userdate($post->modified, $strftimerecent);
            $subjectclass = $log->action == 'add discussion' ? ' bold' : '';
            //Accessibility: markup as a list.
            if ($count < 1) {
                echo "\n<ul class='unlist'>\n";
            }
            $count++;
            echo '<li><div class="head">' . '<div class="date">' . $date . '</div>' . '<div class="name">' . fullname($post, has_capability('moodle/site:viewfullnames', $coursecontext)) . '</div>' . '</div>';
            echo '<div class="info' . $subjectclass . '">';
            echo '"<a href="' . $CFG->wwwroot . '/mod/forum/' . str_replace('&', '&amp;', $log->url) . '">';
            $post->subject = break_up_long_words(format_string($post->subject, true));
            echo $post->subject;
            echo "</a>\"</div></li>\n";
        }
    }
    echo "</ul>\n";
    return $content;
}
Beispiel #23
0
function chat_print_recent_activity($course, $isteacher, $timestart)
{
    /// Given a course and a date, prints a summary of all chat rooms
    /// that currently have people in them.
    /// This function is called from course/lib.php: print_recent_activity()
    global $CFG;
    $timeold = time() - $CFG->chat_old_ping;
    $lastpingsearch = $CFG->chat_method == 'sockets' ? '' : 'AND cu.lastping > \'' . $timeold . '\'';
    if (!($chatusers = get_records_sql("SELECT u.id, cu.chatid, u.firstname, u.lastname\n                                        FROM {$CFG->prefix}chat_users cu,\n                                             {$CFG->prefix}chat ch,\n                                             {$CFG->prefix}user u\n                                       WHERE cu.userid = u.id\n                                         AND cu.chatid = ch.id {$lastpingsearch}\n                                         AND ch.course = '{$course->id}'\n                                       ORDER BY cu.chatid ASC"))) {
        return false;
    }
    $outputstarted = false;
    $current = 0;
    foreach ($chatusers as $chatuser) {
        if ($current != $chatuser->chatid) {
            if ($current) {
                echo '</ul></div>';
                // room
                $current = 0;
            }
            if ($chat = get_record('chat', 'id', $chatuser->chatid)) {
                // we find the course module id
                $cm = get_coursemodule_from_instance('chat', $chat->id, $course->id);
                $context = get_context_instance(CONTEXT_MODULE, $cm->id);
                // needs to be fixed
                if (!(has_capability('mod/chat:readlog', $context) or instance_is_visible('chat', $chat))) {
                    // Chat hidden to students
                    continue;
                }
                if (!$outputstarted) {
                    print_headline(get_string('currentchats', 'chat') . ':');
                    $outputstarted = true;
                }
                echo '<div class="room"><p class="head"><a href="' . $CFG->wwwroot . '/mod/chat/view.php?c=' . $chat->id . '">' . format_string($chat->name, true) . '</a></p><ul>';
            }
            $current = $chatuser->chatid;
        }
        $fullname = fullname($chatuser, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id)));
        echo '<li class="info name">' . $fullname . '</li>';
    }
    if ($current) {
        echo '</ul></div>';
        // room
    }
    return true;
}
Beispiel #24
0
  <?php 
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
include_once "{$DOCUMENT_ROOT}/it/includes/common.inc";
include_once "{$DOCUMENT_ROOT}/it/includes/functions.inc";
print_header('Archivio delle notizie', 'utf-8');
?>

    <div id="content">
	
		<h2 class="hdr">Archivio delle notizie</h2>
     <?php 
if (isset($_GET['id'])) {
    print_headline();
} else {
    print_all_headlines_nonadmin();
}
?>


      </div>
    </div>
  </div>

<?php 
print_footer();
Beispiel #25
0
function workshop_print_recent_activity($course, $viewfullanmes, $timestart)
{
    global $CFG;
    $isteacher = has_capability('mod/workshop:manage', get_context_instance(CONTEXT_COURSE, $course->id));
    $modinfo = get_fast_modinfo($course);
    // have a look for agreed assessments for this user (agree)
    $agreecontent = false;
    if (!$isteacher) {
        // teachers only need to see submissions
        if ($logs = workshop_get_agree_logs($course, $timestart)) {
            $agreecontent = true;
            print_headline(get_string("workshopagreedassessments", "workshop") . ":");
            foreach ($logs as $log) {
                if (!workshop_is_teacher($workshop, $log->userid)) {
                    // don't break anonymous rule
                    $log->firstname = $course->student;
                    $log->lastname = '';
                }
                print_recent_activity_note($log->time, $log, $log->name, $CFG->wwwroot . '/mod/workshop/' . $log->url);
            }
        }
    }
    // have a look for new assessments for this user (assess)
    $assesscontent = false;
    if (!$isteacher) {
        // teachers only need to see submissions
        if ($logs = workshop_get_assess_logs($course, $timestart)) {
            // got some, see if any belong to a visible module
            foreach ($logs as $id => $log) {
                $cm = $modinfo->instances['workshop'][$log->workshopid];
                if (!$cm->uservisible) {
                    unset($logs[$id]);
                    continue;
                }
            }
            // if we got some "live" ones then output them
            if ($logs) {
                $assesscontent = true;
                print_headline(get_string("workshopassessments", "workshop") . ":");
                foreach ($logs as $log) {
                    if (!workshop_is_teacher($tempmod->id, $log->userid)) {
                        // don't break anonymous rule
                        $log->firstname = $course->student;
                        // Keep anonymous
                        $log->lastname = '';
                    }
                    print_recent_activity_note($log->time, $log, $log->name, $CFG->wwwroot . '/mod/workshop/' . $log->url);
                }
            }
        }
    }
    // have a look for new comments for this user (comment)
    $commentcontent = false;
    if (!$isteacher) {
        // teachers only need to see submissions
        if ($logs = workshop_get_comment_logs($course, $timestart)) {
            // got some, see if any belong to a visible module
            foreach ($logs as $id => $log) {
                $cm = $modinfo->instances['workshop'][$log->workshopid];
                if (!$cm->uservisible) {
                    unset($logs[$id]);
                    continue;
                }
            }
            // if we got some "live" ones then output them
            if ($logs) {
                $commentcontent = true;
                print_headline(get_string("workshopcomments", "workshop") . ":");
                foreach ($logs as $log) {
                    $log->firstname = $course->student;
                    // Keep anonymous
                    $log->lastname = '';
                    print_recent_activity_note($log->time, $log, $log->name, $CFG->wwwroot . '/mod/workshop/' . $log->url);
                }
            }
        }
    }
    // have a look for new assessment gradings for this user (grade)
    $gradecontent = false;
    if ($logs = workshop_get_grade_logs($course, $timestart)) {
        // got some, see if any belong to a visible module
        foreach ($logs as $id => $log) {
            $cm = $modinfo->instances['workshop'][$log->workshopid];
            if (!$cm->uservisible) {
                unset($logs[$id]);
                continue;
            }
        }
        // if we got some "live" ones then output them
        if ($logs) {
            $gradecontent = true;
            print_headline(get_string("workshopfeedback", "workshop") . ":");
            foreach ($logs as $log) {
                $log->firstname = $course->teacher;
                // Keep anonymous
                $log->lastname = '';
                print_recent_activity_note($log->time, $log, $log->name, $CFG->wwwroot . '/mod/workshop/' . $log->url);
            }
        }
    }
    // have a look for new submissions (only show to teachers) (submit)
    $submitcontent = false;
    if ($isteacher) {
        if ($logs = workshop_get_submit_logs($course, $timestart)) {
            // got some, see if any belong to a visible module
            foreach ($logs as $id => $log) {
                $cm = $modinfo->instances['workshop'][$log->workshopid];
                if (!$cm->uservisible) {
                    unset($logs[$id]);
                    continue;
                }
            }
            // if we got some "live" ones then output them
            if ($logs) {
                $submitcontent = true;
                print_headline(get_string("workshopsubmissions", "workshop") . ":");
                foreach ($logs as $log) {
                    print_recent_activity_note($log->time, $log, $log->name, $CFG->wwwroot . '/mod/workshop/' . $log->url);
                }
            }
        }
    }
    return $agreecontent or $assesscontent or $commentcontent or $gradecontent or $submitcontent;
}
Beispiel #26
0
function journal_print_recent_activity($course, $isteacher, $timestart)
{
    global $CFG;
    if (!empty($CFG->journal_showrecentactivity)) {
        // Don't even bother
        return false;
    }
    $content = false;
    $journals = NULL;
    // log table should not be used here
    if (!($logs = get_records_select('log', 'time > \'' . $timestart . '\' AND ' . 'course = \'' . $course->id . '\' AND ' . 'module = \'journal\' AND ' . '(action = \'add entry\' OR action = \'update entry\')', 'time ASC'))) {
        return false;
    }
    foreach ($logs as $log) {
        ///Get journal info.  I'll need it later
        $j_log_info = journal_log_info($log);
        $cm = $modinfo->instances['journal'][$j_log_info->id];
        if (!$cm->uservisible) {
            continue;
        }
        if (!isset($journals[$log->info])) {
            $journals[$log->info] = $j_log_info;
            $journals[$log->info]->time = $log->time;
            $journals[$log->info]->url = str_replace('&', '&amp;', $log->url);
        }
    }
    if ($journals) {
        $content = true;
        print_headline(get_string('newjournalentries', 'journal') . ':');
        foreach ($journals as $journal) {
            print_recent_activity_note($journal->time, $journal, $journal->name, $CFG->wwwroot . '/mod/journal/' . $journal->url);
        }
    }
    return $content;
}
Beispiel #27
0
function survey_print_recent_activity($course, $viewfullnames, $timestart)
{
    global $CFG;
    $modinfo = get_fast_modinfo($course);
    $ids = array();
    foreach ($modinfo->cms as $cm) {
        if ($cm->modname != 'survey') {
            continue;
        }
        if (!$cm->uservisible) {
            continue;
        }
        $ids[$cm->instance] = $cm->instance;
    }
    if (!$ids) {
        return false;
    }
    $slist = implode(',', $ids);
    // there should not be hundreds of glossaries in one course, right?
    if (!($rs = get_recordset_sql("SELECT sa.userid, sa.survey, MAX(sa.time) AS time,\n                                         u.firstname, u.lastname, u.email, u.picture\n                                    FROM {$CFG->prefix}survey_answers sa\n                                         JOIN {$CFG->prefix}user u ON u.id = sa.userid\n                                   WHERE sa.survey IN ({$slist}) AND sa.time > {$timestart}\n                                   GROUP BY sa.userid, sa.survey, u.firstname, u.lastname, u.email, u.picture\n                                   ORDER BY time ASC"))) {
        return false;
    }
    $surveys = array();
    while ($survey = rs_fetch_next_record($rs)) {
        $cm = $modinfo->instances['survey'][$survey->survey];
        $survey->name = $cm->name;
        $survey->cmid = $cm->id;
        $surveys[] = $survey;
    }
    rs_close($rs);
    if (!$surveys) {
        return false;
    }
    print_headline(get_string('newsurveyresponses', 'survey') . ':');
    foreach ($surveys as $survey) {
        $url = $CFG->wwwroot . '/mod/survey/view.php?id=' . $survey->cmid;
        print_recent_activity_note($survey->time, $survey, $survey->name, $url, false, $viewfullnames);
    }
    return true;
}
Beispiel #28
0
function glossary_print_recent_activity($course, $viewfullnames, $timestart)
{
    /// Given a course and a time, this module should find recent activity
    /// that has occurred in glossary activities and print it out.
    /// Return true if there was output, or false is there was none.
    global $CFG, $USER;
    //TODO: use timestamp in approved field instead of changing timemodified when approving in 2.0
    if (!defined('GLOSSARY_RECENT_ACTIVITY_LIMIT')) {
        define('GLOSSARY_RECENT_ACTIVITY_LIMIT', 50);
    }
    $modinfo = get_fast_modinfo($course);
    $ids = array();
    foreach ($modinfo->cms as $cm) {
        if ($cm->modname != 'glossary') {
            continue;
        }
        if (!$cm->uservisible) {
            continue;
        }
        $ids[$cm->instance] = $cm->id;
    }
    if (!$ids) {
        return false;
    }
    // generate list of approval capabilities for all glossaries in the course.
    $approvals = array();
    foreach ($ids as $glinstanceid => $glcmid) {
        $context = get_context_instance(CONTEXT_MODULE, $glcmid);
        // get records glossary entries that are approved if user has no capability to approve entries.
        if (has_capability('mod/glossary:approve', $context)) {
            $approvals[] = ' ge.glossaryid = ' . $glinstanceid . ' ';
        } else {
            $approvals[] = ' (ge.approved = 1 AND ge.glossaryid = ' . $glinstanceid . ') ';
        }
    }
    $selectsql = "SELECT ge.id, ge.concept, ge.approved, ge.timemodified, ge.glossaryid,\n                                                 ge.userid, u.firstname, u.lastname, u.email, u.picture ";
    $countsql = "SELECT COUNT(*)";
    $joins = array(" FROM {$CFG->prefix}glossary_entries ge ");
    $joins[] = "JOIN {$CFG->prefix}user u ON u.id = ge.userid ";
    $fromsql = implode($joins, "\n");
    $clausesql = ' WHERE ge.timemodified > ' . $timestart . ' AND (';
    $approvalsql = implode($approvals, ' OR ');
    $ordersql = ') ORDER BY ge.timemodified ASC';
    $entries = get_records_sql($selectsql . $fromsql . $clausesql . $approvalsql . $ordersql, 0, GLOSSARY_RECENT_ACTIVITY_LIMIT + 1);
    $fromsql = implode($joins, "\n");
    if (empty($entries)) {
        return false;
    }
    print_headline(get_string('newentries', 'glossary') . ':');
    $strftimerecent = get_string('strftimerecent');
    $entrycount = 0;
    foreach ($entries as $entry) {
        if ($entrycount < GLOSSARY_RECENT_ACTIVITY_LIMIT) {
            if ($entry->approved) {
                $dimmed = '';
                $link = $CFG->wwwroot . '/mod/glossary/view.php?g=' . $entry->glossaryid . '&amp;mode=entry&amp;hook=' . $entry->id;
            } else {
                $dimmed = ' dimmed_text';
                $link = $CFG->wwwroot . '/mod/glossary/view.php?id=' . $ids[$entry->glossaryid] . '&amp;mode=approval&amp;hook=' . format_text($entry->concept, true);
            }
            echo '<div class="head' . $dimmed . '">';
            echo '<div class="date">' . userdate($entry->timemodified, $strftimerecent) . '</div>';
            echo '<div class="name">' . fullname($entry, $viewfullnames) . '</div>';
            echo '</div>';
            echo '<div class="info"><a href="' . $link . '">' . format_text($entry->concept, true) . '</a></div>';
            $entrycount += 1;
        } else {
            $numnewentries = count_records_sql($countsql . $joins[0] . $clausesql . $approvalsql . ')');
            echo '<div class="head"><div class="activityhead">' . get_string('andmorenewentries', 'glossary', $numnewentries - GLOSSARY_RECENT_ACTIVITY_LIMIT) . '</div></div>';
            break;
        }
    }
    return true;
}