From bf4de5b583fff1a784e9c5062b8fc693a23d65c6 Mon Sep 17 00:00:00 2001 From: moodler Date: Wed, 22 Mar 2006 09:49:29 +0000 Subject: [PATCH] Cleanups --- mod/data/fields.php | 18 ++++++++++-------- mod/data/templates.php | 12 ++++++------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/mod/data/fields.php b/mod/data/fields.php index c9c63675e4..fd05a7a8b1 100755 --- a/mod/data/fields.php +++ b/mod/data/fields.php @@ -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); diff --git a/mod/data/templates.php b/mod/data/templates.php index 19df48b98d..9f6186edf7 100755 --- a/mod/data/templates.php +++ b/mod/data/templates.php @@ -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 ''; + echo ''; } // Print special tags. @@ -223,4 +223,4 @@ /// Finish the page print_footer($course); -?> \ No newline at end of file +?> -- 2.39.5