本文整理汇总了PHP中moodleform_mod类的典型用法代码示例。如果您正苦于以下问题:PHP moodleform_mod类的具体用法?PHP moodleform_mod怎么用?PHP moodleform_mod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了moodleform_mod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validation
public function validation($data, $files)
{
global $DB;
$errors = parent::validation($data, $files);
// If you enable sharing, you must enter an idnumber.
if (!empty($data['enablesharing']) && empty($data['cmidnumber'])) {
$errors['cmidnumber'] = get_string('error_noidnumber', 'subpage');
}
// If you turn off sharing, there must be no shared pages using it.
if (empty($data['enablesharing']) && !empty($this->_instance)) {
if ($DB->get_field('modules', 'id', array('name' => 'sharedsubpage'))) {
// Check if there is a shared subpage...
if ($DB->record_exists('sharedsubpage', array('subpageid' => $this->_instance))) {
$errors['enablesharing'] = get_string('error_sharingused', 'subpage');
}
}
}
// ID numbers must be unique, systemwide.
if (!empty($data['cmidnumber'])) {
// Except obviously on this existing course-module (if it does exist).
$except = -1;
if (!empty($data['coursemodule'])) {
$except = $data['coursemodule'];
}
if ($DB->record_exists_sql('SELECT 1 FROM {course_modules} WHERE idnumber = ? AND id <> ?', array($data['cmidnumber'], $except))) {
$errors['cmidnumber'] = get_string('error_duplicateidnumber', 'subpage');
}
}
return $errors;
}
示例2: validation
function validation($data, $files) {
global $USER;
if ($errors = parent::validation($data, $files)) {
return $errors;
}
$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
$fs = get_file_storage();
if (!$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $data['package'], 'id', false)) {
if (!$this->current->instance) {
$errors['package'] = get_string('required');
return $errors;
}
} else {
$file = reset($files);
if ($file->get_mimetype() != 'application/zip') {
$errors['package'] = get_string('invalidfiletype', 'error', '', $file);
// better delete current file, it is not usable anyway
$fs->delete_area_files($usercontext->id, 'user', 'draft', $data['package']);
}
}
return $errors;
}
示例3:
/**
* Load in existing data as form defaults. Usually new entry defaults are stored directly in
* form definition (new entry form); this function is used to load in data where values
* already exist and data is being edited (edit entry form).
*
* @see: /course/moodleform.php
*/
function set_data($default_values)
{
if (is_object($default_values)) {
$default_values = (array) $default_values;
}
$default_values['details']['text'] = $default_values['intro'];
parent::set_data($default_values);
}
示例4:
function get_data()
{
$data = parent::get_data();
if (!$data) {
return false;
}
return $data;
}
示例5: validation
public function validation($data, $files)
{
$errors = parent::validation($data, $files);
if (count($errors) == 0) {
return true;
} else {
return $errors;
}
}
示例6: validation
function validation($data, $files)
{
$errors = parent::validation($data, $files);
// Completion: Automatic on-view completion can not work together with
// "display inline" option
if (empty($errors['completion']) && array_key_exists('completion', $data) && $data['completion'] == COMPLETION_TRACKING_AUTOMATIC && !empty($data['completionview']) && $data['display'] == FOLDER_DISPLAY_INLINE) {
$errors['completion'] = get_string('noautocompletioninline', 'mod_folder');
}
return $errors;
}
示例7: validation
function validation($data, $files)
{
global $COURSE;
$errors = parent::validation($data, $files);
$mform =& $this->_form;
$maxmembers = $data['maxmembers'];
if ($maxmembers < 0) {
$errors['maxmembers'] = get_string('error');
}
return $errors;
}
示例8: validation
function validation($data, $files)
{
$errors = parent::validation($data, $files);
// Disabled this feature because client wants to be able to paste
// URLs with spaces and only have them trimed just before the page
// is redirected.
// if(!ezproxy_has_protocol($data['serverurl'])) {
// $errors['serverurl'] = get_string('missingprotocol', 'ezproxy');
// }
return $errors;
}
示例9:
function get_data()
{
$data = parent::get_data();
if (!$data) {
return false;
}
if (!isset($data->usecoursegroups)) {
$data->usecoursegroups = 0;
}
return $data;
}
示例10:
function get_data()
{
$data = parent::get_data();
if (!$data) {
return false;
}
// Set up completion section even if checkbox is not ticked
if (empty($data->completionsection)) {
$data->completionsection = 0;
}
return $data;
}
示例11: get_data
/**
* Return submitted data if properly submitted or returns NULL if validation fails or
* if there is no submitted data.
*
* @return stdClass submitted data; NULL if not valid or not submitted or cancelled
*/
public function get_data()
{
$data = parent::get_data();
if (!$data) {
return false;
}
if (!empty($data->completionunlocked)) {
// Turn off completion settings if the checkboxes aren't ticked.
$autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
if (!$autocompletion || empty($data->completionsubmit)) {
$data->completionsubmit = 0;
}
}
return $data;
}
示例12: definition_after_data
public function definition_after_data()
{
parent::definition_after_data();
$mform = $this->_form;
if ($id = $mform->getElementValue('update')) {
$dta = $mform->getElementValue('open');
$dt = mktime($dta['hour'][0], $dta['minute'][0], 0, $dta['month'][0], $dta['day'][0], $dta['year'][0]);
if ($dt < time()) {
$el = $mform->createElement('static', 'openlabel', 'Open', date("D d/m/Y H:i", $dt));
$mform->insertElementBefore($el, 'open');
$mform->removeElement('open');
$mform->addElement('hidden', 'opendt', $dt);
}
}
}
示例13: validation
function validation($data, $files)
{
$errors = parent::validation($data, $files);
// Validating entered NeuroK course url.
if (!empty($data['url'])) {
$testurl = $data['url'];
if (preg_match('|^https:|i', $testurl)) {
if (!preg_match('|' . NEUROKBASEURL . '|i', $testurl)) {
$errors['url'] = get_string('invalidurl', 'neurok');
}
} else {
$errors['url'] = get_string('invalidurl', 'neurok');
}
}
return $errors;
}
示例14:
function get_data()
{
$data = parent::get_data();
if (!$data) {
return false;
}
if (!empty($data->completionunlocked)) {
// Turn off completion settings if the checkboxes aren't ticked
$autocompletion = !empty($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
if (empty($data->completionentriesenabled) || !$autocompletion) {
$data->completionentries = 0;
}
}
return $data;
}
示例15: validation
/**
* Perform minimal validation on the settings form
* @param array $data
* @param array $files
*/
public function validation($data, $files)
{
$errors = parent::validation($data, $files);
if ($data['allowsubmissionsfromdate'] && $data['duedate']) {
if ($data['allowsubmissionsfromdate'] > $data['duedate']) {
$errors['duedate'] = get_string('duedatevalidation', 'publication');
}
}
if ($data['duedate'] && $data['cutoffdate']) {
if ($data['duedate'] > $data['cutoffdate']) {
$errors['cutoffdate'] = get_string('cutoffdatevalidation', 'publication');
}
}
if ($data['allowsubmissionsfromdate'] && $data['cutoffdate']) {
if ($data['allowsubmissionsfromdate'] > $data['cutoffdate']) {
$errors['cutoffdate'] = get_string('cutoffdatefromdatevalidation', 'publication');
}
}
if ($data['mode'] == PUBLICATION_MODE_IMPORT) {
if ($data['importfrom'] == "0") {
$errors['importfrom'] = get_string('importfrom_err', 'publication');
}
}
return $errors;
}