You are here

function invite_update_6 in Invite 5.2

Same name and namespace in other branches
  1. 5 invite.install \invite_update_6()

Clean up invitations of deleted users.

File

./invite.install, line 216
Installation file for invite module.

Code

function invite_update_6() {
  $ret = array();
  if (variable_get('invite_allow_join_delete', 0)) {
    $result = db_query("SELECT i.mid FROM {invite} i LEFT JOIN {users} u ON i.mid = u.uid WHERE u.uid IS NULL");
    $count = db_num_rows($result);
    while ($invitee = db_fetch_object($result)) {
      db_query("DELETE FROM {invite} WHERE mid = %d", $invitee->mid);
    }
    $ret[] = array(
      'query' => strtr('%count orphaned invites have been deleted.', array(
        '%count' => $count,
      )),
      'success' => TRUE,
    );
  }
  return $ret;
}