require_capability('mod/publication:grantextension', $context);
$publication = new publication($context, $cm, $course);
$url = new moodle_url('/mod/publication/grantextension.php', array('cmid' => $cm->id));
if (!empty($id)) {
    $url->param('id', $id);
}
$PAGE->set_url($url);
// Create a new form object.
$mform = new mod_publication_grantextension_form(null, array('publication' => $publication, 'userids' => $userids));
if ($mform->is_cancelled()) {
    redirect(new moodle_url('/mod/publication/view.php', array('id' => $cm->id)));
} else {
    if ($data = $mform->get_data()) {
        // Store updated set of files.
        $dataobject = array();
        $dataobject['publication'] = $publication->get_instance()->id;
        foreach ($data->userids as $uid) {
            $dataobject['userid'] = $uid;
            $DB->delete_records('publication_extduedates', $dataobject);
            if ($data->extensionduedate > 0) {
                // Create new record.
                $dataobject['extensionduedate'] = $data->extensionduedate;
                $DB->insert_record('publication_extduedates', $dataobject);
            }
        }
        redirect(new moodle_url('/mod/publication/view.php', array('id' => $cm->id)));
    }
}
// Load existing files into draft area.
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($publication->get_instance()->name));
Пример #2
0
$modinfo = get_fast_modinfo($course);
foreach ($modinfo->instances['publication'] as $cm) {
    if (!$cm->uservisible) {
        continue;
    }
    // Show dimmed if the mod is hidden!
    $class = $cm->visible ? '' : 'dimmed';
    $link = html_writer::tag('a', format_string($cm->name), array('href' => 'view.php?id=' . $cm->id, 'class' => $class));
    $printsection = '';
    if ($usesections) {
        if ($cm->sectionnum !== $currentsection) {
            if ($cm->sectionnum) {
                $printsection = get_section_name($course, $sections[$cm->sectionnum]);
            }
            if ($currentsection !== '') {
                $table->data[] = 'hr';
            }
            $currentsection = $cm->sectionnum;
        }
    }
    $publication = new publication(null, $cm, $course);
    $desc = $publication->get_instance()->intro;
    if ($usesections) {
        $table->data[] = array($printsection, $link, $desc);
    } else {
        $table->data[] = array($link, $desc);
    }
}
echo html_writer::empty_tag('br');
echo html_writer::table($table);
echo $OUTPUT->footer();
Пример #3
0
require_once $CFG->dirroot . '/mod/publication/locallib.php';
require_once $CFG->dirroot . '/mod/publication/mod_publication_files_form.php';
$id = required_param('id', PARAM_INT);
// Course Module ID.
$url = new moodle_url('/mod/publication/view.php', array('id' => $id));
$cm = get_coursemodule_from_id('publication', $id, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
require_login($course, true, $cm);
$PAGE->set_url($url);
$context = context_module::instance($cm->id);
require_capability('mod/publication:view', $context);
$publication = new publication($context, $cm, $course);
$event = \mod_publication\event\course_module_viewed::create(array('objectid' => $PAGE->cm->instance, 'context' => $PAGE->context));
$event->add_record_snapshot('course', $PAGE->course);
$event->trigger();
$pagetitle = strip_tags($course->shortname . ': ' . format_string($publication->get_instance()->name));
$action = optional_param('action', 'view', PARAM_ALPHA);
$savevisibility = optional_param('savevisibility', false, PARAM_RAW);
$download = optional_param('download', 0, PARAM_INT);
if ($download > 0) {
    $publication->download_file($download);
}
if ($savevisibility) {
    require_capability('mod/publication:approve', $context);
    $files = optional_param_array('files', array(), PARAM_INT);
    $sql = 'UPDATE {publication_file} SET teacherapproval=:approval WHERE publication=:pubid AND fileid  IN ';
    $params = array();
    $params['pubid'] = $publication->get_instance()->id;
    foreach ($files as $fileid => $val) {
        $val = $val - 1;
        if ($val == -1) {
Пример #4
0
require_login($course, false, $cm);
$context = context_module::instance($cm->id);
require_capability('mod/publication:upload', $context);
$publication = new publication($context, $cm, $course);
$url = new moodle_url('/mod/publication/upload.php', array('cmid' => $cm->id));
if (!empty($id)) {
    $url->param('id', $id);
}
$PAGE->set_url($url);
$entry = new stdClass();
$entry->id = $USER->id;
$entry->definition = '';
// Updated later.
$entry->definitionformat = FORMAT_HTML;
// Updated later.
$maxfiles = $publication->get_instance()->maxfiles;
$maxbytes = $publication->get_instance()->maxbytes;
// Patch accepted filetypes.
if (isset($publication->get_instance()->allowedfiletypes) and !empty($publication->get_instance()->allowedfiletypes)) {
    $acceptedfiletypes = explode(', ', strtolower($publication->get_instance()->allowedfiletypes));
    foreach ($acceptedfiletypes as &$a) {
        $a = '.' . trim($a);
        // Conversion to fe *.jpg...
    }
} else {
    $acceptedfiletypes = array('*');
}
$definitionoptions = array('trusttext' => true, 'subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'context' => $context, 'accepted_types' => $acceptedfiletypes);
$attachmentoptions = array('subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'accepted_types' => $acceptedfiletypes);
$entry = file_prepare_standard_editor($entry, 'definition', $definitionoptions, $context, 'mod_publication', 'entry', $entry->id);
$entry = file_prepare_standard_filemanager($entry, 'attachment', $attachmentoptions, $context, 'mod_publication', 'attachment', $entry->id);