Exemple #1
0
 /**
  * Form validation
  *
  * @param array $data
  * @param array $files
  * @return array $errors An array of errors
  */
 function validation($data, $files)
 {
     global $COURSE, $DB, $CFG;
     $errors = parent::validation($data, $files);
     $name = trim($data['name']);
     if ($data['id'] and $group = $DB->get_record('groups', array('id' => $data['id']))) {
         if (textlib::strtolower($group->name) != textlib::strtolower($name)) {
             if (groups_get_group_by_name($COURSE->id, $name)) {
                 $errors['name'] = get_string('groupnameexists', 'group', $name);
             }
         }
         if (!empty($CFG->groupenrolmentkeypolicy) and $data['enrolmentkey'] != '' and $group->enrolmentkey !== $data['enrolmentkey']) {
             // enforce password policy only if changing password
             $errmsg = '';
             if (!check_password_policy($data['enrolmentkey'], $errmsg)) {
                 $errors['enrolmentkey'] = $errmsg;
             }
         }
     } else {
         if (groups_get_group_by_name($COURSE->id, $name)) {
             $errors['name'] = get_string('groupnameexists', 'group', $name);
         }
     }
     return $errors;
 }
Exemple #2
0
    /**
     * Perform minimal validation on the grade form
     * @param array $data
     * @param array $files
     */
    function validation($data, $files) {
        global $DB;
        $errors = parent::validation($data, $files);
        // advanced grading
        if (!array_key_exists('grade', $data)) {
            return $errors;
        }

        if ($this->assignment->get_instance()->grade > 0) {
            if (!is_numeric($data['grade']) and (!empty($data['grade']))) {
                $errors['grade'] = get_string('invalidfloatforgrade', 'assign', $data['grade']);
            } else if ($data['grade'] > $this->assignment->get_instance()->grade) {
                $errors['grade'] = get_string('gradeabovemaximum', 'assign', $this->assignment->get_instance()->grade);
            } else if ($data['grade'] < 0) {
                $errors['grade'] = get_string('gradebelowzero', 'assign');
            }
        } else {
            // this is a scale
            if ($scale = $DB->get_record('scale', array('id'=>-($this->assignment->get_instance()->grade)))) {
                $scaleoptions = make_menu_from_list($scale->scale);
                if (!array_key_exists((int)$data['grade'], $scaleoptions)) {
                    $errors['grade'] = get_string('invalidgradeforscale', 'assign');
                }
            }
        }
        return $errors;
    }
 /**
  * Perform minimal validation on the grade form
  * @param array $data
  * @param array $files
  */
 public function validation($data, $files)
 {
     global $DB;
     $errors = parent::validation($data, $files);
     $instance = $this->seplment->get_instance();
     if ($instance->markingworkflow && !empty($data['sendstudentnotifications']) && $data['workflowstate'] != ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
         $errors['sendstudentnotifications'] = get_string('studentnotificationworkflowstateerror', 'sepl');
     }
     // Advanced grading.
     if (!array_key_exists('grade', $data)) {
         return $errors;
     }
     if ($instance->grade > 0) {
         if (unformat_float($data['grade'], true) === false && !empty($data['grade'])) {
             $errors['grade'] = get_string('invalidfloatforgrade', 'sepl', $data['grade']);
         } else {
             if (unformat_float($data['grade']) > $instance->grade) {
                 $errors['grade'] = get_string('gradeabovemaximum', 'sepl', $instance->grade);
             } else {
                 if (unformat_float($data['grade']) < 0) {
                     $errors['grade'] = get_string('gradebelowzero', 'sepl');
                 }
             }
         }
     } else {
         // This is a scale.
         if ($scale = $DB->get_record('scale', array('id' => -$instance->grade))) {
             $scaleoptions = make_menu_from_list($scale->scale);
             if ((int) $data['grade'] !== -1 && !array_key_exists((int) $data['grade'], $scaleoptions)) {
                 $errors['grade'] = get_string('invalidgradeforscale', 'sepl');
             }
         }
     }
     return $errors;
 }
 public function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     // If this is a rate question.
     if ($data['type_id'] == QUESRATE) {
         if ($data['length'] < 2) {
             $errors["length"] = get_string('notenoughscaleitems', 'questionnaire');
         }
         // If this is a rate question with no duplicates option.
         if ($data['precise'] == 2) {
             $allchoices = $data['allchoices'];
             $allchoices = explode("\n", $allchoices);
             $nbvalues = 0;
             foreach ($allchoices as $choice) {
                 if ($choice && !preg_match("/^[0-9]{1,3}=/", $choice)) {
                     $nbvalues++;
                 }
             }
             if ($nbvalues < 2) {
                 $errors["allchoices"] = get_string('noduplicateschoiceserror', 'questionnaire');
             }
         }
     }
     return $errors;
 }
 /**
  * Ensure that the data the user entered is valid
  *
  * @param object $data data object for validation
  * @param object $files file object for validation
  * 
  * @see lib/moodleform#validation()
  * 
  * @return $errors error message
  */
 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     global $DB, $CFG, $USER;
     //Declare them if you need them
     return $errors;
 }
Exemple #6
0
 function validation($data, $files)
 {
     global $DB;
     $errors = parent::validation($data, $files);
     $tab_id = array();
     foreach ($data as $key => $value) {
         $pos = strstr($key, "voc_id");
         if ($pos) {
             // echo "found :$key /$value<=> $pos<br>";
             foreach ($value as $key2 => $value2) {
                 if ($value2 > 0) {
                     $tab_id[] = $value2;
                 }
             }
         } else {
             // echo " NOT found :$key /$value<br>";
         }
     }
     // var_dump($data);
     var_dump($tab_id);
     die('stop');
     if (empty($tab_id)) {
         $errors['shortname'] = 'please select at least one vocabulary';
         $errors[''] = 'please select at least one vocabulary';
         // todo repositionner l'erreur au bon endroit dans le formulaire
     }
     //        // Add field validation check for duplicate shortname.
     //        if ($term= $DB->get_record('taxonomy_term', array('shortname' => $data['shortname']), '*', IGNORE_MULTIPLE)) {
     //            if (empty($data['id']) || $term->id != $data['id']) {
     //                $errors['shortname'] = 'this shortmane is already used';
     //            }
     //        }
     return $errors;
 }
 function validation($data, $files)
 {
     global $db, $CFG;
     $errors = parent::validation($data, $files);
     if (!in_array($data['operator'], $this->allowedops)) {
         $errors['operator'] = get_string('error_operator', 'block_configurable_reports');
     }
     $columns = $db->MetaColumns($CFG->prefix . 'user');
     $usercolumns = array();
     foreach ($columns as $c) {
         $usercolumns[$c->name] = $c->name;
     }
     if ($profile = get_records('user_info_field')) {
         foreach ($profile as $p) {
             $usercolumns['profile_' . $p->shortname] = 'profile_' . $p->shortname;
         }
     }
     if (!in_array($data['field'], $usercolumns)) {
         $errors['field'] = get_string('error_field', 'block_configurable_reports');
     }
     if (!is_numeric($data['value']) && preg_match('/^(<|>)[^(<|>)]/i', $data['operator'])) {
         $errors['value'] = get_string('error_value_expected_integer', 'block_configurable_reports');
     }
     return $errors;
 }
Exemple #8
0
    function validation($data, $files) {
        global $DB, $CFG, $db, $USER;

        $errors = parent::validation($data, $files);

        return $errors;
    }
Exemple #9
0
 /**
  * Validates the add instance form data
  *
  * @param array $data
  * @param array $files
  * @return array
  */
 public function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     if (!array_key_exists('name', $errors)) {
         if (!preg_match('#^[a-zA-Z0-9\\-_ ]+$#', $data['name'])) {
             $errors['name'] = get_string('storenameinvalid', 'cache');
         } else {
             if (empty($this->_customdata['store'])) {
                 $stores = cache_administration_helper::get_store_instance_summaries();
                 if (array_key_exists($data['name'], $stores)) {
                     $errors['name'] = get_string('storenamealreadyused', 'cache');
                 }
             }
         }
     }
     if (method_exists($this, 'configuration_validation')) {
         $newerrors = $this->configuration_validation($data, $files, $errors);
         // We need to selectiviliy merge here
         foreach ($newerrors as $element => $error) {
             if (!array_key_exists($element, $errors)) {
                 $errors[$element] = $error;
             }
         }
     }
     return $errors;
 }
