Example #1
0
function lightboxgallery_user_complete($course, $user, $mod, $resource)
{
    global $CFG;
    if ($logs = get_records_select('log', "userid='{$user->id}' AND module='lightboxgallery' AND action='view' AND info='{$resource->id}'", 'time ASC')) {
        $numviews = count($logs);
        $lastlog = array_pop($logs);
        $strnumviews = get_string('numviews', '', $numviews);
        $strmostrecently = get_string('mostrecently');
        echo "{$strnumviews} - {$strmostrecently} " . userdate($lastlog->time);
        $sql = "SELECT c.*\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 l.id = {$mod->instance} AND u.id = {$user->id}\n              ORDER BY c.timemodified ASC";
        if ($comments = get_records_sql($sql)) {
            $cm = get_coursemodule_from_id('lightboxgallery', $mod->id);
            $context = get_context_instance(CONTEXT_MODULE, $cm->id);
            foreach ($comments as $comment) {
                lightboxgallery_print_comment($comment, $context);
            }
        }
    } else {
        print_string('neverseen', 'resource');
    }
}
Example #2
0
    print_error('Invalid comment ID');
}
require_login($course->id);
$PAGE->set_url('/mod/lightboxgallery/view.php', array('id' => $id));
$PAGE->set_title($gallery->name);
$PAGE->set_heading($course->shortname);
$PAGE->set_button(update_module_button($cm->id, $course->id, get_string('modulename', 'lightboxgallery')));
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$galleryurl = $CFG->wwwroot . '/mod/lightboxgallery/view.php?id=' . $cm->id;
if ($delete && has_capability('mod/lightboxgallery:edit', $context)) {
    if ($confirm && confirm_sesskey()) {
        $DB->delete_records('lightboxgallery_comments', array('id' => $comment->id));
        redirect($galleryurl);
    } else {
        echo $OUTPUT->header();
        lightboxgallery_print_comment($comment, $context);
        echo '<br />';
        $paramsyes = array('id' => $gallery->id, 'delete' => $comment->id, 'sesskey' => sesskey(), 'confirm' => 1);
        $paramsno = array('id' => $cm->id);
        echo $OUTPUT->confirm(get_string('commentdelete', 'lightboxgallery'), new moodle_url('/mod/lightboxgallery/comment.php', $paramsyes), new moodle_url('/mod/lightboxgallery/view.php', $paramsno));
        echo $OUTPUT->footer();
        die;
    }
}
require_capability('mod/lightboxgallery:addcomment', $context);
if (!$gallery->comments) {
    print_error('Comments disabled', $galleryurl);
}
$mform = new mod_lightboxgallery_comment_form(null, $gallery);
if ($mform->is_cancelled()) {
    redirect($galleryurl);
Example #3
0
/**
 * Print a detailed representation of what a user has done with
 * a given particular instance of this module, for user activity reports.
 *
 * @return boolean
 * @todo Finish documenting this function
 */
function lightboxgallery_user_complete($course, $user, $mod, $resource)
{
    global $DB, $CFG;
    $conditions = array('userid' => $user->id, 'module' => 'lightboxgallery', 'action' => 'view', 'info' => $resource->id);
    if ($logs = $DB->get_records('log', $conditions, 'time ASC', '*', '0', '1')) {
        $numviews = $DB->count_records('log', $conditions);
        $lastlog = array_pop($logs);
        $strnumviews = get_string('numviews', '', $numviews);
        $strmostrecently = get_string('mostrecently');
        echo $strnumviews . ' - ' . $strmostrecently . ' ' . userdate($lastlog->time);
        $sql = "SELECT c.*\n                  FROM {lightboxgallery_comments} c\n                       JOIN {lightboxgallery} l ON l.id = c.gallery\n                       JOIN {user}            u ON u.id = c.userid\n                 WHERE l.id = :mod AND u.id = :userid\n              ORDER BY c.timemodified ASC";
        $params = array('mod' => $mod->instance, 'userid' => $user->id);
        if ($comments = $DB->get_records_sql($sql, $params)) {
            $cm = get_coursemodule_from_id('lightboxgallery', $mod->id);
            $context = get_context_instance(CONTEXT_MODULE, $cm->id);
            foreach ($comments as $comment) {
                lightboxgallery_print_comment($comment, $context);
            }
        }
    } else {
        print_string('neverseen', 'resource');
    }
}
/**
 * Print a detailed representation of what a user has done with
 * a given particular instance of this module, for user activity reports.
 *
 * @return boolean
 * @todo Finish documenting this function
 */
function lightboxgallery_user_complete($course, $user, $mod, $resource)
{
    global $DB, $CFG;
    $sql = "SELECT c.*\n              FROM {lightboxgallery_comments} c\n                   JOIN {lightboxgallery} l ON l.id = c.gallery\n                   JOIN {user}            u ON u.id = c.userid\n             WHERE l.id = :mod AND u.id = :userid\n          ORDER BY c.timemodified ASC";
    $params = array('mod' => $mod->instance, 'userid' => $user->id);
    if ($comments = $DB->get_records_sql($sql, $params)) {
        $cm = get_coursemodule_from_id('lightboxgallery', $mod->id);
        $context = context_module::instance($cm->id);
        foreach ($comments as $comment) {
            lightboxgallery_print_comment($comment, $context);
        }
    } else {
        print_string('nocomments', 'lightboxgallery');
    }
}