• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP file_postupdate_standard_filemanager函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: edit_save_data

 /**
  * Saves the data coming from form
  * @param   mixed   data coming from the form
  * @param   string  name of the prefix (ie, competency)
  * @return  mixed   returns data id if success of db insert/update, false on fail, 0 if not permitted
  */
 function edit_save_data($itemnew)
 {
     // , $prefix){ //, $tableprefix) {
     global $DB;
     //, $FILEPICKER_OPTIONS;
     $options = filepicker_options();
     $formelement = $this->inputname . "_filemanager";
     if (!isset($itemnew->{$formelement})) {
         // field not present in form, probably locked and invisible - skip it
         return;
     }
     // if no existing stored data for this object, make a record so we can use its row id
     if (!$DB->get_field('course_meta_info_data', 'id', array('courseid' => $itemnew->id, 'fieldid' => $this->field->id))) {
         $data = new stdClass();
         $data->courseid = $itemnew->id;
         $data->fieldid = $this->field->id;
         $data->data = $itemnew->id . "," . $this->field->id;
         // the value in the view will contain reference to this row; we dont know our id yet
         $DB->insert_record('course_meta_info_data', $data);
     }
     // look up possibly new row id of course_meta_info_data - this will be the itemid in the file store
     $dataid = $DB->get_field('course_meta_info_data', 'id', array('courseid' => $itemnew->id, 'fieldid' => $this->field->id));
     // set the form data to contain the filemanager instance data for this file
     $itemnew = file_postupdate_standard_filemanager($itemnew, $this->inputname, $options, $options['context'], 'course_meta_customfield', 'course_meta_filemanager', $dataid);
 }
开发者ID:EpicBrasil,项目名称:moodle-course_meta,代码行数:31,代码来源:field.class.php


示例2: min

