mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
MDL-14458 - optgroups Fields and Other in search menu; removed unused search code, html labels, added option to sort by time modified; merged from MOODLE_19_STABLE
This commit is contained in:
parent
ea6073bb48
commit
3239b0104e
4 changed files with 84 additions and 81 deletions
|
@ -42,24 +42,24 @@
|
|||
|
||||
if ($id) {
|
||||
if (! $cm = get_coursemodule_from_id('data', $id)) {
|
||||
print_error('Course Module ID was incorrect');
|
||||
error('Course Module ID was incorrect');
|
||||
}
|
||||
if (! $course = get_record('course', 'id', $cm->course)) {
|
||||
print_error('Course is misconfigured');
|
||||
error('Course is misconfigured');
|
||||
}
|
||||
if (! $data = get_record('data', 'id', $cm->instance)) {
|
||||
print_error('Course module is incorrect');
|
||||
error('Course module is incorrect');
|
||||
}
|
||||
|
||||
} else {
|
||||
if (! $data = get_record('data', 'id', $d)) {
|
||||
print_error('Data ID is incorrect');
|
||||
error('Data ID is incorrect');
|
||||
}
|
||||
if (! $course = get_record('course', 'id', $data->course)) {
|
||||
print_error('Course is misconfigured');
|
||||
error('Course is misconfigured');
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
|
||||
print_error('Course Module ID was incorrect');
|
||||
error('Course Module ID was incorrect');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@
|
|||
$rec->defaultsort = 0;
|
||||
$rec->defaultsortdir = 0;
|
||||
if (!update_record('data', $rec)) {
|
||||
print_error('There was an error updating the database');
|
||||
error('There was an error updating the database');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@
|
|||
if (update_record('data', $rec)) {
|
||||
redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id, get_string('changessaved'), 2);
|
||||
} else {
|
||||
print_error('There was an error updating the database');
|
||||
error('There was an error updating the database');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
@ -288,40 +288,58 @@
|
|||
|
||||
|
||||
echo '<div class="fieldadd">';
|
||||
echo get_string('newfield','data').': ';
|
||||
echo '<label for="fieldform_jump">'.get_string('newfield','data').'</label>';
|
||||
popup_form($CFG->wwwroot.'/mod/data/field.php?d='.$data->id.'&mode=new&sesskey='.
|
||||
sesskey().'&newtype=', $menufield, 'fieldform', '', 'choose');
|
||||
helpbutton('fields', get_string('addafield','data'), 'data');
|
||||
echo '</div>';
|
||||
|
||||
echo '<div class="sortdefault">';
|
||||
echo '<form id="sortdefault" action="'.$CFG->wwwroot.'/mod/data/field.php" method="get">';
|
||||
echo '<div>';
|
||||
echo '<input type="hidden" name="d" value="'.$data->id.'" />';
|
||||
echo '<input type="hidden" name="mode" value="sort" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo '<label for="defaultsort">'.get_string('defaultsortfield','data').'</label>';
|
||||
echo '<select id="defaultsort" name="defaultsort">';
|
||||
if ($fields = get_records('data_fields','dataid',$data->id)) {
|
||||
echo '<div class="sortdefault">';
|
||||
echo '<form id="sortdefault" action="'.$CFG->wwwroot.'/mod/data/field.php" method="get">';
|
||||
echo '<fieldset class="invisiblefieldset">';
|
||||
echo '<input type="hidden" name="d" value="'.$data->id.'" />';
|
||||
echo '<input type="hidden" name="mode" value="sort" />';
|
||||
echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
|
||||
echo ' '.get_string('defaultsortfield','data').':';
|
||||
echo '<select name="defaultsort"><option value="0">'.get_string('dateentered','data').'</option>';
|
||||
echo '<optgroup label="'.get_string('fields', 'data').'">';
|
||||
foreach ($fields as $field) {
|
||||
if ($field->id == $data->defaultsort) {
|
||||
if ($data->defaultsort == $field->id) {
|
||||
echo '<option value="'.$field->id.'" selected="selected">'.$field->name.'</option>';
|
||||
} else {
|
||||
echo '<option value="'.$field->id.'">'.$field->name.'</option>';
|
||||
}
|
||||
}
|
||||
echo '</select>';
|
||||
echo ' ';
|
||||
|
||||
$options = array(0 => get_string('ascending', 'data'),
|
||||
1 => get_string('descending', 'data'));
|
||||
choose_from_menu($options, 'defaultsortdir', $data->defaultsortdir, '');
|
||||
echo '<input type="submit" value="'.get_string('go').'" />';
|
||||
echo '</fieldset>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
echo '</optgroup>';
|
||||
}
|
||||
$options = array();
|
||||
$options[DATA_TIMEADDED] = get_string('timeadded', 'data');
|
||||
// TODO: we will need to change defaultsort db to unsinged to make these work in 2.0
|
||||
/* $options[DATA_TIMEMODIFIED] = get_string('timemodified', 'data');
|
||||
$options[DATA_FIRSTNAME] = get_string('authorfirstname', 'data');
|
||||
$options[DATA_LASTNAME] = get_string('authorlastname', 'data');
|
||||
if ($data->approval and has_capability('mod/data:approve', $context)) {
|
||||
$options[DATA_APPROVED] = get_string('approved', 'data');
|
||||
}*/
|
||||
echo '<optgroup label="'.get_string('other', 'data').'">';
|
||||
foreach ($options as $key => $name) {
|
||||
if ($data->defaultsort == $key) {
|
||||
echo '<option value="'.$key.'" selected="selected">'.$name.'</option>';
|
||||
} else {
|
||||
echo '<option value="'.$key.'">'.$name.'</option>';
|
||||
}
|
||||
}
|
||||
echo '</optgroup>';
|
||||
echo '</select>';
|
||||
|
||||
$options = array(0 => get_string('ascending', 'data'),
|
||||
1 => get_string('descending', 'data'));
|
||||
choose_from_menu($options, 'defaultsortdir', $data->defaultsortdir, '');
|
||||
echo '<input type="submit" value="'.get_string('save', 'data').'" />';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue