Sometimes when you have a more open site, or if you don't need the confirmation.
There is no need for having a confirmation message when adding a buddy.
This then would be annoying.

Because I don't know yet how to create a patch i will post this here.
There are function changes in the buddylist.module itself.
I think it would be easier if this function could be added in the buddylist settings.
Confirmation On/Off.

I included the code for drupal 4.6 and drupal 4.7

original code Drupal 4.6:

function buddylist_addbuddy($uid) {
  global $user;

  $buddy = user_load(array('uid' => $uid));
  if (empty($buddy->name)) {
    return t('This user does not exist');
  }
  else if (in_array($uid, array_keys(buddylist_get_buddies($user->uid)))) {
    return t('This user is already on your buddy list');
  }
  else if ($user->uid == $uid) {
    return t('Cannot add yourself to buddy list');
  }
  else {
    if (($_POST['op'] == t('add user')) && $_POST['edit']['confirm']) {
      buddylist_add($uid);
      buddylist_goto_referrer();
    }

    print theme('page', theme('confirm', t('Add user %name to your buddy list?', array('%name' => $buddy->name)), 'user',
           t('%name will be be notified the next time s/he logs in.', array('%name' => $buddy->name)), t('add user')));
  }
}

function buddylist_deletebuddy($uid) {
  global $user;
  $buddy = user_load(array('uid' => $uid));

  if (empty($buddy->name)) {
    return t('This user does not exist');
  }
  else if (!in_array($uid, array_keys(buddylist_get_buddies($user->uid)))) {
    return t('This user is not on your buddy list');
  }
  else {
    if (($_POST['op'] == t('remove user')) && $_POST['edit']['confirm']) {
      buddylist_remove($uid);
      buddylist_goto_referrer();
    }
    print theme('page', theme('confirm', t('Remove user %name from your buddy list?', array('%name' => $buddy->name)), 'user',
           t('%name will be not be notified the next time s/he logs in.', array('%name' => $buddy->name)), t('remove user')));
  }
}

functions without confirmation Drupal 4.6:

function buddylist_addbuddy($uid) {
  global $user;

  $buddy = user_load(array('uid' => $uid));
  if (empty($buddy->name)) {
    return t('This user does not exist');
  }
  else if (in_array($uid, array_keys(buddylist_get_buddies($user->uid)))) {
    return t('This user is already on your buddy list');
  }
  else if ($user->uid == $uid) {
    return t('Cannot add yourself to buddy list');
  }
  else {
      buddylist_add($uid);
      drupal_goto('user/'.$uid);
    }
}

function buddylist_deletebuddy($uid) {
  global $user;
  $buddy = user_load(array('uid' => $uid));

  if (empty($buddy->name)) {
    return t('This user does not exist');
  }
  else if (!in_array($uid, array_keys(buddylist_get_buddies($user->uid)))) {
    return t('This user is not on your buddy list');
  }
  else {
      buddylist_remove($uid);
      drupal_goto('user/'.$uid);
  }
}

Since i updated to drupal 4.7 I did it this way:

function buddylist_addbuddy($uid) {
  global $user;
  $uid = (int)$uid;
  $buddy = user_load(array('uid' => $uid));

  if (empty($buddy->name)) {
    return t('This user does not exist');
  }
  elseif (in_array($uid, array_keys(buddylist_get_buddies($user->uid)))) {
    return t('This user is already on your %buddy list', buddylist_translation());
  }
  elseif ($user->uid == $uid) {
    return t('Cannot add yourself to %buddy list', buddylist_translation());
  }
/* NO CONFIRMATION NEEDED
  $form['uid'] = array('#type' => 'hidden', '#value' => $uid);
  $form['name'] = array('#type' => 'hidden', '#value' => $buddy->name);
  return confirm_form('buddylist_addbuddy_confirm',
    $form,
    t('Add user %name to your %buddy list?', array('%name' => theme('placeholder', $buddy->name)) + buddylist_translation()),
    $_GET['destination'],
    ' ',
    t('Add'), t('Cancel'));
*/
// JUST ADD BUDDY AND RETURN TO THE USERS PAGE (because this was the last place you were seen)
  buddylist_add($uid);
  drupal_goto('user/'.$uid);
}


function buddylist_deletebuddy($uid) {
  global $user;
  $uid = (int)$uid;
  $buddy = user_load(array('uid' => $uid));

  if (empty($buddy->name)) {
    return t('This user does not exist');
  }
  else if (!in_array($uid, array_keys(buddylist_get_buddies($user->uid)))) {
    return t('This user is not on your %buddy list', buddylist_translation());
  }

  $form['uid'] = array('#type' => 'hidden', '#value' => $uid);
  $form['name'] = array('#type' => 'hidden', '#value' => $buddy->name);
  
/* NO CONFIRMATION NEEDED
  return confirm_form('buddylist_deletebuddy_confirm',
    $form,
    t('Remove user %name from your %buddy list?', array('%name' => theme('placeholder', $buddy->name)) + buddylist_translation()),
    $_GET['destination'],
    ' ',
    t('Remove'), t('Cancel'));

*/
//	JUST REMOVE FROM LIST AND RETURN TO THE USERS PAGE (maybe you want to add user again or removed this user by mistake)
	buddylist_remove($uid);
    drupal_goto('user/'.$uid);
}

Comments

quicksketch’s picture

Adding an setting for turning off and on warnings seems like a good idea to me. If there is a greater demand, I'll definately put this together.

fago’s picture

Status: Needs work » Closed (won't fix)

so it doesn't seem that there is a greater demand.. or?