$form->addElement('htmleditor', 'description', get_string('profiledescription', 'admin'));
$form->setHelpButton('description', array('text', get_string('helptext')));
- $form->setType('description', PARAM_MULTILANG);
$form->addElement('selectyesno', 'required', get_string('profilerequired', 'admin'));
* @param string direction of move
* @return boolean success of operation
*/
-function profile_move_field ($id, $move) {
+function profile_move_field($id, $move) {
/// Get the field object
if (!$field = get_record('user_info_field', 'id', $id, '', '', '', '', 'id, sortorder, categoryid')) {
return false;
* @param string direction of move
* @return boolean success of operation
*/
-function profile_move_category ($id, $move) {
+function profile_move_category($id, $move) {
/// Get the category object
if (!($category = get_record('user_info_category', 'id', $id, '', '', '', '', 'id, sortorder'))) {
return false;
}
- function display_field_add(&$form) {
+ function display_field_add(&$mform) {
/// Create the form field
- $form->addElement('select', $this->inputname, format_string($this->field->name), $this->options);
+ $mform->addElement('select', $this->inputname, format_string($this->field->name), $this->options);
}
/// Override base class method
- function display_field_default(&$form) {
+ function display_field_default(&$mform) {
$defaultkey = (int)array_search($field->defaultdata, $this->options);
- $form->setDefault($this->inputname, $defaultkey);
+ $mform->setDefault($this->inputname, $defaultkey);
}
}
/// Param 1 for text type is the size of the field
$form->addElement('text', 'param1', get_string('profilefieldsize', 'admin'), 'size="6"');
- $form->setDefault('param1', 50);
+ $form->setDefault('param1', 30);
$form->setType('param1', PARAM_INT);
/// Param 2 for text type is the maxlength of the field
$form->addElement('text', 'param2', get_string('profilefieldmaxlength', 'admin'), 'size="6"');
- $form->setDefault('param2', 100);
+ $form->setDefault('param2', 2048);
$form->setType('param2', PARAM_INT);
}
class profile_field_text extends profile_field_base {
- function display_field_add(&$form) {
- /// Param 1 for text type is the size of the field
- $size = (empty($this->field->param1)) ? '30' : $this->field->param1;
-
- /// Param 2 for text type is the maxlength of the field
- $maxlength = (empty($this->field->param2)) ? '2048' : $this->field->param2;
+ function display_field_add(&$mform) {
+ $size = $this->field->param1;
+ $maxlength = $this->field->param2;
/// Create the form field
- $form->addElement('text', $this->inputname, format_string($this->field->name), 'maxlength="'.$maxlength.'" size="'.$size.'" ');
- $form->setType($this->inputname, PARAM_MULTILANG);
+ $mform->addElement('text', $this->inputname, format_string($this->field->name), 'maxlength="'.$maxlength.'" size="'.$size.'" ');
+ $mform->setType($this->inputname, PARAM_MULTILANG);
}
}
* @param object instance of the moodleform class
* $return boolean
*/
- function display_field(&$form) {
+ function display_field(&$mform) {
if ($this->field->visible != PROFILE_VISIBLE_NONE
or has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
- $this->display_field_add($form);
- $this->display_field_set_default($form);
- $this->display_field_set_required($form);
- $this->display_field_set_locked($form);
+ $this->display_field_add($mform);
+ $this->display_field_set_default($mform);
+ $this->display_field_set_required($mform);
+ $this->display_field_set_locked($mform);
}
}
* Adds the profile field to the moodle form class
* @param form instance of the moodleform class
*/
- function display_field_add(&$form) {
+ function display_field_add(&$mform) {
error('This abstract method must be overriden');
}
* Sets the default data for the field in the form object
* @param object instance of the moodleform class
*/
- function display_field_set_default(&$form) {
+ function display_field_set_default(&$mform) {
if (!empty($default)) {
- $form->setDefault($this->inputname, $this->field->defaultdata);
+ $mform->setDefault($this->inputname, $this->field->defaultdata);
}
}
* Sets the required flag for the field in the form object
* @param object instance of the moodleform class
*/
- function display_field_set_required(&$form) {
+ function display_field_set_required(&$mform) {
if ($this->field->required and !has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
- $form->addRule($this->inputname, get_string('required'), 'required', null, 'client');
+ $mform->addRule($this->inputname, get_string('required'), 'required', null, 'client');
}
}
* HardFreeze the field if locked.
* @param object instance of the moodleform class
*/
- function display_field_set_locked(&$form) {
+ function display_field_set_locked(&$mform) {
if ($this->field->locked and !has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
- $form->hardFreeze($this->inputname);
+ $mform->hardFreeze($this->inputname);
}
}
* Print out the customisable categories and fields for a users profile
* @param object instance of the moodleform class
*/
-function profile_definition(&$form) {
+function profile_definition(&$mform) {
global $CFG;
if ($categories = get_records_select('user_info_category', '', 'sortorder ASC')) {
foreach ($categories as $category) {
if ($fields = get_records_select('user_info_field', "categoryid=$category->id", 'sortorder ASC')) {
- $form->addElement('header', 'category_'.$category->id, format_string($category->name));
+ $mform->addElement('header', 'category_'.$category->id, format_string($category->name));
foreach ($fields as $field) {
require_once($CFG->dirroot.'/user/profile/field/'.$field->datatype.'/field.class.php');
$newfield = 'profile_field_'.$field->datatype;
$formfield = new $newfield($field->id);
- $formfield->display_field($form);
+ $formfield->display_field($mform);
}
}