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

PHP upload_manager类代码示例

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

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



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

示例1: gwfontform_validate

function gwfontform_validate(Pieform $form, $values)
{
    global $USER, $SESSION;
    require_once 'file.php';
    require_once 'uploadmanager.php';
    $valid = false;
    if ($values['gwfzipfile'] != null) {
        $filetype = $values['gwfzipfile']['type'];
        // Ensures that the correct file was chosen
        $accepted = array('application/zip', 'application/x-zip-compressed', 'multipart/x-zip', 'application/s-compressed');
        foreach ($accepted as $mimetype) {
            if ($mimetype == $filetype) {
                $valid = true;
                break;
            }
        }
        // Safari and Chrome don't register zip mime types. Something better could be used here.
        // Check if file extension, that is the last 4 characters in file name, equals '.zip'...
        $valid = substr($values['gwfzipfile']['name'], -4) == '.zip' ? true : false;
        if (!$valid) {
            $form->set_error('gwfzipfile', get_string('notvalidzipfile', 'skin'));
        }
        // pass it through the virus checker
        $um = new upload_manager('gwfzipfile');
        if ($error = $um->preprocess_file()) {
            $form->set_error($inputname, $error);
        }
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:29,代码来源:installgwf.php


示例2: 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


示例3: addvariantform_validate

function addvariantform_validate(Pieform $form, $values)
{
    global $USER, $SESSION;
    require_once 'file.php';
    require_once 'uploadmanager.php';
    // Make sure they didn't hack the hidden variable to have the name of
    // a font that doesn't exist
    if (!record_exists('skin_fonts', 'name', $values['fontname'])) {
        $form->set_error('fontname', get_string('nosuchfont', 'skin'));
    }
    $uploadfiles = array('fontfileEOT' => array('required' => true, 'suffix' => 'eot'), 'fontfileSVG' => array('required' => true, 'suffix' => 'svg'), 'fontfileTTF' => array('required' => true, 'suffix' => 'ttf'), 'fontfileWOFF' => array('required' => true, 'suffix' => 'woff'));
    foreach ($uploadfiles as $inputname => $details) {
        $um = new upload_manager($inputname, false, null, $details['required']);
        if ($error = $um->preprocess_file()) {
            $form->set_error($inputname, $error);
        }
        if ($details['suffix']) {
            $reqext = ".{$details['suffix']}";
            $fileext = substr($values[$inputname]['name'], -1 * strlen($reqext));
            if ($fileext != $reqext) {
                $form->set_error($inputname, get_string('notvalidfontfile', 'skin', strtoupper($details['suffix'])));
            }
        }
    }
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:25,代码来源:add.php


示例4: wiki_upload_deldir

function wiki_upload_deldir(&$WS)
{
    //cheack if the folder exists
    if (file_exists($WS->dfdir->name)) {
        //delete all folder files
        $upd = new upload_manager();
        $upd->delete_other_files($WS->dfdir->name);
        rmdir($WS->dfdir->name);
        return true;
    } else {
        return true;
    }
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:13,代码来源:uploadlib.php


示例5: importskinform_validate

function importskinform_validate(Pieform $form, $values)
{
    global $USER, $SESSION;
    $filetype = $values['file']['type'];
    if (!$filetype || $filetype != 'text/xml') {
        $form->set_error('file', get_string('notvalidxmlfile', 'skin'));
    }
    require_once 'file.php';
    require_once 'uploadmanager.php';
    $um = new upload_manager('file');
    if ($error = $um->preprocess_file()) {
        $form->set_error('file', $error);
    }
}
开发者ID:patkira,项目名称:mahara,代码行数:14,代码来源:import.php


示例6: upload_response

/**
 * Uploads the file submitted (adapted from mod/workshop/submissions.php)
 *
 * @param string $fileid string corresponding to the input file ('resp##_file')
 * @param int $attemptid attempt id
 * @param int $questionid question id
 * @param int $maxbytes maximum upload size in bytes
 * @return string feedback from upload, related to success or failure
 */
function upload_response($fileid, $course, $attemptid, $questionid, $maxbytes)
{
    global $CFG;
    require_once $CFG->dirroot . '/lib/uploadlib.php';
    $um = new upload_manager($fileid, true, false, $course, true, $maxbytes, true);
    if ($um->preprocess_files()) {
        $dir = quiz_file_area_name($attemptid, $questionid);
        if (!quiz_file_area($dir)) {
            return get_string('uploadproblem');
        }
        if ($um->save_files($dir)) {
            return get_string('uploadedfile');
        }
    }
    return get_string('uploaderror', 'qtype_fileresponse');
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:25,代码来源:locallib.php


示例7: require_login

}
require_login($course->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/lightboxgallery:addimage', $context);
$galleryurl = $CFG->wwwroot . '/mod/lightboxgallery/view.php?id=' . $cm->id;
$straddimage = get_string('addimage', 'lightboxgallery');
$navigation = build_navigation($straddimage, $cm);
print_header($course->shortname . ': ' . $gallery->name . ': ' . $straddimage, $course->fullname, $navigation, '', '', true, ' ', navmenu($course, $cm));
$mform = new mod_lightboxgallery_imageadd_form(null, $gallery);
if ($mform->is_cancelled()) {
    redirect($galleryurl);
} else {
    if (($formdata = $mform->get_data()) && confirm_sesskey()) {
        require_once $CFG->dirroot . '/lib/uploadlib.php';
        $handlecollisions = !get_config('lightboxgallery', 'overwritefiles');
        $um = new upload_manager('attachment', false, $handlecollisions, $course);
        $uploaddir = $course->id . '/' . $gallery->folder;
        if ($um->process_file_uploads($uploaddir)) {
            $folder = $CFG->dataroot . '/' . $uploaddir;
            $filename = $um->get_new_filename();
            $messages = array();
            if (lightboxgallery_get_file_extension($filename) == 'zip') {
                $thumb = '<img src="' . $CFG->pixpath . '/f/zip.gif" class="icon" alt="zip" />';
                $before = lightboxgallery_directory_images($folder);
                if (unzip_file($folder . '/' . $filename, $folder, false)) {
                    $messages[] = get_string('zipextracted', 'lightboxgallery', $filename);
                    $after = lightboxgallery_directory_images($folder);
                    if ($newfiles = array_diff($after, $before)) {
                        $resizeoption = 0;
                        if (in_array($gallery->autoresize, array(AUTO_RESIZE_UPLOAD, AUTO_RESIZE_BOTH))) {
                            $resizeoption = $gallery->resize;
开发者ID:itziko,项目名称:Moodle-jQuery-Lightbox-Gallery,代码行数:31,代码来源:imageadd.php


示例8: upload_file

 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


示例9: foreach

        foreach ($submissions as $submission) {
            if ($submission->timecreated > $timenow - $CFG->maxeditingtime) {
                // ignore this submission
                redirect("view.php?id={$cm->id}");
                print_footer($course);
                exit;
            }
        }
    }
}
// check existence of title
if ($title == '') {
    notify(get_string("notitlegiven", "exercise"));
} else {
    require_once $CFG->dirroot . '/lib/uploadlib.php';
    $um = new upload_manager('newfile', false, false, $course, false, $exercise->maxbytes);
    if ($um->preprocess_files()) {
        $newsubmission->exerciseid = $exercise->id;
        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;
        }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:31,代码来源:upload.php


示例10: define

 if (empty($copyright)) {
     $redirect_url = url . $USER->username . "/files/";
     if ($folderid > -1) {
         $redirect_url .= $folderid;
     }
     define('redirect_url', $redirect_url);
     $messages[] = gettext("Upload unsuccessful. You must check the copyright box for a file to be uploaded.");
     break;
 }
 $ul_username = run("users:id_to_name", $page_owner);
 $upload_folder = $textlib->substr($ul_username, 0, 1);
 require_once $CFG->dirroot . 'lib/uploadlib.php';
 $total_quota = get_field_sql('SELECT sum(size) FROM ' . $CFG->prefix . 'files WHERE owner = ?', array($page_owner));
 $max_quota = get_field('users', 'file_quota', 'ident', $page_owner);
 $maxbytes = $max_quota - $tota_quota;
 $um = new upload_manager('new_file', false, true, false, $maxbytes, true);
 $reldir = "files/" . $upload_folder . "/" . $ul_username . "/";
 $dir = $CFG->dataroot . $reldir;
 if ($um->process_file_uploads($dir)) {
     $f = new StdClass();
     $f->owner = $USER->ident;
     $f->files_owner = $page_owner;
     $f->folder = $folderid;
     $f->originalname = $um->get_original_filename();
     if (empty($title)) {
         $title = $um->get_original_filename();
     }
     $f->title = $title;
     $f->description = $description;
     $f->location = $reldir . '/' . $um->get_new_filename();
     $f->access = $access;
开发者ID:pzingg,项目名称:saugus_elgg,代码行数:31,代码来源:files_actions.php


示例11: upload

 function upload()
 {
     global $CFG, $USER;
     $NUM_REVIEWS = 2;
     $POOL_SIZE = 2 * $NUM_REVIEWS + 1;
     // including current submitter
     require_capability('mod/assignment:submit', get_context_instance(CONTEXT_MODULE, $this->cm->id));
     $this->view_header(get_string('upload'));
     if ($this->isopen()) {
         if (!record_exists('assignment_submissions', 'assignment', $this->assignment->id, 'userid', $USER->id)) {
             $newsubmission = NULL;
             // Process online text
             if (isset($this->assignment->var3) && $this->assignment->var3 == self::ONLINE_TEXT) {
                 $newsubmission = $this->prepare_new_submission($USER->id);
                 $newsubmission->data1 = addslashes(required_param('text', PARAM_CLEANHTML));
                 $sumbissionName = get_string('yoursubmission', 'assignment_peerreview');
                 // echo '<pre>'.print_r($_POST,true).'</pre>';
             } else {
                 $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->preprocess_files()) {
                     //Check the file extension
                     $submittedFilename = $um->get_original_filename();
                     $extension = $this->assignment->fileextension;
                     if (strtolower(substr($submittedFilename, strlen($submittedFilename) - strlen($extension))) != $extension) {
                         notify(get_string("incorrectfileextension", "assignment_peerreview", $extension));
                     } else {
                         if ($um->save_files($dir)) {
                             $sumbissionName = $um->get_new_filename();
                             $newsubmission = $this->prepare_new_submission($USER->id);
                             $newsubmission->numfiles = 1;
                         }
                     }
                 }
             }
             if ($newsubmission) {
                 // Enter submission into DB and log
                 $newsubmission->timecreated = time();
                 $newsubmission->timemodified = time();
                 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);
                     // $this->email_teachers($newsubmission);
                     print_heading(get_string('uploadedfile'));
                     $submissionSuccess = true;
                 } else {
                     notify(get_string("uploadnotregistered", "assignment", $sumbissionName));
                 }
                 // Allocate reviews
                 $recentSubmissions = array();
                 $numberOfRecentSubmissions = 0;
                 if ($submissionResult = get_records_sql('SELECT userid FROM ' . $CFG->prefix . 'assignment_submissions WHERE assignment=\'' . $this->assignment->id . '\' ORDER BY timecreated DESC, id DESC', 0, $POOL_SIZE + 1)) {
                     $recentSubmissions = array_values($submissionResult);
                     $numberOfRecentSubmissions = count($recentSubmissions);
                 }
                 if ($numberOfRecentSubmissions >= $POOL_SIZE) {
                     for ($i = 2; $i < 2 * $NUM_REVIEWS + 1; $i += 2) {
                         if (!insert_record('assignment_review', $this->prepare_new_review($USER->id, $recentSubmissions[$i]->userid))) {
                             notify(get_string("reviewsallocationerror", "assignment_peerreview"));
                         }
                     }
                 }
                 // If pool just got large enough, allocated reviews to previous submitters
                 if ($numberOfRecentSubmissions == $POOL_SIZE) {
                     $recentSubmissions = array_reverse($recentSubmissions);
                     for ($i = 0; $i < $POOL_SIZE - 1; $i++) {
                         for ($j = 1; $j <= $NUM_REVIEWS; $j++) {
                             insert_record('assignment_review', $this->prepare_new_review($recentSubmissions[$i]->userid, $recentSubmissions[$i - 2 * $j + ($i - 2 * $j >= 0 ? 0 : $NUM_REVIEWS * 2 + 1)]->userid));
                         }
                         // Send an email to student
                         $subject = get_string('reviewsallocatedsubject', 'assignment_peerreview');
                         $linkToReview = $CFG->wwwroot . '/mod/assignment/view.php?id=' . $this->cm->id;
                         $message = get_string('reviewsallocated', 'assignment_peerreview') . "\n\n" . get_string('assignmentname', 'assignment') . ': ' . $this->assignment->name . "\n" . get_string('course') . ': ' . $this->course->fullname . "\n\n";
                         $messageText = $message . $linkToReview;
                         $messageHTML = nl2br($message) . '<a href="' . $linkToReview . '" target="_blank">' . get_string('reviewsallocatedlinktext', 'assignment_peerreview') . '</a>';
                         $this->email_from_teacher($this->course->id, $recentSubmissions[$i]->userid, $subject, $messageText, $messageHTML);
                     }
                 }
                 if ($numberOfRecentSubmissions >= $POOL_SIZE) {
                     redirect('view.php?id=' . $this->cm->id, get_string("reviewsallocated", "assignment_peerreview"), 2);
                 } else {
                     notify(get_string("poolnotlargeenough", "assignment_peerreview"), 'notifysuccess');
                     print_continue('view.php?id=' . $this->cm->id);
                 }
             }
         } else {
             notify(get_string("resubmit", "assignment_peerreview", $this->course->teacher));
             // re-submitting not allowed
             print_continue('view.php?id=' . $this->cm->id);
         }
     } else {
         notify(get_string("closed", "assignment_peerreview"));
         // assignment closed
         print_continue('view.php?id=' . $this->cm->id);
     }
     $this->view_footer();
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:97,代码来源:assignment.class.php


示例12: get_proposal

    //Check proposal owner
    $proposal = get_proposal($proposal_id, $USER->id);
} elseif (Context == 'admin') {
    preg_match('#^admin/proposals/(\\d+)/files#', $q, $matches);
    $proposal_id = !empty($matches) ? (int) $matches[1] : 0;
    $proposal = get_proposal($proposal_id);
}
require $CFG->comdir . 'prop_files_optional_params.php';
//check owner and status, dont delete acepted, scheduled or deleted¿?
// can delete canceled proposal
if (!empty($proposal) && ($proposal->id_status < 5 || ($proposal->id_status = 6))) {
    if (!empty($submit)) {
        if (empty($errmsg)) {
            //upload manager
            require_once $CFG->incdir . 'uploadlib.php';
            $um = new upload_manager('S_filename', false, true);
            $uploaddir = 'proposals/' . $proposal->id;
            if ($um->process_file_uploads($uploaddir)) {
                $f = new StdClass();
                $f->id_propuesta = $proposal->id;
                $f->name = $filename;
                $f->title = $title;
                $f->descr = $descr;
                $f->public = $public;
                $f->size = $um->get_filesize();
                $f->reg_time = time();
                //insert into db
                if ($rs = insert_record('prop_files', $f)) {
                    $errmsg[] = __('Archivo registrado exitosamente.');
                    //reset file
                    $file = new StdClass();
开发者ID:BackupTheBerlios,项目名称:yupana,代码行数:31,代码来源:prop_files.php


示例13: profile_photo_validate_input_field

function profile_photo_validate_input_field($parameter)
{
    global $CFG, $messages, $data, $profile_id;
    $found = false;
    foreach ($data['profile:details'] as $profileitem) {
        if (is_array($profileitem)) {
            $fname = $profileitem[1];
            $ftype = $profileitem[2];
        } else {
            $fname = $profileitem->internal_name;
            $ftype = $profileitem->field_type;
        }
        if ($fname == $parameter->name) {
            $found = true;
            break;
        }
    }
    if ($found && ($ftype = "profile_photo")) {
        require_once $CFG->dirroot . 'lib/uploadlib.php';
        require_once $CFG->dirroot . 'lib/filelib.php';
        $textlib = textlib_get_instance();
        $upload_folder = $textlib->substr(user_info("username", $profile_id), 0, 1);
        $um = new upload_manager('profile_photo_' . $fname, true, true, false, 5000000, true);
        $reldir = "profile_photos/" . $upload_folder . "/" . user_info("username", $profile_id) . "/" . $parameter->name . "/";
        $dir = $CFG->dataroot . $reldir;
        if ($um->process_file_uploads($dir)) {
            $parameter->value = $reldir . $um->get_new_filename();
            update_record('profile_data', $parameter);
        } else {
            $messages[] = $um->get_errors();
        }
    }
    return true;
}
开发者ID:BackupTheBerlios,项目名称:tulipan-svn,代码行数:34,代码来源:lib.php


示例14: optional_param

 $description = optional_param('icondescription');
 $icondefault = optional_param('icondefault');
 // if (!empty($description)) {
 $ok = true;
 if ($ok == true) {
     $numicons = count_records('icons', 'owner', $page_owner);
     if ($numicons >= $_SESSION['icon_quota']) {
         $ok = false;
         $messages[] = gettext("You have already met your icon quota. You must delete some icons before you can upload any new ones.");
     }
 }
 require_once $CFG->dirroot . 'lib/uploadlib.php';
 // TODO passing 0 as maxbytes here as icon_quota is based on number of icons
 // so upload_manager will look at PHP settings instead.
 // not ideal but as good as it can be for the now.
 $um = new upload_manager('iconfile', false, true, false, 0, true);
 $messages[] = gettext("Attempting to upload icon file ...");
 $ul_username = run("users:id_to_name", $page_owner);
 $upload_folder = $textlib->substr($ul_username, 0, 1);
 $dir = $CFG->dataroot . "icons/" . $upload_folder . "/" . $ul_username . "/";
 if ($ok = $um->process_file_uploads($dir)) {
     if (!($imageattr = @getimagesize($um->get_new_filepath()))) {
         $ok = false;
         $messages[] = gettext("The uploaded icon file was invalid. Please ensure you are using JPEG, GIF or PNG files.");
     }
 }
 if ($ok == true) {
     if ($imageattr[0] > 100 || $imageattr[1] > 100) {
         // $ok = false;
         // $messages[] = gettext("The uploaded icon file was too large. Files must have maximum dimensions of 100x100.");
         require_once $CFG->dirroot . 'lib/iconslib.php';
开发者ID:pzingg,项目名称:saugus_elgg,代码行数:31,代码来源:function_actions.php


示例15: 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


示例16: workshop_copy_assessment

                    $newassessment = workshop_copy_assessment($assessment, $newsubmission, true);
                    // set the resubmission flag so student can be emailed/told about
                    // this assessment
                    set_field("workshop_assessments", "resubmission", 1, "id", $newassessment->id);
                }
            } else {
                // a hot assessment, was not used, just dump it
                delete_records("workshop_assessments", "id", $assessment->id);
            }
        }
    }
    add_to_log($course->id, "workshop", "resubmit", "view.php?id={$cm->id}", "{$workshop->id}", "{$cm->id}");
}
// do something about the attachments, if there are any
if ($workshop->nattachments) {
    require_once $CFG->dirroot . '/lib/uploadlib.php';
    $um = new upload_manager(null, false, false, $course, false, $workshop->maxbytes);
    if ($um->preprocess_files()) {
        $dir = workshop_file_area_name($workshop, $newsubmission);
        if ($um->save_files($dir)) {
            print_heading(get_string("uploadsuccess", "workshop"));
        }
        // um will take care of printing errors.
    }
}
if (!$workshop->nattachments) {
    print_heading(get_string("submitted", "workshop") . " " . get_string("ok"));
}
add_to_log($course->id, "workshop", "submit", "view.php?id={$cm->id}", "{$workshop->id}", "{$cm->id}");
print_continue("view.php?id={$cm->id}");
print_footer($course);
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:31,代码来源:upload.php


示例17: _postprocess

 function _postprocess(&$resource)
 {
     global $RESOURCE_WINDOW_OPTIONS;
     global $COURSE, $CFG;
     // for file upload patch
     $alloptions = $RESOURCE_WINDOW_OPTIONS;
     if (!empty($resource->forcedownload)) {
         $resource->popup = '';
         $resource->options = 'forcedownload';
     } else {
         if ($resource->windowpopup) {
             $optionlist = array();
             foreach ($alloptions as $option) {
                 $optionlist[] = $option . "=" . $resource->{$option};
                 unset($resource->{$option});
             }
             $resource->popup = implode(',', $optionlist);
             unset($resource->windowpopup);
             $resource->options = '';
         } else {
             if (empty($resource->framepage)) {
                 $resource->options = '';
             } else {
                 switch ($resource->framepage) {
                     case 1:
                         $resource->options = 'frame';
                         break;
                     case 2:
                         $resource->options = 'objectframe';
                         break;
                     default:
                         $resource->options = '';
                         break;
                 }
             }
             unset($resource->framepage);
             $resource->popup = '';
         }
     }
     $optionlist = array();
     for ($i = 0; $i < $this->maxparameters; $i++) {
         $parametername = "parameter{$i}";
         $parsename = "parse{$i}";
         if (!empty($resource->{$parsename}) and $resource->{$parametername} != "-") {
             $optionlist[] = $resource->{$parametername} . "=" . $resource->{$parsename};
         }
         unset($resource->{$parsename});
         unset($resource->{$parametername});
     }
     $resource->alltext = implode(',', $optionlist);
     //	if ($fromform->type == 'fileupload') {
     // upload file to fixed pre-defined "/" folder
     require_once $CFG->dirroot . '/lib/uploadlib.php';
     if (!($basedir = make_upload_directory("{$COURSE->id}"))) {
         error("The site administrator needs to fix the file permissions");
     }
     $wdir = '/';
     $um = new upload_manager('userfile', false, false, $course, false, 0);
     $dir = "{$basedir}{$wdir}";
     if ($um->process_file_uploads($dir)) {
         notify(get_string('uploadedfile'));
     }
     $resource->reference = $um->files["userfile"]["name"];
     // end of upload code
     //	}
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:66,代码来源:resource.class.php


示例18: save_uploaded_file

 /**
  * Processes a newly uploaded file, copies it to disk, and creates
  * a new artefact object.
  * Takes the name of a file input.
  * Returns false for no errors, or a string describing the error.
  */
 public static function save_uploaded_file($inputname, $data)
 {
     require_once 'uploadmanager.php';
     $um = new upload_manager($inputname);
     if ($error = $um->preprocess_file()) {
         throw new UploadException($error);
     }
     $size = $um->file['size'];
     if (!empty($data->owner)) {
         global $USER;
         if ($data->owner == $USER->get('id')) {
             $owner = $USER;
         } else {
             $owner = new User();
             $owner->find_by_id($data->owner);
         }
         if (!$owner->quota_allowed($size)) {
             throw new QuotaExceededException(get_string('uploadexceedsquota', 'artefact.file'));
         }
     }
     $data->size = $size;
     $data->filetype = $um->file['type'];
     $data->oldextension = $um->original_filename_extension();
     $f = self::new_file($um->file['tmp_name'], $data);
     $f->commit();
     $id = $f->get('id');
     // Save the file using its id as the filename, and use its id modulo
     // the number of subdirectories as the directory name.
     if ($error = $um->save_file(self::get_file_directory($id), $id)) {
         $f->delete();
         throw new UploadException($error);
     } else {
         if ($owner) {
             $owner->quota_add($size);
             $owner->commit();
         }
     }
     return $id;
 }
开发者ID:Br3nda,项目名称:mahara,代码行数:45,代码来源:lib.php


示例19: update_content

 function update_content($recordid, $value, $name)
 {
     global $CFG;
     if (!($oldcontent = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid))) {
         // Quickly make one now!
         $oldcontent = new object();
         $oldcontent->fieldid = $this->field->id;
         $oldcontent->recordid = $recordid;
         if ($oldcontent->id = insert_record('data_content', $oldcontent)) {
             error('Could not make an empty record!');
         }
     }
     $content = new object();
     $content->id = $oldcontent->id;
     $names = explode('_', $name);
     switch ($names[2]) {
         case 'file':
             // file just uploaded
             #                $course = get_course('course', 'id', $this->data->course);
             $filename = $_FILES[$names[0] . '_' . $names[1]];
             $filename = $filename['name'];
             $dir = $this->data->course . '/' . $CFG->moddata . '/data/' . $this->data->id . '/' . $this->field->id . '/' . $recordid;
             // only use the manager if file is present, to avoid "are you sure you selected a file to upload" msg
             if ($filename) {
                 require_once $CFG->libdir . '/uploadlib.php';
                 // FIX ME: $course not defined here
                 $um = new upload_manager($names[0] . '_' . $names[1], true, false, $this->data->course, false, $this->field->param3);
                 if ($um->process_file_uploads($dir)) {
                     $newfile_name = $um->get_new_filename();
                     $content->content = $newfile_name;
                     update_record('data_content', $content);
                 }
             }
             break;
         case 'filename':
             // only changing alt tag
             $content->content1 = clean_param($value, PARAM_NOTAGS);
             update_record('data_content', $content);
             break;
         default:
             break;
     }
 }
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:43,代码来源:field.class.php


示例20: trim

 $attachment = $attachname = '';
 if (has_capability('moodle/course:managefiles', $context)) {
     $form->attachment = trim($form->attachment);
     if (isset($form->attachment) and !empty($form->attachment)) {
         $form->attachment = clean_param($form->attachment, PARAM_PATH);
         if (file_exists($CFG->dataroot . '/' . $course->id . '/' . $form->attachment)) {
             $attachment = $course->id . '/' . $form->attachment;
             $pathparts = pathinfo($form->attachment);
             $attachname = $pathparts['basename'];
         } else {
             $form->error = get_string('attachmenterror', 'block_quickmail', $form->attachment);
         }
     }
 } else {
     require_once $CFG->libdir . '/uploadlib.php';
     $um = new upload_manager('attachment', false, true, $course, false, 0, true);
     // process the student posted attachment if it exists
     if ($um->process_file_uploads('temp/block_quickmail')) {
         // original name gets saved in the database
         $form->attachment = $um->get_original_filename();
         // check if file is there
         if (file_exists($um->get_new_filepath())) {
             // get path to the file without $CFG->dataroot
             $attachment = 'temp/block_quickmail/' . $um->get_new_filename();
             // get the new name (name may change due to filename collisions)
             $attachname = $um->get_new_filename();
         } else {
             $form->error = get_string("attachmenterror", "block_quickmail", $form->attachment);
         }
     } else {
         $form->attachment = '';
开发者ID:henriquecrang,项目名称:e-UNI,代码行数:31,代码来源:email.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP uploader类代码示例发布时间:2022-05-23
下一篇:
PHP upload类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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