Exemple #10
0
 function validation($data, $files)
 {
     global $USER;
     if ($errors = parent::validation($data, $files)) {
         return $errors;
     }
     $usercontext = context_user::instance($USER->id);
     $fs = get_file_storage();
     if (!($files = $fs->get_area_files($usercontext->id, 'user', 'draft', $data['importfile'], 'id', false))) {
         $errors['importfile'] = get_string('required');
         return $errors;
     } else {
         $file = reset($files);
         if ($file->get_mimetype() != 'application/zip') {
             $errors['importfile'] = get_string('invalidfiletype', 'error', $file->get_filename());
             // better delete current file, it is not usable anyway
             $fs->delete_area_files($usercontext->id, 'user', 'draft', $data['importfile']);
         } else {
             if (!($chpterfiles = toolbook_importhtml_get_chapter_files($file, $data['type']))) {
                 $errors['importfile'] = get_string('errornochapters', 'booktool_importhtml');
             }
         }
     }
     return $errors;
 }
Exemple #11
0
    /**
     * Perform minimal validation on the grade form
     * @param array $data
     * @param array $files
     */
    public function validation($data, $files) {
        global $DB;
        $errors = parent::validation($data, $files);
        $instance = $this->assignment->get_instance();
        // Advanced grading.
        if (!array_key_exists('grade', $data)) {
            return $errors;
        }

        if ($instance->grade > 0) {
            if (unformat_float($data['grade']) === null && (!empty($data['grade']))) {
                $errors['grade'] = get_string('invalidfloatforgrade', 'assign', $data['grade']);
            } else if (unformat_float($data['grade']) > $instance->grade) {
                $errors['grade'] = get_string('gradeabovemaximum', 'assign', $instance->grade);
            } else if (unformat_float($data['grade']) < 0) {
                $errors['grade'] = get_string('gradebelowzero', 'assign');
            }
        } else {
            // This is a scale.
            if ($scale = $DB->get_record('scale', array('id'=>-($instance->grade)))) {
                $scaleoptions = make_menu_from_list($scale->scale);
                if (!array_key_exists((int)$data['grade'], $scaleoptions)) {
                    $errors['grade'] = get_string('invalidgradeforscale', 'assign');
                }
            }
        }
        return $errors;
    }
 function validation($data, $files)
 {
     global $DB;
     $errors = parent::validation($data, $files);
     $foundcourses = null;
     $foundreqcourses = null;
     if (!empty($data['shortname'])) {
         $foundcourses = $DB->get_records('course', array('shortname' => $data['shortname']));
         $foundreqcourses = $DB->get_records('course_request', array('shortname' => $data['shortname']));
     }
     if (!empty($foundreqcourses)) {
         if (!empty($foundcourses)) {
             $foundcourses = array_merge($foundcourses, $foundreqcourses);
         } else {
             $foundcourses = $foundreqcourses;
         }
     }
     if (!empty($foundcourses)) {
         foreach ($foundcourses as $foundcourse) {
             if (!empty($foundcourse->requester)) {
                 $pending = 1;
                 $foundcoursenames[] = $foundcourse->fullname . ' [*]';
             } else {
                 $foundcoursenames[] = $foundcourse->fullname;
             }
         }
         $foundcoursenamestring = implode(',', $foundcoursenames);
         $errors['shortname'] = get_string('shortnametaken', '', $foundcoursenamestring);
         if (!empty($pending)) {
             $errors['shortname'] .= get_string('starpending');
         }
     }
     return $errors;
 }
Exemple #13
0
    function validation($data, $files) {
        global $DB, $CFG;
        $id = optional_param('id', -1, PARAM_INT);
        $errors = array();
        $errors = parent::validation($data, $files);
        if ($data['schoolid'] == 0) {
            $errors['schoolid'] = get_string('schoolrequired', 'local_collegestructure');
        }
        if ($data['id'] < 0) {
            $examtypes1 = $DB->get_record('local_examtypes', array('schoolid' => $data['schoolid'], 'examtype' => $data['examtype']));
            $exam1 = core_text::strtolower($examtypes1->examtype);
            $exam2 = core_text::strtolower($data['examtype']);
            if ($exam1 == $exam2) {
                $errors['examtype'] = get_string('examexits', 'local_examtype');
            }
        }

        if ($data['id'] > 0) {
            $exists = $DB->get_field('local_examtypes', 'examtype', array('id' => $id));
            if (!($exists === $data['examtype'] )) {
                $examtypes1 = $DB->get_record('local_examtypes', array('schoolid' => $data['schoolid'], 'examtype' => $data['examtype']));
                $exam1 = core_text::strtolower($examtypes1->examtype);
                $exam2 = core_text::strtolower($data['examtype']);
                if ($exam1 == $exam2) {
                    $errors['examtype'] = get_string('examexits', 'local_examtype');
                }
            }
        }
        return $errors;
    }