$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') {
                $file->delete();
                print_error('fileis_notavideo', 'opencast', $url, $file->get_mimetype());
            }
            $filename = $file->get_filename();
            preg_match('/\\.([^.]+)$/', $filename, $extension);
            if (!in_array(strtolower($extension[1]), mod_opencast_series::getAllowedFileExtensions())) {
开发者ID:ndunand,项目名称:moodle-mod_opencast,代码行数:31,代码来源:upload_event.php


示例3: edit

 /**
  * Updates this entry in the database. Access control checks must be done by calling code.
  *
  * @param mform $form Used for attachments
  * @return void
  */
 public function edit($params = array(), $form = null, $summaryoptions = array(), $attachmentoptions = array())
 {
     global $CFG, $USER, $DB, $PAGE;
     $sitecontext = get_context_instance(CONTEXT_SYSTEM);
     $entry = $this;
     $this->form = $form;
     foreach ($params as $var => $val) {
         $entry->{$var} = $val;
     }
     $entry = file_postupdate_standard_editor($entry, 'summary', $summaryoptions, $sitecontext, 'blog', 'post', $entry->id);
     $entry = file_postupdate_standard_filemanager($entry, 'attachment', $attachmentoptions, $sitecontext, 'blog', 'attachment', $entry->id);
     if (!empty($CFG->useblogassociations)) {
         $entry->add_associations();
     }
     $entry->lastmodified = time();
     // Update record
     $DB->update_record('post', $entry);
     tag_set('post', $entry->id, $entry->tags);
     add_to_log(SITEID, 'blog', 'update', 'index.php?userid=' . $USER->id . '&entryid=' . $entry->id, $entry->subject);
 }
开发者ID:nfreear,项目名称:moodle,代码行数:26,代码来源:locallib.php


示例4: get_coursemodule_from_id

// 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();
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:31,代码来源:edit.php


示例5: update_course

/**
 * Update a course.
 *
 * Please note this functions does not verify any access control,
 * the calling code is responsible for all validation (usually it is the form definition).
 *
 * @param object $data  - all the data needed for an entry in the 'course' table
 * @param array $editoroptions course description editor options
 * @return void
 */
function update_course($data, $editoroptions = NULL)
{
    global $DB;
    $data->timemodified = time();
    $oldcourse = course_get_format($data->id)->get_course();
    $context = context_course::instance($oldcourse->id);
    if ($editoroptions) {
        $data = file_postupdate_standard_editor($data, 'summary', $editoroptions, $context, 'course', 'summary', 0);
    }
    if ($overviewfilesoptions = course_overviewfiles_options($data->id)) {
        $data = file_postupdate_standard_filemanager($data, 'overviewfiles', $overviewfilesoptions, $context, 'course', 'overviewfiles', 0);
    }
    // Check we don't have a duplicate shortname.
    if (!empty($data->shortname) && $oldcourse->shortname != $data->shortname) {
        if ($DB->record_exists_sql('SELECT id from {course} WHERE shortname = ? AND id <> ?', array($data->shortname, $data->id))) {
            throw new moodle_exception('shortnametaken', '', '', $data->shortname);
        }
    }
    // Check we don't have a duplicate idnumber.
    if (!empty($data->idnumber) && $oldcourse->idnumber != $data->idnumber) {
        if ($DB->record_exists_sql('SELECT id from {course} WHERE idnumber = ? AND id <> ?', array($data->idnumber, $data->id))) {
            throw new moodle_exception('courseidnumbertaken', '', '', $data->idnumber);
        }
    }
    if (!isset($data->category) or empty($data->category)) {
        // prevent nulls and 0 in category field
        unset($data->category);
    }
    $changesincoursecat = $movecat = (isset($data->category) and $oldcourse->category != $data->category);
    if (!isset($data->visible)) {
        // data not from form, add missing visibility info
        $data->visible = $oldcourse->visible;
    }
    if ($data->visible != $oldcourse->visible) {
        // reset the visibleold flag when manually hiding/unhiding course
        $data->visibleold = $data->visible;
        $changesincoursecat = true;
    } else {
        if ($movecat) {
            $newcategory = $DB->get_record('course_categories', array('id' => $data->category));
            if (empty($newcategory->visible)) {
                // make sure when moving into hidden category the course is hidden automatically
                $data->visible = 0;
            }
        }
    }
    // Update with the new data
    $DB->update_record('course', $data);
    // make sure the modinfo cache is reset
    rebuild_course_cache($data->id);
    // update course format options with full course data
    course_get_format($data->id)->update_course_format_options($data, $oldcourse);
    $course = $DB->get_record('course', array('id' => $data->id));
    if ($movecat) {
        $newparent = context_coursecat::instance($course->category);
        $context->update_moved($newparent);
    }
    $fixcoursesortorder = $movecat || isset($data->sortorder) && $oldcourse->sortorder != $data->sortorder;
    if ($fixcoursesortorder) {
        fix_course_sortorder();
    }
    // purge appropriate caches in case fix_course_sortorder() did not change anything
    cache_helper::purge_by_event('changesincourse');
    if ($changesincoursecat) {
        cache_helper::purge_by_event('changesincoursecat');
    }
    // Test for and remove blocks which aren't appropriate anymore
    blocks_remove_inappropriate($course);
    // Save any custom role names.
    save_local_role_names($course->id, $data);
    // update enrol settings
    enrol_course_updated(false, $course, $data);
    // Trigger a course updated event.
    $event = \core\event\course_updated::create(array('objectid' => $course->id, 'context' => context_course::instance($course->id), 'other' => array('shortname' => $course->shortname, 'fullname' => $course->fullname)));
    $event->set_legacy_logdata(array($course->id, 'course', 'update', 'edit.php?id=' . $course->id, $course->id));
    $event->trigger();
    if ($oldcourse->format !== $course->format) {
        // Remove all options stored for the previous format
        // We assume that new course format migrated everything it needed watching trigger
        // 'course_updated' and in method format_XXX::update_course_format_options()
        $DB->delete_records('course_format_options', array('courseid' => $course->id, 'format' => $oldcourse->format));
    }
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:93,代码来源:lib.php


示例6: edit

 /**
  * Updates this entry in the database. Access control checks must be done by calling code.
  *
  * @param array       $params            Entry parameters.
  * @param moodleform  $form              Used for attachments.
  * @param array       $summaryoptions    Summary options.
  * @param array       $attachmentoptions Attachment options.
  *
  * @return void
  */
 public function edit($params = array(), $form = null, $summaryoptions = array(), $attachmentoptions = array())
 {
     global $CFG, $DB;
     $sitecontext = context_system::instance();
     $entry = $this;
     $this->form = $form;
     foreach ($params as $var => $val) {
         $entry->{$var} = $val;
     }
     $entry = file_postupdate_standard_editor($entry, 'summary', $summaryoptions, $sitecontext, 'blog', 'post', $entry->id);
     $entry = file_postupdate_standard_filemanager($entry, 'attachment', $attachmentoptions, $sitecontext, 'blog', 'attachment', $entry->id);
     if (!empty($CFG->useblogassociations)) {
         $entry->add_associations();
     }
     $entry->lastmodified = time();
     // Update record.
     $DB->update_record('post', $entry);
     core_tag_tag::set_item_tags('core', 'post', $entry->id, context_user::instance($this->userid), $entry->tags);
     $event = \core\event\blog_entry_updated::create(array('objectid' => $entry->id, 'relateduserid' => $entry->userid));
     $event->set_blog_entry($entry);
     $event->trigger();
 }
开发者ID:gabrielrosset,项目名称:moodle,代码行数:32,代码来源:locallib.php


示例7: save_files

 /**
  * Saves any files that the teacher may have attached or embedded.
  *
  * @param $assignment
  * @param $submission
  * @param $data
  * @global $PAGE
  * @global $CFG
  * @return string
  */
 private function save_files($assignment, $submission, $data)
 {
     global $PAGE, $CFG;
     $isupload = $assignment->assignmenttype == 'upload';
     $isuploadsingle = $assignment->assignmenttype == 'uploadsingle';
     if ($isupload || $isuploadsingle) {
         $fileui_options = array();
         if ($isupload) {
             $fileui_options = array('subdirs' => 1, 'maxbytes' => $assignment->maxbytes, 'maxfiles' => $assignment->var1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL);
         } else {
             if ($isuploadsingle) {
                 $fileui_options = array('subdirs' => 0, 'maxbytes' => $CFG->userquota, 'maxfiles' => 1, 'accepted_types' => '*', 'return_types' => FILE_INTERNAL);
             }
         }
         file_postupdate_standard_filemanager($data, 'files', $fileui_options, $PAGE->context, 'mod_assignment', 'response', $submission->id);
     }
     return '';
 }
开发者ID:nadavkav,项目名称:moodle-block_ajax_marking,代码行数:28,代码来源:block_ajax_marking_assignment.class.php


示例8: upload_file

    function upload_file($mform, $options) {
        global $CFG, $USER, $DB, $OUTPUT;

        $returnurl  = new moodle_url('/mod/assignment/view.php', array('id'=>$this->cm->id));
        $submission = $this->get_submission($USER->id);

        if (!$this->can_upload_file($submission)) {
            $this->view_header(get_string('upload'));
            echo $OUTPUT->notification(get_string('uploaderror', 'assignment'));
            echo $OUTPUT->continue_button($returnurl);
            $this->view_footer();
            die;
        }

        if ($formdata = $mform->get_data()) {
            $fs = get_file_storage();
            $submission = $this->get_submission($USER->id, true); //create new submission if needed
            $fs->delete_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id);
            $formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $this->context, 'mod_assignment', 'submission', $submission->id);
            $updates = new stdClass();
            $updates->id = $submission->id;
            $updates->numfiles = count($fs->get_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id, 'sortorder', false));
            $updates->timemodified = time();
            $DB->update_record('assignment_submissions', $updates);
            add_to_log($this->course->id, 'assignment', 'upload',
                    'view.php?a='.$this->assignment->id, $this->assignment->id, $this->cm->id);
            $this->update_grade($submission);
            if (!$this->drafts_tracked()) {
                $this->email_teachers($submission);
            }

            // send files to event system
            $files = $fs->get_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id);
            // Let Moodle know that assessable files were  uploaded (eg for plagiarism detection)
            $eventdata = new stdClass();
            $eventdata->modulename   = 'assignment';
            $eventdata->cmid         = $this->cm->id;
            $eventdata->itemid       = $submission->id;
            $eventdata->courseid     = $this->course->id;
            $eventdata->userid       = $USER->id;
            if ($files) {
                $eventdata->files        = $files; // This is depreceated - please use pathnamehashes instead!
            }
            $eventdata->pathnamehashes = array_keys($files);
            events_trigger('assessable_file_uploaded', $eventdata);
            $returnurl  = new moodle_url('/mod/assignment/view.php', array('id'=>$this->cm->id));
            redirect($returnurl);
        }

        $this->view_header(get_string('upload'));
        echo $OUTPUT->notification(get_string('uploaderror', 'assignment'));
        echo $OUTPUT->continue_button($returnurl);
        $this->view_footer();
        die;
    }
