Commit fa154636 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Add validation of max length for some profile fields (bug #618553)


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent e24210b8
......@@ -39,6 +39,7 @@ safe_require('artefact', 'internal');
$fieldset = param_alpha('fs', 'aboutme');
$element_list = call_static_method('ArtefactTypeProfile', 'get_all_fields');
$element_data = ArtefactTypeProfile::get_field_element_data();
$element_required = call_static_method('ArtefactTypeProfile', 'get_mandatory_fields');
// load existing profile information
......@@ -97,6 +98,10 @@ foreach ( $element_list as $element => $type ) {
'title' => get_string($element, 'artefact.internal'),
);
if (isset($element_data[$element]['rules'])) {
$items[$element]['rules'] = $element_data[$element]['rules'];
}
if ($type == 'wysiwyg') {
$items[$element]['rows'] = 10;
$items[$element]['cols'] = 50;
......
......@@ -348,6 +348,15 @@ class ArtefactTypeProfile extends ArtefactType {
);
}
public static function get_field_element_data() {
return array(
'firstname' => array('rules' => array('maxlength' => 50)),
'lastname' => array('rules' => array('maxlength' => 50)),
'studentid' => array('rules' => array('maxlength' => 50)),
'preferredname' => array('rules' => array('maxlength' => 50)),
);
}
public static function get_mandatory_fields() {
$m = array();
$all = self::get_all_fields();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment