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


PHP upload_manager::get_original_filename方法代码示例

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


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

示例1: pathinfo

         $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 = '';
         // no attachment
     }
 }
 // no errors, then email
开发者ID:henriquecrang,项目名称:e-UNI,代码行数:31,代码来源:email.php

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

示例3: run

 }
 $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;
     $f->size = $um->get_filesize();
     $f->time_uploaded = time();
     $file_id = insert_record('files', $f);
     $value = trim(optional_param('new_file_keywords'));
     insert_tags_from_string($value, 'file', $file_id, $access, $page_owner);
     $metadata = optional_param('metadata');
     if (is_array($metadata)) {
         foreach ($metadata as $name => $value) {
开发者ID:pzingg,项目名称:saugus_elgg,代码行数:31,代码来源:files_actions.php

示例4: time

     $submission->timemodified = time();
     $submission->data1 = required_param('text', PARAM_CLEANHTML);
     if (update_record('assignment_submissions', $submission)) {
         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));
     }
 } 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));
                 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:31,代码来源:resubmit.php


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