开发者ID:JP-Git,项目名称:moodle,代码行数:55,代码来源:assignment.class.php


示例9: upload_file

 function upload_file($mform, $options)
 {
     global $CFG, $USER, $DB, $OUTPUT;
     $returnurl = new moodle_url('/mod/assignment/view.php', array('id' => $this->cm->id));
     $submission = $this->get_submission($USER->id);
     if (!$this->can_upload_file($submission)) {
         $this->view_header(get_string('upload'));
         echo $OUTPUT->notification(get_string('uploaderror', 'assignment'));
         echo $OUTPUT->continue_button($returnurl);
         $this->view_footer();
         die;
     }
     if ($formdata = $mform->get_data()) {
         $fs = get_file_storage();
         $submission = $this->get_submission($USER->id, true);
         //create new submission if needed
         $fs->delete_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id);
         $formdata = file_postupdate_standard_filemanager($formdata, 'files', $options, $this->context, 'mod_assignment', 'submission', $submission->id);
         $updates = new stdClass();
         $updates->id = $submission->id;
         $updates->numfiles = count($fs->get_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id, 'sortorder', false));
         $updates->timemodified = time();
         $DB->update_record('assignment_submissions', $updates);
         $this->update_grade($submission);
         if (!$this->drafts_tracked()) {
             $this->email_teachers($submission);
         }
         // send files to event system
         $files = $fs->get_area_files($this->context->id, 'mod_assignment', 'submission', $submission->id);
         // Let Moodle know that assessable files were  uploaded (eg for plagiarism detection)
         $params = array('context' => $this->context, 'objectid' => $submission->id, 'other' => array('assignmentid' => $this->assignment->id, 'content' => '', 'pathnamehashes' => array_keys($files)));
         $event = \assignment_upload\event\assessable_uploaded::create($params);
         $event->set_legacy_files($files);
         $event->trigger();
         $returnurl = new moodle_url('/mod/assignment/view.php', array('id' => $this->cm->id));
         redirect($returnurl);
     }
     $this->view_header(get_string('upload'));
     echo $OUTPUT->notification(get_string('uploaderror', 'assignment'));
     echo $OUTPUT->continue_button($returnurl);
     $this->view_footer();
     die;
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:43,代码来源:assignment.class.php


