function swftools_profiles_profile_save in SWF Tools 6.3
Saves a profile to the database.
Parameters
array $profile: The profile to save, as an array.
Return value
bool Status flag indicating outcome of the operation:
- SAVED_UPDATED: The save updated an existing profile in the database.
- SAVED_NEW: The save inserted a new profile in the database.
1 call to swftools_profiles_profile_save()
- swftools_profiles_profile_form_submit in profiles/
swftools_profiles.admin.inc - Implementation of hook_form_submit().
File
- profiles/
swftools_profiles.admin.inc, line 411 - Configuration settings for SWF Tools profiles.
Code
function swftools_profiles_profile_save($profile) {
// Set flag to show if this is an existing profile
$is_existing = FALSE;
// Set the name of the existing profile
$existing_profile = !empty($profile['old_profile']) ? $profile['old_profile'] : $profile['profile'];
// See if this profile is in the database
$is_existing = db_result(db_query("SELECT COUNT(*) FROM {swftools_profiles} WHERE profile = '%s'", $existing_profile));
// If the profile exists, update it, otherwise insert it
if ($is_existing) {
db_query("UPDATE {swftools_profiles} SET profile = '%s', name = '%s', description = '%s', multiple = %d, download_link = %d WHERE profile = '%s'", $profile['profile'], $profile['name'], $profile['description'], $profile['multiple'], $profile['download_link'], $existing_profile);
return SAVED_UPDATED;
}
else {
db_query("INSERT INTO {swftools_profiles} (profile, name, description, multiple, download_link) VALUES ('%s', '%s', '%s', %d, %d)", $profile['profile'], $profile['name'], $profile['description'], $profile['multiple'], $profile['download_link']);
return SAVED_NEW;
}
}