Commit a02e2eaf authored by Sam Hemelryk's avatar Sam Hemelryk
Browse files

Merge branch 'w16_MDL-32405_m23_estrict4' of git://github.com/skodak/moodle

parents 788c5164 c990e4bf
......@@ -210,7 +210,7 @@ class MoodleQuickForm_selectgroups extends HTML_QuickForm_element {
function loadArrayOptGroups($arr, $values=null)
{
if (!is_array($arr)) {
return PEAR::raiseError('Argument 1 of HTML_Select::loadArrayOptGroups is not a valid array');
return self::raiseError('Argument 1 of HTML_Select::loadArrayOptGroups is not a valid array');
}
if (isset($values)) {
$this->setSelected($values);
......@@ -255,7 +255,7 @@ class MoodleQuickForm_selectgroups extends HTML_QuickForm_element {
function loadArrayOptions($optgroup, $arr, $values=null)
{
if (!is_array($arr)) {
return PEAR::raiseError('Argument 1 of HTML_Select::loadArray is not a valid array');
return self::raiseError('Argument 1 of HTML_Select::loadArray is not a valid array');
}
if (isset($values)) {
$this->setSelected($values);
......
......@@ -61,7 +61,7 @@ function pear_handle_error($error){
print_object($error->backtrace);
}
if (!empty($CFG->debug) and $CFG->debug >= DEBUG_ALL){
if (!empty($CFG->debug) and ($CFG->debug >= DEBUG_ALL or $CFG->debug == -1)){
//TODO: this is a wrong place to init PEAR!
$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_CALLBACK;
$GLOBALS['_PEAR_default_error_options'] = 'pear_handle_error';
......@@ -2117,7 +2117,7 @@ function validate_' . $this->_formName . '(frm) {
}
if (!empty($elementList)) {
return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Nonexistant element(s): '" . implode("', '", array_keys($elementList)) . "' in HTML_QuickForm::freeze()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Nonexistant element(s): '" . implode("', '", array_keys($elementList)) . "' in HTML_QuickForm::freeze()", 'HTML_QuickForm_Error', true);
}
return true;
}
......
......@@ -89,6 +89,17 @@ class HTML_Common {
$this->setTabOffset($tabOffset);
} // end constructor
public static function raiseError($message = null,
$code = null,
$mode = null,
$options = null,
$userinfo = null,
$error_class = null,
$skipmsg = false) {
$pear = new PEAR();
return $pear->raiseError($message, $code, $mode, $options, $userinfo, $error_class, $skipmsg);
}
/**
* Returns the current API version
* @access public
......
......@@ -398,7 +398,7 @@ class HTML_QuickForm extends HTML_Common {
$this->setConstants($datasource->constantValues($this), $constantsFilter);
}
} else {
return PEAR::raiseError(null, QUICKFORM_INVALID_DATASOURCE, null, E_USER_WARNING, "Datasource is not an object in QuickForm::setDatasource()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_INVALID_DATASOURCE, null, E_USER_WARNING, "Datasource is not an object in QuickForm::setDatasource()", 'HTML_QuickForm_Error', true);
}
} // end func setDatasource
......@@ -421,13 +421,13 @@ class HTML_QuickForm extends HTML_Common {
if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) {
foreach ($filter as $val) {
if (!is_callable($val)) {
return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true);
} else {
$defaultValues = $this->_recursiveFilter($val, $defaultValues);
}
}
} elseif (!is_callable($filter)) {
return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true);
} else {
$defaultValues = $this->_recursiveFilter($filter, $defaultValues);
}
......@@ -460,13 +460,13 @@ class HTML_QuickForm extends HTML_Common {
if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) {
foreach ($filter as $val) {
if (!is_callable($val)) {
return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setConstants()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setConstants()", 'HTML_QuickForm_Error', true);
} else {
$constantValues = $this->_recursiveFilter($val, $constantValues);
}
}
} elseif (!is_callable($filter)) {
return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setConstants()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setConstants()", 'HTML_QuickForm_Error', true);
} else {
$constantValues = $this->_recursiveFilter($filter, $constantValues);
}
......@@ -557,7 +557,7 @@ class HTML_QuickForm extends HTML_Common {
{
$type = strtolower($type);
if (!HTML_QuickForm::isTypeRegistered($type)) {
$error = PEAR::raiseError(null, QUICKFORM_UNREGISTERED_ELEMENT, null, E_USER_WARNING, "Element '$type' does not exist in HTML_QuickForm::_loadElement()", 'HTML_QuickForm_Error', true);
$error = self::raiseError(null, QUICKFORM_UNREGISTERED_ELEMENT, null, E_USER_WARNING, "Element '$type' does not exist in HTML_QuickForm::_loadElement()", 'HTML_QuickForm_Error', true);
return $error;
}
$className = $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][$type][1];
......@@ -614,7 +614,7 @@ class HTML_QuickForm extends HTML_Common {
$elKeys = array_keys($this->_elements);
$this->_duplicateIndex[$elementName][] = end($elKeys);
} else {
$error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::addElement()", 'HTML_QuickForm_Error', true);
$error = self::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::addElement()", 'HTML_QuickForm_Error', true);
return $error;
}
} else {
......@@ -650,10 +650,10 @@ class HTML_QuickForm extends HTML_Common {
function &insertElementBefore(&$element, $nameAfter)
{
if (!empty($this->_duplicateIndex[$nameAfter])) {
$error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, 'Several elements named "' . $nameAfter . '" exist in HTML_QuickForm::insertElementBefore().', 'HTML_QuickForm_Error', true);
$error = self::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, 'Several elements named "' . $nameAfter . '" exist in HTML_QuickForm::insertElementBefore().', 'HTML_QuickForm_Error', true);
return $error;
} elseif (!$this->elementExists($nameAfter)) {
$error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$nameAfter' does not exist in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true);
$error = self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$nameAfter' does not exist in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true);
return $error;
}
$elementName = $element->getName();
......@@ -662,7 +662,7 @@ class HTML_QuickForm extends HTML_Common {
// Like in addElement(), check that it's not an incompatible duplicate
if (!empty($elementName) && isset($this->_elementIndex[$elementName])) {
if ($this->_elements[$this->_elementIndex[$elementName]]->getType() != $element->getType()) {
$error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true);
$error = self::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true);
return $error;
}
$duplicate = true;
......@@ -745,7 +745,7 @@ class HTML_QuickForm extends HTML_Common {
if (isset($this->_elementIndex[$element])) {
return $this->_elements[$this->_elementIndex[$element]];
} else {
$error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElement()", 'HTML_QuickForm_Error', true);
$error = self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElement()", 'HTML_QuickForm_Error', true);
return $error;
}
} // end func getElement
......@@ -768,7 +768,7 @@ class HTML_QuickForm extends HTML_Common {
function &getElementValue($element)
{
if (!isset($this->_elementIndex[$element])) {
$error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElementValue()", 'HTML_QuickForm_Error', true);
$error = self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElementValue()", 'HTML_QuickForm_Error', true);
return $error;
}
$value = $this->_elements[$this->_elementIndex[$element]]->getValue();
......@@ -983,7 +983,7 @@ class HTML_QuickForm extends HTML_Common {
function &removeElement($elementName, $removeRules = true)
{
if (!isset($this->_elementIndex[$elementName])) {
$error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$elementName' does not exist in HTML_QuickForm::removeElement()", 'HTML_QuickForm_Error', true);
$error = self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$elementName' does not exist in HTML_QuickForm::removeElement()", 'HTML_QuickForm_Error', true);
return $error;
}
$el =& $this->_elements[$this->_elementIndex[$elementName]];
......@@ -1024,17 +1024,17 @@ class HTML_QuickForm extends HTML_Common {
{
if (!$force) {
if (!is_array($element) && !$this->elementExists($element)) {
return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
} elseif (is_array($element)) {
foreach ($element as $el) {
if (!$this->elementExists($el)) {
return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$el' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$el' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
}
}
}
}
if (false === ($newName = $this->isRuleRegistered($type, true))) {
return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true);
} elseif (is_string($newName)) {
$type = $newName;
}
......@@ -1089,7 +1089,7 @@ class HTML_QuickForm extends HTML_Common {
function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $validation = 'server', $reset = false)
{
if (!$this->elementExists($group)) {
return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Group '$group' does not exist in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Group '$group' does not exist in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true);
}
$groupObj =& $this->getElement($group);
......@@ -1103,7 +1103,7 @@ class HTML_QuickForm extends HTML_Common {
$reset = isset($rule[4]) && $rule[4];
$type = $rule[1];
if (false === ($newName = $this->isRuleRegistered($type, true))) {
return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true);
} elseif (is_string($newName)) {
$type = $newName;
}
......@@ -1131,7 +1131,7 @@ class HTML_QuickForm extends HTML_Common {
}
} elseif (is_string($arg1)) {
if (false === ($newName = $this->isRuleRegistered($type, true))) {
return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true);
} elseif (is_string($newName)) {
$type = $newName;
}
......@@ -1179,7 +1179,7 @@ class HTML_QuickForm extends HTML_Common {
function addFormRule($rule)
{
if (!is_callable($rule)) {
return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, 'Callback function does not exist in HTML_QuickForm::addFormRule()', 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, 'Callback function does not exist in HTML_QuickForm::addFormRule()', 'HTML_QuickForm_Error', true);
}
$this->_formRules[] = $rule;
}
......@@ -1198,7 +1198,7 @@ class HTML_QuickForm extends HTML_Common {
function applyFilter($element, $filter)
{
if (!is_callable($filter)) {
return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::applyFilter()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::applyFilter()", 'HTML_QuickForm_Error', true);
}
if ($element == '__ALL__') {
$this->_submitValues = $this->_recursiveFilter($filter, $this->_submitValues);
......@@ -1528,7 +1528,7 @@ class HTML_QuickForm extends HTML_Common {
if (is_array($res)) {
$this->_errors += $res;
} else {
return PEAR::raiseError(null, QUICKFORM_ERROR, null, E_USER_WARNING, 'Form rule callback returned invalid value in HTML_QuickForm::validate()', 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_ERROR, null, E_USER_WARNING, 'Form rule callback returned invalid value in HTML_QuickForm::validate()', 'HTML_QuickForm_Error', true);
}
}
}
......@@ -1568,7 +1568,7 @@ class HTML_QuickForm extends HTML_Common {
}
if (!empty($elementList)) {
return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Nonexistant element(s): '" . implode("', '", array_keys($elementList)) . "' in HTML_QuickForm::freeze()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Nonexistant element(s): '" . implode("', '", array_keys($elementList)) . "' in HTML_QuickForm::freeze()", 'HTML_QuickForm_Error', true);
}
return true;
} // end func freeze
......@@ -1603,7 +1603,7 @@ class HTML_QuickForm extends HTML_Common {
function process($callback, $mergeFiles = true)
{
if (!is_callable($callback)) {
return PEAR::raiseError(null, QUICKFORM_INVALID_PROCESS, null, E_USER_WARNING, "Callback function does not exist in QuickForm::process()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_INVALID_PROCESS, null, E_USER_WARNING, "Callback function does not exist in QuickForm::process()", 'HTML_QuickForm_Error', true);
}
$values = ($mergeFiles === true) ? HTML_QuickForm::arrayMerge($this->_submitValues, $this->_submitFiles) : $this->_submitValues;
return call_user_func($callback, $values);
......@@ -1826,7 +1826,7 @@ class HTML_QuickForm extends HTML_Common {
function exportValue($element)
{
if (!isset($this->_elementIndex[$element])) {
return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElementValue()", 'HTML_QuickForm_Error', true);
return self::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElementValue()", 'HTML_QuickForm_Error', true);
}
$value = $this->_elements[$this->_elementIndex[$element]]->exportValue($this->_submitValues, false);
if (isset($this->_duplicateIndex[$element])) {
......@@ -1912,7 +1912,7 @@ class HTML_QuickForm extends HTML_Common {
* @param mixed result code
* @return bool whether $value is an error
*/
function isError($value)
static function isError($value)
{
return (is_object($value) && is_a($value, 'html_quickform_error'));
} // end func isError
......@@ -1927,7 +1927,7 @@ class HTML_QuickForm extends HTML_Common {
* @param int error code
* @return string error message
*/
function errorMessage($value)
static function errorMessage($value)
{
// make the variable static so that it only has to do the defining on the first call
static $errorMessages;
......
......@@ -165,7 +165,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
switch ($event) {
case 'updateValue':
if ($caller->getAttribute('method') == 'get') {
return PEAR::raiseError('Cannot add a file upload field to a GET method form');
return self::raiseError('Cannot add a file upload field to a GET method form');
}
$this->_value = $this->_findValue();
$caller->updateAttributes(array('enctype' => 'multipart/form-data'));
......
......@@ -326,7 +326,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element {
function loadArray($arr, $values=null)
{
if (!is_array($arr)) {
return PEAR::raiseError('Argument 1 of HTML_Select::loadArray is not a valid array');
return self::raiseError('Argument 1 of HTML_Select::loadArray is not a valid array');
}
if (isset($values)) {
$this->setSelected($values);
......@@ -358,7 +358,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element {
function loadDbResult(&$result, $textCol=null, $valueCol=null, $values=null)
{
if (!is_object($result) || !is_a($result, 'db_result')) {
return PEAR::raiseError('Argument 1 of HTML_Select::loadDbResult is not a valid DB_result');
return self::raiseError('Argument 1 of HTML_Select::loadDbResult is not a valid DB_result');
}
if (isset($values)) {
$this->setValue($values);
......@@ -401,7 +401,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element {
} elseif (is_subclass_of($conn, "db_common")) {
$dbConn = &$conn;
} else {
return PEAR::raiseError('Argument 1 of HTML_Select::loadQuery is not a valid type');
return self::raiseError('Argument 1 of HTML_Select::loadQuery is not a valid type');
}
$result = $dbConn->query($sql);
if (DB::isError($result)) {
......
......@@ -58,7 +58,7 @@ class profile_define_base {
* editing a profile field specific to the current data type
* @param object instance of the moodleform class
*/
function define_form_specific(&$form) {
function define_form_specific($form) {
/// do nothing - overwrite if necessary
}
......@@ -115,6 +115,7 @@ class profile_define_base {
* Validate the data from the add/edit profile field form
* that is specific to the current data type
* @param object data from the add/edit profile field form
* @param array files
* @return array associative array of error messages
*/
function define_validate_specific($data, $files) {
......
......@@ -2,7 +2,7 @@
class profile_define_checkbox extends profile_define_base {
function define_form_specific(&$form) {
function define_form_specific($form) {
/// select whether or not this should be checked by default
$form->addElement('selectyesno', 'defaultdata', get_string('profiledefaultchecked', 'admin'));
$form->setDefault('defaultdata', 0); // defaults to 'no'
......
......@@ -22,9 +22,9 @@ class profile_field_checkbox extends profile_field_base {
}
}
function edit_field_add(&$mform) {
function edit_field_add($mform) {
/// Create the form field
$checkbox = &$mform->addElement('advcheckbox', $this->inputname, format_string($this->field->name));
$checkbox = $mform->addElement('advcheckbox', $this->inputname, format_string($this->field->name));
if ($this->data == '1') {
$checkbox->setChecked(true);
}
......
......@@ -47,9 +47,10 @@ class profile_define_datetime extends profile_define_base {
* Validate the data from the profile field form
*
* @param object data from the add/edit profile field form
* @param array files
* @return array associative array of error messages
*/
function define_validate_specific($data) {
function define_validate_specific($data, $files) {
$errors = array();
// Make sure the start year is not greater than the end year
......
......@@ -2,7 +2,7 @@
class profile_define_menu extends profile_define_base {
function define_form_specific(&$form) {
function define_form_specific($form) {
/// Param 1 for menu type contains the options
$form->addElement('textarea', 'param1', get_string('profilemenuoptions', 'admin'), array('rows' => 6, 'cols' => 40));
$form->setType('param1', PARAM_MULTILANG);
......
......@@ -34,7 +34,7 @@ class profile_field_menu extends profile_field_base {
* Overwrites the base class method
* @param object moodleform instance
*/
function edit_field_add(&$mform) {
function edit_field_add($mform) {
$mform->addElement('select', $this->inputname, format_string($this->field->name), $this->options);
}
......@@ -42,7 +42,7 @@ class profile_field_menu extends profile_field_base {
* Set the default value for this field instance
* Overwrites the base class method
*/
function edit_field_set_default(&$mform) {
function edit_field_set_default($mform) {
if (FALSE !==array_search($this->field->defaultdata, $this->options)){
$defaultkey = (int)array_search($this->field->defaultdata, $this->options);
} else {
......@@ -55,10 +55,11 @@ class profile_field_menu extends profile_field_base {
* The data from the form returns the key. This should be converted to the
* respective option string to be saved in database
* Overwrites base class accessor method
* @param integer the key returned from the select input in the form
* @param mixed $data - the key returned from the select input in the form
* @param stdClass $datarecord The object that will be used to save the record
*/
function edit_save_data_preprocess($key) {
return isset($this->options[$key]) ? $this->options[$key] : NULL;
function edit_save_data_preprocess($data, $datarecord) {
return isset($this->options[$data]) ? $this->options[$data] : NULL;
}
/**
......@@ -67,7 +68,7 @@ class profile_field_menu extends profile_field_base {
* Overwrites the base class method
* @param object user object
*/
function edit_load_user_data(&$user) {
function edit_load_user_data($user) {
$user->{$this->inputname} = $this->datakey;
}
......@@ -75,7 +76,7 @@ class profile_field_menu extends profile_field_base {
* HardFreeze the field if locked.
* @param object instance of the moodleform class
*/
function edit_field_set_locked(&$mform) {
function edit_field_set_locked($mform) {
if (!$mform->elementExists($this->inputname)) {
return;
}
......
......@@ -2,7 +2,7 @@
class profile_define_text extends profile_define_base {
function define_form_specific(&$form) {
function define_form_specific($form) {
/// Default data
$form->addElement('text', 'defaultdata', get_string('profiledefaultdata', 'admin'), 'size="50"');
$form->setType('defaultdata', PARAM_MULTILANG);
......
......@@ -26,7 +26,7 @@ class profile_field_text extends profile_field_base {
return $data;
}
function edit_field_add(&$mform) {
function edit_field_add($mform) {
$size = $this->field->param1;
$maxlength = $this->field->param2;
$fieldtype = ($this->field->param3 == 1 ? 'password' : 'text');
......
......@@ -2,7 +2,7 @@
class profile_define_textarea extends profile_define_base {
function define_form_specific(&$form) {
function define_form_specific($form) {
/// Default data
$form->addElement('editor', 'defaultdata', get_string('profiledefaultdata', 'admin'));
$form->setType('defaultdata', PARAM_RAW); // we have to trust person with capability to edit this default description
......
......@@ -2,7 +2,7 @@
class profile_field_textarea extends profile_field_base {
function edit_field_add(&$mform) {
function edit_field_add($mform) {
$cols = $this->field->param1;
$rows = $this->field->param2;
......@@ -17,7 +17,7 @@ class profile_field_textarea extends profile_field_base {
return false;
}
function edit_save_data_preprocess($data, &$datarecord) {
function edit_save_data_preprocess($data, $datarecord) {
if (is_array($data)) {
$datarecord->dataformat = $data['format'];
$data = $data['text'];
......@@ -25,7 +25,7 @@ class profile_field_textarea extends profile_field_base {
return $data;
}
function edit_load_user_data(&$user) {
function edit_load_user_data($user) {
if ($this->data !== NULL) {
$this->data = clean_text($this->data, $this->dataformat);
$user->{$this->inputname} = array('text'=>$this->data, 'format'=>$this->dataformat);
......
......@@ -43,7 +43,7 @@ class profile_field_base {
* Abstract method: Adds the profile field to the moodle form class
* @param form instance of the moodleform class
*/
function edit_field_add(&$mform) {
function edit_field_add($mform) {
print_error('mustbeoveride', 'debug', '', 'edit_field_add');
}
......@@ -64,7 +64,7 @@ class profile_field_base {
* @param object instance of the moodleform class
* $return boolean
*/
function edit_field(&$mform) {
function edit_field($mform) {
if ($this->field->visible != PROFILE_VISIBLE_NONE
or has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM))) {
......@@ -82,7 +82,7 @@ class profile_field_base {
* @param object instance of the moodleform class
* $return boolean
*/
function edit_after_data(&$mform) {
function edit_after_data($mform) {
if ($this->field->visible != PROFILE_VISIBLE_NONE
or has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM))) {
......@@ -158,7 +158,7 @@ class profile_field_base {
* Sets the default data for the field in the form object
* @param object instance of the moodleform class
*/
function edit_field_set_default(&$mform) {
function edit_field_set_default($mform) {
if (!empty($default)) {
$mform->setDefault($this->inputname, $this->field->defaultdata);
}
......@@ -168,7 +168,7 @@ class profile_field_base {
* Sets the required flag for the field in the form object
* @param object instance of the moodleform class
*/
function edit_field_set_required(&$mform) {
function edit_field_set_required($mform) {
if ($this->is_required() and !has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM))) {
$mform->addRule($this->inputname, get_string('required'), 'required', null, 'client');
}
......@@ -178,7 +178,7 @@ class profile_field_base {
* HardFreeze the field if locked.
* @param object instance of the moodleform class
*/
function edit_field_set_locked(&$mform) {
function edit_field_set_locked($mform) {
if (!$mform->elementExists($this->inputname)) {
return;
}
......@@ -190,11 +190,11 @@ class profile_field_base {
/**
* Hook for child classess to process the data before it gets saved in database
* @param mixed
* @param stdClass The object that will be used to save the record
* @param mixed $data
* @param stdClass $datarecord The object that will be used to save the record
* @return mixed
*/
function edit_save_data_preprocess($data, &$datarecord) {
function edit_save_data_preprocess($data, $datarecord) {
return $data;
}
......@@ -203,7 +203,7 @@ class profile_field_base {
* form
* @param object a user object
*/
function edit_load_user_data(&$user) {
function edit_load_user_data($user) {
if ($this->data !== NULL) {
$user->{$this->inputname} = $this->data;
}
......@@ -336,7 +336,7 @@ class profile_field_base {
/***** General purpose functions for customisable user profiles *****/
function profile_load_data(&$user) {
function profile_load_data($user) {
global $CFG, $DB;
if ($fields = $DB->get_records('user_info_field')) {
......@@ -353,7 +353,7 @@ function profile_load_data(&$user) {
* Print out the customisable categories and fields for a users profile
* @param object instance of the moodleform class
*/
function profile_definition(&$mform) {
function profile_definition($mform) {
global $CFG, $DB;
// if user is "admin" fields are displayed regardless
......@@ -386,7 +386,7 @@ function profile_definition(&$mform) {
}
}
function profile_definition_after_data(&$mform, $userid) {
function profile_definition_after_data($mform, $userid) {
global $CFG, $DB;
$userid = ($userid < 0) ? 0 : (int)$userid;
......@@ -453,7 +453,7 @@ function profile_display_fields($userid) {
* should appear on the signup page
* @param object moodle form object
*/
function profile_signup_fields(&$mform) {
function profile_signup_fields($mform) {
global $CFG, $DB;
//only retrieve required custom fields (with category information)
......@@ -513,7 +513,7 @@ function profile_user_record($userid) {
* @param object $user user object
* @return void $user object is modified
*/
function profile_load_custom_fields(&$user) {
function profile_load_custom_fields($user) {
$user->profile = (array)profile_user_record($user->id);
}
......