示例10: moodle_exception

        $formdata->content = '';
        // updated later
        $formdata->contentformat = FORMAT_HTML;
        // updated later
        $formdata->contenttrust = 0;
        // updated later
        if (is_null($example->id)) {
            $example->id = $formdata->id = $DB->insert_record('teamwork_submissions', $formdata);
        } else {
            if (empty($formdata->id) or empty($example->id) or $formdata->id != $example->id) {
                throw new moodle_exception('err_examplesubmissionid', 'teamwork');
            }
        }
        // save and relink embedded images and save attachments
        $formdata = file_postupdate_standard_editor($formdata, 'content', $contentopts, $teamwork->context, 'mod_teamwork', 'submission_content', $example->id);
        $formdata = file_postupdate_standard_filemanager($formdata, 'attachment', $attachmentopts, $teamwork->context, 'mod_teamwork', 'submission_attachment', $example->id);
        if (empty($formdata->attachment)) {
            // explicit cast to zero integer
            $formdata->attachment = 0;
        }
        // store the updated values or re-save the new example (re-saving needed because URLs are now rewritten)
        $DB->update_record('teamwork_submissions', $formdata);
        redirect($teamwork->exsubmission_url($formdata->id));
    }
}
// Output starts here
echo $output->header();
echo $output->heading(format_string($teamwork->name), 2);
// show instructions for submitting as they may contain some list of questions and we need to know them
// while reading the submitted answer
if (trim($teamwork->instructauthors)) {
开发者ID:Gavinthisisit,项目名称:Moodle,代码行数:31,代码来源:exsubmission.php


示例11: save

 /**
  * Save & preprocess the files and trigger plagiarism plugin, if enabled, to scan the uploaded files via events trigger
  *
  * @global stdClass $USER
  * @global moodle_database $DB
  * @param stdClass $submission
  * @param stdClass $data
  * @return bool
  */
 public function save(stdClass $submission, stdClass $data)
 {
     global $USER, $DB, $SESSION;
     // Pre-process all files to convert to useful PDF format.
     $fileoptions = $this->get_file_options();
     file_postupdate_standard_filemanager($data, 'pdfs', $fileoptions, $this->assignment->get_context(), 'assignsubmission_pdf', ASSIGNSUBMISSION_PDF_FA_DRAFT, $submission->id);
     $pdfsubmission = $this->get_pdf_submission($submission->id);
     // Plagiarism code event trigger when files are uploaded.
     $fs = get_file_storage();
     $files = $fs->get_area_files($this->assignment->get_context()->id, 'assignsubmission_pdf', ASSIGNSUBMISSION_PDF_FA_DRAFT, $submission->id, "id", false);
     // Check all files are PDF v1.4 or less.
     $submissionok = true;
     foreach ($files as $key => $file) {
         if (!AssignPDFLib::ensure_pdf_compatible($file)) {
             $filename = $file->get_filename();
             $file->delete();
             unset($files[$key]);
             if (!isset($SESSION->assignsubmission_pdf_invalid)) {
                 $SESSION->assignsubmission_pdf_invalid = array();
             }
             $SESSION->assignsubmission_pdf_invalid[] = $filename;
             $submissionok = false;
         }
     }
     if (!$submissionok) {
         return false;
     }
     $templatedata = null;
     if (isset($data->pdf_template)) {
         $templatedata = serialize($data->pdf_template);
     }
     $count = $this->count_files($submission->id, ASSIGNSUBMISSION_PDF_FA_DRAFT);
     // Send files to event system.
     // Let Moodle know that an assessable file was uploaded (eg for plagiarism detection).
     $eventdata = new stdClass();
     $eventdata->modulename = 'assign';
     $eventdata->cmid = $this->assignment->get_course_module()->id;
     $eventdata->itemid = $submission->id;
     $eventdata->courseid = $this->assignment->get_course()->id;
     $eventdata->userid = $USER->id;
     if ($count > 1) {
         $eventdata->files = $files;
         // This is depreceated - please use pathnamehashes instead!
     }
     $eventdata->file = $files;
     // This is depreceated - please use pathnamehashes instead!
     $eventdata->pathnamehashes = array_keys($files);
     events_trigger('assessable_file_uploaded', $eventdata);
     if ($pdfsubmission) {
         $pdfsubmission->numpages = 0;
         $pdfsubmission->templatedata = $templatedata;
         $DB->update_record('assignsubmission_pdf', $pdfsubmission);
     } else {
         $pdfsubmission = new stdClass();
         $pdfsubmission->submission = $submission->id;
         $pdfsubmission->assignment = $this->assignment->get_instance()->id;
         $pdfsubmission->numpages = 0;
         $pdfsubmission->templatedata = $templatedata;
         $DB->insert_record('assignsubmission_pdf', $pdfsubmission);
     }
     if (!$this->assignment->get_instance()->submissiondrafts) {
         // No 'submit assignment' button - need to submit immediately.
         $this->submit_for_grading($submission);
     }
     return true;
 }
开发者ID:tyleung,项目名称:CMPUT401MoodleExams,代码行数:75,代码来源:locallib.php


示例12: moodle_exception

        $formdata->content = '';
        // updated later
        $formdata->contentformat = FORMAT_HTML;
        // updated later
        $formdata->contenttrust = 0;
        // updated later
        if (is_null($example->id)) {
            $example->id = $formdata->id = $DB->insert_record('workshop_submissions', $formdata);
        } else {
            if (empty($formdata->id) or empty($example->id) or $formdata->id != $example->id) {
                throw new moodle_exception('err_examplesubmissionid', 'workshop');
            }
        }
        // Save and relink embedded images and save attachments.
        $formdata = file_postupdate_standard_editor($formdata, 'content', $workshop->submission_content_options(), $workshop->context, 'mod_workshop', 'submission_content', $example->id);
        $formdata = file_postupdate_standard_filemanager($formdata, 'attachment', $workshop->submission_attachment_options(), $workshop->context, 'mod_workshop', 'submission_attachment', $example->id);
        if (empty($formdata->attachment)) {
            // explicit cast to zero integer
            $formdata->attachment = 0;
        }
        // store the updated values or re-save the new example (re-saving needed because URLs are now rewritten)
        $DB->update_record('workshop_submissions', $formdata);
        redirect($workshop->exsubmission_url($formdata->id));
    }
}
// Output starts here
echo $output->header();
echo $output->heading(format_string($workshop->name), 2);
// show instructions for submitting as they may contain some list of questions and we need to know them
// while reading the submitted answer
if (trim($workshop->instructauthors)) {
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:exsubmission.php


示例13: redirect

    redirect($redir);
} else {
    if ($data = $mform->get_data()) {
        $sendnotification = false;
        if (!$contributionid) {
            // Create new contribution.
            $ins = (object) array('chapterid' => $chapter->id, 'giportfolioid' => $giportfolio->id, 'pagenum' => 0, 'subchapter' => 0, 'title' => '', 'content' => '', 'contentformat' => FORMAT_HTML, 'hidden' => 0, 'timecreated' => time(), 'timemodified' => 0, 'userid' => $USER->id);
            $contributionid = $DB->insert_record('giportfolio_contributions', $ins);
            if ($giportfolio->notifyaddentry) {
                $sendnotification = true;
            }
        }
        $data->id = $contributionid;
        $data->timemodified = time();
        $data = file_postupdate_standard_editor($data, 'content', $editoroptions, $context, 'mod_giportfolio', 'contribution', $contributionid);
        $data = file_postupdate_standard_filemanager($data, 'attachment', $attachmentoptions, $context, 'mod_giportfolio', 'attachment', $contributionid);
        $DB->update_record('giportfolio_contributions', $data);
        if ($sendnotification) {
            $graders = get_users_by_capability($context, 'mod/giportfolio:gradegiportfolios');
            if ($graders) {
                $url = new moodle_url('/mod/giportfolio/viewcontribute.php', array('id' => $cm->id, 'chapterid' => $chapter->id, 'userid' => $USER->id));
                $subj = get_string('notifyaddentry_subject', 'mod_giportfolio', fullname($USER));
                $info = (object) array('course' => format_string($course->fullname), 'portfolio' => format_string($giportfolio->name), 'username' => fullname($USER), 'chapter' => format_string($chapter->title), 'link' => $url->out(false));
                $messagetext = get_string('notifyaddentry_body', 'mod_giportfolio', $info);
                $info->link = html_writer::link($url, $url->out(false));
                $messagehtml = nl2br(get_string('notifyaddentry_body', 'mod_giportfolio', $info));
                $eventdata = (object) array('component' => 'mod_giportfolio', 'name' => 'addentry', 'userfrom' => get_admin(), 'userto' => null, 'subject' => $subj, 'fullmessage' => $messagetext, 'fullmessageformat' => FORMAT_PLAIN, 'fullmessagehtml' => $messagehtml, 'smallmessage' => $messagetext);
                foreach ($graders as $grader) {
                    $eventdata->userto = $grader;
                    message_send($eventdata);
                }
开发者ID:andrewhancox,项目名称:moodle-mod_giportfolio,代码行数:31,代码来源:editcontribution.php


示例14: glossary_edit_entry

/**
 * Creates or updates a glossary entry
 *
 * @param  stdClass $entry entry data
 * @param  stdClass $course course object
 * @param  stdClass $cm course module object
 * @param  stdClass $glossary glossary object
 * @param  stdClass $context context object
 * @return stdClass the complete new or updated entry
 * @since  Moodle 3.2
 */
function glossary_edit_entry($entry, $course, $cm, $glossary, $context) {
    global $DB, $USER;

    list($definitionoptions, $attachmentoptions) = glossary_get_editor_and_attachment_options($course, $context, $entry);

    $timenow = time();

    $categories = empty($entry->categories) ? array() : $entry->categories;
    unset($entry->categories);
    $aliases = trim($entry->aliases);
    unset($entry->aliases);

    if (empty($entry->id)) {
        $entry->glossaryid       = $glossary->id;
        $entry->timecreated      = $timenow;
        $entry->userid           = $USER->id;
        $entry->timecreated      = $timenow;
        $entry->sourceglossaryid = 0;
        $entry->teacherentry     = has_capability('mod/glossary:manageentries', $context);
        $isnewentry              = true;
    } else {
        $isnewentry              = false;
    }

    $entry->concept          = trim($entry->concept);
    $entry->definition       = '';          // Updated later.
    $entry->definitionformat = FORMAT_HTML; // Updated later.
    $entry->definitiontrust  = 0;           // Updated later.
    $entry->timemodified     = $timenow;
    $entry->approved         = 0;
    $entry->usedynalink      = isset($entry->usedynalink) ? $entry->usedynalink : 0;
    $entry->casesensitive    = isset($entry->casesensitive) ? $entry->casesensitive : 0;
    $entry->fullmatch        = isset($entry->fullmatch) ? $entry->fullmatch : 0;

    if ($glossary->defaultapproval or has_capability('mod/glossary:approve', $context)) {
        $entry->approved = 1;
    }

    if ($isnewentry) {
        // Add new entry.
        $entry->id = $DB->insert_record('glossary_entries', $entry);
    } else {
        // Update existing entry.
        $DB->update_record('glossary_entries', $entry);
    }

    // Save and relink embedded images and save attachments.
    if (!empty($entry->definition_editor)) {
        $entry = file_postupdate_standard_editor($entry, 'definition', $definitionoptions, $context, 'mod_glossary', 'entry',
            $entry->id);
    }
    if (!empty($entry->attachment_filemanager)) {
        $entry = file_postupdate_standard_filemanager($entry, 'attachment', $attachmentoptions, $context, 'mod_glossary',
            'attachment', $entry->id);
    }

    // Store the updated value values.
    $DB->update_record('glossary_entries', $entry);

    // Refetch complete entry.
    $entry = $DB->get_record('glossary_entries', array('id' => $entry->id));

    // Update entry categories.
    $DB->delete_records('glossary_entries_categories', array('entryid' => $entry->id));
    // TODO: this deletes cats from both both main and secondary glossary :-(.
    if (!empty($categories) and array_search(0, $categories) === false) {
        foreach ($categories as $catid) {
            $newcategory = new stdClass();
            $newcategory->entryid    = $entry->id;
            $newcategory->categoryid = $catid;
            $DB->insert_record('glossary_entries_categories', $newcategory, false);
        }
    }

    // Update aliases.
    $DB->delete_records('glossary_alias', array('entryid' => $entry->id));
    if ($aliases !== '') {
        $aliases = explode("\n", $aliases);
        foreach ($aliases as $alias) {
            $alias = trim($alias);
            if ($alias !== '') {
                $newalias = new stdClass();
                $newalias->entryid = $entry->id;
                $newalias->alias   = $alias;
                $DB->insert_record('glossary_alias', $newalias, false);
            }
        }
    }

//.........这里部分代码省略.........
开发者ID:EsdrasCaleb,项目名称:moodle,代码行数:101,代码来源:lib.php


示例15: get_data

 public function get_data()
 {
     $data = parent::get_data();
     if ($data) {
         $editoroptions = $this->get_editor_options();
         switch ($this->_customdata->assignment->assignmenttype) {
             case 'team':
             case 'upload':
             case 'uploadsingle':
                 $data = file_postupdate_standard_filemanager($data, 'files', $editoroptions, $this->_customdata->context, 'mod_assignment', 'response', $this->_customdata->teamid);
                 break;
             default:
                 break;
         }
         $data = file_postupdate_standard_editor($data, 'submissioncomment', $editoroptions, $this->_customdata->context, $editoroptions['component'], $editoroptions['filearea'], $this->_customdata->teamid);
     }
     return $data;
 }
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:18,代码来源:assignment.class.php


示例16: update_course

/**
 * Update a course.
 *
 * Please note this functions does not verify any access control,
 * the calling code is responsible for all validation (usually it is the form definition).
 *
 * @param object $data  - all the data needed for an entry in the 'course' table
 * @param array $editoroptions course description editor options
 * @return void
 */
function update_course($data, $editoroptions = NULL)
{
    global $CFG, $DB;
    $data->timemodified = time();
    $oldcourse = course_get_format($data->id)->get_course();
    $context = context_course::instance($oldcourse->id);
    if ($editoroptions) {
        $data = file_postupdate_standard_editor($data, 'summary', $editoroptions, $context, 'course', 'summary', 0);
    }
    if ($overviewfilesoptions = course_overviewfiles_options($data->id)) {
        $data = file_postupdate_standard_filemanager($data, 'overviewfiles', $overviewfilesoptions, $context, 'course', 'overviewfiles', 0);
    }
    if (!isset($data->category) or empty($data->category)) {
        // prevent nulls and 0 in category field
        unset($data->category);
    }
    $changesincoursecat = $movecat = (isset($data->category) and $oldcourse->category != $data->category);
    if (!isset($data->visible)) {
        // data not from form, add missing visibility info
        $data->visible = $oldcourse->visible;
    }
    if ($data->visible != $oldcourse->visible) {
        // reset the visibleold flag when manually hiding/unhiding course
        $data->visibleold = $data->visible;
        $changesincoursecat = true;
    } else {
        if ($movecat) {
            $newcategory = $DB->get_record('course_categories', array('id' => $data->category));
            if (empty($newcategory->visible)) {
                // make sure when moving into hidden category the course is hidden automatically
                $data->visible = 0;
            }
        }
    }
    // Update with the new data
    $DB->update_record('course', $data);
    // make sure the modinfo cache is reset
    rebuild_course_cache($data->id);
    // update course format options with full course data
    course_get_format($data->id)->update_course_format_options($data, $oldcourse);
    $course = $DB->get_record('course', array('id' => $data->id));
    if ($movecat) {
        $newparent = context_coursecat::instance($course->category);
        context_moved($context, $newparent);
    }
    fix_course_sortorder();
    // purge appropriate caches in case fix_course_sortorder() did not change anything
    cache_helper::purge_by_event('changesincourse');
    if ($changesincoursecat) {
        cache_helper::purge_by_event('changesincoursecat');
    }
    // Test for and remove blocks which aren't appropriate anymore
    blocks_remove_inappropriate($course);
    // Save any custom role names.
    save_local_role_names($course->id, $data);
    // update enrol settings
    enrol_course_updated(false, $course, $data);
    add_to_log($course->id, "course", "update", "edit.php?id={$course->id}", $course->id);
    // Trigger events
    events_trigger('course_updated', $course);
    if ($oldcourse->format !== $course->format) {
        // Remove all options stored for the previous format
        // We assume that new course format migrated everything it needed watching trigger
        // 'course_updated' and in method format_XXX::update_course_format_options()
        $DB->delete_records('course_format_options', array('courseid' => $course->id, 'format' => $oldcourse->format));
    }
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:77,代码来源:lib.php


示例17: view_batch_upload_files

    /**
     * Upload files and send them to multiple users.
     *
     * @param array $users - An array of user ids
     * @return string - The response html
     */
    public function view_batch_upload_files($users) {
        global $CFG, $DB, $USER;

        require_capability('mod/assign:grade', $this->assignment->get_context());
        require_once($CFG->dirroot . '/mod/assign/feedback/file/batchuploadfilesform.php');
        require_once($CFG->dirroot . '/mod/assign/renderable.php');

        $formparams = array('cm'=>$this->assignment->get_course_module()->id,
                            'users'=>$users,
                            'context'=>$this->assignment->get_context());

        $usershtml = '';

        $usercount = 0;
        foreach ($users as $userid) {
            if ($usercount >= ASSIGNFEEDBACK_FILE_MAXSUMMARYUSERS) {
                $moreuserscount = count($users) - ASSIGNFEEDBACK_FILE_MAXSUMMARYUSERS;
                $usershtml .= get_string('moreusers', 'assignfeedback_file', $moreuserscount);
                break;
            }
            $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST);

            $usersummary = new assign_user_summary($user,
                                                   $this->assignment->get_course()->id,
                                                   has_capability('moodle/site:viewfullnames',
                                                   $this->assignment->get_course_context()),
                                                   $this->assignment->is_blind_marking(),
                                                   $this->assignment->get_uniqueid_for_user($user->id));
            $usershtml .= $this->assignment->get_renderer()->render($usersummary);
            $usercount += 1;
        }

        $formparams['usershtml'] = $usershtml;

        $mform = new assignfeedback_file_batch_upload_files_form(null, $formparams);

        if ($mform->is_cancelled()) {
            redirect(new moodle_url('view.php',
                                    array('id'=>$this->assignment->get_course_module()->id,
                                          'action'=>'grading')));
            return;
        } else if ($data = $mform->get_data()) {
            // Copy the files from the draft area to a temporary import area.
            $data = file_postupdate_standard_filemanager($data,
                                                         'files',
                                                         $this->get_file_options(),
                                                         $this->assignment->get_context(),
                                                         'assignfeedback_file',
                                                    

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP file_prepare_directory函数代码示例发布时间:2022-05-15
下一篇:
PHP file_postupdate_standard_editor函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap