Skip to content

Commit

Permalink
Changes to the redirects.
Browse files Browse the repository at this point in the history
  • Loading branch information
ikawhero committed Jan 12, 2007
1 parent 5a4ef4c commit c517d8f
Showing 1 changed file with 48 additions and 27 deletions.
75 changes: 48 additions & 27 deletions user/profile/index.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
exit; exit;
} }
$field->id = 0; $field->id = 0;
$field->datatype = $datatypes[$type]; $field->datatype = $type;
$field->categoryid = 0; $field->categoryid = 0;
} elseif (!($field = get_record('user_info_field', 'id', $id))) { } elseif (!($field = get_record('user_info_field', 'id', $id))) {
redirect($redirect); redirect($redirect);
Expand All @@ -102,26 +102,18 @@






/// Print the header
admin_externalpage_print_header($adminroot);






/// Are we adding or editing a cateogory? /// Are we adding or editing a cateogory?
if ( ($action == 'editcategory' )) { if ( ($action == 'editcategory' )) {


if ($id == 0) {
$strheading = get_string('profilecreatenewcategory', 'admin');
} else {
$strheading = get_string('profileeditcategory', 'admin', $category->name);
}

print_heading($strheading);

require_once('index_category_form.php'); require_once('index_category_form.php');
$categoryform = new category_form(null, compact('category')); $categoryform = new category_form(null, compact('category'));
if ($categoryform->is_cancelled()) { if ($categoryform->is_cancelled()) {
redirect($redirect, $strcancelled); redirect($redirect);
exit;
} else { } else {
if ($data = $categoryform->data_submitted()) { if ($data = $categoryform->data_submitted()) {
if ($data->id == 0) { if ($data->id == 0) {
Expand All @@ -137,27 +129,34 @@
exit; exit;
} }
} }
redirect($redirect, $strchangessaved); redirect($redirect);
exit;

} else { } else {

if ($id == 0) {
$strheading = get_string('profilecreatenewcategory', 'admin');
} else {
$strheading = get_string('profileeditcategory', 'admin', $category->name);
}

/// Print the header
admin_externalpage_print_header($adminroot);

print_heading($strheading);

$categoryform->display(); $categoryform->display();
} }
} }


/// Are we adding or editing a field? /// Are we adding or editing a field?
} elseif ( $action == 'editfield' ) { } elseif ( $action == 'editfield' ) {


if ($id == 0) {
$strheading = get_string('profilecreatenewfield', 'admin');
} else {
$strheading = get_string('profileeditfield', 'admin', $field->name);
}

print_heading($strheading);

require_once('index_field_form.php'); require_once('index_field_form.php');
$fieldform = new field_form(null, compact('field')); $fieldform = new field_form(null, compact('field'));
if ($fieldform->is_cancelled()) { if ($fieldform->is_cancelled()) {
redirect($redirect, $strcancelled); redirect($redirect);
exit;
} else { } else {
if ($data = $fieldform->data_submitted()) { if ($data = $fieldform->data_submitted()) {
require_once($CFG->dirroot.'/user/profile/field/'.$field->datatype.'/field.class.php'); require_once($CFG->dirroot.'/user/profile/field/'.$field->datatype.'/field.class.php');
Expand All @@ -166,26 +165,45 @@
if (!$formfield->edit_save($data)) { if (!$formfield->edit_save($data)) {
error('There was an error updating the database'); error('There was an error updating the database');
} else { } else {
redirect($redirect, $strchangessaved); redirect($redirect);
exit;
} }


} else { } else {

if ($id == 0) {
$strheading = get_string('profilecreatenewfield', 'admin');
} else {
$strheading = get_string('profileeditfield', 'admin', $field->name);
}

/// Print the header
admin_externalpage_print_header($adminroot);

print_heading($strheading);

$fieldform->display(); $fieldform->display();
} }
} }


/// Deleting a category that has fields in it, print confirm screen? /// Deleting a category that has fields in it, print confirm screen?
} elseif ( ($action == 'deletecategory') and !$confirm ) { } elseif ( ($action == 'deletecategory') and !$confirm ) {


/// Print the header
admin_externalpage_print_header($adminroot);

print_heading('profiledeletecategory', 'admin'); print_heading('profiledeletecategory', 'admin');

$fieldcount = count_records('user_info_field', 'categoryid', $id); $fieldcount = count_records('user_info_field', 'categoryid', $id);
echo '<center>'.get_string('profileconfirmcategorydeletion', 'admin', $fieldcount).'<br /><a href="index.php?id='.$id.'&amp;action=deletecategory&amp;sesskey='.$USER->sesskey.'&amp;confirm=1">'.get_string('yes').' <a href="index.php">'.get_string('no').'</center>'; echo '<center>'.get_string('profileconfirmcategorydeletion', 'admin', $fieldcount).'<br /><a href="index.php?id='.$id.'&amp;action=deletecategory&amp;sesskey='.$USER->sesskey.'&amp;confirm=1">'.get_string('yes').' <a href="index.php">'.get_string('no').'</center>';




/// Deleting a field that has user data, print confirm screen /// Deleting a field that has user data, print confirm screen
} elseif ( ($action == 'deletefield') and !$confirm ) { } elseif ( ($action == 'deletefield') and !$confirm ) {


/// Print the header
admin_externalpage_print_header($adminroot);

print_heading('profiledeletefield', 'admin'); print_heading('profiledeletefield', 'admin');


$datacount = count_records('user_info_data', 'fieldid', $id); $datacount = count_records('user_info_data', 'fieldid', $id);
Expand All @@ -196,6 +214,11 @@
/// Print the table of categories and fields /// Print the table of categories and fields
} else { } else {


/// Print the header
admin_externalpage_print_header($adminroot);

print_heading(get_string('profilefields', 'admin'));

/// Check that we have at least one category defined /// Check that we have at least one category defined
if (count_records_select('user_info_category', '1') == 0) { if (count_records_select('user_info_category', '1') == 0) {
unset($defaultcategory); unset($defaultcategory);
Expand All @@ -204,8 +227,6 @@
insert_record('user_info_category', $defaultcategory); insert_record('user_info_category', $defaultcategory);
} }


print_heading(get_string('profilefields', 'admin'));

/// We only displaying if there are fields defined or there is a category with a name different to the default name /// We only displaying if there are fields defined or there is a category with a name different to the default name
if ( ( (count_records_select('user_info_category', "name<>'$strdefaultcategory'") > 0) or if ( ( (count_records_select('user_info_category', "name<>'$strdefaultcategory'") > 0) or
(count_records_select('user_info_field', '1') > 0) ) and (count_records_select('user_info_field', '1') > 0) ) and
Expand Down

0 comments on commit c517d8f

Please sign in to comment.