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


PHP workshop::clean_file_extensions方法代码示例

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


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

示例1: validation

 function validation($data, $files)
 {
     global $CFG, $USER, $DB;
     $errors = parent::validation($data, $files);
     if (empty($data['id']) and empty($data['example'])) {
         // make sure there is no submission saved meanwhile from another browser window
         $sql = "SELECT COUNT(s.id)\n                      FROM {workshop_submissions} s\n                      JOIN {workshop} w ON (s.workshopid = w.id)\n                      JOIN {course_modules} cm ON (w.id = cm.instance)\n                      JOIN {modules} m ON (m.name = 'workshop' AND m.id = cm.module)\n                     WHERE cm.id = ? AND s.authorid = ? AND s.example = 0";
         if ($DB->count_records_sql($sql, array($data['cmid'], $USER->id))) {
             $errors['title'] = get_string('err_multiplesubmissions', 'mod_workshop');
         }
     }
     if (isset($data['attachment_filemanager']) and isset($this->_customdata['workshop']->submissionfiletypes)) {
         $whitelist = workshop::normalize_file_extensions($this->_customdata['workshop']->submissionfiletypes);
         if ($whitelist) {
             $draftfiles = file_get_drafarea_files($data['attachment_filemanager']);
             if ($draftfiles) {
                 $wrongfiles = array();
                 foreach ($draftfiles->list as $file) {
                     if (!workshop::is_allowed_file_type($file->filename, $whitelist)) {
                         $wrongfiles[] = $file->filename;
                     }
                 }
                 if ($wrongfiles) {
                     $a = array('whitelist' => workshop::clean_file_extensions($whitelist), 'wrongfiles' => implode(', ', $wrongfiles));
                     $errors['attachment_filemanager'] = get_string('err_wrongfileextension', 'mod_workshop', $a);
                 }
             }
         }
     }
     return $errors;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:submission_form.php

示例2: validation

 /**
  * Validates the form input
  *
  * @param array $data submitted data
  * @param array $files submitted files
  * @return array eventual errors indexed by the field name
  */
 public function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     // Validate lists of allowed extensions.
     foreach (array('submissionfiletypes', 'overallfeedbackfiletypes') as $fieldname) {
         if (isset($data[$fieldname])) {
             $invalidextensions = workshop::invalid_file_extensions($data[$fieldname], array_keys(core_filetypes::get_types()));
             if ($invalidextensions) {
                 $errors[$fieldname] = get_string('err_unknownfileextension', 'mod_workshop', workshop::clean_file_extensions($invalidextensions));
             }
         }
     }
     // check the phases borders are valid
     if ($data['submissionstart'] > 0 and $data['submissionend'] > 0 and $data['submissionstart'] >= $data['submissionend']) {
         $errors['submissionend'] = get_string('submissionendbeforestart', 'mod_workshop');
     }
     if ($data['assessmentstart'] > 0 and $data['assessmentend'] > 0 and $data['assessmentstart'] >= $data['assessmentend']) {
         $errors['assessmentend'] = get_string('assessmentendbeforestart', 'mod_workshop');
     }
     // check the phases do not overlap
     if (max($data['submissionstart'], $data['submissionend']) > 0 and max($data['assessmentstart'], $data['assessmentend']) > 0) {
         $phasesubmissionend = max($data['submissionstart'], $data['submissionend']);
         $phaseassessmentstart = min($data['assessmentstart'], $data['assessmentend']);
         if ($phaseassessmentstart == 0) {
             $phaseassessmentstart = max($data['assessmentstart'], $data['assessmentend']);
         }
         if ($phasesubmissionend > 0 and $phaseassessmentstart > 0 and $phaseassessmentstart < $phasesubmissionend) {
             foreach (array('submissionend', 'submissionstart', 'assessmentstart', 'assessmentend') as $f) {
                 if ($data[$f] > 0) {
                     $errors[$f] = get_string('phasesoverlap', 'mod_workshop');
                     break;
                 }
             }
         }
     }
     // Check that the submission grade pass is a valid number.
     if (!empty($data['submissiongradepass'])) {
         $submissiongradefloat = unformat_float($data['submissiongradepass'], true);
         if ($submissiongradefloat === false) {
             $errors['submissiongradepass'] = get_string('err_numeric', 'form');
         } else {
             if ($submissiongradefloat > $data['grade']) {
                 $errors['submissiongradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['grade']);
             }
         }
     }
     // Check that the grade pass is a valid number.
     if (!empty($data['gradinggradepass'])) {
         $gradepassfloat = unformat_float($data['gradinggradepass'], true);
         if ($gradepassfloat === false) {
             $errors['gradinggradepass'] = get_string('err_numeric', 'form');
         } else {
             if ($gradepassfloat > $data['gradinggrade']) {
                 $errors['gradinggradepass'] = get_string('gradepassgreaterthangrade', 'grades', $data['gradinggrade']);
             }
         }
     }
     return $errors;
 }
开发者ID:sirromas,项目名称:lms,代码行数:66,代码来源:mod_form.php

示例3: workshop_update_instance

/**
 * Given an object containing all the necessary data,
 * (defined by the form in mod_form.php) this function
 * will update an existing instance with new data.
 *
 * @param stdClass $workshop An object from the form in mod_form.php
 * @return bool success
 */
function workshop_update_instance(stdclass $workshop) {
    global $CFG, $DB;
    require_once(dirname(__FILE__) . '/locallib.php');

    $workshop->timemodified          = time();
    $workshop->id                    = $workshop->instance;
    $workshop->useexamples           = (int)!empty($workshop->useexamples);
    $workshop->usepeerassessment     = 1;
    $workshop->useselfassessment     = (int)!empty($workshop->useselfassessment);
    $workshop->latesubmissions       = (int)!empty($workshop->latesubmissions);
    $workshop->phaseswitchassessment = (int)!empty($workshop->phaseswitchassessment);

    if (isset($workshop->gradinggradepass)) {
        $workshop->gradinggradepass = unformat_float($workshop->gradinggradepass);
    }

    if (isset($workshop->submissiongradepass)) {
        $workshop->submissiongradepass = unformat_float($workshop->submissiongradepass);
    }

    if (isset($workshop->submissionfiletypes)) {
        $workshop->submissionfiletypes = workshop::clean_file_extensions($workshop->submissionfiletypes);
    }

    if (isset($workshop->overallfeedbackfiletypes)) {
        $workshop->overallfeedbackfiletypes = workshop::clean_file_extensions($workshop->overallfeedbackfiletypes);
    }

    // todo - if the grading strategy is being changed, we may want to replace all aggregated peer grades with nulls

    $DB->update_record('workshop', $workshop);
    $context = context_module::instance($workshop->coursemodule);

    // process the custom wysiwyg editors
    if ($draftitemid = $workshop->instructauthorseditor['itemid']) {
        $workshop->instructauthors = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'instructauthors',
                0, workshop::instruction_editors_options($context), $workshop->instructauthorseditor['text']);
        $workshop->instructauthorsformat = $workshop->instructauthorseditor['format'];
    }

    if ($draftitemid = $workshop->instructreviewerseditor['itemid']) {
        $workshop->instructreviewers = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'instructreviewers',
                0, workshop::instruction_editors_options($context), $workshop->instructreviewerseditor['text']);
        $workshop->instructreviewersformat = $workshop->instructreviewerseditor['format'];
    }

    if ($draftitemid = $workshop->conclusioneditor['itemid']) {
        $workshop->conclusion = file_save_draft_area_files($draftitemid, $context->id, 'mod_workshop', 'conclusion',
                0, workshop::instruction_editors_options($context), $workshop->conclusioneditor['text']);
        $workshop->conclusionformat = $workshop->conclusioneditor['format'];
    }

    // re-save the record with the replaced URLs in editor fields
    $DB->update_record('workshop', $workshop);

    // update gradebook items
    workshop_grade_item_update($workshop);
    workshop_grade_item_category_update($workshop);

    // update calendar events
    workshop_calendar_update($workshop, $workshop->coursemodule);

    return true;
}
开发者ID:rohitshriwas,项目名称:moodle,代码行数:72,代码来源:lib.php

