当前位置: 首页>>代码示例>>PHP>>正文


PHP upload_manager::get_new_filename方法代码示例

本文整理汇总了PHP中upload_manager::get_new_filename方法的典型用法代码示例。如果您正苦于以下问题:PHP upload_manager::get_new_filename方法的具体用法?PHP upload_manager::get_new_filename怎么用?PHP upload_manager::get_new_filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在upload_manager的用法示例。


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

示例1: moodle_binary_store_file

function moodle_binary_store_file(&$filename, &$id, &$meta, $ext = ".bin")
{
    # READ-Only
    global $_FILES, $CFG, $course, $wiki, $groupid, $userid, $ewiki_title, $cm;
    if (!$wiki->ewikiacceptbinary) {
        print_error('cannotacceptbin', 'wiki');
        return 0;
    }
    $entry = wiki_get_entry($wiki, $course, $userid, $groupid);
    if (!$entry->id) {
        print_error('cannotgetentry', 'wiki');
    }
    require_once $CFG->dirroot . '/lib/uploadlib.php';
    $um = new upload_manager('upload', false, false, $course, false, 0, true, true);
    if ($um->process_file_uploads("{$course->id}/{$CFG->moddata}/wiki/{$wiki->id}/{$entry->id}/{$ewiki_title}")) {
        $filename = '';
        // this to make sure we don't keep processing in the parent function
        if (!$id) {
            $newfilename = $um->get_new_filename();
            $id = EWIKI_IDF_INTERNAL . $newfilename;
        }
        return true;
    }
    print_error('uploaderror', 'wiki', '', $um->print_upload_log(true));
    return false;
}
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:26,代码来源:moodle_binary_store.php

示例2:

 /**
  * If we're only handling one file (if inputname was given in the constructor)
  * this will return the (possibly changed) filename of the file.
  * @return mixed false in case of failure, string if ok
  */
 function get_new_filename()
 {
     return $this->_upload_manager->get_new_filename();
 }
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:9,代码来源:formslib.php

示例3: forum_add_attachment

/**
 *
 */
function forum_add_attachment($post, $inputname, &$message)
{
    global $CFG;
    if (!($forum = get_record("forum", "id", $post->forum))) {
        return "";
    }
    if (!($course = get_record("course", "id", $forum->course))) {
        return "";
    }
    require_once $CFG->dirroot . '/lib/uploadlib.php';
    $um = new upload_manager($inputname, true, false, $course, false, $forum->maxbytes, true, true);
    $dir = forum_file_area_name($post);
    if ($um->process_file_uploads($dir)) {
        $message .= $um->get_errors();
        return $um->get_new_filename();
    }
    $message .= $um->get_errors();
    return null;
}
开发者ID:r007,项目名称:PMoodle,代码行数:22,代码来源:lib.php

示例4: dialogue_add_attachment

/**
 * Saves an uploaded Dialogue attachment to the moddata directory
 *  
 * @param   object  $entry
 * @param   string  $inputname
 * @param   string  messages string, passed by reference
 * @return  string  new file name
 */
function dialogue_add_attachment($entry, $inputname, &$message)
{
    global $CFG, $COURSE;
    require_once $CFG->dirroot . '/lib/uploadlib.php';
    $um = new upload_manager($inputname, true, false, $COURSE, false, 0, true, true);
    $dir = dialogue_file_area_name($entry);
    if ($um->process_file_uploads($dir)) {
        $message .= $um->get_errors();
        return $um->get_new_filename();
    }
    $message .= $um->get_errors();
    return null;
}
开发者ID:netspotau,项目名称:moodle-mod_dialogue,代码行数:21,代码来源:lib.php

示例5: tracker_recordelements

