You are here

function ad_permission_owner_add_form_submit in Advertisement 5.2

File

permission/ad_permission.module, line 230
Provide granular permissions for advertisements.

Code

function ad_permission_owner_add_form_submit($form_id, $form_values) {
  $owner = user_load(array(
    'name' => $form_values['username'],
  ));
  if (!ad_permission_owners_add($form_values['aid'], $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_values['username'],
    )));
    drupal_goto('node/' . $form_values['aid'] . "/adowners/{$owner->uid}/permissions");
  }
}