|
By dongsheng:
MDL-14129, remove all the other error() call
|
| 40 |
function data_field_base($field=0, $data=0) { // Field or data or both, each can be id or object |
function data_field_base($field=0, $data=0) { // Field or data or both, each can be id or object |
| 41 |
|
|
| 42 |
if (empty($field) && empty($data)) { |
if (empty($field) && empty($data)) { |
| 43 |
error('Programmer error: You must specify field and/or data when defining field class. '); |
print_error('Programmer error: You must specify field and/or data when defining field class. '); |
| 44 |
} |
} |
| 45 |
|
|
| 46 |
if (!empty($field)) { |
if (!empty($field)) { |
| 47 |
if (is_object($field)) { |
if (is_object($field)) { |
| 48 |
$this->field = $field; // Programmer knows what they are doing, we hope |
$this->field = $field; // Programmer knows what they are doing, we hope |
| 49 |
} else if (!$this->field = get_record('data_fields','id',$field)) { |
} else if (!$this->field = get_record('data_fields','id',$field)) { |
| 50 |
error('Bad field ID encountered: '.$field); |
print_error('Bad field ID encountered: '.$field); |
| 51 |
} |
} |
| 52 |
if (empty($data)) { |
if (empty($data)) { |
| 53 |
if (!$this->data = get_record('data','id',$this->field->dataid)) { |
if (!$this->data = get_record('data','id',$this->field->dataid)) { |
| 54 |
error('Bad data ID encountered in field data'); |
print_error('Bad data ID encountered in field data'); |
| 55 |
} |
} |
| 56 |
} |
} |
| 57 |
} |
} |
| 61 |
if (is_object($data)) { |
if (is_object($data)) { |
| 62 |
$this->data = $data; // Programmer knows what they are doing, we hope |
$this->data = $data; // Programmer knows what they are doing, we hope |
| 63 |
} else if (!$this->data = get_record('data','id',$data)) { |
} else if (!$this->data = get_record('data','id',$data)) { |
| 64 |
error('Bad data ID encountered: '.$data); |
print_error('Bad data ID encountered: '.$data); |
| 65 |
} |
} |
| 66 |
} else { // No way to define it! |
} else { // No way to define it! |
| 67 |
error('Data id or object must be provided to field class'); |
print_error('Data id or object must be provided to field class'); |
| 68 |
} |
} |
| 69 |
} |
} |
| 70 |
|
|
| 1705 |
global $USER; |
global $USER; |
| 1706 |
|
|
| 1707 |
if (!$cm = get_coursemodule_from_instance('data', $data->id)) { |
if (!$cm = get_coursemodule_from_instance('data', $data->id)) { |
| 1708 |
error('Course Module ID was incorrect'); |
print_error('Course Module ID was incorrect'); |
| 1709 |
} |
} |
| 1710 |
$context = get_context_instance(CONTEXT_MODULE, $cm->id); |
$context = get_context_instance(CONTEXT_MODULE, $cm->id); |
| 1711 |
|
|
| 1835 |
|
|
| 1836 |
/* Check all is well */ |
/* Check all is well */ |
| 1837 |
if (!is_directory_a_preset($tempfolder)) { |
if (!is_directory_a_preset($tempfolder)) { |
| 1838 |
error("Not all files generated!"); |
print_error("Not all files generated!"); |
| 1839 |
} |
} |
| 1840 |
|
|
| 1841 |
$filelist = array( |
$filelist = array( |
| 1878 |
global $CFG; |
global $CFG; |
| 1879 |
|
|
| 1880 |
if (!is_directory_a_preset($this->folder)) { |
if (!is_directory_a_preset($this->folder)) { |
| 1881 |
error("$this->userid/$this->shortname Not a preset"); |
print_error("$this->userid/$this->shortname Not a preset"); |
| 1882 |
} |
} |
| 1883 |
|
|
| 1884 |
/* Grab XML */ |
/* Grab XML */ |
| 1929 |
|
|
| 1930 |
function import_options() { |
function import_options() { |
| 1931 |
if (!confirm_sesskey()) { |
if (!confirm_sesskey()) { |
| 1932 |
error("Sesskey Invalid"); |
print_error("Sesskey Invalid"); |
| 1933 |
} |
} |
| 1934 |
|
|
| 1935 |
$strblank = get_string('blank', 'data'); |
$strblank = get_string('blank', 'data'); |
| 1981 |
echo "<p>$strwarning</p>"; |
echo "<p>$strwarning</p>"; |
| 1982 |
} |
} |
| 1983 |
else if (empty($newfields)) { |
else if (empty($newfields)) { |
| 1984 |
error("New preset has no defined fields!"); |
print_error("New preset has no defined fields!"); |
| 1985 |
} |
} |
| 1986 |
echo '<input type="submit" value="'.$strcontinue.'" /></fieldset></form></div>'; |
echo '<input type="submit" value="'.$strcontinue.'" /></fieldset></form></div>'; |
| 1987 |
|
|
| 2000 |
$cid = optional_param("field_$nid", -1, PARAM_INT); |
$cid = optional_param("field_$nid", -1, PARAM_INT); |
| 2001 |
if ($cid == -1) continue; |
if ($cid == -1) continue; |
| 2002 |
|
|
| 2003 |
if (array_key_exists($cid, $preservedfields)) error("Not an injective map"); |
if (array_key_exists($cid, $preservedfields)) print_error("Not an injective map"); |
| 2004 |
else $preservedfields[$cid] = true; |
else $preservedfields[$cid] = true; |
| 2005 |
} |
} |
| 2006 |
|
|