/** * Define this form - called by the parent constructor */ public function definition() { global $COURSE, $USER; $mform = $this->_form; $params = $this->_customdata; $mform->addElement('header', 'batchuploadfilesforusers', get_string('batchuploadfilesforusers', 'setaskfeedback_file', count($params['users']))); $mform->addElement('static', 'userslist', get_string('selectedusers', 'setaskfeedback_file'), $params['usershtml']); $data = new stdClass(); $fileoptions = array('subdirs' => 1, 'maxbytes' => $COURSE->maxbytes, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL); $data = file_prepare_standard_filemanager($data, 'files', $fileoptions, $params['context'], 'setaskfeedback_file', ASSIGNFEEDBACK_FILE_BATCH_FILEAREA, $USER->id); $mform->addElement('filemanager', 'files_filemanager', '', null, $fileoptions); $this->set_data($data); $mform->addElement('hidden', 'id', $params['cm']); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'operation', 'plugingradingbatchoperation_file_uploadfiles'); $mform->setType('operation', PARAM_ALPHAEXT); $mform->addElement('hidden', 'action', 'viewpluginpage'); $mform->setType('action', PARAM_ALPHA); $mform->addElement('hidden', 'pluginaction', 'uploadfiles'); $mform->setType('pluginaction', PARAM_ALPHA); $mform->addElement('hidden', 'plugin', 'file'); $mform->setType('plugin', PARAM_PLUGIN); $mform->addElement('hidden', 'pluginsubtype', 'setaskfeedback'); $mform->setType('pluginsubtype', PARAM_PLUGIN); $mform->addElement('hidden', 'selectedusers', implode(',', $params['users'])); $mform->setType('selectedusers', PARAM_SEQUENCE); $this->add_action_buttons(true, get_string('uploadfiles', 'setaskfeedback_file')); }
/** * Get form elements for grading form * * @param stdClass $grade * @param MoodleQuickForm $mform * @param stdClass $data * @return bool true if elements were added to the form */ public function get_form_elements($grade, MoodleQuickForm $mform, stdClass $data) { $fileoptions = $this->get_file_options(); $gradeid = $grade ? $grade->id : 0; $data = file_prepare_standard_filemanager($data, 'files', $fileoptions, $this->assignment->get_context(), 'assignfeedback_file', ASSIGNFEEDBACK_FILE_FILEAREA, $gradeid); $mform->addElement('filemanager', 'files_filemanager', '', null, $fileoptions); return true; }
} $title = get_string('editfiles', 'wiki'); $struser = get_string('user'); $url = new moodle_url('/mod/wiki/filesedit.php', array('subwiki' => $subwiki->id, 'pageid' => $pageid)); $PAGE->set_url($url); $PAGE->set_context($context); $PAGE->set_title($title); $PAGE->set_heading($course->fullname); $PAGE->navbar->add(format_string(get_string('wikifiles', 'wiki')), $CFG->wwwroot . '/mod/wiki/files.php?pageid=' . $pageid); $PAGE->navbar->add(format_string($title)); $data = new stdClass(); $data->returnurl = $returnurl; $data->subwikiid = $subwiki->id; $maxbytes = get_max_upload_file_size($CFG->maxbytes, $COURSE->maxbytes); $options = array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => -1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL | FILE_REFERENCE); file_prepare_standard_filemanager($data, 'files', $options, $context, 'mod_wiki', 'attachments', $subwiki->id); $mform = new mod_wiki_filesedit_form(null, array('data' => $data, 'options' => $options)); if ($mform->is_cancelled()) { redirect($returnurl); } else { if ($formdata = $mform->get_data()) { $formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $context, 'mod_wiki', 'attachments', $subwiki->id); redirect($returnurl); } } echo $OUTPUT->header(); echo $OUTPUT->heading(format_string($wiki->name)); echo $OUTPUT->box(format_module_intro('wiki', $wiki, $PAGE->cm->id), 'generalbox', 'intro'); echo $OUTPUT->box_start('generalbox'); $mform->display(); echo $OUTPUT->box_end();
} } else { // new entry require_capability('mod/glossary:write', $context); // note: guest user does not have any write capability $entry = new stdClass(); $entry->id = null; } $maxfiles = 99; // TODO: add some setting $maxbytes = $course->maxbytes; // TODO: add some setting $definitionoptions = array('trusttext' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'context' => $context, 'subdirs' => file_area_contains_subdirs($context, 'mod_glossary', 'entry', $entry->id)); $attachmentoptions = array('subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes); $entry = file_prepare_standard_editor($entry, 'definition', $definitionoptions, $context, 'mod_glossary', 'entry', $entry->id); $entry = file_prepare_standard_filemanager($entry, 'attachment', $attachmentoptions, $context, 'mod_glossary', 'attachment', $entry->id); $entry->cmid = $cm->id; // create form and set initial data $mform = new mod_glossary_entry_form(null, array('current' => $entry, 'cm' => $cm, 'glossary' => $glossary, 'definitionoptions' => $definitionoptions, 'attachmentoptions' => $attachmentoptions)); if ($mform->is_cancelled()) { if ($id) { redirect("view.php?id={$cm->id}&mode=entry&hook={$id}"); } else { redirect("view.php?id={$cm->id}"); } } else { if ($entry = $mform->get_data()) { $timenow = time(); $categories = empty($entry->categories) ? array() : $entry->categories; unset($entry->categories); $aliases = trim($entry->aliases);
file_prepare_standard_filemanager($course, 'overviewfiles', $overviewfilesoptions, $coursecontext, 'course', 'overviewfiles', 0); } // Inject current aliases. $aliases = $DB->get_records('role_names', array('contextid' => $coursecontext->id)); foreach ($aliases as $alias) { $course->{'role_' . $alias->roleid} = $alias->name; } // Populate course tags. $course->tags = core_tag_tag::get_item_tags_array('core', 'course', $course->id); } else { // Editor should respect category context if course context is not set. $editoroptions['context'] = $catcontext; $editoroptions['subdirs'] = 0; $course = file_prepare_standard_editor($course, 'summary', $editoroptions, null, 'course', 'summary', null); if ($overviewfilesoptions) { file_prepare_standard_filemanager($course, 'overviewfiles', $overviewfilesoptions, null, 'course', 'overviewfiles', 0); } } // First create the form. $args = array('course' => $course, 'category' => $category, 'editoroptions' => $editoroptions, 'returnto' => $returnto, 'returnurl' => $returnurl); $editform = new course_edit_form(null, $args); if ($editform->is_cancelled()) { // The form has been cancelled, take them back to what ever the return to is. redirect($returnurl); } else { if ($data = $editform->get_data()) { // Process data if submitted. if (empty($course->id)) { // In creating the course. $course = create_course($data, $editoroptions); // Get the context of the newly created course.
echo $output->header(); echo $output->box(get_string('assessmentreferenceconflict', 'workshopplus')); echo $output->continue_button($workshopplus->view_url()); echo $output->footer(); die; } redirect($workshopplus->exassess_url($asid)); } if ($edit and $canmanage) { require_once dirname(__FILE__) . '/submission_form.php'; $maxfiles = $workshopplus->nattachments; $maxbytes = $workshopplus->maxbytes; $contentopts = array('trusttext' => true, 'subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'context' => $workshopplus->context); $attachmentopts = array('subdirs' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes); $example = file_prepare_standard_editor($example, 'content', $contentopts, $workshopplus->context, 'mod_workshopplus', 'submission_content', $example->id); $example = file_prepare_standard_filemanager($example, 'attachment', $attachmentopts, $workshopplus->context, 'mod_workshopplus', 'submission_attachment', $example->id); $mform = new workshopplus_submission_form($PAGE->url, array('current' => $example, 'workshopplus' => $workshopplus, 'contentopts' => $contentopts, 'attachmentopts' => $attachmentopts)); if ($mform->is_cancelled()) { redirect($workshopplus->view_url()); } elseif ($canmanage and $formdata = $mform->get_data()) { if ($formdata->example == 1) { // this was used just for validation, it must be set to one when dealing with example submissions unset($formdata->example); } else { throw new coding_exception('Invalid submission form data value: example'); } $timenow = time(); if (is_null($example->id)) { $formdata->workshopplusid = $workshopplus->id; $formdata->example = 1; $formdata->authorid = $USER->id;
$PAGE->set_context($context); $title = strip_tags($course->fullname . ': ' . get_string('modulename', 'assignment') . ': ' . format_string($assignment->name, true)); $PAGE->set_title($title); $PAGE->set_heading($title); $instance = new assignment_onlinejudge($cm->id, $assignment, $cm, $course); $submission = $instance->get_submission($formdata->userid, true); $filemanager_options = array('subdirs' => 1, 'maxbytes' => $assignment->maxbytes, 'maxfiles' => $assignment->var1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL); $mform = new mod_assignment_upload_form(null, array('contextid' => $contextid, 'userid' => $formdata->userid, 'options' => $filemanager_options)); if ($mform->is_cancelled()) { redirect(new moodle_url('/mod/assignment/view.php', array('id' => $cm->id))); } else { if ($formdata = $mform->get_data()) { $instance->upload($mform, $filemanager_options); die; } } echo $OUTPUT->header(); echo $OUTPUT->box_start('generalbox'); if ($instance->can_upload_file($submission) && $id == null) { $data = new stdClass(); // move submission files to user draft area $data = file_prepare_standard_filemanager($data, 'files', $filemanager_options, $context, 'mod_assignment', 'submission', $submission->id); // set file manager itemid, so it will find the files in draft area $mform->set_data($data); $mform->display(); } else { echo $OUTPUT->notification(get_string('uploaderror', 'assignment')); echo $OUTPUT->continue_button(new moodle_url('/mod/assignment/view.php', array('id' => $cm->id))); } echo $OUTPUT->box_end(); echo $OUTPUT->footer();
} if ($asid == workshop::ALLOCATION_EXISTS) { // the training assessment of the example was not found but the allocation already // exists. this probably means that the user is the author of the reference assessment. echo $output->header(); echo $output->box(get_string('assessmentreferenceconflict', 'workshop')); echo $output->continue_button($workshop->view_url()); echo $output->footer(); die; } redirect($workshop->exassess_url($asid)); } if ($edit and $canmanage) { require_once dirname(__FILE__) . '/submission_form.php'; $example = file_prepare_standard_editor($example, 'content', $workshop->submission_content_options(), $workshop->context, 'mod_workshop', 'submission_content', $example->id); $example = file_prepare_standard_filemanager($example, 'attachment', $workshop->submission_attachment_options(), $workshop->context, 'mod_workshop', 'submission_attachment', $example->id); $mform = new workshop_submission_form($PAGE->url, array('current' => $example, 'workshop' => $workshop, 'contentopts' => $workshop->submission_content_options(), 'attachmentopts' => $workshop->submission_attachment_options())); if ($mform->is_cancelled()) { redirect($workshop->view_url()); } elseif ($canmanage and $formdata = $mform->get_data()) { if ($formdata->example == 1) { // this was used just for validation, it must be set to one when dealing with example submissions unset($formdata->example); } else { throw new coding_exception('Invalid submission form data value: example'); } $timenow = time(); if (is_null($example->id)) { $formdata->workshopid = $workshop->id; $formdata->example = 1; $formdata->authorid = $USER->id;
/** * during editing this prepares the file manager with the correct file reference * @param object instance of the userdata for this form (course edit form) */ function edit_load_user_data(&$user) { global $DB; //, $FILEPICKER_OPTIONS; $options = filepicker_options(); //$dataid = $this->data; //if (!empty($dataid)) { if ($dataid = $DB->get_field('course_meta_info_data', 'id', array('courseid' => $this->courseid, 'fieldid' => $this->fieldid))) { $user->{$this->inputname} = file_prepare_standard_filemanager($user, $this->inputname, $options, $options['context'], 'course_meta_customfield', 'course_meta_filemanager', $dataid); } }
/** * Get form elements for grading form. * * @param stdClass $grade * @param MoodleQuickForm $mform * @param stdClass $data * @param int $userid The userid we are currently grading * @return bool true if elements were added to the form */ public function get_form_elements_for_user($grade, MoodleQuickForm $mform, stdClass $data, $userid) { $fileoptions = $this->get_file_options(); $gradeid = $grade ? $grade->id : 0; $elementname = 'files_' . $userid; $data = file_prepare_standard_filemanager($data, $elementname, $fileoptions, $this->seplment->get_context(), 'seplfeedback_file', ASSIGNFEEDBACK_FILE_FILEAREA, $gradeid); $mform->addElement('filemanager', $elementname . '_filemanager', $this->get_name(), null, $fileoptions); return true; }
/** * Get form elements for grading form. * * @param stdClass $grade * @param MoodleQuickForm $mform * @param stdClass $data * @param int $userid The userid we are currently grading * @return bool true if elements were added to the form */ public function get_form_elements_for_user($grade, MoodleQuickForm $mform, stdClass $data, $userid) { $fileoptions = $this->get_file_options(); $gradeid = $grade ? $grade->id : 0; $elementname = 'files_' . $userid; $data = file_prepare_standard_filemanager($data, $elementname, $fileoptions, $this->assignment->get_context(), 'assignfeedback_file', ASSIGNFEEDBACK_FILE_FILEAREA, $gradeid); $mform->addElement('filemanager', $elementname . '_filemanager', html_writer::tag('span', $this->get_name(), array('class' => 'accesshide')), null, $fileoptions); return true; }
/** * Add elements to submission form * * @param mixed $submission stdClass|null * @param MoodleQuickForm $mform * @param stdClass $data * @return bool */ public function get_form_elements($submission, MoodleQuickForm $mform, stdClass $data) { global $DB; if ($this->get_config('maxfilesubmissions') <= 0) { return false; } $fileoptions = $this->get_file_options(); $submissionid = $submission ? $submission->id : 0; $context = $this->assignment->get_context(); $fs = get_file_storage(); $coversheetfiles = $fs->get_area_files($context->id, 'assignsubmission_pdf', ASSIGNSUBMISSION_PDF_FA_COVERSHEET, false, '', false); if ($coversheetfiles) { $file = reset($coversheetfiles); $fileurl = moodle_url::make_pluginfile_url($file->get_contextid(), $file->get_component(), $file->get_filearea(), null, $file->get_filepath(), $file->get_filename()); $filelink = html_writer::link($fileurl, $file->get_filename(), array('target' => '_blank')); $mform->addElement('static', 'pdf_coversheet', '', get_string('coversheetnotice', 'assignsubmission_pdf') . ': ' . $filelink); } file_prepare_standard_filemanager($data, 'pdfs', $fileoptions, $this->assignment->get_context(), 'assignsubmission_pdf', ASSIGNSUBMISSION_PDF_FA_DRAFT, $submissionid); $label = html_writer::tag('span', get_string('pdfsubmissions', 'assignsubmission_pdf'), array('class' => 'accesshide')); $mform->addElement('filemanager', 'pdfs_filemanager', $label, null, $fileoptions); if ($coversheetfiles) { if ($templateid = $this->get_config('templateid')) { $templateitems = $DB->get_records('assignsubmission_pdf_tmplit', array('templateid' => $templateid)); $templatedata = array(); if ($submissionid) { if ($templatedata = $DB->get_field('assignsubmission_pdf', 'templatedata', array('submission' => $submissionid))) { $templatedata = unserialize($templatedata); } } foreach ($templateitems as $item) { $elname = "pdf_template[{$item->id}]"; if ($item->type == 'shorttext') { $mform->addElement('text', $elname, s($item->setting)); } else { if ($item->type == 'text') { $mform->addElement('textarea', $elname, s($item->setting)); } else { continue; } } $mform->setType($elname, PARAM_TEXT); $mform->addRule($elname, null, 'required', null, 'client'); if (isset($templatedata[$item->id])) { $mform->setDefault($elname, $templatedata[$item->id]); } } } } return true; }
echo $output->header(); echo $output->box(get_string('assessmentreferenceconflict', 'teamwork')); echo $output->continue_button($teamwork->view_url()); echo $output->footer(); die; } redirect($teamwork->exassess_url($asid)); } if ($edit and $canmanage) { require_once dirname(__FILE__) . '/submission_form.php'; $maxfiles = $teamwork->nattachments; $maxbytes = $teamwork->maxbytes; $contentopts = array('trusttext' => true, 'subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'context' => $teamwork->context); $attachmentopts = array('subdirs' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes); $example = file_prepare_standard_editor($example, 'content', $contentopts, $teamwork->context, 'mod_teamwork', 'submission_content', $example->id); $example = file_prepare_standard_filemanager($example, 'attachment', $attachmentopts, $teamwork->context, 'mod_teamwork', 'submission_attachment', $example->id); $mform = new teamwork_submission_form($PAGE->url, array('current' => $example, 'teamwork' => $teamwork, 'contentopts' => $contentopts, 'attachmentopts' => $attachmentopts)); if ($mform->is_cancelled()) { redirect($teamwork->view_url()); } elseif ($canmanage and $formdata = $mform->get_data()) { if ($formdata->example == 1) { // this was used just for validation, it must be set to one when dealing with example submissions unset($formdata->example); } else { throw new coding_exception('Invalid submission form data value: example'); } $timenow = time(); if (is_null($example->id)) { $formdata->teamworkid = $teamwork->id; $formdata->example = 1; $formdata->authorid = $USER->id;
/** * Add elements to submission form * * @param mixed $submission stdClass|null * @param MoodleQuickForm $mform * @param stdClass $data * @return bool */ public function get_form_elements($submission, MoodleQuickForm $mform, stdClass $data) { if ($this->get_config('maxfilesubmissions') <= 0) { return false; } $fileoptions = $this->get_file_options(); $submissionid = $submission ? $submission->id : 0; $data = file_prepare_standard_filemanager($data, 'files', $fileoptions, $this->setaskment->get_context(), 'setasksubmission_file', ASSIGNSUBMISSION_FILE_FILEAREA, $submissionid); $mform->addElement('filemanager', 'files_filemanager', $this->get_name(), null, $fileoptions); return true; }
$chapter = $DB->get_record('giportfolio_userchapters', array('id' => $chapterid, 'giportfolioid' => $giportfolio->id, 'iduser' => $USER->id), '*', MUST_EXIST); } // Chapter is hidden for students. if ($chapter->hidden) { require_capability('mod/giportfolio:viewhiddenchapters', $context); } giportfolio_add_fake_block($chapters, $chapter, $giportfolio, $cm, 0, 0); // Add TOC. $editoroptions = array('noclean' => true, 'subdirs' => true, 'maxfiles' => -1, 'maxbytes' => 0, 'context' => $context); $attachmentoptions = array('subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes); $contribution = null; if ($contributionid) { $contribution = $DB->get_record('giportfolio_contributions', array('id' => $contributionid, 'chapterid' => $chapterid, 'userid' => $USER->id), '*', MUST_EXIST); $formdata = clone $contribution; $formdata = file_prepare_standard_editor($formdata, 'content', $editoroptions, $context, 'mod_giportfolio', 'contribution', $formdata->id); $formdata = file_prepare_standard_filemanager($formdata, 'attachment', $attachmentoptions, $context, 'mod_giportfolio', 'attachment', $formdata->id); $formdata->contributionid = $formdata->id; } else { $formdata = new stdClass(); } $formdata->id = $cm->id; $formdata->chapterid = $chapter->id; // Header and strings. $PAGE->set_title(format_string($giportfolio->name)); $PAGE->add_body_class('mod_giportfolio'); $PAGE->set_heading(format_string($course->fullname)); $redir = new moodle_url('/mod/giportfolio/viewgiportfolio.php', array('id' => $cm->id, 'chapterid' => $chapter->id)); // Handle delete / show / hide actions. if ($action) { if (!$contribution) { print_error('invalidcontributionid', 'giportfolio');
$courseid = optional_param('courseid', '', PARAM_INT); $context = get_context_instance(CONTEXT_COURSE, $courseid); if (!has_capability('mod/csv_enrol:uploadcsv', $context, $USER->id)) { die("Unauthorized."); } $title = get_string('csvenrol', 'block_csv_enrol'); $struser = get_string('user'); $PAGE->set_url('/blocks/csv_enrol/edit.php'); $PAGE->set_context($context); $PAGE->set_title($title); $PAGE->set_heading($title); $PAGE->set_pagelayout('incourse'); $PAGE->set_pagetype('user-private-files'); $data = new stdClass(); $options = array('subdirs' => 1, 'maxbytes' => $CFG->userquota, 'maxfiles' => -1, 'accepted_types' => '*.csv', 'return_types' => FILE_INTERNAL); file_prepare_standard_filemanager($data, 'files', $options, $context, 'user', 'csvenrol', 0); $course = $DB->get_record('course', array('id' => $courseid)); //used for coursename $data->coursename = $course->fullname; $data->courseid = $courseid; $mform = new block_csv_enrol_form(null, array('data' => $data, 'options' => $options)); $formdata = $mform->get_data(); //3 options: file uploaded, cancelled, or saved if ($mform->is_cancelled()) { redirect(new moodle_url($CFG->wwwroot . '/course/view.php', array('id' => $courseid))); } else { if ($formdata && $mform->get_file_content('userfile')) { //upload file, store, and process csv $content = $mform->get_file_content('userfile'); //save uploaded file $fs = get_file_storage();
require_login($course); require_capability('moodle/course:managefiles', $context); $PAGE->set_url($url); $heading = get_string('coursefiles') . ': ' . format_string($course->fullname, true, array('context' => $context)); $strfiles = get_string("files"); if ($node = $PAGE->settingsnav->find('coursefiles', navigation_node::TYPE_SETTING)) { $node->make_active(); } else { $PAGE->navbar->add($strfiles); } $PAGE->set_context($context); $PAGE->set_title($heading); $PAGE->set_heading($heading); $PAGE->set_pagelayout('incourse'); $data = new stdClass(); $options = array('subdirs' => 1, 'maxfiles' => -1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL); file_prepare_standard_filemanager($data, 'files', $options, $context, $component, $filearea, $itemid); $form = new coursefiles_edit_form(null, array('data' => $data, 'contextid' => $contextid)); $returnurl = new moodle_url('/files/index.php', array('contextid' => $contextid)); if ($form->is_cancelled()) { redirect($returnurl); } if ($data = $form->get_data()) { $data = file_postupdate_standard_filemanager($data, 'files', $options, $context, $component, $filearea, $itemid); redirect($returnurl); } echo $OUTPUT->header(); echo $OUTPUT->container_start(); $form->display(); echo $OUTPUT->container_end(); echo $OUTPUT->footer();
// Course module ID $cm = get_coursemodule_from_id('folder', $id, 0, false, MUST_EXIST); $context = get_context_instance(CONTEXT_MODULE, $cm->id, MUST_EXIST); $folder = $DB->get_record('folder', array('id' => $cm->instance), '*', MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); require_login($course, false, $cm); require_capability('mod/folder:managefiles', $context); add_to_log($course->id, 'folder', 'edit', 'edit.php?id=' . $cm->id, $folder->id, $cm->id); $PAGE->set_url('/mod/folder/edit.php', array('id' => $cm->id)); $PAGE->set_title($course->shortname . ': ' . $folder->name); $PAGE->set_heading($course->fullname); $PAGE->set_activity_record($folder); $data = new stdClass(); $data->id = $cm->id; $options = array('subdirs' => 1, 'maxbytes' => $CFG->maxbytes, 'maxfiles' => -1, 'accepted_types' => '*'); file_prepare_standard_filemanager($data, 'files', $options, $context, 'mod_folder', 'content', 0); $mform = new mod_folder_edit_form(null, array('data' => $data, 'options' => $options)); if ($mform->is_cancelled()) { redirect(new moodle_url('/mod/folder/view.php', array('id' => $cm->id))); } else { if ($formdata = $mform->get_data()) { $formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $context, 'mod_folder', 'content', 0); $DB->set_field('folder', 'revision', $folder->revision + 1, array('id' => $folder->id)); redirect(new moodle_url('/mod/folder/view.php', array('id' => $cm->id))); } } echo $OUTPUT->header(); echo $OUTPUT->box_start('generalbox foldertree'); $mform->display(); echo $OUTPUT->box_end(); echo $OUTPUT->footer();
$returnbutton = false; $returnurl = new moodle_url('/user/files.php'); } $context = get_context_instance(CONTEXT_USER, $USER->id); require_capability('moodle/user:manageownfiles', $context); $title = get_string('myfiles'); $struser = get_string('user'); $PAGE->set_url('/user/files.php'); $PAGE->set_context($context); $PAGE->set_title($title); $PAGE->set_heading($title); $PAGE->set_pagelayout('mydashboard'); $PAGE->set_pagetype('user-files'); $data = new stdClass(); $data->returnurl = $returnurl; $options = array('subdirs' => 1, 'maxbytes' => $CFG->userquota, 'maxfiles' => -1, 'accepted_types' => '*'); file_prepare_standard_filemanager($data, 'files', $options, $context, 'user', 'private', 0); $mform = new user_files_form(null, array('data' => $data, 'options' => $options, 'cancelbutton' => $returnbutton)); if ($mform->is_cancelled()) { redirect($returnurl); } else { if ($formdata = $mform->get_data()) { $formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $context, 'user', 'private', 0); redirect($returnurl); } } echo $OUTPUT->header(); echo $OUTPUT->box_start('generalbox'); $mform->display(); echo $OUTPUT->box_end(); echo $OUTPUT->footer();
case CONTEXT_COURSE: $entry->courseassoc = $assocrec->contextid; break; case CONTEXT_MODULE: $entry->modassoc = $assocrec->contextid; break; } } } } require_once 'edit_form.php'; $summaryoptions = array('maxfiles' => 99, 'maxbytes' => $CFG->maxbytes, 'trusttext' => true, 'context' => $sitecontext, 'subdirs' => file_area_contains_subdirs($sitecontext, 'blog', 'post', $entry->id)); $attachmentoptions = array('subdirs' => false, 'maxfiles' => 99, 'maxbytes' => $CFG->maxbytes); $blogeditform = new blog_edit_form(null, compact('entry', 'summaryoptions', 'attachmentoptions', 'sitecontext', 'courseid', 'modid')); $entry = file_prepare_standard_editor($entry, 'summary', $summaryoptions, $sitecontext, 'blog', 'post', $entry->id); $entry = file_prepare_standard_filemanager($entry, 'attachment', $attachmentoptions, $sitecontext, 'blog', 'attachment', $entry->id); if (!empty($CFG->usetags) && !empty($entry->id)) { include_once $CFG->dirroot . '/tag/lib.php'; $entry->tags = tag_get_tags_array('post', $entry->id); } $entry->action = $action; // set defaults $blogeditform->set_data($entry); if ($blogeditform->is_cancelled()) { redirect($returnurl); } else { if ($data = $blogeditform->get_data()) { switch ($action) { case 'add': $blogentry = new blog_entry(null, $data, $blogeditform); $blogentry->add();
$strategy = $workshop->grading_strategy_instance(); // load the assessment form and process the submitted data eventually $mform = $strategy->get_assessment_form($PAGE->url, 'assessment', $assessment, $assessmenteditable); // Set data managed by the workshop core, subplugins set their own data themselves. $currentdata = (object)array( 'feedbackauthor' => $assessment->feedbackauthor, 'feedbackauthorformat' => $assessment->feedbackauthorformat, ); if ($assessmenteditable and $workshop->overallfeedbackmode) { $currentdata = file_prepare_standard_editor($currentdata, 'feedbackauthor', $workshop->overall_feedback_content_options(), $workshop->context, 'mod_workshop', 'overallfeedback_content', $assessment->id); if ($workshop->overallfeedbackfiles) { $currentdata = file_prepare_standard_filemanager($currentdata, 'feedbackauthorattachment', $workshop->overall_feedback_attachment_options(), $workshop->context, 'mod_workshop', 'overallfeedback_attachment', $assessment->id); } } $mform->set_data($currentdata); if ($mform->is_cancelled()) { redirect($workshop->view_url()); } elseif ($assessmenteditable and ($data = $mform->get_data())) { if ($canmanage) { if (is_null($assessment->grade)) { $workshop->log('add reference assessment', $workshop->exassess_url($assessment->id), $assessment->submissionid); } else { $workshop->log('update reference assessment', $workshop->exassess_url($assessment->id), $assessment->submissionid); } } else {
print_error('invalidcoursemodule', null, $return_course); } if (!($context = context_module::instance($cm->id))) { print_error('badcontext', null, $return_course); } $sc_obj = new mod_opencast_series(); $sc_obj->fetch($opencast->id); // Display $PAGE->set_title(format_string($opencast->name)); $PAGE->set_heading($course->fullname); $maxbytes = min(mod_opencast_series::getValueForKey('userupload_maxfilesize'), $opencast->userupload_maxfilesize); $usercontext = context_user::instance($USER->id); $data = new stdClass(); $data->returnurl = $return_channel; $options = ['subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => 1, 'accepted_types' => ['video'], 'areamaxbytes' => $maxbytes]; file_prepare_standard_filemanager($data, 'files', $options, $usercontext, 'mod_opencast', 'userfiles', $id); $mform = new mod_opencast_upload_form($url, ['data' => $data, 'options' => $options]); if ($mform->is_cancelled()) { redirect($return_channel); } else { if ($formdata = $mform->get_data()) { $formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $usercontext, 'mod_opencast', 'userfiles', $id); $fs = get_file_storage(); $files = $fs->get_area_files($usercontext->id, 'mod_opencast', 'userfiles', $id); foreach ($files as $file) { $filesize = $file->get_filesize(); if (!$filesize) { $file->delete(); continue; } if ($file->get_mimetype() && substr($file->get_mimetype(), 0, 5) !== 'video') {
public function set_data($data) { $editoroptions = $this->get_editor_options(); if (!isset($data->text)) { $data->text = ''; } if (!isset($data->format)) { $data->textformat = FORMAT_HTML; } else { $data->textformat = $data->format; } if (!empty($this->_customdata->submission->id)) { $itemid = $this->_customdata->submission->id; } else { $itemid = null; } switch ($this->_customdata->assignment->assignmenttype) { case 'upload' : case 'uploadsingle' : $data = file_prepare_standard_filemanager($data, 'files', $editoroptions, $this->_customdata->context, 'mod_assignment', 'response', $itemid); break; default : break; } $data = file_prepare_standard_editor($data, 'submissioncomment', $editoroptions, $this->_customdata->context, $editoroptions['component'], $editoroptions['filearea'], $itemid); return parent::set_data($data); }
/** * Add elements to submission form * * @param mixed $submission stdClass|null * @param MoodleQuickForm $mform * @param stdClass $data * @return bool */ public function get_form_elements($submission, MoodleQuickForm $mform, stdClass $data) { if ($this->get_config('maxfilesubmissions') <= 0) { return false; } $fileoptions = $this->get_file_options(); $submissionid = $submission ? $submission->id : 0; $data = file_prepare_standard_filemanager($data, 'files', $fileoptions, $this->assignment->get_context(), 'assignsubmission_file', ASSIGNSUBMISSION_FILE_FILEAREA, $submissionid); $mform->addElement('filemanager', 'files_filemanager', html_writer::tag('span', $this->get_name(), array('class' => 'accesshide')), null, $fileoptions); return true; }
} else { print_error('nopermissions', 'error', $workshop->view_url(), 'view or create submission'); } if ($assess and $submission->id and !$isreviewer and $canallocate and $workshop->assessing_allowed($USER->id)) { require_sesskey(); $assessmentid = $workshop->add_allocation($submission, $USER->id); redirect($workshop->assess_url($assessmentid)); } if ($edit) { require_once dirname(__FILE__) . '/submission_form.php'; $maxfiles = $workshop->nattachments; $maxbytes = $workshop->maxbytes; $contentopts = array('trusttext' => true, 'subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'context' => $workshop->context, 'return_types' => FILE_INTERNAL | FILE_EXTERNAL); $attachmentopts = array('subdirs' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'return_types' => FILE_INTERNAL); $submission = file_prepare_standard_editor($submission, 'content', $contentopts, $workshop->context, 'mod_workshop', 'submission_content', $submission->id); $submission = file_prepare_standard_filemanager($submission, 'attachment', $attachmentopts, $workshop->context, 'mod_workshop', 'submission_attachment', $submission->id); $mform = new workshop_submission_form($PAGE->url, array('current' => $submission, 'workshop' => $workshop, 'contentopts' => $contentopts, 'attachmentopts' => $attachmentopts)); if ($mform->is_cancelled()) { redirect($workshop->view_url()); } elseif ($cansubmit and $formdata = $mform->get_data()) { if ($formdata->example == 0) { // this was used just for validation, it must be set to zero when dealing with normal submissions unset($formdata->example); } else { throw new coding_exception('Invalid submission form data value: example'); } $timenow = time(); if (is_null($submission->id)) { $formdata->workshopid = $workshop->id; $formdata->example = 0; $formdata->authorid = $USER->id;
$PAGE->set_heading($course->fullname); $PAGE->set_activity_record($project); if ($taskid) { $task = $DB->get_record('project_task', array('id' => $taskid), '*', MUST_EXIST); } else { $task = new stdClass(); $task->id = null; } $maxfiles = 99; // TODO: add some setting $maxbytes = $course->maxbytes; // TODO: add some setting $definitionoptions = array('trusttext' => true, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes, 'context' => $context, 'subdirs' => file_area_contains_subdirs($context, 'mod_project', 'task', $task->id)); $attachmentoptions = array('subdirs' => false, 'maxfiles' => $maxfiles, 'maxbytes' => $maxbytes); //$task = file_prepare_standard_editor($task, 'definition', $definitionoptions, $context, 'mod_project', 'task', $task->id); $task = file_prepare_standard_filemanager($task, 'attachment', $attachmentoptions, $context, 'mod_project', 'attachment', $task->id); $task->cmid = $cm->id; $options = array('noclean' => true, 'subdirs' => true, 'maxfiles' => -1, 'maxbytes' => 0, 'context' => $context); $mform = new task_view_form(null, array('task' => $task, 'project' => $project, 'members' => $members)); // If data submitted, then process and store. if ($mform->is_cancelled()) { if (empty($tasks->id)) { redirect("view.php?id={$cm->id}"); } else { redirect("view.php?id={$cm->id}&taskid={$task->id}"); } } else { if ($data = $mform->get_data()) { if ($data->id) { //store the files /*if(!empty($data->userfile)){