Cleanups
This commit is contained in:
+10
-8
@@ -33,8 +33,6 @@
|
||||
$newtype = optional_param('newtype','',PARAM_ALPHA); // type of the new field
|
||||
$mode = optional_param('mode','',PARAM_ALPHA);
|
||||
|
||||
$displaynotice = ''; //str to print after an operation,
|
||||
|
||||
if ($id) {
|
||||
if (! $cm = get_record('course_modules', 'id', $id)) {
|
||||
error('Course Module ID was incorrect');
|
||||
@@ -81,7 +79,7 @@
|
||||
/// Only store this new field if it doesn't already exist.
|
||||
if (data_fieldname_exists($fieldinput->name, $data->id)) {
|
||||
|
||||
$displaynotice = get_string('invalidfieldname','data');
|
||||
$displaynoticebad = get_string('invalidfieldname','data');
|
||||
|
||||
} else {
|
||||
|
||||
@@ -101,7 +99,7 @@
|
||||
add_to_log($course->id, 'data', 'fields add',
|
||||
"fields.php?d=$data->id&mode=display&fid=$fid", $fid, $cm->id);
|
||||
|
||||
$displaynotice = get_string('fieldadded','data');
|
||||
$displaynoticegood = get_string('fieldadded','data');
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -113,7 +111,7 @@
|
||||
$fieldinput->name = optional_param('name','',PARAM_NOTAGS);
|
||||
|
||||
if (data_fieldname_exists($fieldinput->name, $data->id, $fid)) {
|
||||
$displaynotice = get_string('invalidfieldname','data');
|
||||
$displaynoticebad = get_string('invalidfieldname','data');
|
||||
|
||||
} else {
|
||||
/// Check for arrays and convert to a comma-delimited string
|
||||
@@ -130,7 +128,7 @@
|
||||
add_to_log($course->id, 'data', 'fields update',
|
||||
"fields.php?d=$data->id&mode=display&fid=$fid", $fid, $cm->id);
|
||||
|
||||
$displaynotice = get_string('fieldupdated','data');
|
||||
$displaynoticegood = get_string('fieldupdated','data');
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -150,7 +148,7 @@
|
||||
add_to_log($course->id, 'data', 'fields delete',
|
||||
"fields.php?d=$data->id", $field->field->name, $cm->id);
|
||||
|
||||
$displaynotice = get_string('fielddeleted', 'data');
|
||||
$displaynoticegood = get_string('fielddeleted', 'data');
|
||||
|
||||
} else {
|
||||
// Print confirmation message.
|
||||
@@ -186,7 +184,11 @@
|
||||
}
|
||||
asort($menufield); //sort in alphabetical order
|
||||
|
||||
notify($displaynotice); //print message, if any
|
||||
if (!empty($displaynoticegood)) {
|
||||
notify($displaynoticegood, 'notifysuccess'); // good (usually green)
|
||||
} else if (!empty($displaynoticebad)) {
|
||||
notify($displaynoticebad); // bad (usuually red)
|
||||
}
|
||||
|
||||
if (($mode == 'new') && confirm_sesskey()) { /// Adding a new field
|
||||
$field = data_get_field_new($newtype, $data);
|
||||
|
||||
@@ -90,15 +90,14 @@
|
||||
// Generate default template.
|
||||
if (!empty($mytemplate->defaultform)){
|
||||
data_generate_default_form($data->id, $mode);
|
||||
}
|
||||
else if (!empty($mytemplate->allforms)){ //generate all default templates
|
||||
|
||||
} else if (!empty($mytemplate->allforms)){ //generate all default templates
|
||||
data_generate_default_form($data->id, 'singletemplate');
|
||||
data_generate_default_form($data->id, 'listtemplate');
|
||||
data_generate_default_form($data->id, 'addtemplate');
|
||||
data_generate_default_form($data->id, 'rsstemplate');
|
||||
add_to_log($course->id, 'data', 'templates def', "templates.php?id=$cm->id&d=$data->id", $data->id, $cm->id);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
$newtemplate->id = $data->id;
|
||||
$newtemplate->{$mode} = $mytemplate->template;
|
||||
@@ -171,8 +170,9 @@
|
||||
echo '}';
|
||||
echo '">';
|
||||
|
||||
$fields = get_records('data_fields', 'dataid', $data->id);
|
||||
foreach ($fields as $field) {
|
||||
echo '<option value="[['.$field->name.']]">'.$field->name.' ('. get_string($field->type, 'data'). ')</option>';
|
||||
echo '<option value="[['.$field->name.']]">'.$field->name.'</option>';
|
||||
}
|
||||
|
||||
// Print special tags.
|
||||
@@ -223,4 +223,4 @@
|
||||
|
||||
/// Finish the page
|
||||
print_footer($course);
|
||||
?>
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user