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 { ...@@ -210,7 +210,7 @@ class MoodleQuickForm_selectgroups extends HTML_QuickForm_element {
function loadArrayOptGroups($arr, $values=null) function loadArrayOptGroups($arr, $values=null)
{ {
if (!is_array($arr)) { 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)) { if (isset($values)) {
$this->setSelected($values); $this->setSelected($values);
...@@ -255,7 +255,7 @@ class MoodleQuickForm_selectgroups extends HTML_QuickForm_element { ...@@ -255,7 +255,7 @@ class MoodleQuickForm_selectgroups extends HTML_QuickForm_element {
function loadArrayOptions($optgroup, $arr, $values=null) function loadArrayOptions($optgroup, $arr, $values=null)
{ {
if (!is_array($arr)) { 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)) { if (isset($values)) {
$this->setSelected($values); $this->setSelected($values);
......
...@@ -61,7 +61,7 @@ function pear_handle_error($error){ ...@@ -61,7 +61,7 @@ function pear_handle_error($error){
print_object($error->backtrace); 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! //TODO: this is a wrong place to init PEAR!
$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_CALLBACK; $GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_CALLBACK;
$GLOBALS['_PEAR_default_error_options'] = 'pear_handle_error'; $GLOBALS['_PEAR_default_error_options'] = 'pear_handle_error';
...@@ -2117,7 +2117,7 @@ function validate_' . $this->_formName . '(frm) { ...@@ -2117,7 +2117,7 @@ function validate_' . $this->_formName . '(frm) {
} }
if (!empty($elementList)) { 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; return true;
} }
......
...@@ -89,6 +89,17 @@ class HTML_Common { ...@@ -89,6 +89,17 @@ class HTML_Common {
$this->setTabOffset($tabOffset); $this->setTabOffset($tabOffset);
} // end constructor } // 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 * Returns the current API version
* @access public * @access public
......
...@@ -398,7 +398,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -398,7 +398,7 @@ class HTML_QuickForm extends HTML_Common {
$this->setConstants($datasource->constantValues($this), $constantsFilter); $this->setConstants($datasource->constantValues($this), $constantsFilter);
} }
} else { } 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 } // end func setDatasource
...@@ -421,13 +421,13 @@ class HTML_QuickForm extends HTML_Common { ...@@ -421,13 +421,13 @@ class HTML_QuickForm extends HTML_Common {
if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) { if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) {
foreach ($filter as $val) { foreach ($filter as $val) {
if (!is_callable($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 { } else {
$defaultValues = $this->_recursiveFilter($val, $defaultValues); $defaultValues = $this->_recursiveFilter($val, $defaultValues);
} }
} }
} elseif (!is_callable($filter)) { } 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 { } else {
$defaultValues = $this->_recursiveFilter($filter, $defaultValues); $defaultValues = $this->_recursiveFilter($filter, $defaultValues);
} }
...@@ -460,13 +460,13 @@ class HTML_QuickForm extends HTML_Common { ...@@ -460,13 +460,13 @@ class HTML_QuickForm extends HTML_Common {
if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) { if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) {
foreach ($filter as $val) { foreach ($filter as $val) {
if (!is_callable($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 { } else {
$constantValues = $this->_recursiveFilter($val, $constantValues); $constantValues = $this->_recursiveFilter($val, $constantValues);
} }
} }
} elseif (!is_callable($filter)) { } 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 { } else {
$constantValues = $this->_recursiveFilter($filter, $constantValues); $constantValues = $this->_recursiveFilter($filter, $constantValues);
} }
...@@ -557,7 +557,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -557,7 +557,7 @@ class HTML_QuickForm extends HTML_Common {
{ {
$type = strtolower($type); $type = strtolower($type);
if (!HTML_QuickForm::isTypeRegistered($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; return $error;
} }
$className = $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][$type][1]; $className = $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][$type][1];
...@@ -614,7 +614,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -614,7 +614,7 @@ class HTML_QuickForm extends HTML_Common {
$elKeys = array_keys($this->_elements); $elKeys = array_keys($this->_elements);
$this->_duplicateIndex[$elementName][] = end($elKeys); $this->_duplicateIndex[$elementName][] = end($elKeys);
} else { } 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; return $error;
} }
} else { } else {
...@@ -650,10 +650,10 @@ class HTML_QuickForm extends HTML_Common { ...@@ -650,10 +650,10 @@ class HTML_QuickForm extends HTML_Common {
function &insertElementBefore(&$element, $nameAfter) function &insertElementBefore(&$element, $nameAfter)
{ {
if (!empty($this->_duplicateIndex[$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; return $error;
} elseif (!$this->elementExists($nameAfter)) { } 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; return $error;
} }
$elementName = $element->getName(); $elementName = $element->getName();
...@@ -662,7 +662,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -662,7 +662,7 @@ class HTML_QuickForm extends HTML_Common {
// Like in addElement(), check that it's not an incompatible duplicate // Like in addElement(), check that it's not an incompatible duplicate
if (!empty($elementName) && isset($this->_elementIndex[$elementName])) { if (!empty($elementName) && isset($this->_elementIndex[$elementName])) {
if ($this->_elements[$this->_elementIndex[$elementName]]->getType() != $element->getType()) { 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; return $error;
} }
$duplicate = true; $duplicate = true;
...@@ -745,7 +745,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -745,7 +745,7 @@ class HTML_QuickForm extends HTML_Common {
if (isset($this->_elementIndex[$element])) { if (isset($this->_elementIndex[$element])) {
return $this->_elements[$this->_elementIndex[$element]]; return $this->_elements[$this->_elementIndex[$element]];
} else { } 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; return $error;
} }
} // end func getElement } // end func getElement
...@@ -768,7 +768,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -768,7 +768,7 @@ class HTML_QuickForm extends HTML_Common {
function &getElementValue($element) function &getElementValue($element)
{ {
if (!isset($this->_elementIndex[$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; return $error;
} }
$value = $this->_elements[$this->_elementIndex[$element]]->getValue(); $value = $this->_elements[$this->_elementIndex[$element]]->getValue();
...@@ -983,7 +983,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -983,7 +983,7 @@ class HTML_QuickForm extends HTML_Common {
function &removeElement($elementName, $removeRules = true) function &removeElement($elementName, $removeRules = true)
{ {
if (!isset($this->_elementIndex[$elementName])) { 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; return $error;
} }
$el =& $this->_elements[$this->_elementIndex[$elementName]]; $el =& $this->_elements[$this->_elementIndex[$elementName]];
...@@ -1024,17 +1024,17 @@ class HTML_QuickForm extends HTML_Common { ...@@ -1024,17 +1024,17 @@ class HTML_QuickForm extends HTML_Common {
{ {
if (!$force) { if (!$force) {
if (!is_array($element) && !$this->elementExists($element)) { 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)) { } elseif (is_array($element)) {
foreach ($element as $el) { foreach ($element as $el) {
if (!$this->elementExists($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))) { 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)) { } elseif (is_string($newName)) {
$type = $newName; $type = $newName;
} }
...@@ -1089,7 +1089,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -1089,7 +1089,7 @@ class HTML_QuickForm extends HTML_Common {
function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $validation = 'server', $reset = false) function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $validation = 'server', $reset = false)
{ {
if (!$this->elementExists($group)) { 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); $groupObj =& $this->getElement($group);
...@@ -1103,7 +1103,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -1103,7 +1103,7 @@ class HTML_QuickForm extends HTML_Common {
$reset = isset($rule[4]) && $rule[4]; $reset = isset($rule[4]) && $rule[4];
$type = $rule[1]; $type = $rule[1];
if (false === ($newName = $this->isRuleRegistered($type, 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::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)) { } elseif (is_string($newName)) {
$type = $newName; $type = $newName;
} }
...@@ -1131,7 +1131,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -1131,7 +1131,7 @@ class HTML_QuickForm extends HTML_Common {
} }
} elseif (is_string($arg1)) { } elseif (is_string($arg1)) {
if (false === ($newName = $this->isRuleRegistered($type, 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::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)) { } elseif (is_string($newName)) {
$type = $newName; $type = $newName;
} }
...@@ -1179,7 +1179,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -1179,7 +1179,7 @@ class HTML_QuickForm extends HTML_Common {
function addFormRule($rule) function addFormRule($rule)
{ {
if (!is_callable($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; $this->_formRules[] = $rule;
} }
...@@ -1198,7 +1198,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -1198,7 +1198,7 @@ class HTML_QuickForm extends HTML_Common {
function applyFilter($element, $filter) function applyFilter($element, $filter)
{ {
if (!is_callable($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__') { if ($element == '__ALL__') {
$this->_submitValues = $this->_recursiveFilter($filter, $this->_submitValues); $this->_submitValues = $this->_recursiveFilter($filter, $this->_submitValues);
...@@ -1528,7 +1528,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -1528,7 +1528,7 @@ class HTML_QuickForm extends HTML_Common {
if (is_array($res)) { if (is_array($res)) {
$this->_errors += $res; $this->_errors += $res;
} else { } 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 { ...@@ -1568,7 +1568,7 @@ class HTML_QuickForm extends HTML_Common {
} }
if (!empty($elementList)) { 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; return true;
} // end func freeze } // end func freeze
...@@ -1603,7 +1603,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -1603,7 +1603,7 @@ class HTML_QuickForm extends HTML_Common {
function process($callback, $mergeFiles = true) function process($callback, $mergeFiles = true)
{ {
if (!is_callable($callback)) { 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; $values = ($mergeFiles === true) ? HTML_QuickForm::arrayMerge($this->_submitValues, $this->_submitFiles) : $this->_submitValues;
return call_user_func($callback, $values); return call_user_func($callback, $values);
...@@ -1826,7 +1826,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -1826,7 +1826,7 @@ class HTML_QuickForm extends HTML_Common {
function exportValue($element) function exportValue($element)
{ {
if (!isset($this->_elementIndex[$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); $value = $this->_elements[$this->_elementIndex[$element]]->exportValue($this->_submitValues, false);
if (isset($this->_duplicateIndex[$element])) { if (isset($this->_duplicateIndex[$element])) {
...@@ -1912,7 +1912,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -1912,7 +1912,7 @@ class HTML_QuickForm extends HTML_Common {
* @param mixed result code * @param mixed result code
* @return bool whether $value is an error * @return bool whether $value is an error
*/ */
function isError($value) static function isError($value)
{ {
return (is_object($value) && is_a($value, 'html_quickform_error')); return (is_object($value) && is_a($value, 'html_quickform_error'));
} // end func isError } // end func isError
...@@ -1927,7 +1927,7 @@ class HTML_QuickForm extends HTML_Common { ...@@ -1927,7 +1927,7 @@ class HTML_QuickForm extends HTML_Common {
* @param int error code * @param int error code
* @return string error message * @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 // make the variable static so that it only has to do the defining on the first call
static $errorMessages; static $errorMessages;
......
...@@ -165,7 +165,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input ...@@ -165,7 +165,7 @@ class HTML_QuickForm_file extends HTML_QuickForm_input
switch ($event) { switch ($event) {
case 'updateValue': case 'updateValue':
if ($caller->getAttribute('method') == 'get') { 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(); $this->_value = $this->_findValue();
$caller->updateAttributes(array('enctype' => 'multipart/form-data')); $caller->updateAttributes(array('enctype' => 'multipart/form-data'));
......
...@@ -326,7 +326,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element { ...@@ -326,7 +326,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element {
function loadArray($arr, $values=null) function loadArray($arr, $values=null)
{ {
if (!is_array($arr)) { 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)) { if (isset($values)) {
$this->setSelected($values); $this->setSelected($values);
...@@ -358,7 +358,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element { ...@@ -358,7 +358,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element {
function loadDbResult(&$result, $textCol=null, $valueCol=null, $values=null) function loadDbResult(&$result, $textCol=null, $valueCol=null, $values=null)
{ {
if (!is_object($result) || !is_a($result, 'db_result')) { 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)) { if (isset($values)) {
$this->setValue($values); $this->setValue($values);
...@@ -401,7 +401,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element { ...@@ -401,7 +401,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element {
} elseif (is_subclass_of($conn, "db_common")) { } elseif (is_subclass_of($conn, "db_common")) {
$dbConn = &$conn; $dbConn = &$conn;
} else { } 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); $result = $dbConn->query($sql);
if (DB::isError($result)) { if (DB::isError($result)) {
......
...@@ -58,7 +58,7 @@ class profile_define_base { ...@@ -58,7 +58,7 @@ class profile_define_base {
* editing a profile field specific to the current data type * editing a profile field specific to the current data type
* @param object instance of the moodleform class * @param object instance of the moodleform class
*/ */
function define_form_specific(&$form) { function define_form_specific($form) {
/// do nothing - overwrite if necessary /// do nothing - overwrite if necessary
} }
...@@ -115,6 +115,7 @@ class profile_define_base { ...@@ -115,6 +115,7 @@ class profile_define_base {
* Validate the data from the add/edit profile field form * Validate the data from the add/edit profile field form
* that is specific to the current data type * that is specific to the current data type
* @param object data from the add/edit profile field form * @param object data from the add/edit profile field form
* @param array files
* @return array associative array of error messages * @return array associative array of error messages
*/ */
function define_validate_specific($data, $files) { function define_validate_specific($data, $files) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class profile_define_checkbox extends profile_define_base { 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 /// select whether or not this should be checked by default
$form->addElement('selectyesno', 'defaultdata', get_string('profiledefaultchecked', 'admin')); $form->addElement('selectyesno', 'defaultdata', get_string('profiledefaultchecked', 'admin'));
$form->setDefault('defaultdata', 0); // defaults to 'no' $form->setDefault('defaultdata', 0); // defaults to 'no'
......
...@@ -22,9 +22,9 @@ class profile_field_checkbox extends profile_field_base { ...@@ -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 /// 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') { if ($this->data == '1') {
$checkbox->setChecked(true); $checkbox->setChecked(true);
} }
......
...@@ -47,9 +47,10 @@ class profile_define_datetime extends profile_define_base { ...@@ -47,9 +47,10 @@ class profile_define_datetime extends profile_define_base {
* Validate the data from the profile field form * Validate the data from the profile field form
* *
* @param object data from the add/edit profile field form * @param object data from the add/edit profile field form
* @param array files
* @return array associative array of error messages * @return array associative array of error messages
*/ */
function define_validate_specific($data) { function define_validate_specific($data, $files) {
$errors = array(); $errors = array();
// Make sure the start year is not greater than the end year // Make sure the start year is not greater than the end year
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class profile_define_menu extends profile_define_base { 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 /// Param 1 for menu type contains the options
$form->addElement('textarea', 'param1', get_string('profilemenuoptions', 'admin'), array('rows' => 6, 'cols' => 40)); $form->addElement('textarea', 'param1', get_string('profilemenuoptions', 'admin'), array('rows' => 6, 'cols' => 40));
$form->setType('param1', PARAM_MULTILANG); $form->setType('param1', PARAM_MULTILANG);
......
...@@ -34,7 +34,7 @@ class profile_field_menu extends profile_field_base { ...@@ -34,7 +34,7 @@ class profile_field_menu extends profile_field_base {
* Overwrites the base class method * Overwrites the base class method
* @param object moodleform instance * @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); $mform->addElement('select', $this->inputname, format_string($this->field->name), $this->options);
} }
...@@ -42,7 +42,7 @@ class profile_field_menu extends profile_field_base { ...@@ -42,7 +42,7 @@ class profile_field_menu extends profile_field_base {
* Set the default value for this field instance * Set the default value for this field instance
* Overwrites the base class method * Overwrites the base class method
*/