You are here

function ad_owners_add_form_submit in Advertisement 6

Same name and namespace in other branches
  1. 5 ad.module \ad_owners_add_form_submit()
  2. 6.3 owners/ad_owners.module \ad_owners_add_form_submit()
  3. 6.2 owners/ad_owners.module \ad_owners_add_form_submit()
  4. 7 owners/ad_owners.module \ad_owners_add_form_submit()

File

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

Code

function ad_owners_add_form_submit($form, &$form_state) {
  $owner = user_load(array(
    'name' => $form_state['values']['username'],
  ));
  $node = node_load($form_state['values']['aid']);
  if (!ad_owners_add($node, $owner->uid)) {
    form_set_error('username', t('The user is already an owner of the ad.'));
  }
  else {
    drupal_set_message(t('The user %username has been added as an owner of this advertisement.', array(
      '%username' => $form_state['values']['username'],
    )));
    drupal_goto('node/' . $form_state['values']['aid'] . '/adowners/' . $owner->uid . '/permissions');
  }
}