function ad_type_save in Advertisement 7.2
Saves an ad type.
This function will either insert a new ad type if $ad_type->is_new is set or attempt to update an existing ad type if it is not. It does not currently support changing the machine-readable name of the ad type, nor is this possible through the form supplied by the Ad UI module.
Parameters
$ad_type: The ad type object containing the basic properties as initialized in ad_type_new().
Return value
The return value of the call to drupal_write_record() to save the ad type, either FALSE on failure or SAVED_NEW or SAVED_UPDATED indicating the type of query performed to save the ad type.
2 calls to ad_type_save()
- ad_install in ./
ad.install - Implements hook_install().
- ad_ui_type_form_submit in includes/
ad_ui.types.inc - Form submit handler: save an ad type.
File
- ./
ad.module, line 142 - Defines the core ad entity, including the entity itself, the bundle definitions (ad types), and various API functions to manage ads and interact with them through forms and autocompletes.
Code
function ad_type_save($ad_type) {
$op = drupal_write_record('ad_type', $ad_type, empty($ad_type->is_new) ? 'type' : array());
menu_rebuild();
// If this is a new ad type and the insert did not fail...
if (!empty($ad_type->is_new) && $op !== FALSE) {
// Notify the field API that a new bundle has been created.
field_attach_create_bundle('ad', $ad_type->type);
// Notify other modules that a new ad type has been created.
module_invoke_all('ad_type_insert', $ad_type);
}
else {
// Notify other modules that an existing ad type has been updated.
module_invoke_all('ad_type_update', $ad_type);
}
return $op;
}