/**
* stores in database the element values
* @uses $CFG
* @param object $issue
*/
function tracker_recordelements(&$issue)
{
    global $CFG, $COURSE;
    $keys = array_keys($_POST);
    // get the key value of all the fields submitted
    $keys = preg_grep('/element./', $keys);
    // filter out only the element keys
    $filekeys = array_keys($_FILES);
    // get the key value of all the fields submitted
    $filekeys = preg_grep('/element./', $filekeys);
    // filter out only the element keys
    $keys = array_merge($keys, $filekeys);
    foreach ($keys as $key) {
        preg_match('/element(.*)$/', $key, $elementid);
        $elementname = $elementid[1];
        $sql = "\n            SELECT \n              e.id as elementid,\n              e.type as type\n            FROM\n                {$CFG->prefix}tracker_elementused eu,\n                {$CFG->prefix}tracker_element e\n            WHERE\n                eu.elementid = e.id AND\n                e.name = '{$elementname}' AND\n                eu.trackerid = {$issue->trackerid} \n        ";
        $attribute = get_record_sql($sql);
        $attribute->timemodified = $issue->datereported;
        $values = optional_param($key, '', PARAM_CLEANHTML);
        $attribute->issueid = $issue->id;
        $attribute->trackerid = $issue->trackerid;
        /// For those elements where more than one option can be selected
        if (is_array($values)) {
            foreach ($values as $value) {
                $attribute->elementitemid = $value;
                $attributeid = insert_record('tracker_issueattribute', $attribute);
                if (!$attributeid) {
                    error("Could not submit issue(s) attribute(s): issue:{$issue->id} issueid:{$elementid['1']} elementitemid:{$attribute->elementitemid}");
                }
            }
        } else {
            //For the rest of the elements that can only support one answer
            if ($attribute->type != 'file') {
                require_once $CFG->libdir . '/uploadlib.php';
                $attribute->elementitemid = $values;
                $attributeid = insert_record('tracker_issueattribute', $attribute);
            } else {
                $uploader = new upload_manager($key, false, false, $COURSE->id, true, 0, true);
                $uploader->preprocess_files();
                $newfilename = $uploader->get_new_filename();
                $encodedfilename = '';
                if (!empty($newfilename)) {
                    $encodedfilename = md5(time()) . '_' . $newfilename;
                    $storebase = "{$COURSE->id}/moddata/tracker/{$issue->trackerid}/{$issue->id}";
                    if (!filesystem_is_dir($storebase)) {
                        filesystem_create_dir($storebase, FS_RECURSIVE);
                    }
                    $uploader->save_files($storebase);
                    filesystem_move_file($storebase . '/' . $newfilename, $storebase . '/' . $encodedfilename);
                    $attribute->elementitemid = $encodedfilename;
                    $attributeid = insert_record('tracker_issueattribute', $attribute);
                }
            }
            if (empty($attributeid)) {
                error("Could not submit issue attribute: issue:{$issue->id} elementid:{$elementid['1']} elementitemid:{$attribute->elementitemid}");
            }
        }
    }
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:64,代码来源:locallib.php

示例6: notify

 function upload_file()
 {
     global $CFG, $USER;
     $mode = optional_param('mode', '', PARAM_ALPHA);
     $offset = optional_param('offset', 0, PARAM_INT);
     $returnurl = 'view.php?id=' . $this->cm->id;
     $filecount = $this->count_user_files($USER->id);
     $submission = $this->get_submission($USER->id);
     if (!$this->can_upload_file($submission)) {
         $this->view_header(get_string('upload'));
         notify(get_string('uploaderror', 'assignment'));
         print_continue($returnurl);
         $this->view_footer();
         die;
     }
     $dir = $this->file_area_name($USER->id);
     check_dir_exists($CFG->dataroot . '/' . $dir, true, true);
     // better to create now so that student submissions do not block it later
     require_once $CFG->dirroot . '/lib/uploadlib.php';
     $um = new upload_manager('newfile', false, true, $this->course, false, $this->assignment->maxbytes, true);
     if ($um->process_file_uploads($dir)) {
         $submission = $this->get_submission($USER->id, true);
         //create new submission if needed
         $updated = new object();
         $updated->id = $submission->id;
         $updated->timemodified = time();
         if (update_record('assignment_submissions', $updated)) {
             add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
             $submission = $this->get_submission($USER->id);
             $this->update_grade($submission);
             if (!$this->drafts_tracked()) {
                 $this->email_teachers($submission);
             }
         } else {
             $new_filename = $um->get_new_filename();
             $this->view_header(get_string('upload'));
             notify(get_string('uploadnotregistered', 'assignment', $new_filename));
             print_continue($returnurl);
             $this->view_footer();
             die;
         }
         redirect('view.php?id=' . $this->cm->id);
     }
     $this->view_header(get_string('upload'));
     notify(get_string('uploaderror', 'assignment'));
     echo $um->get_errors();
     print_continue($returnurl);
     $this->view_footer();
     die;
 }
开发者ID:NextEinstein,项目名称:riverhills,代码行数:50,代码来源:assignment.class.php

示例7: notify

            notify(get_string("uploadnotregistered", "assignment", $newfile_name));
        }
    } else {
        // Process the resubmission
        $dir = $assignmentinstance->file_area_name($userid);
        require_once $CFG->dirroot . '/lib/uploadlib.php';
        $um = new upload_manager('newfile', true, false, $assignmentinstance->course, false, $assignmentinstance->assignment->maxbytes);
        if ($um->preprocess_files()) {
            //Check the file extension
            $submittedFilename = $um->get_original_filename();
            $extension = $assignmentinstance->assignment->fileextension;
            if (strtolower(substr($submittedFilename, strlen($submittedFilename) - strlen($extension))) != $extension) {
                notify(get_string("incorrectfileextension", "assignment_peerreview", $extension));
            } else {
                if ($um->save_files($dir)) {
                    $newfile_name = $um->get_new_filename();
                    $um->config->silent = true;
                    $um->delete_other_files($dir, $dir . '/' . $newfile_name);
                    $submission = $assignmentinstance->get_submission($userid);
                    if (set_field('assignment_submissions', 'timemodified', time(), 'id', $submission->id)) {
                        add_to_log($assignmentinstance->course->id, 'assignment', 'upload', 'view.php?a=' . $assignmentinstance->assignment->id, $assignmentinstance->assignment->id, $assignmentinstance->cm->id);
                        notify(get_string('resubmissionsuccessful', 'assignment_peerreview'), 'notifysuccess');
                    } else {
                        notify(get_string("uploadnotregistered", "assignment", $newfile_name));
                    }
                }
            }
        }
    }
    print_continue($CFG->wwwroot . '/mod/assignment/submissions.php?id=' . $assignmentinstance->cm->id);
} else {
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:resubmit.php

示例8: error

        if (isteacher($course->id)) {
            // it's an exercise submission, flag it as such
            $newsubmission->userid = 0;
            $newsubmission->isexercise = 1;
            // it's a description of an exercise
        } else {
            $newsubmission->userid = $USER->id;
        }
        $newsubmission->title = $title;
        $newsubmission->timecreated = $timenow;
        if ($timenow > $exercise->deadline) {
            $newsubmission->late = 1;
        }
        if (!($newsubmission->id = insert_record("exercise_submissions", $newsubmission))) {
            error("exercise upload: Failure to create new submission record!");
        }
        $dir = exercise_file_area_name($exercise, $newsubmission);
        if ($um->save_files($dir)) {
            add_to_log($course->id, "exercise", "submit", "view.php?id={$cm->id}", "{$exercise->id}");
            print_heading(get_string("uploadsuccess", "assignment", $um->get_new_filename()));
        }
        // upload manager will print errors.
        // clear resubmit flags
        if (!set_field("exercise_submissions", "resubmit", 0, "exerciseid", $exercise->id, "userid", $USER->id)) {
            error("Exercise Upload: unable to reset resubmit flag");
        }
    }
    // upload manager will print errors.
}
print_continue("view.php?id={$cm->id}");
print_footer($course);
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:upload.php

示例9: notify

 /**
  * Team members should have same files in their  folder.
  * This method will handle the team submission files.
  */
 function upload_file()
 {
     global $CFG, $USER;
     $mode = optional_param('mode', '', PARAM_ALPHA);
     $offset = optional_param('offset', 0, PARAM_INT);
     $teamid = optional_param('teamid', '', PARAM_INT);
     $returnurl = 'view.php?id=' . $this->cm->id;
     $submission = $this->get_submission($USER->id);
     if (!$this->can_upload_file($submission, $teamid) || !confirm_sesskey()) {
         $this->view_header(get_string('upload'));
         notify(get_string('uploaderror', 'assignment'));
         print_continue($returnurl);
         $this->view_footer();
         die;
     }
     //team can not be empty
     $members = $this->get_members_from_team($teamid);
     if ($members && is_array($members)) {
         require_once $CFG->dirroot . '/lib/uploadlib.php';
         $currenttime = time();
         $um = new upload_manager('newfile', false, true, $this->course, false, $this->assignment->maxbytes, true);
         $dir = $this->team_file_area_name($teamid);
         check_dir_exists($CFG->dataroot . '/' . $dir, true, true);
         if ($um->process_file_uploads($dir)) {
             // if file was uploaded successfully, update members' assignment_submission records.
             foreach ($members as $member) {
                 //update all team members's assignment_submission records.
                 $submission = $this->get_submission($member->student, true);
                 //create new submission if needed
                 $updated = new object();
                 $updated->id = $submission->id;
                 $updated->timemodified = $currenttime;
                 if (update_record('assignment_submissions', $updated)) {
                     add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
                     $submission = $this->get_submission($member->student);
                     $this->update_grade($submission);
                     if (!$this->drafts_tracked()) {
                         $this->email_teachers($submission);
                     }
                 } else {
                     $new_filename = $um->get_new_filename();
                     $this->view_header(get_string('upload'));
                     notify(get_string('uploadnotregistered', 'assignment', $new_filename));
                     print_continue($returnurl);
                     $this->view_footer();
                     die;
                 }
             }
             // Start Optional Turnitin code
             //                       $plagiarismvalues = get_records_menu('plagiarism_config', 'cm',$this->cm->id,'','name,value');
             //                        if (!empty($plagiarismvalues['use_turnitin']) &&
             //                             (empty($this->assignment->tii_draft_submit) or !$this->drafts_tracked()) ) {
             //                         if ($tii_file = get_record_select('tii_files', "course='".$this->course->id.
             //                                         "' AND module='".$this->cm->module.
             //                                         "' AND instance='".$this->assignment->id.
             //                                         "' AND userid = '".$USER->id.
             //                                         "' AND filename = '".$um->get_new_filename()."'")) {
             //update record.
             //                             $tii_file->tiicode = 'pending';
             //                             $tii_file->tiiscore ='0';
             //                             if (!update_record('tii_files', $tii_file)) {
             //                                 debugging("update tii_files failed!");
             //                             }
             //                         } else {
             //                             $tii_file = new object();
             //                             $tii_file->course = $this->course->id;
             //                             $tii_file->module = $this->cm->module;
             //                             $tii_file->instance = $this->assignment->id;
             //                             $tii_file->userid = $USER->id;
             //                             $tii_file->filename = $um->get_new_filename();
             //                             $tii_file->tiicode = 'pending';
             //                             if (!insert_record('tii_files', $tii_file)) {
             //                                 debugging("insert into tii_files failed");
             //                             }
             //                          }
             //                        }
             // End Optional Turnitin code
         } else {
             $this->view_header(get_string('upload'));
             notify('upload process fail');
             print_continue($returnurl);
             $this->view_footer();
         }
         redirect('view.php?id=' . $this->cm->id);
     }
     $this->view_header(get_string('upload'));
     notify(get_string('uploaderror', 'assignment'));
     echo $um->get_errors();
     print_continue($returnurl);
     $this->view_footer();
     die;
 }
