You are here

function ad_owner_remove_form_validate in Advertisement 7

Same name and namespace in other branches
  1. 6.3 owners/ad_owners.module \ad_owner_remove_form_validate()
  2. 6 owners/ad_owners.module \ad_owner_remove_form_validate()
  3. 6.2 owners/ad_owners.module \ad_owner_remove_form_validate()

Don't allow the removal of the primary owner of the advertisement.

File

owners/ad_owners.module, line 444
Enhances the ad module to support ad owners.

Code

function ad_owner_remove_form_validate($form, &$form_state) {
  $node = node_load($form_state['values']['aid']);
  if ($node->uid == $form_state['values']['uid']) {
    $owner = user_load(array(
      'uid' => $form_state['values']['uid'],
    ));
    drupal_set_message(t('%name is the primary owner of this advertisement.  You cannot remove the primary owner.', array(
      '%name' => $owner->name,
    )), 'error');
    $form_state['redirect'] = 'node/' . $form_state['values']['aid'] . '/adowners';
  }
}