/**
  * Allows to edit Personal Message Settings.
  *
  * @uses ProfileOptions controller. (@todo refactor this.)
  * @uses Profile template.
  * @uses Profile language file.
  */
 public function action_settings()
 {
     global $txt, $user_info, $context, $scripturl, $profile_vars, $cur_profile, $user_profile;
     require_once SUBSDIR . '/Profile.subs.php';
     // Load the member data for editing
     loadMemberData($user_info['id'], false, 'profile');
     $cur_profile = $user_profile[$user_info['id']];
     // Load up the profile template, its where PM settings are located
     loadLanguage('Profile');
     loadTemplate('Profile');
     // We want them to submit back to here.
     $context['profile_custom_submit_url'] = $scripturl . '?action=pm;sa=settings;save';
     $context['page_title'] = $txt['pm_settings'];
     $context['user']['is_owner'] = true;
     $context['id_member'] = $user_info['id'];
     $context['require_password'] = false;
     $context['menu_item_selected'] = 'settings';
     $context['submit_button_text'] = $txt['pm_settings'];
     // Add our position to the linktree.
     $context['linktree'][] = array('url' => $scripturl . '?action=pm;sa=settings', 'name' => $txt['pm_settings']);
     // Are they saving?
     if (isset($_REQUEST['save'])) {
         checkSession('post');
         // Mimic what profile would do.
         $_POST = htmltrim__recursive($_POST);
         $_POST = htmlspecialchars__recursive($_POST);
         // Save the fields.
         saveProfileFields();
         if (!empty($profile_vars)) {
             updateMemberData($user_info['id'], $profile_vars);
         }
         // Invalidate any cached data and reload so we show the saved values
         cache_put_data('member_data-profile-' . $user_info['id'], null, 0);
         loadMemberData($user_info['id'], false, 'profile');
         $cur_profile = $user_profile[$user_info['id']];
     }
     // Load up the fields.
     require_once CONTROLLERDIR . '/ProfileOptions.controller.php';
     $controller = new ProfileOptions_Controller();
     $controller->action_pmprefs();
 }