开发者ID:ruddj,项目名称:Moodle-2.0-Team-Assignment,代码行数:96,代码来源:assignment.class.php

示例10: array

 function process_attachment($course = null)
 {
     if (!$course) {
         $course = get_record('course', 'id', $this->courseid);
     }
     $rtn = array();
     $um = new upload_manager('attach', false, true, $course, false, 0, true);
     if ($um->process_file_uploads('temp/block_student_gradeviewer')) {
         $rtn[] = $um->get_new_filename();
         $rtn[] = 'temp/block_student_gradeviewer/' . $um->get_new_filename();
     } else {
         $rtn = array('', '');
     }
     return $rtn;
 }
开发者ID:rrusso,项目名称:EARS,代码行数:15,代码来源:lib.php

示例11: notify

 function upload_file()
 {
     global $CFG, $USER;
     $mode = optional_param('mode', '', PARAM_ALPHA);
     $offset = optional_param('offset', 0, PARAM_INT);
     $returnurl = 'view.php?id=' . $this->cm->id;
     $status = false;
     // Indicated whether the file was successfully moved or not.
     $form = new backpack_form();
     // Make sure that data was returned from the form.
     if (!($data = $form->get_data())) {
         $data = $form->get_submitted_data();
     }
     $dir = $this->file_area_name($USER->id);
     check_dir_exists($CFG->dataroot . '/' . $dir, true, true);
     // better to create now so that student submissions do not block it later
     $filecount = $this->count_user_files($USER->id);
     $submission = $this->get_submission($USER->id);
     // Ensure that this user can actually submit a file to this assignment or not.
     if (!$this->can_upload_file($submission)) {
         $this->view_header(get_string('upload'));
         notify(get_string('uploaderror', 'assignment'));
         print_continue($returnurl);
         $this->view_footer();
         die;
     }
     //obtain the repository object, if possible
     //(should be obtainable since the config has already been checked)
     $repo = $this->get_repository_object();
     // If a repository file was chosen for upload
     if (!empty($data->alfrescoassignment) && isset($repo) && $repo->verify_setup() && $repo->is_configured()) {
         $file = $data->alfrescoassignment;
         // Get the UUID value from the repo file URL.
         if (preg_match('/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/', $file, $matches) > 0) {
             if (!empty($matches[0])) {
                 $uuid = $matches[0];
                 $info = $repo->get_info($uuid);
                 $status = $repo->copy_local($uuid, $info->title, $CFG->dataroot . '/' . $dir);
             }
         }
         // If a local file was chosen for upload
     } else {
         if (!empty($data->addfile)) {
             require_once $CFG->dirroot . '/lib/uploadlib.php';
             $um = new upload_manager('localassignment', false, true, $this->course, false, $this->assignment->maxbytes, true);
             $status = $um->process_file_uploads($dir);
         }
     }
     if ($status) {
         $submission = $this->get_submission($USER->id, true);
         //create new submission if needed
         $updated = new stdClass();
         $updated->id = $submission->id;
         $updated->timemodified = time();
         if (update_record('assignment_submissions', $updated)) {
             add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
             $submission = $this->get_submission($USER->id);
             $this->update_grade($submission);
             if (!$this->drafts_tracked()) {
                 $this->email_teachers($submission);
             }
         } else {
             $new_filename = $um->get_new_filename();
             $this->view_header(get_string('upload'));
             notify(get_string('uploadnotregistered', 'assignment', $new_filename));
             print_continue($returnurl);
             $this->view_footer();
             die;
         }
         redirect('view.php?id=' . $this->cm->id);
     }
     $this->view_header(get_string('upload'));
     notify(get_string('uploaderror', 'assignment'));
     if (!empty($um)) {
         echo $um->get_errors();
     }
     print_continue($returnurl);
     $this->view_footer();
     die;
 }