Exemple #14
0
 /**
  * Form validation
  *
  * @param array $data
  * @param array $files
  * @return array $errors An array of validataion errors for the form.
  */
 function validation($data, $files)
 {
     global $COURSE, $DB;
     $errors = parent::validation($data, $files);
     $name = trim($data['name']);
     if (isset($data['idnumber'])) {
         $idnumber = trim($data['idnumber']);
     } else {
         $idnumber = '';
     }
     if ($data['id'] and $grouping = $DB->get_record('groupings', array('id' => $data['id']))) {
         if (core_text::strtolower($grouping->name) != core_text::strtolower($name)) {
             if (groups_get_grouping_by_name($COURSE->id, $name)) {
                 $errors['name'] = get_string('groupingnameexists', 'group', $name);
             }
         }
         if (!empty($idnumber) && $grouping->idnumber != $idnumber) {
             if (groups_get_grouping_by_idnumber($COURSE->id, $idnumber)) {
                 $errors['idnumber'] = get_string('idnumbertaken');
             }
         }
     } else {
         if (groups_get_grouping_by_name($COURSE->id, $name)) {
             $errors['name'] = get_string('groupingnameexists', 'group', $name);
         } else {
             if (!empty($idnumber) && groups_get_grouping_by_idnumber($COURSE->id, $idnumber)) {
                 $errors['idnumber'] = get_string('idnumbertaken');
             }
         }
     }
     return $errors;
 }
