Skip to content

Commit

Permalink
MDL-23475 Some cleanups to make adding/editing entries a bit smoother…
Browse files Browse the repository at this point in the history
…. Fixed buttons on Delete too.
  • Loading branch information
moodler committed Jul 22, 2010
1 parent aa28106 commit e822f07
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
35 changes: 18 additions & 17 deletions mod/data/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
}
}

/// Print the page header
/// Define page variables
$strdata = get_string('modulenameplural','data');

if ($rid) {
Expand All @@ -135,15 +135,11 @@

$PAGE->set_title($data->name);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();

/// Check to see if groups are being used here
groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/data/edit.php?d='.$data->id);
$currentgroup = groups_get_activity_group($cm);
$groupmode = groups_get_activity_groupmode($cm);

echo $OUTPUT->heading(format_string($data->name));

if ($currentgroup) {
$groupselect = " AND groupid = '$currentgroup'";
$groupparam = "&groupid=$currentgroup";
Expand All @@ -153,13 +149,6 @@
$currentgroup = 0;
}

/// Print the tabs

$currenttab = 'add';
if ($rid) {
$editentry = true; //used in tabs
}
include('tabs.php');

/// Process incoming data for adding/updating records

Expand Down Expand Up @@ -197,7 +186,7 @@

add_to_log($course->id, 'data', 'update', "view.php?d=$data->id&rid=$rid", $data->id, $cm->id);

redirect($CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&rid='.$rid);
redirect($CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&rid='.$rid);

} else { /// Add some new records

Expand Down Expand Up @@ -245,7 +234,7 @@
$DB->insert_record('data_content',$content);
}

//for each field in the add form, add it to the data_content.
/// For each field in the add form, add it to the data_content.
foreach ($datarecord as $name => $value){
if (!in_array($name, $ignorenames)) {
$namearr = explode('_', $name); // Second one is the field id
Expand All @@ -260,16 +249,28 @@

add_to_log($course->id, 'data', 'add', "view.php?d=$data->id&rid=$recordid", $data->id, $cm->id);

echo $OUTPUT->notification(get_string('entrysaved','data'));

if (!empty($datarecord->saveandview)) {
redirect($CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&rid='.$recordid);
redirect($CFG->wwwroot.'/mod/data/view.php?d='.$data->id.'&rid='.$recordid);
}
}
}
} // End of form processing


/// Print the page header

echo $OUTPUT->header();
groups_print_activity_menu($cm, $CFG->wwwroot.'/mod/data/edit.php?d='.$data->id);
echo $OUTPUT->heading(format_string($data->name));

/// Print the tabs

$currenttab = 'add';
if ($rid) {
$editentry = true; //used in tabs
}
include('tabs.php');


/// Print the browsing interface

Expand Down
6 changes: 3 additions & 3 deletions mod/data/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
$currentgroup = groups_get_activity_group($cm);
$groupmode = groups_get_activity_groupmode($cm);

// deletect entries not approved yet and show hint instead of not found error
// detect entries not approved yet and show hint instead of not found error
if ($record and $data->approval and !$record->approved and $record->userid != $USER->id and !has_capability('mod/data:manageentries', $context)) {
if (!$currentgroup or $record->groupid == $currentgroup or $record->groupid == 0) {
print_error('notapproved', 'data');
Expand Down Expand Up @@ -353,9 +353,9 @@
} else { // Print a confirmation page
if ($deleterecord = $DB->get_record('data_records', array('id'=>$delete))) { // Need to check this is valid
if ($deleterecord->dataid == $data->id) { // Must be from this database
$deletebutton = new single_button(new moodle_url('/mod/data/view.php?d='.$data->id.'&delete='.$delete.'&confirm=1'), get_string('delete'), 'post');
echo $OUTPUT->confirm(get_string('confirmdeleterecord','data'),
'view.php?d='.$data->id.'&delete='.$delete.'&confirm=1',
'view.php?d='.$data->id);
$deletebutton, 'view.php?d='.$data->id);

$records[] = $deleterecord;
echo data_print_template('singletemplate', $records, $data, '', 0, true);
Expand Down

0 comments on commit e822f07

Please sign in to comment.