]> git.mjollnir.org Git - moodle.git/commitdiff
Tweaky tweaky tweak
authormoodler <moodler>
Wed, 22 Mar 2006 09:53:13 +0000 (09:53 +0000)
committermoodler <moodler>
Wed, 22 Mar 2006 09:53:13 +0000 (09:53 +0000)
mod/data/fields.php

index fd05a7a8b1563b369dc144fce3c95a31ec709ac6..d31550f52044405444388a9ba217d65aec4d18a5 100755 (executable)
                 if ($confirm = optional_param('confirm', 0, PARAM_INT)) {
 
                     // Delete the field completely
-                    $field = data_get_field_from_id($fid, $data);
-                    $field->delete_field();
-
-                    // Update the templates.
-                    data_replace_field_in_templates($data, $field->field->name, '');
-                    
-                    add_to_log($course->id, 'data', 'fields delete', 
-                               "fields.php?d=$data->id", $field->field->name, $cm->id);
-
-                    $displaynoticegood = get_string('fielddeleted', 'data');
+                    if ($field = data_get_field_from_id($fid, $data)) {
+                        $field->delete_field();
+
+                        // Update the templates.
+                        data_replace_field_in_templates($data, $field->field->name, '');
+                        
+                        add_to_log($course->id, 'data', 'fields delete', 
+                                   "fields.php?d=$data->id", $field->field->name, $cm->id);
+    
+                        $displaynoticegood = get_string('fielddeleted', 'data');
+                    }
 
                 } else {
                     // Print confirmation message.
 
     } else {                                              /// Display the main listing of all fields
       
-        echo '<div class="fieldadd" align="center">';
-        echo get_string('newfield','data').': ';
-        popup_form($CFG->wwwroot.'/mod/data/fields.php?d='.$data->id.'&amp;mode=new&amp;sesskey='.
-                   sesskey().'&amp;newtype=', $menufield, 'fieldform', '', 'choose');
-        helpbutton('fields', get_string('addafield','data'), 'data');
-        echo '</div>';
         
         if (!record_exists('data_fields','dataid',$data->id)) {
-            print_string('nofieldindatabase','data');  // nothing in database
+            notify(get_string('nofieldindatabase','data'));  // nothing in database
 
         } else {    //else print quiz style list of fields
 
             print_table($table);
         } 
         
+        echo '<div class="fieldadd" align="center">';
+        echo get_string('newfield','data').': ';
+        popup_form($CFG->wwwroot.'/mod/data/fields.php?d='.$data->id.'&amp;mode=new&amp;sesskey='.
+                   sesskey().'&amp;newtype=', $menufield, 'fieldform', '', 'choose');
+        helpbutton('fields', get_string('addafield','data'), 'data');
+        echo '</div>';
+        
         print_simple_box_end();
 
     }