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 rejectTeam($TID) { dbRejectTeam($TID); $UID = dbGetOwnerForTeam($TID); drupal_mail('adminFunctions', 'teamRejected', dbGetUserPrimaryEmail($UID), variable_get('language_default'), $params = array('teamName' => dbGetTeamName($TID), 'fullName' => dbGetUserName($UID)), $from = NULL, $send = TRUE); drupal_set_message('The team has been rejected and the team owner has been notified!'); if (isset($_SERVER['HTTP_REFERER'])) { drupal_goto($_SERVER['HTTP_REFERER']); } else { drupal_goto('adminPage'); } }
function hoursAwaitingApproval() { $currentTeam = getCurrentTeam(); if ($currentTeam == false) { drupal_set_message("You don't have a team assigned.", 'error'); return; } $TID = $currentTeam['TID']; $teamNumber = $currentTeam['number']; // create header $markup = ''; $markup .= '<h2>Hours Awaiting Approval</h2>'; $markup .= '<table class="infoTable"><tr>'; $markup .= '<th colspan="2">Outreach</th>'; $markup .= '<th colspan="2">User</th>'; $markup .= '<th colspan="2">Hours</th>'; $markup .= '<th colspan="2"></th>'; $markup .= "</tr>"; $filterParams = array('TID' => $TID, 'isApproved' => false); $hours = dbGetHours($filterParams); // if the team has unapproved hours if (!empty($hours)) { foreach ($hours as $hour) { $OID = $hour['OID']; $outreach = dbGetOutreach($OID); $UID = $hour["UID"]; $numHours = $hour['numberOfHours']; $HID = $hour['HID']; $markup .= "<tr>"; $markup .= '<td colspan="2">' . '<a href="?q=viewOutreach&OID=' . $outreach['OID'] . '">' . chopString($outreach["name"], 20) . '</a>' . '</td>'; $markup .= '<td colspan="2">' . dbGetUserName($UID) . ' </td>'; $markup .= '<td colspan="2"><a href="?q=logHours&HID=' . $HID . '">' . $numHours . '</a></td>'; // approve or reject buttons if (canApproveHours($HID)) { $markup .= "<td colspan=\"2\"><a href=\"?q=approveHours/{$hour['HID']}\"><button>Approve</button></a>"; $markup .= "<a href=\"?q=deleteHours/{$HID}\">"; $markup .= '<button><img class="trashIcon" src="/images/icons/trashWhite.png"></button></a></td>'; } else { $markup .= '<td></td><td></td>'; } $markup .= "</tr>"; } } else { // display none if the team has no hours waiting approval $markup .= "<tr>"; $markup .= '<td style="text-align:center" colspan="8"><em>[None]</em></td>'; $markup .= "</tr>"; } $markup .= "</table>"; $retArray = array(); $retArray['#markup'] = $markup; return $retArray; }
function manageNotifications() { $params = drupal_get_query_parameters(); if (isset($params['OID'])) { $OID = $params['OID']; $outreachName = dbGetOutreachName($OID); // create page header, table, and add notification button $markup = ''; $markup .= '<table>'; $markup .= "<tr><td><h1>Manage Notifications for \"{$outreachName}\" </h1>"; $markup .= '</td><td style="text-align:right">'; $markup .= '<a href="?q=notificationForm&OID=' . $OID . '"><button>Add Notification</button></a></td></tr></table>'; $markup .= '<table class="infoTable"><tr><th colspan="3">Target Users</th><th colspan="3">Notification Message</th><th colspan="2">Date To Be Sent</th><th colspan="2"></th></tr>'; $notifications = dbGetNotificationsForOutreach($OID); // if outreach already has notifications if (!empty($notifications)) { foreach ($notifications as $notification) { $markup .= '<tr>'; $markup .= '<td colspan="3">' . dbGetUserName($notification['UID']) . '</td>'; $markup .= '<td colspan="3">' . $notification['message'] . '</td>'; $date = dbDateSQL2PHP($notification['dateTargeted']); $markup .= '<td colspan="2">' . date(TIME_FORMAT, $date) . '</td>'; $markup .= '<td colspan="2"><a href="?q=deleteNotification/' . $notification['NID']; $markup .= "/{$OID}\"><button>Delete</button></a></td>"; $markup .= '</td>'; } $markup .= '</table>'; } else { // if outreach does not have notifications $markup .= "<tr>"; $markup .= '<td style="text-align:center" colspan="10"><em>[None]</em></td>'; $markup .= "</tr>"; } $markup .= "</table>"; return array('#markup' => $markup); } else { // returns message if OID is not correct drupal_set_message('No outreach selected.', 'error'); drupal_goto($_SERVER['HTTP_REFERER']); } }
function deleteTeamPage_submit($form, $form_state) { global $user; $UID = $user->uid; $TID = $form_state['TID']; if (dbUserHasPermissionForTeam($user->uid, 'deleteTeam', $TID)) { dbDeactivateTeam($TID); dbKickAllUsersFromTeam($TID); dbRemoveAllRolesFromTeam($TID); } else { drupal_set_message('You do not have permission to perform this action.', 'error'); return; } // send an email to the CROMA team detailing the team deletion $params['feedback'] = stripTags($form_state['values']['misc'], ''); $params['userName'] = dbGetUserName($UID); $params['teamName'] = dbGetTeamName($TID); $params['teamNumber'] = dbGetTeamNumber($TID); drupal_mail('teams', 'teamDeleted', '*****@*****.**', variable_get('language_default'), $params, $from = NULL, $send = TRUE); drupal_set_message(dbGetTeamName($TID) . " has been deleted."); drupal_goto('<front>'); }
function addTeamMember_submit($form, $form_state) { $UID = dbSearchUserByEmail($form_state['values']['primaryEmail']); $teamName = dbGetTeamName($form_state['TID']); // if the user doesn't exist yet if ($UID == false) { // programmatically creates a Drupal user and sends an email to set-up account $UID = createNewUser($form_state); } else { $params['fullName'] = dbGetUserName($UID); $params['teamName'] = $teamName; drupal_mail('teams', 'approvedForTeam', $form_state['values']['primaryEmail'], NULL, $params, '*****@*****.**'); } $notification = array('UID' => $UID, 'TID' => $form_state['TID'], 'dateCreated' => dbDatePHP2SQL(time()), 'dateTargeted' => dbDatePHP2SQL(time())); $notification['message'] = 'You have just been added to ' . $teamName . '!'; $notification['bttnTitle'] = 'View Team'; $notification['bttnLink'] = "?q=viewTeam&TID={$form_state['TID']}"; dbAddNotification($notification); dbAssignUserToTeam($UID, $form_state['TID']); $userName = dbGetUserName($UID); drupal_set_message("{$userName} has been invited to your team!"); }
function recentTeamOutreach() { global $user; $UID = $user->uid; $params = drupal_get_query_parameters(); if (isset($params['TID'])) { $TID = $params['TID']; $team = dbGetTeam($TID); $teamNumber = $team['number']; } else { $team = getCurrentTeam(); $TID = $team['TID']; $team = dbGetTeam($TID); $teamNumber = $team['number']; } // checks to see if team can access page if (teamIsIneligible($TID)) { drupal_set_message('Your team does not have permission to access this page.', 'error'); drupal_goto($_SERVER['HTTP_REFERER']); } // create header $markup = '<h1>Team Dashboard</h1><br>'; $markup .= '<h2>' . $team['number'] . ' Outreach</h2>'; $searchParams['teams'] = array($TID); $markup .= '<div align="left" style="float: left">Sort By: '; if (isset($params['sortByDate'])) { $outreaches = dbGetOutreachesForTeam($TID, 'upcoming', NUM_RECENT_OUTREACHES_SHOWN); $markup .= '<a href="?q=teamDashboard">Recently Added</a><b> | Upcoming Events</b></div>'; } else { $outreaches = dbGetOutreachesForTeam($TID, 'logDate', NUM_RECENT_OUTREACHES_SHOWN); $markup .= '<b>Recently Added | </b><a href="?q=teamDashboard&sortByDate">Upcoming Events</a></div>'; } $markup .= '<div align="right" style="float:right">'; // moderator page button if (!teamIsIneligible($TID) && hasPermissionForTeam('manageOutreachTags', $TID)) { $markup .= '<a href="?q=teamModeratorPage">'; $markup .= '<div class="help tooltip4">'; $markup .= '<button>Moderators</button>'; $markup .= '<span id="helptext"; class="helptext tooltiptext4">'; $markup .= 'Click here to view ideas, write-ups, and hours awaiting approval.'; $markup .= '</span></div></a>'; } else { $markup .= ''; } // all team outreach button $markup .= '<a href="?q=outreach&allTeamOutreach"><div class="help tooltip3"><button>All Team Outreach</button><span id="helptext"; class="helptext tooltiptext3">Click here to view all of your teams outreach.</span></div></a></div>'; // create table $markup .= '<table class="infoTable"><tr><th>Name</th><th>Event Date</th><th>Owner</th><th></th></tr>'; foreach ($outreaches as $outreach) { $OID = $outreach['OID']; $markup .= '<tr><td><a href="?q=viewOutreach&OID=' . $OID . '"</a>'; $markup .= chopString($outreach["name"], 20) . '</td>'; // displays event date if (dbGetEarliestTimeForOutreach($OID) != false) { $markup .= '<td>' . date(TIME_FORMAT, dbDateSQL2PHP(dbGetEarliestTimeForOutreach($OID))) . '</td>'; } else { $markup .= '<td>[none]</td>'; } $owner = dbGetOutreachOwner($OID); // displays outreach owner if ($owner != false) { $markup .= '<td><a href="?q=viewUser&UID=' . $owner . '">' . dbGetUserName($owner) . '</a></td>'; } else { $markup .= '<td>[none]</td>'; // insert placeholder if no outreach owner } $markup .= '<td>'; // sign up for outreach button $signUp = dbIsUserSignedUp($UID, $OID); if (dbIsUserSignedUp($UID, $OID)) { if (dbIsOutreachOver($OID)) { $markup .= '<a href="?q=signUp&OID=' . $OID . '"><button type="button" disabled>Edit Sign Up</button></a>'; } else { $markup .= '<a href="?q=signUp&OID=' . $OID . '"><button type="button">Edit Sign Up</button></div></a>'; } } else { if (dbIsOutreachOver($OID)) { $markup .= '<a href="?q=signUp&OID=' . $OID . '"><button type="button" disabled>Sign Up</button></div></a>'; } else { $markup .= '<a href="?q=signUp&OID=' . $OID . '"><button type="button">Sign Up</button></div></a>'; } } $markup .= '</td></tr>'; } // if no outreaches for team if (empty($outreaches)) { $markup .= '<tr><td colspan="10">No outreach found! Click <a href="?q=outreachForm">here</a> to create new outreach!</td></tr></table>'; return array('#markup' => $markup); } $markup .= '</table>'; return array('#markup' => $markup); }
function viewHours() { $params = drupal_get_query_parameters(); global $user; // checks to make sure you are assigned to a team if (dbGetTeamsForUser($user->uid) == NULL) { drupal_set_message("You don't have a team assigned.", 'error'); drupal_goto($_SERVER['HTTP_REFERER']); } // setting all permissions to a default "false" value $canEdit = $canApprove = $myHours = false; $markup = ''; // showing the hours if the UID is set for a user $filterParams = array(); if (isset($params['UID'])) { $UID = $params['UID']; $myHours = $UID == $user->uid; $filterParams['hourCounting.UID'] = $UID; $userName = dbGetUserName($UID); $markup = "<table><tr><td><h1>Hours for {$userName}</h1></td></tr></table>"; } // showing the hours if the OID is set for an outreach if (isset($params['OID'])) { $OID = $params['OID']; $TID = getCurrentTeam()['TID']; $filterParams['OID'] = $OID; $canEdit = canEditHoursForOutreach($OID); // can be set for the entire page if (hasPermissionForTeam('manageOutreachTags', $TID)) { $canApprove = true; // can be set for the entire page } $outreachName = dbGetOutreachName($OID); $markup = "<table><tr><td><h1>Hours for {$outreachName}</a></h1></td>"; } if (isset($params['OID']) && isset($params['UID']) && !isset($params['TID'])) { $markup = "<table><tr><td><h1>Hours contributed to {$outreachName} by {$userName}</h1></td></tr></table>"; } // showing the hours needing to be approved for a team if the TID is set if (isset($params['TID'])) { $TID = $params['TID']; $filterParams['TID'] = $TID; $filterParams['isApproved'] = 0; $teamName = dbGetTeamName($TID); $markup = "<table><tr><td><h1>Hours to be approved for {$teamName}</h1></td></tr></table>"; } // if the filters are not empty... if (!empty($filterParams)) { $hoursEntries = dbGetHours($filterParams); // get all the matching "hour" records if (isset($OID)) { $markup .= '<td style="text-align:right">'; $markup .= "<a href=\"?q=logHours&OID={$OID}\"><button>Add Hours</button></a></td></tr></table>"; } $markup .= '<table class="infoTable">'; // starting the table if (empty($OID)) { $markup .= '<th>Event</th>'; } if (!$myHours) { $markup .= '<th>Person</th>'; } $markup .= '<th>Type</th><th># Hours</th>'; $markup .= '<th></th>'; // create placeholder column foreach ($hoursEntries as $hours) { $markup .= '<tr>'; if (!isset($OID)) { // permissions must be set per hour record $canEdit = canEditHours($hours['HID']); // can be set for the entire page $canApprove = canApproveHours($hours['HID']); // can be set for the entire page if (isset($TID) && !$canApprove) { // if trying to approve hours for the team continue; } $outreachName = dbGetOutreachName($hours['OID']); $markup .= "<td><a href=\"?q=viewOutreach&OID={$hours['OID']}\">{$outreachName}</a></td>"; } // if the hours don't belong the current user, show the name of the person they do belong to if (!$myHours) { $markup .= '<td>'; if ($hours['UID'] != null) { $name = dbGetUserName($hours['UID']); $email = dbGetUserPrimaryEmail($hours['UID']); $markup .= "<a href=\"mailto:{$email}\" target=\"_top\">{$name}</a>"; } else { $markup .= '[none]'; } $markup .= '</td>'; } switch ($hours['type']) { // switch the type to be more formal case 'prep': $formalType = "Preparation"; break; case 'atEvent': $formalType = "At Event"; break; case 'writeUp': $formalType = "Write Up"; break; case 'followUp': $formalType = "Follow Up"; break; case 'other': $formalType = "Other"; break; } $markup .= "<td>{$formalType}</td>"; $markup .= "<td>{$hours['numberOfHours']}</td>"; if ($canEdit || $canApprove) { $markup .= '<td>'; if ($canEdit) { // if user can edit... $markup .= "<a href=\"?q=logHours&HID={$hours['HID']}\">"; $markup .= '<button><img class="editIcon" src="/images/icons/editWhite.png"></button></a>'; $markup .= "<a href=\"?q=deleteHours/{$hours['HID']}\">"; $markup .= '<button><img class="trashIcon" src="/images/icons/trashWhite.png"></button></a>'; } if ($canApprove && !$hours['isApproved']) { // if user can approve hours and the hours are not approved... $markup .= "<a href=\"?q=approveHours/{$hours['HID']}\">"; $markup .= '<button>Approve Hours</button></a>'; } else { if (!$hours['isApproved']) { $markup .= '<button disabled>Approve Hours</button>'; } } $markup .= '</td>'; } $markup .= '</tr>'; } if (empty($hoursEntries)) { $markup .= '<tr><td style="text-align:center" colspan="10"><em>[None]</em></td></tr>'; } $markup .= '</table>'; } else { // no filter params drupal_set_message('No filter parameters selected.', 'error'); drupal_goto($_SERVER['HTTP_REFERER']); } return array('#markup' => $markup); }
function writeUpsAwaitingApproval() { $currentTeam = getCurrentTeam(); if ($currentTeam == false) { drupal_set_message("You don't have a team assigned.", 'error'); return; } $TID = $currentTeam['TID']; $teamNumber = $currentTeam['number']; // create header $markup = '<h2>Write-Ups Awaiting Approval</h2>'; $markup .= '<table class="infoTable"><tr><th colspan="3">Name</th>'; $markup .= '<th colspan="2">Log Date</th>'; $markup .= '<th colspan="2">Owner</th>'; $markup .= '<th></th>'; $markup .= "</tr>"; // "true" indicates to only get write-ups that have been submitted $outreaches = dbGetWriteUpsForTeam($TID, true); // if the team has write-ups if (!empty($outreaches)) { $count = 0; foreach ($outreaches as $outreach) { $count++; $TID = $outreach['TID']; $team = dbGetTeam($outreach['TID']); $rawDate = $outreach['logDate']; $rawDate = dbDateSQL2PHP($rawDate); $logDate = date(TIME_FORMAT, $rawDate); $OID = $outreach['OID']; $owner = dbGetOutreachOwner($OID); $markup .= "<tr>"; $markup .= '<td colspan="3">' . '<a href="?q=viewOutreach&OID=' . $outreach['OID'] . '">' . chopString($outreach["name"], 20) . '</a>' . '</td>'; $markup .= '<td colspan="2">' . $logDate . '</td>'; $markup .= '<td colspan="2">' . dbGetUserName($owner) . ' </td>'; // button to view the write up if (hasPermissionForTeam('approveIdeas', $TID)) { $markup .= '<td><a href="?q=writeupform&approving&OID=' . $OID . '"><button>View</button></a></td>'; } else { $markup .= '<td></td>'; } $markup .= "</tr>"; } // if the team doesn't have any write-ups } else { $markup .= "<tr>"; $markup .= '<td style="text-align:center" colspan="8"><em>[None]</em></td>'; $markup .= "</tr>"; } $markup .= "</table>"; $retArray = array(); $retArray['#markup'] = $markup; return $retArray; }
function teamForm_submit($form, $form_state) { global $user; $params = drupal_get_query_parameters(); $new = !isset($params['TID']); // determine if adding or editing $names = array('name', 'number', 'type', 'city', 'state', 'country', 'FID', 'rookieYear'); $row = getFields($names, $form_state['values']); $row = stripTags($row, ''); if ($row['rookieYear'] === '') { $row['rookieYear'] = null; } if ($new) { // team doesn't exist yet $row['UID'] = $user->uid; $TID = dbCreateTeam($row); } else { $result = dbUpdateTeam($params['TID'], $row); if ($result) { $TID = $params['TID']; if (!teamIsIneligible($TID)) { setCurrentTeam($params['TID'], $row['name']); } } else { drupal_set_message('Error in updating team', 'error'); return; } } if ($TID != false) { if ($new) { // if team is submitted correctly drupal_set_message('Your team form has been submitted. The CROMA team will contact you when your team has been successfully created.'); dbGiveUserRole($user->uid, $TID, 'teamOwner'); dbAssignUserToTeam($user->uid, $TID); // send email $params = array('TID' => $TID, 'name' => $row['name'], 'number' => $row['number'], 'user' => $user->uid, 'userName' => dbGetUserName($user->uid)); drupal_mail('teams', 'teamCreated', '*****@*****.**', variable_get('language_default'), $params, $from = NULL, $send = TRUE); drupal_goto('teamDashboard'); } else { drupal_set_message('Your team has been updated!'); if (!dbIsTeamApproved($TID)) { drupal_goto('manageUserTeams'); } else { drupal_goto('viewTeam', array('query' => array('TID' => $params['TID']))); } } } else { // if something went wrong... drupal_set_message('Error creating team. Please try again.'); } }
function hoursForm_submit($form, $form_state) { global $user; // getting value of new from form state $new = isset($form_state['new']) ? $form_state['new'] : true; $OID = $form_state['OID']; // looping through the rows of hours for ($i = 0; $i < $form_state['numRows']; $i++) { $fields = array("numberOfHours-{$i}", "description-{$i}", "type-{$i}"); $row = getFields($fields, $form_state['values']); // dont allow any html tags $row = stripTags($row, ''); // setting the values which were read in into the row which will go into the database $row['numberOfHours'] = $row["numberOfHours-{$i}"]; $row['description'] = $row["description-{$i}"]; $row['isApproved'] = 0; $row['type'] = $row["type-{$i}"]; unset($row["type-{$i}"], $row["numberOfHours-{$i}"], $row["description-{$i}"]); if (isset($form_state['values']['fields']['UID'])) { $UID = $form_state['values']['fields']['UID']; } else { $UID = $user->uid; } if ($UID != 0) { $row['UID'] = $UID; } $row['OID'] = $OID; // if adding new hours if ($new) { if (dbLogHours($row) == false) { drupal_set_message("Error", 'error'); break; } } else { // editing old hours $row['isApproved'] = 0; if (dbUpdateHours($row, $form_state['HID']) == false) { drupal_set_message("Error", 'error'); break; } } } // end of for loop drupal_set_message("Your hours have been logged!"); // assigning user to outreach if not new if (!$new) { dbAssignUserToOutreach($UID, $OID, $row['type']); drupal_goto("viewOutreach", array('query' => array("OID" => $OID))); } else { // notifying appropriate users of changes/addition of hours $outreachName = dbGetOutreachName($OID); $personName = dbGetUserName($user->uid); $notification['message'] = "{$personName} has logged hours for {$outreachName}!"; $notification['TID'] = dbGetTeamForOutreach($OID); $notification['dateTargeted'] = dbDatePHP2SQL(time()); $notification['dateCreated'] = dbDatePHP2SQL(time()); notifyUsersByRole($notification, 'moderator'); notifyOwnerOfOutreach($OID, $notification); if ($OID != 0) { drupal_goto("viewHours", array('query' => array("OID" => $OID))); } else { drupal_goto("viewHours", array('query' => array("UID" => $UID))); } } }
function viewOutreachEvent() { global $user; $UID = $user->uid; $params = drupal_get_query_parameters(); if (isset($params['OID']) && $params['OID'] > 0) { $OID = $params['OID']; $outreach = dbGetOutreach($OID); if ($outreach == false) { drupal_set_message('Invalid outreach event. Click <a href="?q=teamDashboard">here</a> to navigate back to events in Team Dashboard.', 'error'); return; } $TID = $outreach['TID']; if (!isMyTeam($TID)) { drupal_set_message('You do not have permission to access this page.', 'error'); return; } // if the outreach status is outreach and the event is over, then turn the status to write up if ($outreach['status'] == "isOutreach") { outreachToWriteUp($OID); } // determine if the user can physically sign up $canSignUp = !dbIsOutreachOver($OID) && ($outreach['status'] == 'isOutreach' || $outreach['status'] == 'doingWriteUp'); $markup = ''; $markup .= '<div style="float:left; width:38%">'; $markup .= '<table style="margin:0px 0px 10px 0px;"><tr>'; $markup .= '<td style="padding:0px 14px 10px 14px;"><div align="left"><h2 style="margin:0px 0px 7px 0px;"><b>'; // display outreach name $markup .= "{$outreach['name']}"; $markup .= '</b></h2></div></td></tr>'; $markup .= '<tr><td>'; $markup .= showOutreachStatusIcon($outreach['status']); // displays the icon for a public outreach $markup .= $outreach['isPublic'] ? '<span title="Public"><img class="eventPrivacyIcon" src="/images/icons/publicBlue.png"></span>' : '<span title="Private"><img class="eventPrivacyIcon" src="/images/icons/privateBlue.png"></span>'; // displays the icon for a cancelled outreach $markup .= $outreach['cancelled'] ? '<span title="Event Cancelled"><img class="eventCancelledIcon" src="/images/icons/cancelledRed.png"' : ''; $markup .= '</td></tr></table>'; $markup .= '<table id="photoAndEdit"><tr><td style="padding:0px;">'; // cannot edit photo if user doesn't have the correct permissions if (!isMyOutreach($OID) && !hasPermissionForTeam('editAnyOutreach', getCurrentTeam()['TID'])) { $markup .= '<div align="right">'; $markup .= '<span title="Edit Photo"><button type="button" disabled><img class="editIcon" src="/images/icons/editThumbnailWhite.png"></button></span>'; $markup .= '</div>'; } else { // edit photo if user has permissions $markup .= '<div align="right">'; $markup .= '<a href= "?q=editThumbnail'; $markup .= '&OID=' . $OID . '&FID=' . $outreach['FID'] . '">'; $markup .= '<span title="Edit Photo"><button type="button"><img class="editIcon" src="/images/icons/editThumbnailWhite.png"></button></a></span>'; $markup .= '</div>'; } $markup .= '</td></tr><tr><td style="padding:0px;">'; // default picture for outreach if (!empty($outreach['FID'])) { $FID = dbGetOutreachThumbnail($OID); $url = generateURL($FID); $markup .= '<div align="center"><img src="' . $url . '" style="max-width:150px; width:auto; height:auto; padding: 5px 0px 5px 0px">'; } else { $markup .= '<div align="center"><img src="/images/defaultPics/team.png" style="max-width:200px; width:auto; height:auto; padding: 15px 0px 15px 0px">'; } $markup .= '</div></td></tr></table></div>'; $markup .= '<div align="right">'; // if the status is write-up, then allow a user to submit a write up if ($outreach['status'] == 'doingWriteUp' && !$outreach['isWriteUpSubmitted']) { $markup .= '<a href="?q=writeupform&OID=' . $outreach['OID'] . '"><button>Write Up</button></a>'; } else { if ($outreach['isWriteUpSubmitted'] && hasPermissionForTeam('approveIdeas', $TID) && $outreach['status'] == 'doingWriteUp') { $markup .= '<a href="?q=writeupform&OID=' . $outreach['OID'] . '&approving"><button>Approve Write Up</button></a>'; } } // if the status is idea, then allow a user with permissions to approve or reject the idea if ($outreach['status'] == 'isIdea' && hasPermissionForTeam('approveIdeas', $TID)) { $markup .= '<a href="?q=approveIdea/' . $outreach['OID'] . '/' . $TID . '"><button>Approve</button></a>'; $markup .= '<a href="?q=rejectIdea/' . $outreach['OID'] . '/' . $TID . '"><button>Reject</button></a>'; } // notifications button if (!isMyOutreach($OID) && !hasPermissionForTeam('editAnyOutreach', getCurrentTeam()['TID'])) { $markup .= '<button type="button" disabled>Notifications</button>'; } else { $markup .= '<a href="?q=manageNotifications&OID=' . $outreach['OID'] . '"><button>Notifications</button></a>'; } // manage sign-ups button if (!dbIsOutreachCancelled($OID)) { if (dbIsUserSignedUp($UID, $OID)) { if (dbIsOutreachOver($OID)) { $markup .= '<a href="?q=signUp&OID=' . $OID . '"><div class="help tooltip4"><button type="button" disabled>Edit Sign Up</button><span id="helptext"; class="helptext tooltiptext4">You cannot edit your sign up for this event because it is already over.</span></div></a>'; } else { $markup .= '<a href="?q=signUp&OID=' . $OID . '"><div class="help tooltip4"><button type="button">Edit Sign Up</button><span id="helptext"; class="helptext tooltiptext4">Click here to edit your sign up for this event.</span></div></a>'; } } else { if (dbIsOutreachOver($OID) || $outreach['status'] == 'isIdea') { $markup .= '<a href="?q=signUp&OID=' . $OID . '"><div class="help tooltip4"><button type="button" disabled>Sign Up</button><span id="helptext"; class="helptext tooltiptext4">You cannot sign up for this event because it is already over.</span></div></a>'; } else { $markup .= '<a href="?q=signUp&OID=' . $OID . '"><div class="help tooltip4"><button type="button">Sign Up</button><span id="helptext"; class="helptext tooltiptext4">Click here to sign up for this event.</span></div></a>'; } } } else { $markup .= '<a href="?q=signUp&OID=' . $OID . '"><div class="help tooltip4"><button type="button" disabled>Sign Up</button><span id="helptext"; class="helptext tooltiptext4">You cannot sign up for this event because it is cancelled.</span></div></a>'; } // hours button if (!dbIsOutreachCancelled($OID)) { $markup .= '<a href= "?q=viewHours'; $markup .= '&OID=' . $OID . '">'; $markup .= '<button type="button" '; $markup .= $outreach['status'] == 'isIdea' ? ' disabled' : ''; $markup .= '>Hours</button></a>'; } else { // if outreach is cancelled $markup .= '<button type="button" disabled'; $markup .= $outreach['status'] == 'isIdea' ? ' disabled' : ''; $markup .= '>Hours</button>'; } // view media button $markup .= '<a href="?q=viewMedia'; $markup .= '&OID=' . $OID . '">'; $markup .= '<button type="button"'; $markup .= $outreach['status'] == 'isIdea' ? ' disabled' : ''; $markup .= '>Media</button></a>'; // edit outreach button if (!isMyOutreach($OID) && !hasPermissionForTeam('editAnyOutreach', getCurrentTeam()['TID'])) { $markup .= '<button type="button" disabled><img class="editIcon" src="/images/icons/editWhite.png"></button>'; } else { $markup .= '<a href= "?q=outreachForm'; $markup .= '&OID=' . $OID . '">'; $markup .= '<button type="button"><img class="editIcon" src="/images/icons/editWhite.png"></button></a>'; } $markup .= '</div>'; $markup .= '<div style="width:60%; float:right; padding-left:10px">'; $hasPointOfContact = false; if (!(empty($outreach['co_organization']) && empty($outreach['co_firstName']) && empty($outreach['co_email']) && empty($outreach['co_phoneNumber']))) { $hasPointOfContact = true; } // account for cases where no info is present if ($outreach['description'] == null) { $outreach['description'] = '[none]'; } if ($outreach['type'] == null || $outreach['type'] == '') { $outreach['type'] = '[none]'; } if ($outreach['status'] == null) { $outreach['status'] = '[none]'; } if ($outreach['co_organization'] == null) { $outreach['co_organization'] = '[none]'; } if ($outreach['co_position'] == null) { $outreach['co_position'] = '[none]'; } if ($outreach['co_firstName'] == null) { $outreach['co_firstName'] = '[none]'; } if ($outreach['co_email'] == null) { $outreach['co_email'] = '[none]'; } if ($outreach['co_phoneNumber'] == null) { $outreach['co_phoneNumber'] = '[none]'; } if ($outreach['city'] == null) { $outreach['city'] = '[none]'; } if ($outreach['state'] == null) { $outreach['state'] = '[none]'; } if ($outreach['address'] == null) { $outreach['address'] = '[none]'; } if ($outreach['country'] == null) { $outreach['country'] = '[none]'; } if ($outreach['totalAttendance'] == null) { $outreach['totalAttendance'] = 0; } if ($outreach['testimonial'] == null) { $outreach['testimonial'] = '[none]'; } $team = dbGetTeam($outreach['TID']); // begin displaying info body $markup .= '<table id="miniViewTeam" style="margin:16px 0px 0px 0px"><tr><td><h3><b><u>General<u></b></h3></td></tr>'; $owner = dbGetOutreachOwner($OID); $markup .= "<tr><td colspan='3'><b>Owner: </b>" . dbGetUserName($owner) . "</a></td>"; $markup .= "<td colspan='3'><b>Team: </b>{$team['number']}</td></tr>"; $markup .= '<tr><td colspan="3"><b>Tags: </b>'; $tags = dbGetTagsForOutreach($OID); if (!empty($tags)) { dpm($tags); $first = true; $length = count($tags); $i = 1; foreach ($tags as $OTID => $tagName) { $markup .= '<a href="?q=outreach&tag=' . $OTID . '">' . $tagName . '</a>'; if ($i < $length) { $markup .= ', '; } $i++; } // if there aren't any tags } else { $markup .= '[none]'; } $markup .= '</td></tr>'; $times = dbGetTimesForOutreach($OID); // display time if the outreach status isn't an idea if ($outreach['status'] != 'isIdea') { if (!empty($times)) { foreach ($times as $time) { $startTime = date(TIME_FORMAT, dbDateSQL2PHP($time['startTime'])); $endTime = date(TIME_FORMAT, dbDateSQL2PHP($time['endTime'])); $markup .= '<tr><td colspan="3"><b>Start Date: </b>' . $startTime . '</td>'; $markup .= '<td colspan="3"><b>End Date: </b>' . $endTime . '</td></tr>'; } } } $markup .= '<tr><td colspan="5" style="word-break:break-word"><b>Description: </b>'; $markup .= wordwrap($outreach['description'], 70, "<br />\n"); $markup .= '</td></tr>'; // if the outreach has contact information if ($hasPointOfContact) { $markup .= '<tr><td><h3><b><u>Contact Info<u></b></h3></td></tr>'; $markup .= '<tr><td colspan="3"><b>Host Organization: </b>'; $markup .= strip_tags($outreach['co_organization'], ALLOWED_TAGS) . '</td>'; $markup .= '<td colspan="3"><b>Contact Name: </b>'; $markup .= strip_tags($outreach['co_firstName'] . ' ' . $outreach['co_lastName'], ALLOWED_TAGS) . '</td></tr>'; $markup .= '<tr><td colspan="3"><b>Contact Email: </b>' . strip_tags($outreach['co_email'], ALLOWED_TAGS) . '</td>'; $phoneNumber = dbFormatPhoneNumber($outreach['co_phoneNumber']); $markup .= '<td colspan="3"><b>Contact Number: </b>' . $phoneNumber . '</td></tr>'; $markup .= '<tr><td colspan="6"><b>Address: </b>' . strip_tags($outreach['address'], ALLOWED_TAGS) . ', ' . strip_tags($outreach['city'], ALLOWED_TAGS) . ', ' . strip_tags($outreach['state'], ALLOWED_TAGS) . '</td></tr>'; $markup .= '</tr>'; } else { $markup .= '<tr><td><h3><b><u>Contact Info<u></b></h3></td></tr>'; $markup .= '<tr><td colspan="6"><b>Address: </b>' . strip_tags($outreach['address'], ALLOWED_TAGS) . ', ' . strip_tags($outreach['city'], ALLOWED_TAGS) . ', ' . strip_tags($outreach['state'], ALLOWED_TAGS) . '</td></tr>'; $markup .= '</tr>'; } $markup .= '<tr><td><h3><b><u>Statistics<u></b></h3></td></tr>'; $markup .= '<tr>'; if ($outreach['status'] != 'isIdea') { $numPpl = dbGetNumPplSignedUpForEvent($OID); $markup .= '<td colspan="3"><b>'; // only show the link if people are signed up if ($numPpl != 0) { $markup .= '<a href="?q=outreachList&OID=' . $OID . '"target="_blank">'; } $markup .= 'People Signed Up: </b>'; // end the link if ($numPpl != 0) { $markup .= '</a>'; } $markup .= $numPpl . '</td>'; // view total hours for the outreach $markup .= '<td colspan="3"><b>Total Hours: </b><a href="?q=viewHours&OID=' . $OID . '">' . dbGetHoursForOutreach($OID) . '</a></td></tr>'; //if the outreach status is idea } else { $markup .= '<td colspan="3">'; $markup .= '<b>People Signed Up: </b>'; $markup .= 'None'; $markup .= '</td></tr>'; } $markup .= '</table></div>'; // if the outreach has an approved write-up if ($outreach['isWriteUpApproved'] && $outreach['status'] == 'locked') { $writeUp = empty($outreach["writeUp"]) ? '[None]' : $outreach["writeUp"]; $totalAttendance = empty($outreach["totalAttendance"]) ? '[Not Filled Out]' : $outreach["totalAttendance"]; $testimonial = empty($outreach["testimonial"]) ? '[None]' : $outreach["testimonial"]; $markup .= '<div style="float:left; width:38%;"><table id="miniViewTeam" style="margin:16px 0px 0px 0px"><tr><td><h3><b><u>Write Up<u></b></h3></td>'; $markup .= '<td><a href="?q=writeupform&OID=' . $outreach['OID'] . '&approved"><button> View</button></a></td></tr>'; $markup .= '<tr><td><b>Write Up:</b></td></tr>'; $markup .= '<tr><td>' . $writeUp . '</td></tr>'; $markup .= '<tr><td><b>Total Attendance:</b></td></tr>'; $markup .= '<tr><td>' . $totalAttendance . '</td></tr>'; $markup .= '<tr><td><b>Testimonials/Comments:</b></td></tr>'; $markup .= '<tr><td>' . $testimonial . '</td></tr>'; $markup .= '</table></div>'; } $retArray = array(); $retArray['#markup'] = $markup; return $retArray; } else { drupal_set_message('Invalid outreach event. Click <a href="?q=teamDashboard">here</a> to navigate back to events in Team Dashboard.', 'error'); } }
function reject($form, $form_state) { global $user; $params = drupal_get_query_parameters(); $TID = getCurrentTeam()['TID']; $OID = $params["OID"]; $outreachData = dbGetOutreach($OID); $writeUpUpdate['status'] = "doingWriteUp"; $writeUpUpdate['writeUpUID'] = null; $writeUpUpdate['isWriteUpSubmitted'] = 0; $result = dbUpdateOutreach($OID, $writeUpUpdate); $notification = array(); $userName = dbGetUserName($user->uid); $outName = dbGetOutreachName($OID); $notification['dateCreated'] = dbDatePHP2SQL(time()); $notification['dateTargeted'] = dbDatePHP2SQL(time()); $notification['message'] = "{$userName} has rejected a write up for {$outName}."; $notification['bttnTitle'] = 'Redo Write Up'; $notification['bttnLink'] = '?q=viewOutreach&OID=' . $OID; $notification['TID'] = $TID; $notification['UID'] = $outreachData['writeUpUID']; dbAddNotification($notification); drupal_set_message("Write Up Rejected."); drupal_goto('viewOutreach', array('query' => array('OID' => $OID))); }
function rescindTeamApplication($TID) { global $user; dbRescindTeamApplication($user->uid, $TID); $teamName = dbGetTeamName($TID); $userName = dbGetUserName($user->uid); $notification['message'] = "{$userName} is no longer applying to {$teamName}."; $notification['dateCreated'] = dbDatePHP2SQL(time()); $notification['dateTargeted'] = dbDatePHP2SQL(time()); $notification['TID'] = $TID; notifyUsersByRole($notification, 'teamAdmin'); drupal_set_message("Your application to {$teamName} has been removed."); if (isset($_SERVER['HTTP_REFERER'])) { drupal_goto($_SERVER['HTTP_REFERER']); } else { drupal_goto('manageUserTeams'); } }
function outreachForm_submit($form, $form_state) { global $user; $UID = $user->uid; $TID = $form_state['TID']; $outreachFields = array("name", "peopleImpacted", "address", "city", "state", "country", "status", "co_organization", "co_firstName", "co_lastName", "co_email", "co_phoneNumber", "isPublic"); $outreachData = getFields($outreachFields, $form_state['values']); $outreachData = stripTags($outreachData, ''); // remove all tags $outreachData['description'] = stripTags(array($form_state['values']['description'])); // allow some tags $outreachData["TID"] = $TID; if ($form_state['new']) { $outreachData["UID"] = $UID; } if (isset($form_state['OID'])) { $OID = $form_state['OID']; $oldOutreachData = dbGetOutreach($OID); if ($outreachData["status"] == "doingWriteUp" && $oldOutreachData["isWriteUpApproved"] == true) { $outreachData["writeUpUID"] = null; $outreachData["isWriteUpSubmitted"] = 0; $outreachData["isWriteUpApproved"] = 0; } } if (!$form_state['new']) { // updating existing event $OID = $form_state['OID']; $result = dbUpdateOutreach($OID, $outreachData); if ($result) { // if db call was successful for ($i = 0; $i < $form_state['numRows']; $i++) { // loop through date rows $TOID = isset($form_state['fields']['dates']["TOID-{$i}"]) ? $form_state['fields']['dates']["TOID-{$i}"] : 0; $timeData['startTime'] = dbDatePHP2SQL(strtotime($form_state['values']["startTime-{$i}"])); dpm($timeData['startTime']); $timeData['endTime'] = dbDatePHP2SQL(strtotime($form_state['values']["endTime-{$i}"])); if ($timeData['startTime'] != null && $timeData['endTime'] != null) { // if row isn't empty if ($TOID != 0) { // update existing record dbUpdateTimesForOutreach($TOID, $timeData); } else { // add a new time record if there wasn't one previously $timeData['OID'] = $OID; dbAddTimesToOutreach($timeData); } } else { // remove time record if empty dbRemoveTimeFromOutreach($TOID); } } for ($i = $form_state['numRows']; $i < $form_state['initialNumTimes']; $i++) { // executes if times were deleted dbRemoveTimeFromOutreach($form_state['fields']['dates']["TOID-{$i}"]); } $notification = array(); $userName = dbGetUserName($user->uid); $outName = dbGetOutreachName($OID); $notification['dateCreated'] = dbDatePHP2SQL(time()); $notification['dateTargeted'] = dbDatePHP2SQL(time()); $notification['message'] = "{$userName} has updated outreach {$outName}."; $notification['bttnTitle'] = 'View'; $notification['bttnLink'] = '?q=viewOutreach&OID=' . $OID; $notification['TID'] = $TID; notifyUsersByRole($notification, 'moderator'); // handle tags if (!empty($form_state['values']['tags'])) { $newTags = $form_state['values']['tags']; $previous = dbGetTagsForOutreach($OID, true); // the "true" means this will return only OTID's if ($previous == false) { // if there aren't any tags $previous = array(); } $deleted = array_diff($previous, $newTags); $added = array_diff($newTags, $previous); foreach ($deleted as $delete) { // $delete is the OTID to be removed from the outreach if (!empty($delete)) { dbRemoveTagFromOutreach($delete, $OID); } } foreach ($added as $add) { // $add is the OTID to be added to the outreach if (!empty($add)) { dbAddTagToOutreach($add, $OID); } } } drupal_set_message("Outreach updated!"); } else { drupal_set_message("Outreach not updated."); } } else { // adding new event $outreachData['logDate'] = dbDatePHP2SQL(time()); $OID = dbCreateOutreach($outreachData); if ($OID != false) { dbAddUserAsOwnerOfOutreach($UID, $OID); dbAssignUserToOutreach($UID, $OID, 'owner'); // handle times if ($outreachData['status'] != 'isIdea') { for ($i = 0; $i < $form_state['numRows']; $i++) { $time = array("startTime-{$i}", "endTime-{$i}"); $timeData = getFields($time, $form_state['values']); if ($timeData["startTime-{$i}"] != null && $timeData["endTime-{$i}"] != null) { // rename array keys to match columns $timeData['startTime'] = dbDatePHP2SQL(strtotime($timeData["startTime-{$i}"])); $timeData['endTime'] = dbDatePHP2SQL(strtotime($timeData["endTime-{$i}"])); unset($timeData["endTime-{$i}"], $timeData["startTime-{$i}"]); $timeData['OID'] = $OID; dbAddTimesToOutreach($timeData); } } } // handle tags if (!empty($form_state['values']['tags'])) { foreach ($form_state['values']['tags'] as $OTID) { dbAddTagToOutreach($OTID, $OID); } } // create notification $notification = array(); $userName = dbGetUserName($user->uid); $outName = dbGetOutreachName($OID); $notification['dateCreated'] = dbDatePHP2SQL(time()); $notification['dateTargeted'] = dbDatePHP2SQL(time()); $notification['message'] = "{$userName} has created outreach {$outName}."; $notification['bttnTitle'] = 'View'; $notification['bttnLink'] = '?q=viewOutreach&OID=' . $OID; $notification['TID'] = $TID; notifyUsersByRole($notification, 'moderator'); drupal_set_message("Outreach created!"); } else { // if the $OID IS false form_set_error("Outreach not created successfully"); } } if (dbIsOutreachOver($OID)) { drupal_set_message("It appears you are logging an old event. Don't forget to <a href=\"?q=logHours&OID={$OID}\"><b>log old hours</b></a>!"); } drupal_goto('viewOutreach', array('query' => array('OID' => $OID))); }
function signUp_submit($form, $form_state) { global $user; $UID = $user->uid; $params = drupal_get_query_parameters(); $OID = $params['OID']; $new = $form_state['new']; $fields = array("times"); $fieldsData = getFields($fields, $form_state['values']); $types = $fieldsData['times']; $types = array_values($types); if ($new) { // if the user is signing up for the first time foreach ($types as $type) { if ($type !== 0) { dbAssignUserToOutreach($UID, $OID, $type); // assigning user to outreach and the various time(s) they signed up for } } $msgToUser = "******"; } if (!$new) { // user is updating the time(s) $previous = dbGetUserSignUpType($UID, $OID); $deleted = array_diff($previous, $types); $added = array_diff($types, $previous); foreach ($deleted as $delete) { if (!empty($delete)) { dbRemoveCommitmentFromOutreach($UID, $OID, $delete); // removing the times the user "unchecked" } } foreach ($added as $add) { // adding the times the user "checked" if (!empty($add)) { dbAssignUserToOutreach($UID, $OID, $add); } } $msgToUser = "******"; } // sending a notification to the appropriate user(s) $notification = array(); $userName = dbGetUserName($UID); $outName = dbGetOutreachName($OID); $team = getCurrentTeam(); $TID = $team['TID']; $notification['dateTargeted'] = $notification['dateCreated'] = dbDatePHP2SQL(time()); $notification['message'] = "{$userName} has just signed up for your outreach: {$outName}!"; $notification['TID'] = $TID; notifyOwnerOfOutreach($OID, $notification); $outreachEventLink = '<a href="?q=viewOutreach&OID=' . $OID . '">' . dbGetOutreachName($OID) . '</a>'; drupal_set_message("{$msgToUser} {$outreachEventLink}!"); drupal_goto('viewOutreach', array('query' => array('OID' => $OID))); }
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 viewUserOutreach() { global $user; $UID = $user->uid; $userName = dbGetUserName($UID); $params = drupal_get_query_parameters(); $currentYear = date("Y"); $totalFilterHours = 0; $markup = "<h1>All Outreach for {$userName}</h1>"; if (isset($params["cancelled"])) { $outreaches = dbGetCancelledOutreach($TID); } else { if (isset($params['query']) && $params['query'] == 'search') { $outreaches = dbSearchOutreach($_SESSION['searchSQL'], $_SESSION['proxyFields']); } else { $outreaches = dbGetOutreachesForTeam($TID); if (isset($params['status']) && $params['status'] != 'all') { $proxyFields = array(); $outreaches = dbSearchOutreach(generateSearchSQL(array('status' => array($params['status'])), $proxyFields), $proxyFields); } } } foreach ($outreaches as &$outreach) { $outreach['hours'] = dbGetHoursForOutreach($outreach['OID']); $totalFilterHours += $outreach['hours']; } unset($outreach); $markup .= '<div style="float:left"><h4>Hours With Current Filters: ' . $totalFilterHours . '</h4></div><br><br>'; $sortParam = isset($params["sort"]) ? $params['sort'] : 'name'; $statusParam = isset($params["status"]) ? $params['status'] : 'all'; orderByValue($outreaches, $sortParam, true); // custom function (see helperFunctions.inc) $markup .= '<div align="left" style="float: left">Sort By: '; switch ($sortParam) { case 'name': $markup .= '<b>Name</b><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=status">Status</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=hours">Hours</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=logDate">Log Date</a><br>'; break; case 'status': $markup .= '<a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=name">Name</a><b> | </b><b>Status | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=hours">Hours</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=logDate">Log Date</a><br>'; break; case 'hours': $markup .= '<a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=name">Name</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=status">Status</a><b> | </b><b>Hours | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=logDate">Log Date</a><br>'; break; case 'logDate': $markup .= '<a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=name">Name</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=status">Status</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=hours">Hours</a><b> | </b><b>Log Date</b><br>'; break; } $markup .= 'Include Status: '; switch ($statusParam) { case 'isIdea': $markup .= '<a href="?q=allTeamOutreach&sort=' . $sortParam . '">All</a><b> | </b><b>Idea | </b><a href="?q=allTeamOutreach&status=isOutreach&sort=' . $sortParam . '">Outreach</a><b> | </b><a href="?q=allTeamOutreach&status=doingWriteUp&sort=' . $sortParam . '">Write Up</a><br>'; break; case 'isOutreach': $markup .= '<a href="?q=allTeamOutreach&sort=' . $sortParam . '">All</a><b> | </b><a href="?q=allTeamOutreach&status=isIdea&sort=' . $sortParam . '">Idea</a><b> | </b><b>Outreach | </b><a href="?q=allTeamOutreach&status=doingWriteUp&sort=' . $sortParam . '">Write Up</a><br>'; break; case 'doingWriteUp': $markup .= '<a href="?q=allTeamOutreach&sort=' . $sortParam . '">All</a><b> | </b><a href="?q=allTeamOutreach&status=isIdea&sort=' . $sortParam . '">Idea</a><b> | </b><a href="?q=allTeamOutreach&status=isOutreach&sort=' . $sortParam . '">Outreach</a><b> | </b><b>Write Up</b><br>'; break; default: $markup .= '<b>All</b><b> | </b><a href="?q=allTeamOutreach&status=isIdea&sort=' . $sortParam . '">Idea</a><b> | </b><a href="?q=allTeamOutreach&status=isOutreach&sort=' . $sortParam . '">Outreach</a><b> | </b><a href="?q=allTeamOutreach&status=doingWriteUp&sort=' . $sortParam . '">Write Up</a><br>'; } $markup .= '</div>'; orderByValue($outreaches, $sortParam, true); // custom function (see helperFunctions.inc) // Begin Displaying Outreach Events $markup .= '<div align="right" style="float:right"><a href="?q=searchForm"><button>Search</button></a>'; if (!isset($params["cancelled"])) { $markup .= '<a href="?q=allTeamOutreach&cancelled"><button>Cancelled</button></a>'; } else { $markup .= '<a href="?q=allTeamOutreach"><button>All Outreaches</button></a>'; } $markup .= '<a href="?q=viewOutreachSettings"><button'; $markup .= dbGetRIDForTeam($user->uid, $TID) > 0 ? '' : ' disabled'; $markup .= '>Outreach Settings</button></a>'; $markup .= '</div><br>'; $markup .= '<table><tr><th>Name</th>'; $markup .= '<th>Description</th>'; $markup .= '<th>Status</th>'; $markup .= '<th>Hours</th>'; $markup .= '<th>Log Date</th>'; foreach ($outreaches as $outreach) { $hours = dbGetHoursForOutreach($outreach['OID']); $status; switch ($outreach['status']) { case 'isOutreach': $status = 'Outreach'; break; case 'isIdea': $status = 'Idea'; break; case 'doingWriteUp': $status = 'Write-Up'; break; default: $status = '[none]'; break; } $markup .= "<tr><td><a href='?q=viewOutreach&OID={$outreach['OID']}'>{$outreach['name']}</a></td>"; if (isset($outreach['description'])) { $markup .= "<td>" . chopString($outreach['description'], 50) . "</td>"; } else { $markup .= '<td>[none]</td>'; } $markup .= "<td>{$status}</td>"; $markup .= "<td>{$hours}</td>"; $eventDate = date(TIME_FORMAT, dbDateSQL2PHP($outreach['logDate'])); $markup .= "<td>{$eventDate}</td></tr>"; } $markup .= '</table>'; return array('#markup' => $markup); }
function rejectUser($UID, $TID) { if (teamIsIneligible($TID)) { drupal_set_message('Your team does not have permission to access this page.', 'error'); drupal_goto($_SERVER['HTTP_REFERER']); } // currently delete the user's application to the team dbRejectUser($UID, $TID); $notification = array('UID' => $UID, 'TID' => $TID, 'dateCreated' => dbDatePHP2SQL(time()), 'dateTargeted' => dbDatePHP2SQL(time())); $notification['message'] = 'You have been rejected from ' . dbGetTeamName($TID) . '.'; $notification['bttnTitle'] = 'Reapply'; $notification['bttnLink'] = "?q=applyForTeamForm"; dbAddNotification($notification); module_load_include('inc', 'mimemail'); drupal_mail('teams', 'rejectedFromTeam', dbGetUserPrimaryEmail($UID), variable_get('language_default'), $params = array('teamName' => dbGetTeamName($TID), 'fullName' => dbGetUserName($UID)), $from = NULL, $send = TRUE); drupal_set_message("User has been rejected from your team."); if (isset($_SERVER['HTTP_REFERER'])) { drupal_goto($_SERVER['HTTP_REFERER']); } else { drupal_goto('viewUsersToBeApproved', array('query' => array('TID' => $TID))); } }