You are here

function _pm_block_user_settings_filter in Privatemsg 7

Same name and namespace in other branches
  1. 6.2 pm_block_user/pm_block_user.admin.inc \_pm_block_user_settings_filter()
  2. 6 pm_block_user/pm_block_user.module \_pm_block_user_settings_filter()
  3. 7.2 pm_block_user/pm_block_user.admin.inc \_pm_block_user_settings_filter()

Takes an array of settings and filters out anything that's un-needed. Leaving only settings to be saved.

Parameters

$settings: The array of settings to filter.

Return value

Array of settings, ready to be stored in the database.

See also

pm_block_user_settings_submit()

1 call to _pm_block_user_settings_filter()
pm_block_user_settings_submit in pm_block_user/pm_block_user.admin.inc
Submit handler for admin form.

File

pm_block_user/pm_block_user.admin.inc, line 96
Administration menu callbacks for pm_block_user.module.

Code

function _pm_block_user_settings_filter($settings) {

  // Add-in the names of any settings to be saved into the array below.
  $save_keys = array(
    'author',
    'recipient',
    'action',
    'enabled',
  );
  $matching = array();

  // Run through each of the keys we want to save, creating a new array.
  // It's not possible to simply check for unwanted values and unset() them as
  // the array is multi-dimensional.
  foreach ($save_keys as $save_key) {
    if (isset($settings[$save_key])) {
      $matching[$save_key] = $settings[$save_key];
    }
  }
  if (count($matching) > 0) {
    return $matching;
  }
  else {
    return array_map('_pm_block_user_settings_filter', $settings);
  }
}