function amp_admin_metadata_form_submit in Accelerated Mobile Pages (AMP) 7
Submit handler for the amp_admin_metadata_form. Sets the logo file to permanent.
1 string reference to 'amp_admin_metadata_form_submit'
- amp_admin_metadata_form in ./
amp.admin.inc - Form constructor for the AMP metadata form.
File
- ./
amp.admin.inc, line 371 - Administrative page callbacks for the AMP module.
Code
function amp_admin_metadata_form_submit($form, &$form_state) {
$old_fid = variable_get('amp_metadata_organization_logo', 0);
if ($form_state['values']['amp_metadata_organization_logo'] != $old_fid) {
$file = file_load($form_state['values']['amp_metadata_organization_logo']);
// If this is a new file...
if (!$file->status) {
$file->status = FILE_STATUS_PERMANENT;
file_save($file);
file_usage_add($file, 'amp', 'logo', 1);
}
// Delete the old file
$old_file = $old_fid ? file_load($old_fid) : FALSE;
if ($old_file) {
file_usage_delete($old_file, 'amp', 'logo', 1);
// Only delete a file if it is the only place it is in use.
if (empty(file_usage_list($old_file))) {
file_delete($old_file);
}
}
}
}