You are here

function _mobile_tools_validate_device_groups in Mobile Tools 7.2

Validates the defined device groups. Removes any invalid entries and logs the error.

1 call to _mobile_tools_validate_device_groups()
mobile_tools_device_groups_rebuild in ./mobile_tools.module
Rebuild the list of implemented device groups

File

./mobile_tools.module, line 788
Functionality to ease the creation of mixed device environments.

Code

function _mobile_tools_validate_device_groups(&$device_groups) {
  foreach ($device_groups as $id => $name) {
    if (!ctype_alpha($id)) {
      unset($device_groups[$id]);
      drupal_set_message(t('Invalid device group ID @group. Group IDs must be alphabetic.', array(
        '@group' => $id,
      )), 'error', FALSE);
      watchdog('mobile_tools', 'Invalid device group ID @group. Group IDs must be alphabetic.', array(
        '@group' => $id,
      ), WATCHDOG_ERROR);
    }

    // @todo add validation on the device group name
    //    else if (!ctype_alpha($name)) {
    //      unset($device_groups[$id]);
    //      drupal_set_message(t('Invalid device group name @group. Group names must be alphabetic.', array('@group' => $name)), 'error', FALSE);
    //      watchdog('mobile_tools', 'Invalid device group name @group. Group names must be alphabetic.', array('@group' => $name), WATCHDOG_ERROR);
    //    }
  }
}