function bynder_add_submit in Bynder 7
File
- includes/
bynder.browser.inc, line 89 - Manages the Bynder media browser functionality
Code
function bynder_add_submit($form, &$form_state) {
if ($selected_assets = $form_state['values']['selected_assets']) {
$fids = array();
foreach ($selected_assets as $assetId => $selected) {
if ($selected) {
$result = bynder_save_image($assetId, $form);
if (isset($result['success'])) {
$fids[] = $result['fid'];
}
else {
drupal_set_message(t($result['message']), 'error');
}
}
}
// Save the files
if (!empty($fids)) {
if (current_path() != 'admin/content/media/add/bynder') {
drupal_goto('/media/browser', array(
'query' => array(
'render' => 'media-popup',
'fid' => $fids,
),
));
}
else {
drupal_set_message(t("Successfully added the selected assets."), 'status');
drupal_goto('admin/content/file');
}
}
}
drupal_set_message(t("Couldn't add any assets, please try again."), 'error');
}