Exemple #15
0
 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;
 }
 function validation($data, $files)
 {
     global $USER;
     $errors = parent::validation($data, $files);
     update_login_count();
     // ignore submitted username
     if (!($user = authenticate_user_login($USER->username, $data['password']))) {
         $errors['password'] = get_string('invalidlogin');
         return $errors;
     }
     reset_login_count();
     if ($data['newpassword1'] != $data['newpassword2']) {
         $errors['newpassword1'] = get_string('passwordsdiffer');
         $errors['newpassword2'] = get_string('passwordsdiffer');
         return $errors;
     }
     if ($data['password'] == $data['newpassword1']) {
         $errors['newpassword1'] = get_string('mustchangepassword');
         $errors['newpassword2'] = get_string('mustchangepassword');
         return $errors;
     }
     $errmsg = '';
     //prevents eclipse warnings
     if (!check_password_policy($data['newpassword1'], $errmsg)) {
         $errors['newpassword1'] = $errmsg;
         $errors['newpassword2'] = $errmsg;
         return $errors;
     }
     return $errors;
 }
 function validation($data, $files)
 {
     global $CFG;
     $cm = $this->_customdata;
     $errors = parent::validation($data, $files);
     $reference = stripslashes($data['reference']);
     if ($reference != '') {
         //null path is root
         $reference = book_prepare_link($reference);
         if ($reference == '') {
             //evil characters in $ref!
             $errors['choosesomething'] = get_string('error');
         } else {
             $coursebase = $CFG->dataroot . '/' . $cm->course;
             if ($reference == '') {
                 $base = $coursebase;
             } else {
                 $base = $coursebase . '/' . $reference;
             }
             if (!is_dir($base) and !is_file($base)) {
                 $errors['choosesomething'] = get_string('error');
             }
         }
     }
     return $errors;
 }
 function validation($data, $files)
 {
     global $COURSE, $CFG;
     $errors = parent::validation($data, $files);
     $textlib = textlib_get_instance();
     $name = trim(stripslashes($data['name']));
     if ($data['id'] and $group = get_record('groups', 'id', $data['id'])) {
         if ($textlib->strtolower($group->name) != $textlib->strtolower($name)) {
             if (groups_get_group_by_name($COURSE->id, $name)) {
                 $errors['name'] = get_string('groupnameexists', 'group', $name);
             }
         }
         if (!empty($CFG->enrol_manual_usepasswordpolicy) and $data['enrolmentkey'] != '' and $group->enrolmentkey !== $data['enrolmentkey']) {
             // enforce password policy only if changing password
             $errmsg = '';
             if (!check_password_policy($data['enrolmentkey'], $errmsg)) {
                 $errors['enrolmentkey'] = $errmsg;
             }
         }
     } else {
         if (groups_get_group_by_name($COURSE->id, $name)) {
             $errors['name'] = get_string('groupnameexists', 'group', $name);
         }
     }
     return $errors;
 }
 public function validation($data, $files) {
     $errors = parent::validation($data, $files);
     if (empty($data['cancel']) and !trim($data['labelname'])) {
         $errors['labelname'] = get_string('erroremptylabelname', 'local_mail');
     }
     return $errors;
 }
 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     $tocoursefilesid = $this->_customdata['tocoursefilesid'];
     $fromcoursefilesid = $this->_customdata['fromcoursefilesid'];
     if (isset($data['urls']) && count($data['urls'])) {
         foreach ($data['urls'] as $key => $urlaction) {
             switch ($urlaction) {
                 case QUESTION_FILEMOVE:
                     if (!has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $fromcoursefilesid))) {
                         $errors["urls[{$key}]"] = get_string('filecantmovefrom', 'question');
                     }
                     //no break; COPY check is also applied to MOVE action
                 //no break; COPY check is also applied to MOVE action
                 case QUESTION_FILECOPY:
                     if (!has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $tocoursefilesid))) {
                         $errors["urls[{$key}]"] = get_string('filecantmoveto', 'question');
                     }
                     break;
                 case QUESTION_FILEMOVELINKSONLY:
                 case QUESTION_FILEDONOTHING:
                     break;
             }
         }
     }
     //check that there hasn't been any changes in files between time form was displayed
     //and now when it has been submitted.
     if (isset($data['urls']) && count($data['urls']) != count($this->_customdata['urls'])) {
         $errors['urls[0]'] = get_string('errorfileschanged', 'question');
     }
     return $errors;
 }
 /**
  * Ensure that the data the user entered is valid.
  * @see lib/moodleform#validation()
  */
 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     if (!empty($data['admselcourse'])) {
         if (empty($data['admobj_select'])) {
             $errors['admobj_select'] = get_string('err_required', 'local_metadata');
         }
     } else {
         if (!empty($data['group_sel'])) {
             if (empty($data['group_select'])) {
                 $errors['group_select'] = get_string('err_required', 'local_metadata');
             }
         } else {
             if (!empty($data['admaddobjective'])) {
                 if (empty($data['admpro_select'])) {
                     $errors['admpro_select'] = get_string('err_required', 'local_metadata');
                 }
             } else {
                 if (!empty($data['admdelobjective'])) {
                     if (empty($data['admpro_current'])) {
                         $errors['admpro_current'] = get_string('err_required', 'local_metadata');
                     }
                 }
             }
         }
     }
     return $errors;
 }
Exemple #22
0
 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     // TODO - this reg expr can be improved
     if (!preg_match("/(\\(*\\s*\\bc\\d{1,2}\\b\\s*\\(*\\)*\\s*(\\(|and|or)\\s*)+\\(*\\s*\\bc\\d{1,2}\\b\\s*\\(*\\)*\\s*\$/i", $data['conditionexpr'])) {
         $errors['conditionexpr'] = get_string('badconditionexpr', 'block_configurable_reports');
     }
     if (substr_count($data['conditionexpr'], '(') != substr_count($data['conditionexpr'], ')')) {
         $errors['conditionexpr'] = get_string('badconditionexpr', 'block_configurable_reports');
     }
     if (isset($this->_customdata['elements']) && is_array($this->_customdata['elements'])) {
         $elements = $this->_customdata['elements'];
         $nel = count($elements);
         if (!empty($elements) && $nel > 1) {
             preg_match_all('/(\\d+)/', $data['conditionexpr'], $matches, PREG_PATTERN_ORDER);
             foreach ($matches[0] as $num) {
                 if ($num > $nel) {
                     $errors['conditionexpr'] = get_string('badconditionexpr', 'block_configurable_reports');
                     break;
                 }
             }
         }
     }
     return $errors;
 }
Exemple #23
0
	function validation($data, $files){
		$errors = parent::validation($data, $files);
		
		$errors = $this->_customdata['compclass']->validate_form_elements($data,$errors);
		
		return $errors;
	}	
