You are here

function modal_entityform_page_edit in Modal operations 7

Modal Entityform edit page callback.

1 string reference to 'modal_entityform_page_edit'
modal_entityform_menu in modal_entityform/modal_entityform.module
Implements hook_menu().

File

modal_entityform/modal_entityform.module, line 104
Allows entityform submitting and editing in modal window.

Code

function modal_entityform_page_edit($entityform, $js, $force_page_reload = TRUE) {

  // Fall back if $js is not set.
  if (!$js) {
    $parameters = drupal_get_query_parameters();
    unset($_GET['destination']);
    drupal_goto('entityform/' . $entityform->entityform_id . '/edit', array(
      'query' => $parameters,
    ));
    return NULL;
  }

  // Fix superglobals (such as $_GET) in order to make arg() work properly.
  modal_set_path_data('entityform/' . $entityform->entityform_id . '/edit');
  ctools_include('modal');
  ctools_include('ajax');
  $entityform_type_entity = entityform_type_load($entityform->type);
  if (!modal_entityform_access('edit', $entityform)) {
    $commands = array(
      ctools_modal_command_display(t('Access denied'), t('You are not authorized to access this page.')),
    );
    $commands[] = ajax_command_invoke('#modalContent', 'addClass', array(
      'modal-denied-entityform-edit modal-denied-entityform-edit-' . $entityform->type,
    ));
    drupal_alter('modal_entityform_edit_access_denied', $commands, $entityform_type_entity, $entityform);
    return array(
      '#type' => 'ajax',
      '#commands' => $commands,
    );
  }
  $title = $entityform_type_entity->label;
  drupal_alter('modal_entityform_edit_title', $title, $entityform_type_entity, $entityform);
  return modal_entityform_form($entityform, $title, $entityform_type_entity, $force_page_reload);
}