开发者ID:remotelearner,项目名称:elis.alfresco,代码行数:80,代码来源:assignment.class.php

示例12: upload

 function upload()
 {
     global $CFG, $USER;
     require_capability('mod/assignment:submit', get_context_instance(CONTEXT_MODULE, $this->cm->id));
     $this->view_header(get_string('upload'));
     $filecount = $this->count_user_files($USER->id);
     $submission = $this->get_submission($USER->id);
     if ($this->isopen() && (!$filecount || $this->assignment->resubmit || !$submission->timemarked)) {
         if ($submission = $this->get_submission($USER->id)) {
             //TODO: change later to ">= 0", to prevent resubmission when graded 0
             if ($submission->grade > 0 and !$this->assignment->resubmit) {
                 notify(get_string('alreadygraded', 'assignment'));
             }
         }
         $dir = $this->file_area_name($USER->id);
         require_once $CFG->dirroot . '/lib/uploadlib.php';
         $um = new upload_manager('newfile', true, false, $this->course, false, $this->assignment->maxbytes);
         if ($um->process_file_uploads($dir) and confirm_sesskey()) {
             $newfile_name = $um->get_new_filename();
             if ($submission) {
                 $submission->timemodified = time();
                 $submission->numfiles = 1;
                 $submission->submissioncomment = addslashes($submission->submissioncomment);
                 unset($submission->data1);
                 // Don't need to update this.
                 unset($submission->data2);
                 // Don't need to update this.
                 if (update_record("assignment_submissions", $submission)) {
                     add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
                     $submission = $this->get_submission($USER->id);
                     $this->update_grade($submission);
                     $this->email_teachers($submission);
                     print_heading(get_string('uploadedfile'));
                 } else {
                     notify(get_string("uploadfailnoupdate", "assignment"));
                 }
             } else {
                 $newsubmission = $this->prepare_new_submission($USER->id);
                 $newsubmission->timemodified = time();
                 $newsubmission->numfiles = 1;
                 if (insert_record('assignment_submissions', $newsubmission)) {
                     add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
                     $submission = $this->get_submission($USER->id);
                     $this->update_grade($submission);
                     $this->email_teachers($newsubmission);
                     print_heading(get_string('uploadedfile'));
                 } else {
                     notify(get_string("uploadnotregistered", "assignment", $newfile_name));
                 }
             }
         }
     } else {
         notify(get_string("uploaderror", "assignment"));
         //submitting not allowed!
     }
     print_continue('view.php?id=' . $this->cm->id);
     $this->view_footer();
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:58,代码来源:assignment.class.php

示例13: notify

 /**
  * Team members should have same files in their  folder.
  */
 function upload_file()
 {
     global $CFG, $USER;
     error_log('upload_file method');
     $mode = optional_param('mode', '', PARAM_ALPHA);
     $offset = optional_param('offset', 0, PARAM_INT);
     $teamid = optional_param('teamid', '', PARAM_INT);
     $returnurl = 'view.php?id=' . $this->cm->id;
     $filecount = $this->count_user_files($USER->id);
     $submission = $this->get_submission($USER->id);
     if (!$this->can_upload_file($submission, $teamid)) {
         $this->view_header(get_string('upload'));
         notify(get_string('uploaderror', 'assignment'));
         print_continue($returnurl);
         $this->view_footer();
         die;
     }
     //team can not be empty
     $members = $this->get_members_from_team($teamid);
     if ($members && is_array($members)) {
         require_once $CFG->dirroot . '/lib/uploadlib.php';
         $currenttime = time();
         $um = new upload_manager('newfile', false, true, $this->course, false, $this->assignment->maxbytes, true);
         $dir = $this->file_area_name($USER->id);
         check_dir_exists($CFG->dataroot . '/' . $dir, true, true);
         error_log('source dir :' . $dir);
         if ($um->process_file_uploads($dir)) {
             //copy this new file  to other members dir
             //update members' assignment_submission records.
             $file = $um->get_new_filename();
             foreach ($members as $member) {
                 //save this file in other team members' file dir.
                 if ($member->student != $USER->id) {
                     //not process the file folder for itself
                     $memberdir = $this->file_area_name($member->student);
                     check_dir_exists($CFG->dataroot . '/' . $memberdir, true, true);
                     error_log('member dir:' . $memberdir);
                     $this->copy_file($USER->id, $file, $CFG->dataroot . '/' . $memberdir);
                 }
                 //update all team members's assignment_submission records.
                 error_log('update member assignment submission');
                 $submission = $this->get_submission($member->student, true);
                 //create new submission if needed
                 $updated = new object();
                 $updated->id = $submission->id;
                 $updated->timemodified = $currenttime;
                 if (update_record('assignment_submissions', $updated)) {
                     add_to_log($this->course->id, 'assignment', 'upload', 'view.php?a=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
                     $submission = $this->get_submission($member->student);
                     $this->update_grade($submission);
                     if (!$this->drafts_tracked()) {
                         $this->email_teachers($submission);
                     }
                 } else {
                     $new_filename = $um->get_new_filename();
                     $this->view_header(get_string('upload'));
                     notify(get_string('uploadnotregistered', 'assignment', $new_filename));
                     print_continue($returnurl);
                     $this->view_footer();
                     die;
                 }
             }
         } else {
             $this->view_header(get_string('upload'));
             notify('upload process fail');
             print_continue($returnurl);
             $this->view_footer();
         }
         redirect('view.php?id=' . $this->cm->id);
     }
     $this->view_header(get_string('upload'));
     notify(get_string('uploaderror', 'assignment'));
     echo $um->get_errors();
     print_continue($returnurl);
     $this->view_footer();
     die;
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:80,代码来源:assignment.class.php

示例14: upload

 function upload()
 {
     global $CFG, $USER;
     require_capability('mod/assignment:submit', get_context_instance(CONTEXT_MODULE, $this->cm->id));
     // $this->view_header(get_string('upload'));
     echo "<center>";
     $filecount = $this->count_user_files($USER->id);
     $submission = $this->get_submission($USER->id);
     if ($this->isopen() && (!$filecount || $this->assignment->resubmit || !$submission->timemarked)) {
         if ($submission = $this->get_submission($USER->id)) {
             //TODO: change later to ">= 0", to prevent resubmission when graded 0
             if ($submission->grade > 0 and !$this->assignment->resubmit) {
                 notify(get_string('alreadygraded', 'assignment'));
             }
         }
         $dir = $this->file_area_name($USER->id);
         require_once $CFG->dirroot . '/lib/uploadlib.php';
         $um = new upload_manager('newfile', true, false, $this->course, false, $this->assignment->maxbytes);
         if ($um->process_file_uploads($dir)) {
             $newfile_name = $um->get_new_filename();
             if ($submission) {
                 $submission->timemodified = time();
                 $submission->numfiles = 1;
                 $submission->submissioncomment = addslashes($submission->submissioncomment);
                 unset($submission->data1);
                 // Don't need to update this.
                 unset($submission->data2);
                 // Don't need to update this.
                 if (update_record("assignment_submissions", $submission)) {
                     add_to_log($this->course->id, 'assignment', 'upload', 'view-embedded.php?a=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
                     $submission = $this->get_submission($USER->id);
                     $this->update_grade($submission);
                     $this->email_teachers($submission);
                     echo "Hands-on exams will be graded within 10 business days. Results will be provided via email. If you do not receive your results within 10 business days of submitting your answer file, please open a ticket with Kaseya University at helpdesk.kaseya.com.";
                     print_heading(get_string('uploadedfile'));
                 } else {
                     notify(get_string("uploadfailnoupdate", "assignment"));
                 }
             } else {
                 $newsubmission = $this->prepare_new_submission($USER->id);
                 $newsubmission->timemodified = time();
                 $newsubmission->numfiles = 1;
                 if (insert_record('assignment_submissions', $newsubmission)) {
                     add_to_log($this->course->id, 'assignment', 'upload', 'view-embedded.php?a=' . $this->assignment->id, $this->assignment->id, $this->cm->id);
                     $submission = $this->get_submission($USER->id);
                     $this->update_grade($submission);
                     $this->email_teachers($newsubmission);
                     print_heading(get_string('uploadedfile'));
                 } else {
                     notify(get_string("uploadnotregistered", "assignment", $newfile_name));
                 }
             }
         }
     } else {
         notify(get_string("uploaderror", "assignment"));
         //submitting not allowed!
     }
     print_continue('view-embedded.php?id=' . $this->cm->id);
     echo "</center>";
     // $this->view_footer();
 }
开发者ID:arshanam,项目名称:Moodle-ITScholars-LMS,代码行数:61,代码来源:assignment_embedded.class.php

示例15: error

            if ($template && $template->course == 0 && !$caneditsite) {
                error("No permission to edit site templates");
            }
            delete_records('assignment_uploadpdf_tmplitm', 'id', $itemid);
            $itemid = 0;
        }
    }
} elseif ($uploadpreview) {
    $partdest = $courseid . IMAGE_PATH;
    $fulldest = $CFG->dataroot . '/' . $partdest;
    check_dir_exists($fulldest);
    require_once $CFG->dirroot . '/lib/uploadlib.php';
    $um = new upload_manager('preview', false, false, $course, false, 0, true);
    if ($um->process_file_uploads($partdest)) {
        $fp = $um->get_new_filepath();
        $fn = $um->get_new_filename();
        require_once 'mypdflib.php';
        $pdf = new MyPDFLib();
        $pdf->load_pdf($fp);
        $pdf->set_image_folder($fulldest);
        $imagename = $pdf->get_image(1);
        unlink($fp);
    } else {
        //echo 'No file uploaded';
        //die;
    }
} elseif ($duplicatetemplate) {
    // Should not have access to the 'duplicate' button unless a template is selected
    // but, just in case, we check here (but just do nothing if that is not the case)
    if ($templateid != -1) {
        $template = get_record('assignment_uploadpdf_tmpl', 'id', $templateid);
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:edittemplates.php


注:本文中的upload_manager::get_new_filename方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。