You are here

function pmpapi_groups_edit_form_submit in Public Media Platform API Integration 7

Form submission handler for pmpapi_groups_edit_form().

File

pmpapi_groups/pmpapi_groups.admin.inc, line 115
Basic admin forms, validators, and submit handlers.

Code

function pmpapi_groups_edit_form_submit($form, &$form_state) {
  $values = array(
    'profile' => 'group',
    'attributes' => array(
      'title' => $form_state['values']['name'],
    ),
  );
  if (!empty($form_state['values']['guid'])) {
    $values['attributes']['guid'] = $form_state['values']['guid'];
  }
  foreach ($form_state['values']['orgs'] as $org) {
    $item = new stdClass();
    $item->href = variable_get('pmpapi_base_url') . '/docs/' . $org;
    $values['items'][] = $item;
  }
  if (pmpapi_send($values)) {
    $transaction = !empty($form_state['values']['guid']) ? t('edited') : t('created');
    $message = t('Successfully !transaction the group: @group', array(
      '!transaction' => $transaction,
      '@group' => $form_state['values']['name'],
    ));
    drupal_set_message($message);
  }
  else {
    drupal_set_message(t('Error sending group data to the PMP.'), 'warning');
  }
  $form_state['redirect'] = 'admin/config/services/pmp/groups';
}