You are here

function _content_lock_add_cancelbutton in Content locking (anti-concurrent editing) 6

Same name and namespace in other branches
  1. 6.2 content_lock.module \_content_lock_add_cancelbutton()
  2. 7 content_lock.module \_content_lock_add_cancelbutton()
  3. 7.2 content_lock.module \_content_lock_add_cancelbutton()
1 call to _content_lock_add_cancelbutton()
content_lock_form_alter in ./content_lock.module
Implementation of hook_form_alter().

File

./content_lock.module, line 282
Allows users to lock documents for modification.

Code

function _content_lock_add_cancelbutton(&$form, $form_state, $form_id) {
  if (isset($form['#id'])) {
    if ($form['#id'] == 'comment-form') {
      $node = $form['#node'];
      $form['cancel']['#type'] = 'markup';
      $form['cancel']['#weight'] = 2000;
      $form['cancel']['#value'] = l(t('Cancel'), 'node/' . $form['nid']['#value'] . "/canceledit", array(
        'attributes' => array(
          'class' => 'form-submit form-submit-cancel',
        ),
      ));
    }
    else {
      if ($form['#id'] == 'user-profile-form') {
        $form['buttons'] = array(
          '#weight' => 20000,
        );
        $form['buttons']['submit'] = $form['submit'];
        $form['buttons']['submit']['#weight'] = -5;
        if (isset($form['delete'])) {
          $form['buttons']['delbtn'] = $form['delete'];
          $form['buttons']['delbtn']['#weight'] = -4;
        }
        $form['buttons']['cancel']['#type'] = 'markup';
        $form['buttons']['cancel']['#weight'] = 2000;
        $form['buttons']['cancel']['#value'] = l(t('Cancel'), 'user/' . $form['#uid'] . "/canceledit", array(
          'attributes' => array(
            'class' => 'form-submit form-submit-cancel',
          ),
        ));
        unset($form['submit']);
        unset($form['delete']);
      }
      else {
        if ($form['#id'] == 'node-form') {
          $node = $form['#node'];
          $form['buttons']['cancel']['#type'] = 'markup';
          $form['buttons']['cancel']['#weight'] = 2000;
          $form['buttons']['cancel']['#value'] = l(t('Cancel'), 'node/' . $node->nid . "/canceledit", array(
            'attributes' => array(
              'class' => 'form-submit form-submit-cancel',
            ),
          ));
          if (isset($form['buttons']['delete'])) {
            $form['buttons']['delete']['#weight'] = 2001;
          }
        }
        else {
          if ($form['#id'] == 'node-form' && arg(0) == 'node') {
            $node = $form['#node'];
            $form['buttons']['cancel']['#type'] = 'markup';
            $form['buttons']['cancel']['#weight'] = 2000;
            $form['buttons']['cancel']['#value'] = l(t('Cancel'), '', array(
              'attributes' => array(
                'class' => 'form-submit form-submit-cancel',
              ),
            ));
          }
        }
      }
    }
  }
}