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 rejectIdea($OID) { $outreach = dbGetOutreach($OID); $outreachName = dbGetOutreachName($OID); if (dbRejectIdea($OID)) { $UID = $outreach['UID']; $TID = $outreach['TID']; // notification to user that their outreach has been rejected $notification = array('UID' => $UID, 'TID' => $TID, 'message' => "{$outreachName} has been rejected.", 'dateCreated' => dbDatePHP2SQL(time()), 'dateTargeted' => dbDatePHP2SQL(time())); dbAddNotification($notification); drupal_set_message("{$outreachName} has been rejected"); } else { drupal_set_message("An error has occurred.", 'error'); } if (isset($_SERVER['HTTP_REFERER'])) { drupal_goto($_SERVER['HTTP_REFERER']); } else { drupal_goto('myDashboard'); } }
function dbDuplicateOutreach($OID) { $row = dbGetOutreach($OID); $row['name'] = $row['name'] . ' copy'; $row['logDate'] = dbDatePHP2SQL(time()); unset($row['OID']); $newOID = dbGenericInsert($row, 'outreach'); if ($newOID == 0) { dbErrorMsg("Outreach not created!"); return false; } else { return $newOID; } }
function changeCancel($OID) { $outreach = dbGetOutreach($OID); if ($outreach['cancelled']) { dbUncancelEvent($OID); drupal_set_message('Outreach uncancelled!'); } else { dbCancelEvent($OID); drupal_set_message('Outreach cancelled.'); } if (isset($_SERVER['HTTP_REFERER'])) { drupal_goto($_SERVER['HTTP_REFERER']); } else { drupal_goto('viewOutreach', array('query' => array('OID' => $OID))); } }
function hoursForm($form, &$form_state) { global $user; $params = drupal_get_query_parameters(); $new = isset($form_state['new']) ? $form_state['new'] : true; // checking that you are on a team if (dbGetTeamsForUser($user->uid) == NULL) { drupal_set_message("You don't have a team assigned.", 'error'); drupal_goto($_SERVER['HTTP_REFERER']); } if (isset($params['HID'])) { $new = false; // editing an existing hours record $form_state['new'] = $new; // update form_state to reflect this } // setting values... // creating a new record if ($new) { if (isset($form_state['OID'])) { $OID = $form_state['OID']; } else { $OID = $params['OID']; $form_state['OID'] = $OID; } $UID = $user->uid; // editing an existing hours record } else { if (isset($form_state['HID'])) { $HID = $form_state['HID']; } else { $HID = $params['HID']; $form_state['HID'] = $HID; } $hour = dbGetHour($HID); $UID = $hour['UID']; $OID = $hour['OID']; $form_state['OID'] = $OID; if ($hour['isApproved']) { drupal_set_message('Note that this hour will have to be re-approved once changes are made.', 'error'); } } // checking that you are accessing this page with a valid outreach if (!isset($OID) && !isset($params['HID'])) { drupal_set_message("No outreach selected.", 'error'); return; } // checking that you are associated with the team for which this outreach belongs to $TID = dbGetTeamForOutreach($OID); if (!isMyTeam($TID)) { $teamName = dbGetTeamName($TID); drupal_set_message("You are no longer on the team associated with this outreach ({$teamName}).", 'error'); return; } // checks if you have permission to edit hours if (!(hasPermissionForTeam('editAnyHours', dbGetTeamForOutreach($OID)) || isMyOutreach($OID) || dbIsUserSignedUp($user->uid, $OID))) { drupal_set_message("You don't have permission to log hours for this outreach.", 'error'); return; } if (isset($form_state['OID']) || isset($params['HID'])) { $outreachData = dbGetOutreach($OID); //begins form $form['fields'] = array('#prefix' => '<div id="rows-div">', '#type' => 'fieldset', '#title' => t("Enter Hours For Outreach: \"{$outreachData['name']}\""), '#suffix' => '</div>'); $users = dbGetUsersListFromTeam($TID); $users['0'] = '[none]'; if (hasPermissionForTeam('editAnyHours', $TID)) { $form['fields']['UID'] = array('#prefix' => '<td>', '#type' => 'select', '#title' => t('User:'******'#options' => $users, '#attributes' => array('style' => 'width:200px'), '#default_value' => $UID, '#chosen' => true, '#suffix' => '</td>'); } $form['fields']['tableHeader'] = array('#markup' => '<table>'); if (empty($form_state['numRows'])) { $form_state['numRows'] = 1; } if (!hasPermissionForTeam('editAnyHours', $TID)) { $signUpInfo = dbGetUserSignUpInfo($UID, $OID); $numSignUps = count($signUpInfo); $signUpCountLoop = 0; $type = array(); foreach ($signUpInfo as $info) { if ($numSignUps > 1 && $signUpCountLoop != $numSignUps - 1 && $form_state['numRows'] != $numSignUps) { $form_state['numRows']++; } if ($info['type'] == 'prep') { $type[$signUpCountLoop] = array('prep' => 'Preparation'); } else { if ($info['type'] == 'atEvent') { $type[$signUpCountLoop] = array('atEvent' => 'At Event'); } else { if ($info['type'] == 'writeUp') { $type[$signUpCountLoop] = array('writeUp' => 'Write-Up'); } else { if ($info['type'] == 'followUp') { $type[$signUpCountLoop] = array('followUp' => 'Follow Up'); } else { if ($info['type'] == 'other') { $type[$signUpCountLoop] = array('prep' => 'Other'); } } } } } $signUpCountLoop++; } } // looping through the rows for ($i = 0; $i < $form_state['numRows']; $i++) { $rowMarkUp = "<tr id=\"row-{$i}\""; $rowMarkUp .= '>'; $form['fields']["rowHeader-{$i}"] = array('#markup' => $rowMarkUp); $form['fields']["numberOfHours-{$i}"] = array('#prefix' => '<td colspan="1" style="text-align:left;width:20%;">', '#type' => 'textfield', '#title' => t('Number Of Hours:'), '#suffix' => '</td>', '#default_value' => $new ? '' : $hour['numberOfHours']); if (hasPermissionForTeam('editAnyHours', $TID)) { $types = array('prep' => 'Preparation', 'atEvent' => 'At Event', 'writeUp' => 'Write-Up', 'followUp' => 'Follow Up', 'other' => 'Other'); } else { $types = $type[$i]; } $form['fields']["type-{$i}"] = array('#prefix' => '<td colspan="1" style="text-align:left; width:20%;">', '#type' => 'radios', '#title' => t('Type:'), '#options' => $types, '#suffix' => '</td>', '#default_value' => $new ? '' : $hour['type']); $form['fields']["description-{$i}"] = array('#prefix' => '<td colspan="3" style="text-align:left; width:50%;">', '#type' => 'textarea', '#title' => t('Description:'), '#suffix' => '</td>', '#default_value' => $new ? '' : $hour['description']); if ($i == $form_state['numRows'] - 1) { $form['fields']["addRowButton-{$i}"] = array('#prefix' => '<td colspan="1" style="width:5%">', '#type' => 'submit', '#submit' => array('addHourRow'), '#value' => '+', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'modifyHourRows_callback', 'wrapper' => 'rows-div'), '#suffix' => '</td>'); $form['fields']["removeRowButton-{$i}"] = array('#prefix' => '<td colspan="1" style="width:5%">', '#type' => 'submit', '#submit' => array('removeHourRow'), '#value' => '-', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'modifyHourRows_callback', 'wrapper' => 'rows-div'), '#suffix' => '</td>'); } $form['fields']['rowFooter'] = array('#markup' => '</tr>'); // end of for loop } $form['fields']['submit'] = array('#prefix' => '<tr><td colspan="7" style="text-align:right">', '#type' => 'submit', '#value' => t('Submit'), '#suffix' => '</td></tr>'); $form['fields']['tableFooter'] = array('#markup' => '</table>'); } return $form; }
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 signUp($form, &$form_state) { global $user; $UID = $user->uid; $new = $form_state['new'] = true; $params = drupal_get_query_parameters(); // various checks for permissions if (dbGetTeamsForUser($user->uid) == false) { drupal_set_message("You don't have a team assigned.", 'error'); drupal_goto($_SERVER['HTTP_REFERER']); } // getting the outreach ID from the URL parameters and setting that and the team ID into local variables if (isset($params['OID']) && $params['OID'] > 0) { $OID = $params['OID']; $TID = dbGetTeamForOutreach($OID); if (!dbIsUserApprovedForTeam($UID, $TID)) { drupal_set_message('You do not have the permission to contribute to this event.', 'error'); drupal_goto($_SERVER['HTTP_REFERER']); } if (dbIsOutreachOver($OID)) { drupal_set_message('You can not contribute to this event. It has already ended.', 'error'); drupal_goto($_SERVER['HTTP_REFERER']); } $outreach = dbGetOutreach($OID); if (dbIsUserSignedUp($UID, $OID)) { // if user is already signed up for outreach then sets "new" to false $new = $form_state['new'] = false; $data = dbGetUserSignUpType($UID, $OID); // getting data related to sign up } $types = array('prep' => 'Preparation', 'atEvent' => 'At Event', 'writeUp' => 'Write Up', 'followUp' => 'Follow Up'); $form = array(); $form['fields'] = array('#type' => 'fieldset', '#title' => t('Sign Up For Outreach: ' . dbGetOutreachName($OID))); // displays outreach owner's name and email (unless they are no longer on the team) $ownerUID = dbGetOutreachOwner($OID); $email = dbGetUserPrimaryEmail($ownerUID); if (dbGetUserName($ownerUID) != -1) { $markup = '<b>Owner of Outreach: </b>' . dbGetUserName($ownerUID); if (dbIsUserApprovedForTeam($ownerUID, $TID)) { $markup .= "<br><b>Email of Owner: </b><a href=\"mailto:{$email}\" target=\"_top\">{$email}</a>"; } else { $markup .= ' (no longer on this team)<br>'; } } else { $markup = '<b>Owner of Outreach: </b>[none]<br>'; $markup .= '<b>Email of Owner: </b>[none]'; } $form['tableHeader'] = array('#markup' => $markup); // signing up for time slots listed in the array above (local variable --> "types") $form['fields']['times'] = array('#prefix' => '<table colspan="4"><tr><td colspan="2">', '#type' => 'checkboxes', '#title' => t('<h4>Which time(s) would you like to sign up for?</h4>'), '#options' => $types, '#default_value' => $new ? array() : $data, '#suffix' => '</td>'); // obligatory confirmation for the user to understand their commitment $form['fields']['confirmation'] = array('#prefix' => '<td colspan="2">', '#type' => 'checkbox', '#title' => t('<b>By checking this box, I understand that I am signing up for this event and am committed to the time(s) I agreed to.</b>'), '#suffix' => '</td></tr>'); $form['fields']['html1'] = array('#markup' => '<tr>'); // allows a user to cancel their commitment to their outreach times if (!$new) { $form['fields']['cancel'] = array('#prefix' => '<td colspan="2">', '#type' => 'submit', '#value' => 'Remove Commitment', '#limit_validation_errors' => array(), '#submit' => array('cancelCommit'), '#suffix' => '</td>'); } else { $form['fields']['html'] = array('#markup' => '<td></td>'); } $form['fields']['submit'] = array('#prefix' => '<td colspan="2" style="text-align:right">', '#type' => 'submit', '#value' => t('Submit'), '#suffix' => '</td>'); $form['fields']['footer'] = array('#markup' => '</tr></table>'); return $form; } else { // in case the parameter passed was an invalid OID drupal_set_message('Invalid outreach event. Click <a href="?q=teamDashboard">here</a> to naviagte back to events in Team Dashboard.', 'error'); } }
function viewOutreachIdeas() { global $user; if (dbGetTeamsForUser($user->uid) == NULL) { drupal_set_message("You don't have a team assigned.", 'error'); $TID = 0; } if (isset($params["UID"])) { $UID = $params["UID"]; } else { $UID = $user->uid; } $currentTeam = getCurrentTeam(); $TID = $currentTeam['TID']; $teamNumber = $currentTeam['number']; if (isset($params['OID']) && $params['OID'] > 0) { $OID = $params['OID']; $outreach = dbGetOutreach($OID); } // if the user has more than one team if (count(dbGetTeamsForUser($UID)) > 1) { $markup = '<div class="help tooltip2">'; $markup .= '<h2>My Outreach Ideas</h2>'; $markup .= '<span id="helptext"; class="helptext tooltiptext2">'; $markup .= 'These are your ideas that have not yet been approved to become outreaches.'; $markup .= '</span></div>'; // allows a user to see the outreach ideas of the team currently being used $outreaches = dbGetOutreachIdeas($user->uid, PREVIEW_NUMBER); // begin table $markup .= '<table class="infoTable"><tr><th colspan="3">Name</th>'; $markup .= '<th colspan="3">Log Date</th>'; $markup .= '<th colspan="2">Team</th>'; $markup .= '<th colspan="2"></th>'; $markup .= "</tr>"; // of the user has outreach ideas if (!empty($outreaches)) { foreach ($outreaches as $outreach) { $TID = $outreach['TID']; $team = dbGetTeam($outreach['TID']); $rawDate = $outreach['logDate']; $rawDate = dbDateSQL2PHP($rawDate); $logDate = date(TIME_FORMAT, $rawDate); $markup .= "<tr>"; $markup .= '<td colspan="3">' . '<a href="?q=viewOutreach&OID=' . $outreach['OID'] . '">' . chopString($outreach["name"], 20) . '</a>' . "</td>"; $markup .= '<td colspan="3">' . $logDate . "</td>"; $markup .= "<td colspan='2'>{$team['number']}</td>"; // approve and reject idea buttons if the user has permission if (hasPermissionForTeam('approveIdeas', $TID)) { $markup .= "<td colspan=\"2\"><a href=\"?q=approveIdea/{$outreach['OID']}/{$TID}\"><button>Approve</button></a>"; $markup .= "<a href=\"?q=rejectIdea/{$outreach['OID']}/{$TID}\"><button>Reject</button></a></td>"; } else { $markup .= '<td></td><td></td>'; } $markup .= "</tr>"; } } else { // display none if the user doesnt have any outreaches $markup .= "<tr>"; $markup .= '<td style="text-align:center" colspan="10"><em>[None]</em></td>'; $markup .= "</tr>"; } $markup .= "</table>"; } else { // if the user only has one team $markup = '<div class="help tooltip2">'; $markup .= '<h2>My Outreach Ideas</h2>'; $markup .= '<span id="helptext"; class="helptext tooltiptext2">'; $markup .= 'These are your ideas that have not yet been approved to become outreaches.'; $markup .= '</span></div>'; // allows a user to see the outreach ideas of the team currently being used $outreaches = dbGetOutreachIdeas($user->uid, PREVIEW_NUMBER); $markup .= '<table class="infoTable"><tr><th>Name</th>'; $markup .= "<th>Log Date</th>"; $markup .= "<th></th>"; $markup .= "<th></th>"; $markup .= "</tr>"; // if the user has outreach ideas if (!empty($outreaches)) { foreach ($outreaches as $outreach) { $TID = $outreach['TID']; $rawDate = $outreach['logDate']; $rawDate = dbDateSQL2PHP($rawDate); $logDate = date(TIME_FORMAT, $rawDate); $markup .= "<tr>"; $markup .= "<td>" . '<a href="?q=viewOutreach&OID=' . $outreach['OID'] . '">' . chopString($outreach["name"], 20) . '</a>' . "</td>"; $markup .= "<td>" . $logDate . "</td>"; if (hasPermissionForTeam('approveIdeas', $TID)) { $markup .= "<td><a href=\"?q=approveIdea/{$outreach['OID']}/{$TID}\"><button>Approve</button></a></td>"; $markup .= "<td><a href=\"?q=rejectIdea/{$outreach['OID']}/{$TID}\"><button>Reject</button></a></td>"; } else { $markup .= '<td></td><td></td>'; } $markup .= "</tr>"; } } else { // display none if the user doesn't have any outreach ideas $markup .= "<tr>"; $markup .= '<td style="text-align:center" colspan="10"><em>[None]</em></td>'; $markup .= "</tr>"; } $markup .= "</table>"; } $retArray = array(); $retArray['#markup'] = $markup; return $retArray; }