You are here

function mobile_tools_device_group_save in Mobile Tools 7.3

Saves the given option set to the database.

Set the $new flag if it is a new entry.

Parameters

object $device_group: Device group to save to the database

boolean $new [optional]: New entry flag

Return value

object Returns the saved device group.

1 call to mobile_tools_device_group_save()
mobile_tools_device_group_form_submit in ./mobile_tools.admin.inc
Handles form submission for a new device group

File

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

Code

function mobile_tools_device_group_save($device_group, $new = FALSE) {

  // Create the appropriate link to themekey
  if (module_exists('themekey')) {
    if ($device_group->theme != MOBILE_TOOLS_FLAG_DEFAULT_SITE_THEME) {

      // Ensure the ThemeKey functions are available
      module_load_include('inc', 'themekey', 'themekey_build');
      $themekey = _mobile_tools_prepare_themekey_rule($device_group);
      if (!$new && !is_null($device_group->themekey_id)) {

        // Load the existing themekey rule ID
        $themekey['id'] = $device_group->themekey_id;
      }

      // Save the rule to themekey database
      // @todo lock the themekey rule from being edited
      themekey_rule_set($themekey, 'mobile_tools');

      // Add a reference to the themekey rule to the device group
      // @todo add validation that the save worked
      $device_group->themekey_id = $themekey['id'];
    }
  }
  ctools_include('export');
  return ctools_export_crud_save('mobile_tools_device_group', $device_group);
}