diff --git a/includes/features.contact.inc b/includes/features.contact.inc index c7b5d73..2dbaa2b 100644 --- a/includes/features.contact.inc +++ b/includes/features.contact.inc @@ -1,14 +1,20 @@ array( - 'name' => t('Contact categories'), + 'name' => t('Contact categories'), 'feature_source' => TRUE, - 'default_hook' => 'contact_categories_defaults', - 'default_file' => FEATURES_DEFAULTS_INCLUDED, + 'default_hook' => 'contact_categories_defaults', + 'default_file' => FEATURES_DEFAULTS_INCLUDED, ), ); } @@ -18,7 +24,8 @@ function contact_features_api() { */ function contact_categories_features_export_options() { $options = array(); - foreach (db_select('contact', 'c')->fields('c')->execute()->fetchAll() as $category) { + $categories = db_select('contact', 'c')->fields('c')->execute()->fetchAll(); + foreach ($categories as $category) { $options["$category->category"] = "$category->category"; } return $options; @@ -29,7 +36,7 @@ function contact_categories_features_export_options() { */ function contact_categories_features_export($data, &$export, $module_name = '') { $export['dependencies']['features'] = 'features'; - $export['dependencies']['contact'] = 'contact'; + $export['dependencies']['contact'] = 'contact'; foreach ($data as $name) { $export['features']['contact_categories'][$name] = $name; @@ -54,7 +61,7 @@ function contact_categories_features_export_render($module, $data, $export = NUL $render[$name] = $category; } } - return array('contact_categories_defaults' => ' return '. features_var_export($render, ' ') .';'); + return array('contact_categories_defaults' => ' return ' . features_var_export($render, ' ') . ';'); } /** @@ -74,23 +81,26 @@ function contact_categories_features_rebuild($module) { ->fields('c', array('cid', 'category')) ->execute() ->fetchAll(); - if($existing_categories) { + if ($existing_categories) { foreach ($existing_categories as $existing_category) { - if($default_category['category'] == $existing_category->category) { - db_update('contact')->fields( - array( - 'recipients' => $default_category['recipients'], - 'reply' => $default_category['reply'], - 'weight' => $default_category['weight'], - 'selected' => $default_category['selected'], + if ($default_category['category'] == $existing_category->category) { + db_update('contact') + ->fields( + array( + 'recipients' => $default_category['recipients'], + 'reply' => $default_category['reply'], + 'weight' => $default_category['weight'], + 'selected' => $default_category['selected'], + ) ) - )->condition('category', $existing_category->category, '=')->execute(); + ->condition('category', $existing_category->category, '=') + ->execute(); } else { db_merge('contact') - ->key(array('category' => $default_category['category'])) - ->fields($default_category) - ->execute(); + ->key(array('category' => $default_category['category'])) + ->fields($default_category) + ->execute(); } } }