function saveProfile() { global $error; global $obj_smarty; $arr_submit = array(array('user_id', 'int', true, ''), array('firstname', 'string', false, ''), array('infix', 'string', false, ''), array('lastname', 'string', true, ''), array('country', 'string', false, ''), array('username', 'string', true, ''), array('email', 'email', true, ''), array('birthdate_day', 'int', false, ''), array('birthdate_month', 'int', false, ''), array('birthdate_year', 'int', false, ''), array('password', 'string', false, ''), array('confirm', 'string', false, ''), array('user_info', 'string', false, ''), array('active', 'bool', false, 0)); $frm_submitted = validate_var($arr_submit); if (User::isAdmin() || User::isAdminUser($frm_submitted['user_id'])) { if (!$error || is_null($error)) { $bln_success = User::adminSaveProfile($frm_submitted); if (is_string($bln_success)) { echo json_encode(array('success' => false, 'error' => $bln_success)); exit; } if (!empty($frm_submitted['password']) && !empty($frm_submitted['confirm'])) { if ($frm_submitted['password'] === $frm_submitted['confirm']) { $frm_submitted['passw1'] = $frm_submitted['password']; $frm_submitted['uid'] = $frm_submitted['user_id']; $bln_success = User::changePassword($frm_submitted); } else { $obj_smarty->assign('save_profile_error', 'Passwords do not match'); exit; } } } else { $obj_smarty->assign('save_profile_error', $error); } } else { $error = 'NO rights to change this user'; $obj_smarty->assign('save_profile_error', $error); } if (!is_null($error) && $error !== false) { // give feedback about the error $arr_user = User::getUserById($frm_submitted['user_id']); $arr_birthdate = explode('-', $arr_user['birth_date']); $arr_user['birthdate_month'] = $arr_user['birth_date'] !== '0000-00-00' ? $arr_birthdate[1] : ''; $arr_user['birthdate_day'] = $arr_user['birth_date'] !== '0000-00-00' ? $arr_birthdate[2] : ''; $arr_user['birthdate_year'] = $arr_user['birth_date'] !== '0000-00-00' ? $arr_birthdate[0] : ''; unset($arr_user['password']); unset($arr_user['birth_date']); $obj_smarty->assign('active', 'profile'); $obj_smarty->assign('profile', $arr_user); $obj_smarty->display(FULLCAL_DIR . '/view/admin_panel.tpl'); exit; } else { header('location: ' . FULLCAL_URL . '/admin/users'); exit; } }