Exemple #24
0
 /**
  * Form validation
  *
  * @param array $data
  * @param array $files
  * @return array $errors An array of errors
  */
 function validation($data, $files)
 {
     global $COURSE, $DB, $CFG;
     $errors = parent::validation($data, $files);
     $name = trim($data['name']);
     if (isset($data['idnumber'])) {
         $idnumber = trim($data['idnumber']);
     } else {
         $idnumber = '';
     }
     if ($data['id'] and $group = $DB->get_record('groups', array('id' => $data['id']))) {
         if (core_text::strtolower($group->name) != core_text::strtolower($name)) {
             if (groups_get_group_by_name($COURSE->id, $name)) {
                 $errors['name'] = get_string('groupnameexists', 'group', $name);
             }
         }
         if (!empty($idnumber) && $group->idnumber != $idnumber) {
             if (groups_get_group_by_idnumber($COURSE->id, $idnumber)) {
                 $errors['idnumber'] = get_string('idnumbertaken');
             }
         }
         if ($data['enrolmentkey'] != '') {
             $errmsg = '';
             if (!empty($CFG->groupenrolmentkeypolicy) && $group->enrolmentkey !== $data['enrolmentkey'] && !check_password_policy($data['enrolmentkey'], $errmsg)) {
                 // Enforce password policy when the password is changed.
                 $errors['enrolmentkey'] = $errmsg;
             } else {
                 // Prevent twice the same enrolment key in course groups.
                 $sql = "SELECT id FROM {groups} WHERE id <> :groupid AND courseid = :courseid AND enrolmentkey = :key";
                 $params = array('groupid' => $data['id'], 'courseid' => $COURSE->id, 'key' => $data['enrolmentkey']);
                 if ($DB->record_exists_sql($sql, $params)) {
                     $errors['enrolmentkey'] = get_string('enrolmentkeyalreadyinuse', 'group');
                 }
             }
         }
     } else {
         if (groups_get_group_by_name($COURSE->id, $name)) {
             $errors['name'] = get_string('groupnameexists', 'group', $name);
         } else {
             if (!empty($idnumber) && groups_get_group_by_idnumber($COURSE->id, $idnumber)) {
                 $errors['idnumber'] = get_string('idnumbertaken');
             } else {
                 if ($data['enrolmentkey'] != '') {
                     $errmsg = '';
                     if (!empty($CFG->groupenrolmentkeypolicy) && !check_password_policy($data['enrolmentkey'], $errmsg)) {
                         // Enforce password policy.
                         $errors['enrolmentkey'] = $errmsg;
                     } else {
                         if ($DB->record_exists('groups', array('courseid' => $COURSE->id, 'enrolmentkey' => $data['enrolmentkey']))) {
                             // Prevent the same enrolment key from being used multiple times in course groups.
                             $errors['enrolmentkey'] = get_string('enrolmentkeyalreadyinuse', 'group');
                         }
                     }
                 }
             }
         }
     }
     return $errors;
 }
 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     if (!isset($data['period']) || rlip_schedule_period_minutes($data['period']) < 5) {
         $errors['period'] = get_string('rlip_form_period_error', 'local_datahub');
     }
     return $errors;
 }
Exemple #26
0
 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     if (empty($data['shorten']) and core_text::strlen($data['search']) < core_text::strlen($data['replace'])) {
         $errors['shorten'] = get_string('required');
     }
     return $errors;
 }
 public function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     $timenow = time();
     $accessmanager = $this->_customdata['quizobj']->get_access_manager($timenow);
     $errors = array_merge($errors, $accessmanager->validate_preflight_check($data, $files, $this->_customdata['attemptid']));
     return $errors;
 }
Exemple #28
0
 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     if ($data['xaxis'] == $data['yaxis']) {
         $errors['yaxis'] = get_string('xandynotequal', 'block_configurable_reports');
     }
     return $errors;
 }
Exemple #29
0
 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     if (!preg_match("/^\\d+%?\$/i", trim($data['tablewidth']))) {
         $errors['tablewidth'] = get_string('badtablewidth', 'block_configurable_reports');
     }
     return $errors;
 }
Exemple #30
0
 function validation($fromform, $files)
 {
     $errors = parent::validation($fromform, $files);
     if (!empty($fromform['newcategory']) && trim($fromform['name']) == '') {
         $errors['name'] = get_string('categorynamecantbeblank', 'quiz');
     }
     return $errors;
 }