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 viewPeopleForEvent() { global $user; $params = drupal_get_query_parameters(); $TID = getCurrentTeam()['TID']; if (teamIsIneligible($TID)) { drupal_set_message('Your team does not have permission to access this page.', 'error'); drupal_goto($_SERVER['HTTP_REFERER']); } if (dbGetTeamsForUser($user->uid) == NULL) { drupal_set_message("You don't have a team assigned.", 'error'); drupal_goto($_SERVER['HTTP_REFERER']); } if (isset($params['OID']) && $params['OID'] > 0) { $OID = $params['OID']; $outreach = dbGetOutreach($OID); // if the outreach is invalid 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; } // begin header $markup = '<div align="left">' . "<br><h1><b> Users Signed Up For: {$outreach['name']}</b></h1></div>"; $ppl = dbGetPplSignedUpForEvent($OID); if ($ppl == false) { $markup .= '<tr><td><h4>No people signed up for outreach: ' . $outreach['name'] . '</h4></td></tr>'; } else { // Begin Displaying Info Body $markup .= '<table class="infoTable">'; $markup .= '<tr><th>Name</th>'; $markup .= '<th>Email</th>'; $markup .= '<th>Time Slot(s)</th></tr>'; foreach ($ppl as $UID) { $profile = dbGetUserProfile($UID); $markup .= '<tr><td><a href="?q=viewUser&UID=' . $profile["UID"] . ' ">'; $markup .= $profile["firstName"] . " " . $profile["lastName"] . '</a></td>'; // display the user's email $email = dbGetUserPrimaryEmail($UID); $markup .= "<td><a href=\"mailto:{$email}\" target=\"_top\">{$email}</a></td>"; $timeSlots = dbGetUserSignUpType($UID, $OID); $markup .= '<td>'; foreach ($timeSlots as $timeSlot) { switch ($timeSlot) { case 'prep': $markup .= 'Preparation<br>'; break; case 'atEvent': $markup .= 'At Event<br>'; break; case 'followUp': $markup .= 'Follow Up<br>'; break; case 'writeUp': $markup .= 'Write Up<br>'; break; case 'owner': $markup .= 'Owner<br>'; break; default: break; } } $markup .= '</td>'; } } $markup .= '</table>'; $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'); } }