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 viewUsersForTeam_submit($form, $form_state) { $TID = $form_state['TID']; $roleChanged = false; for ($i = 0; $i < $form_state['numUsers']; $i++) { if (!isset($form_state['values']["RID-{$i}"])) { continue; } $UID = $form_state["UID-{$i}"]; $newRID = $form_state['values']["RID-{$i}"]; $oldRID = $form["RID-{$i}"]['#default_value']; // check if the RID changed if ($newRID != $oldRID) { // adding new role if ($oldRID == 0) { dbGiveUserRID($UID, $TID, $newRID); } else { if ($newRID != 0) { $result = dbUpdateUserRole($UID, $TID, $newRID); } else { dbRemoveAllUserRoles($UID, $TID); } } $userName = dbGetUserName($UID); drupal_set_message("{$userName}'s role has been updated."); $roleChanged = true; $notification = array('UID' => $UID, 'TID' => $TID, 'dateCreated' => date(DEFAULT_TIME_FORMAT, time()), 'dateTargeted' => date(DEFAULT_TIME_FORMAT, time())); // check if the user no longer has a role if (dbGetRoleName($newRID) == false) { $notification['message'] = "You are no longer a " . strtolower(dbGetRoleName($oldRID)); } else { $notification['message'] = 'You are now a ' . strtolower(dbGetRoleName($newRID)); } $notification['message'] .= ' on team ' . dbGetTeamName($TID) . '.'; dbAddNotification($notification); } } if (!$roleChanged) { drupal_set_message('No changes were made. An issue occured.', 'error'); } }
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))); } }