示例4: test_clean_file_extensions

 /**
  * Test cleaning list of extensions.
  */
 public function test_clean_file_extensions()
 {
     $this->resetAfterTest(true);
     $this->assertSame('', workshop::clean_file_extensions(''));
     $this->assertSame('', workshop::clean_file_extensions(null));
     $this->assertSame('', workshop::clean_file_extensions(' '));
     $this->assertSame('0', workshop::clean_file_extensions(0));
     $this->assertSame('0', workshop::clean_file_extensions('0'));
     $this->assertSame('doc, rtf, pdf', workshop::clean_file_extensions('*.Doc, RTF, PDF, .rtf' . PHP_EOL . 'PDF '));
     $this->assertSame('doc, rtf, pdf', 'doc, rtf, pdf');
 }
开发者ID:evltuma,项目名称:moodle,代码行数:14,代码来源:locallib_test.php

示例5: validation

 /**
  * Validate assessment form data.
  *
  * @param array $data
  * @param array $files
  * @return array
  */
 public function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     if (isset($data['feedbackauthorattachment_filemanager']) and isset($this->workshop->overallfeedbackfiletypes)) {
         $whitelist = workshop::normalize_file_extensions($this->workshop->overallfeedbackfiletypes);
         if ($whitelist) {
             $draftfiles = file_get_drafarea_files($data['feedbackauthorattachment_filemanager']);
             if ($draftfiles) {
                 $wrongfiles = array();
                 foreach ($draftfiles->list as $file) {
                     if (!workshop::is_allowed_file_type($file->filename, $whitelist)) {
                         $wrongfiles[] = $file->filename;
                     }
                 }
                 if ($wrongfiles) {
                     $a = array('whitelist' => workshop::clean_file_extensions($whitelist), 'wrongfiles' => implode(', ', $wrongfiles));
                     $errors['feedbackauthorattachment_filemanager'] = get_string('err_wrongfileextension', 'mod_workshop', $a);
                 }
             }
         }
     }
     return $errors;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:30,代码来源:assessment_form.php


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