You are here

function gallery_assist_delete_one in Gallery Assist 6

Add to the form the data from the image that will be deleted. Menu callback which is activated by clicking on the link delete over the images.

Parameters

Array $form_state:

Object $node:

Integer $pid:

Return value

An array containing the form data.

1 string reference to 'gallery_assist_delete_one'
gallery_assist_menu in ./gallery_assist.module
Implementation of hook_menu().

File

./gallery_assist.module, line 552
Drupal content type with gallery functionality.

Code

function gallery_assist_delete_one(&$form_state, $node, $pid) {
  global $user;
  if (gallery_assist_check_access($node, 'delete')) {
    $form = array();
    $form['gallery_assist_delete_one'] = array(
      '#type' => 'fieldset',
      '#prefix' => t('<div>Are you sure you want to delete the image %name? If not <a href="@cancel">cancel</a></div>', array(
        '%name' => $node->gallitems[$pid]->ptitle,
        '@cancel' => url("node/{$node->nid}"),
      )),
    );
    foreach ($node->gallitems[$pid] as $k => $v) {
      $form['gallery_assist_delete_one'][$k] = array(
        '#type' => 'value',
        '#value' => $v,
      );
    }
    $form['gallery_assist_delete_one']['image'] = array(
      '#type' => 'item',
      '#value' => theme('image', $node->gallitems[$pid]->tpath),
    );

    // Build the query string to complete the link and so make exact the redirect.
    $myPath = array();
    $myPath[] = 'node/' . $node->nid;
    if ($_GET['page']) {
      $myPath[] = 'page=' . $_GET['page'];
    }
    if ($_GET['titles']) {
      $myPath[] = 'titles=' . $_GET['titles'];
    }
    $form['deleteone'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
      '#name' => 'deleteone',
      '#redirect' => $myPath,
    );
    $form['#submit'][] = 'gallery_assist_delete_one_submit';
    $form['#redirect'] = $myPath;
    return $form;
  }
  else {
    drupal_access_denied();
  }
}