function deleteUserPage_submit($form, $form_state) { global $user; $UID = $user->uid; $teams = dbGetTeamsForUser($UID); // getting teams that are associated with a user foreach ($teams as $team) { // looping through these teams dbKickUserFromTeam($UID, $team['TID']); // removing the user from these teams dbRemoveAllUserRoles($UID, $team['TID']); // ensuring the user doesn't have any role on the team } dbRemoveAllEmailsForUser($UID); dbDisableUser($UID); $params['feedback'] = stripTags($form_state['values']['misc'], ''); // stripping any "illegal" HTML tags $params['userName'] = dbGetUserName($UID); // getting the user name drupal_mail('users', 'userdeleted', '*****@*****.**', variable_get('language_default'), $params, $from = null, $send = true); // sending the user a confirmation mail drupal_set_message("Your account has been deleted. We're sorry to see you go!"); // message displayed and redirected to front page drupal_goto('<front>'); }
function leaveTeam($TID) { global $user; dbKickUserFromTeam($user->uid, $TID); dbRemoveAllUserRoles($user->uid, $TID); dbRemoveUserFromFutureTeamOutreach($user->uid, $TID); clearCurrentTeam(); $notification = array(); $notification['dateCreated'] = dbDatePHP2SQL(time()); $notification['dateTargeted'] = dbDatePHP2SQL(time()); $userName = dbGetUserName($user->uid); $teamName = dbGetTeamName($TID); $notification['message'] = "{$userName} has left team {$teamName}."; $notification['bttnTitle'] = "View"; $notification['bttnLink'] = "?q=viewUser&UID={$user->uid}"; $notification['TID'] = $TID; notifyUsersByRole($notification, 'teamAdmin'); // notify team owner $notification['UID'] = dbGetTeam($TID)['UID']; dbAddNotification($notification); drupal_set_message("You have successfully left {$teamName}."); if (isset($_SERVER['HTTP_REFERER'])) { drupal_goto($_SERVER['HTTP_REFERER']); } else { drupal_goto('manageUserTeams'); } }
function kickUserFromTeam($UID, $TID) { global $user; if (teamIsIneligible($TID)) { drupal_set_message('Your team does not have permission to access this page.', 'error'); drupal_goto($_SERVER['HTTP_REFERER']); } dbKickUserFromTeam($UID, $TID); dbRemoveAllUserRoles($UID, $TID); // notify the person who has been removed (and allow them to email the one who removed them) $notification = array('UID' => $UID, 'TID' => $TID, 'dateTargeted' => dbDatePHP2SQL(time()), 'dateCreated' => dbDatePHP2SQL(time())); $notification['message'] = 'You have been removed from ' . dbGetTeamName($TID); $notification['bttnTitle'] = 'Email Admin'; $notification['bttnLink'] = "mailto:{$user->mail}"; dbAddNotification($notification); drupal_set_message("User has been removed from your team."); if (isset($_SERVER['HTTP_REFERER'])) { drupal_goto($_SERVER['HTTP_REFERER']); } else { drupal_goto('showUsersForTeam', array('query' => array('TID' => $TID))); } }