diff --git a/user/profile/index.php b/user/profile/index.php
index 0617d173bac..17ab381403f 100644
--- a/user/profile/index.php
+++ b/user/profile/index.php
@@ -41,20 +41,23 @@ switch ($action) {
break;
case 'deletecategory':
$id = required_param('id', PARAM_INT);
- profile_delete_category($id);
+ if (confirm_sesskey()) {
+ profile_delete_category($id);
+ }
redirect($redirect,get_string('deleted'));
break;
case 'deletefield':
$id = required_param('id', PARAM_INT);
$confirm = optional_param('confirm', 0, PARAM_BOOL);
+ // If no userdata for profile than don't show confirmation.
$datacount = $DB->count_records('user_info_data', array('fieldid'=>$id));
- if (data_submitted() and ($confirm and confirm_sesskey()) or $datacount===0) {
+ if (((data_submitted() and $confirm) or ($datacount === 0)) and confirm_sesskey()) {
profile_delete_field($id);
redirect($redirect,get_string('deleted'));
}
- //ask for confirmation
+ // Ask for confirmation, as there is user data available for field.
$fieldname = $DB->get_field('user_info_field', 'name', array('id'=>$id));
$optionsyes = array ('id'=>$id, 'confirm'=>1, 'action'=>'deletefield', 'sesskey'=>sesskey());
$strheading = get_string('profiledeletefield', 'admin', $fieldname);
@@ -173,7 +176,7 @@ function profile_category_icons($category) {
/// Delete
/// Can only delete the last category if there are no fields in it
if ( ($categorycount > 1) or ($fieldcount == 0) ) {
- $editstr .= '
';
} else {
$editstr .= '
';
@@ -216,7 +219,7 @@ function profile_field_icons($field) {
$editstr = '
';
/// Delete
- $editstr .= '
';
/// Move up