function applyForTeamForm_submit($form, $form_state) { global $user; $name = $form_state['values']['personName']; $email = $form_state['values']['email']; $teamName = dbGetTeamName($form_state['TID']); $note = $form_state['values']['message']; // fill in the fields of the application $application['UID'] = $user->uid; $application['TID'] = $form_state['TID']; $application['userEmail'] = stripTags($email, ''); // do not allow tags $application['userMessage'] = stripTags($note); // allow some tags // add a notification for the team owner and admins if (dbApplyForTeam($application)) { // note that this does its own error checking $notification['dateCreated'] = dbDatePHP2SQL(time()); $notification['dateTargeted'] = dbDatePHP2SQL(time()); $notification['TID'] = $form_state['TID']; $notification['message'] = "{$name} has applied to join your team {$teamName}."; $notification['bttnTitle'] = 'View'; $notification['bttnLink'] = '?q=viewUsersToBeApproved&TID=' . $form_state['TID']; notifyUsersByRole($notification, 'teamOwner'); notifyUsersByRole($notification, 'teamAdmin'); drupal_set_message('Your application has been sent! You will receive an email when you have been approved for the team.'); drupal_goto('manageUserTeams'); } }
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 viewUserEventsForTeam() { global $user; $params = drupal_get_query_parameters(); // if user does not have 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['UID'])) { $UID = $params['UID']; } else { $UID = $user->uid; } if (isset($params['TID'])) { $TID = $params['TID']; } else { $currentTeam = getCurrentTeam(); $TID = $currentTeam['TID']; } $outreaches = dbGetOutreachesForUserForTeam($UID, $TID); $teamName = dbGetTeamName($TID); // create page header and table $markup = "<table><h1>My Outreaches For {$teamName}</h1></table>"; $markup .= '<table class="infoTable">'; $markup .= '<tr>'; $markup .= '<th colspan="3">Outreach Name</th>'; $markup .= '<th colspan="3">Description</th>'; $markup .= '<th colspan="2">Hours</th>'; $markup .= "</tr>"; // if user has outreaches for the current team if (!empty($outreaches)) { foreach ($outreaches as $outreach) { $markup .= "<tr>"; $markup .= '<td colspan="3">' . '<a href="?q=viewOutreach&OID=' . $outreach['OID'] . '">' . chopString($outreach["name"], 30) . '</a>' . "</td>"; $markup .= '<td colspan="3">' . chopString($outreach["description"], 30) . "</td>"; $markup .= '<td colspan="2">' . dbGetHoursForUserFromOutreach($UID, $outreach['OID']) . "</tr>"; $markup .= "</tr>"; } $markup .= "</table>"; } else { // if the user does not have any outreaches for the current team $markup .= '<tr><td style="text-align:center" colspan="10"><em>[None]</em></td>'; $markup .= "</tr>"; } $markup .= "</table>"; $retArray = array(); $retArray['#markup'] = $markup; return $retArray; }
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 viewOutreach() { global $user; $UID = $user->uid; $params = drupal_get_query_parameters(); $markup = "<script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.js\"></script>"; $markup .= '<script src="numberCounting.js"></script>'; $markup .= '<h1>Outreach</h1><br>'; // if doing a custom search if (isset($params['query']) && $params['query'] == 'search') { $sql = generateSearchSQL($_SESSION['searchParams'], $_SESSION['proxyFields']); $outreaches = dbSearchOutreach($sql, $_SESSION['proxyFields']); $header = '<h2>Custom Search Results ('; $header .= empty($outreaches) ? '0' : count($outreaches); $header .= ' matches)</h2>'; } else { if (isset($params['tag'])) { $_SESSION['searchParams'] = array('tags' => array($params['tag'])); $_SESSION['proxyFields'] = array(); $sql = generateSearchSQL($_SESSION['searchParams'], $_SESSION['proxyFields']); $outreaches = dbSearchOutreach($sql, $_SESSION['proxyFields']); $header = '<h2>Outreaches Tagged "' . dbGetTagName($params['tag']) . '"</h2>'; } else { if (isset($params['owned'])) { $outreaches = dbGetOwnedOutreachForUser($UID); $header = '<h2>Outreaches I Own</h2>'; } else { if (isset($params['signedUp'])) { $outreaches = dbGetOutreachForUser($UID); $header = '<h2>Outreaches I Am Signed Up For</h2>'; } else { if (isset($params['allTeamOutreach'])) { $TID = getCurrentTeam()['TID']; $_SESSION['searchParams'] = array('TID' => array('value' => $TID, 'matchType' => 'exact')); $_SESSION['proxyFields'] = array(':TID' => $TID); $sql = generateSearchSQL($_SESSION['searchParams'], $_SESSION['proxyFields']); $outreaches = dbSearchOutreach($sql, $_SESSION['proxyFields']); $teamName = dbGetTeamName($TID); $header = "<h2>All Outreach for {$teamName}</h2>"; } else { $_SESSION['searchParams'] = array(); $_SESSION['proxyFields'] = array(); $header = "<h2>No Search Selected</h2>"; } } } } } if (isset($_SESSION['searchParams']['teams']) && count($_SESSION['searchParams']['teams']) > 1) { $multipleTeamsInResult = true; } else { $multipleTeamsInResult = false; } $markup .= $header; // set $outreaches to an array rather than false (so that later functions don't have errors) if (empty($outreaches)) { $outreaches = array(); } $totalFilterOutreaches = count($outreaches); $totalFilterHours = 0; foreach ($outreaches as &$outreach) { $outreach['hours'] = dbGetHoursForOutreach($outreach['OID']); $totalFilterHours += $outreach['hours']; } unset($outreach); $sortParam = isset($params["sort"]) ? $params['sort'] : 'name'; $isAscending = isset($params['isAscending']) ? true : false; orderByValue($outreaches, $sortParam, $isAscending); // custom function (see helperFunctions.inc) $markup .= '<table style="margin:0px">'; $markup .= '<tr><td style="padding:0px; text-align:left"><b>Outreaches with Current Filters: </b><span class="countUp">' . $totalFilterOutreaches . '</span></td>'; $markup .= '<td style="padding:0px; text-align:right" align="right"><b>Hours with Current Filters: </b><span class="countUp">' . $totalFilterHours . '</span></td></tr>'; $markup .= '<tr><td style="padding:0px" align="left">Sort By: '; // remove special params (since they should not be added every time) unset($params['isAscending']); unset($params['sort']); $markup .= sortHeader($sortParam, $params, $isAscending, 'Name', 'name', 'outreach') . ' | '; $markup .= sortHeader($sortParam, $params, $isAscending, 'Status', 'status', 'outreach') . ' | '; $markup .= sortHeader($sortParam, $params, $isAscending, 'Hours', 'hours', 'outreach') . ' | '; $markup .= sortHeader($sortParam, $params, $isAscending, 'Event Date', 'eventDate', 'outreach'); $markup .= '</td><td style="padding:0px; text-align:right">'; if (!isset($params['owned'])) { $markup .= '<a href="?q=outreach&owned"><div class="help tooltip4"><button>Owned</button><span id="helptext"; class="helptext tooltiptext4">Click here to sort by outreach you own.</span></div></a>'; } else { $markup .= '<a href="?q=outreach&allTeamOutreach"><button>All Team Outreach</button></a>'; } if (!isset($params['signedUp'])) { $markup .= '<a href="?q=outreach&signedUp"><div class="help tooltip3"><button>Signed Up</button><span id="helptext"; class="helptext tooltiptext3">Click here to sort by outreach you are signed up for.</span></div></a>'; } else { $markup .= '<a href="?q=outreach&allTeamOutreach"><button>All Team Outreach</button></a>'; } $markup .= '</td></tr></table>'; $markup .= '<table class="infoTable" style="margin:0px"><tr><th colspan="2">Status</th>'; if ($multipleTeamsInResult) { $markup .= '<th colspan="2">Team</th>'; } $markup .= '<th colspan="4">Name</th>'; $markup .= '<th colspan="2">Hours</th>'; $markup .= '<th colspan="2">Event Date</th>'; if (empty($outreaches)) { $markup .= '<tr><td colspan="11">No outreach found! Click <a href="?q=outreachForm">here</a> to create new outreach!</td></tr></table>'; return array('#markup' => $markup); } foreach ($outreaches as $outreach) { $OID = $outreach['OID']; $hours = dbGetHoursForOutreach($OID); $status; switch ($outreach['status']) { case 'isOutreach': $status = '<span title="Outreach Event"><img class="eventIndicatorIcon" src="/images/icons/outreachBlue.png"></span>'; break; case 'isIdea': $status = '<span title="Idea"><img class="eventIndicatorIcon" src="/images/icons/ideaBlue.png"></span>'; break; case 'doingWriteUp': $status = '<span title="Write Up"><img class="eventIndicatorIcon" src="/images/icons/writeUpBlue.png"></span> '; break; case 'locked': $status = '<span title="Locked Event"><img class="eventIndicatorIcon" src="/images/icons/lockedBlue.png"></span>'; break; default: drupal_set_message('Invalid outreach data.'); break; } $markup .= '<tr><td colspan="2" style="padding: 0px 0px 0px 14px;">'; $markup .= showOutreachStatusIcon($outreach['status']) . '</td>'; if ($multipleTeamsInResult) { $markup .= '<td colspan="2"><a href="?q=viewTeam&TID=' . $outreach['TID'] . '">' . dbGetTeamNumber($outreach['TID']) . '</a></td>'; } $markup .= '<td colspan="4"><a href="?q=viewOutreach&OID=' . $OID . '">' . chopString($outreach['name'], 15) . '</a></td>'; $markup .= '<td colspan="2">' . $hours . '</td>'; if (dbGetEarliestTimeForOutreach($OID) != false) { $markup .= '<td colspan="2">' . date(TIME_FORMAT, dbDateSQL2PHP(dbGetEarliestTimeForOutreach($OID))) . '</td>'; } else { $markup .= '<td colspan="2">[none]</td>'; } } $markup .= '</table>'; return array('#markup' => $markup); }
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 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 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 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; }
<?php /* ---- widgets/fancyScrollingStats.php ---- returns JSON-encoded stats data for a team (when called by fancyScrollingStats.js) */ // quick check to determine if this is the release version // normally this would be set through a define in Drupal if ($_SERVER['SERVER_PORT'] == ':80') { $basePath = '/var/www-croma/database-release'; } else { $basePath = '/var/www-croma/database'; } include $basePath . '/croma_dbFunctions.php'; include $basePath . '/drupalCompatibility.php'; if (isset($_POST['teamNumber'])) { $teamNumber = $_POST['teamNumber']; } else { echo 'errorTID'; return; } $TID = dbGetTeamTIDByNumber($teamNumber); $data['numHours'] = dbGetHoursForTeam($TID); $data['teamName'] = dbGetTeamName($TID); $data['numOutreaches'] = dbGetNumOutreachForTeam($TID); $json = json_encode($data); echo $json;
function oldHoursForm($form, &$form_state) { global $user; $params = drupal_get_query_parameters(); // initialization of values if (!isset($form_state['TID'])) { // first time on form $TID = $form_state['TID'] = $params['TID']; // set to url params $offset = dbGetOffsetHours($TID); if ($offset != null) { $new = $form_state['new'] = false; $form_state['numRows'] = count($offset); $form_state['initialNumTimes'] = count($offset); // record how many were there before (in case user deletes one) } else { $new = $form_state['new'] = true; } } else { // not first time on form $TID = $form_state['TID']; $offset = dbGetOffsetHours($TID); } // checking that user is on a team if (dbGetTeamsForUser($user->uid) == false) { drupal_set_message("You don't have a team assigned.", 'error'); drupal_goto($_SERVER['HTTP_REFERER']); } // checking that you are accessing this page with a team in mind if (!isset($TID)) { // if $TID is still null drupal_set_message("No team selected.", 'error'); return; } // checking to make sure you have permission to actually edit the offset hours if (!isMyTeam($TID) || !hasPermissionForTeam('editTeam', $TID)) { drupal_set_message("You don't have permission to edit the 'old hours' for this team.", 'error'); return; } // beginning the form itself $form['fields'] = array('#prefix' => '<div id="oldHourRows-div">', '#type' => 'fieldset', '#title' => t('Enter Old Hours For Team: ' . dbGetTeamName($TID)), '#suffix' => '</div>'); if (!$new) { // if user wants to cancel any changes they made $form['fields']['back'] = array('#prefix' => '<left>', '#limit_validation_errors' => array(), '#submit' => array('backToTeam'), '#type' => 'submit', '#value' => '⇦ Cancel Changes', '#attributes' => array('OnSubmit' => 'if(!confirm("Back?")){return false;}'), '#suffix' => '</left>'); } $form['fields']['tableHeader'] = array('#markup' => '<table>'); if (empty($form_state['numRows'])) { $form_state['numRows'] = 1; } for ($i = 0; $i < $form_state['numRows']; $i++) { $rowMarkUp = "<tr id=\"row-{$i}\""; $rowMarkUp .= '>'; $form['fields']["rowHeader-{$i}"] = array('#markup' => $rowMarkUp); $form['fields']["hours-{$i}"] = array('#prefix' => '<td style="text-align:left;">', '#type' => 'textfield', '#title' => t('Number Of Hours:'), '#suffix' => '</td>', '#default_value' => $new ? '' : $offset[$i]['numberOfHours']); if (!$new) { $form_state['fields']["HTID-{$i}"] = $offset[$i]['HTID']; } $form['fields']["year-{$i}"] = array('#prefix' => '<td style="text-align:left;">', '#type' => 'textfield', '#title' => t('Year:'), '#suffix' => '</td>', '#default_value' => $new ? '' : $offset[$i]['year']); if ($i == $form_state['numRows'] - 1) { $form['fields']["addRowButton-{$i}"] = array('#prefix' => '<td>', '#type' => 'submit', '#submit' => array('addOldHourRow'), '#value' => '+', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'modifyOldHourRows_callback', 'wrapper' => 'oldHourRows-div'), '#suffix' => '</td>'); } if ($i == $form_state['numRows'] - 1) { $form['fields']["removeRowButton-{$i}"] = array('#prefix' => '<td>', '#type' => 'submit', '#submit' => array('removeOldHourRow'), '#value' => '-', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'modifyOldHourRows_callback', 'wrapper' => 'oldHourRows-div'), '#suffix' => '</td>'); } $form['fields']['rowFooter'] = array('#markup' => '</tr>'); } // end of for loop $form['fields']['submit'] = array('#prefix' => '<tr><td colspan="4" style="text-align:right">', '#type' => 'submit', '#value' => t('Submit'), '#suffix' => '</td></tr>'); $form['fields']['tableFooter'] = array('#markup' => '</table>'); return $form; }
function createNewUser($form_state) { //This will generate a random password, you could set your own here $password = user_password(8); $userName = $form_state['values']['firstName'] . ' ' . $form_state['values']['lastName']; //set up the user fields $fields = array('name' => $form_state['values']['primaryEmail'], 'mail' => $form_state['values']['primaryEmail'], 'pass' => $password, 'status' => 1, 'init' => 'email address', 'roles' => array(DRUPAL_AUTHENTICATED_RID => 'authenticated user')); //the first parameter is left blank so a new user is created $account = user_save('', $fields); // Manually set the password so it appears in the e-mail. $account->password = $fields['pass']; // Send the e-mail through the user module. $params['url'] = user_pass_reset_url($account); $params['teamName'] = dbGetTeamName($form_state['TID']); drupal_mail('users', 'userCreated', $form_state['values']['primaryEmail'], NULL, $params, '*****@*****.**'); $fields = array('firstName', 'lastName'); $profileData = getFields($fields, $form_state['values']); $profileData = stripTags($profileData, ''); $profileData['UID'] = $account->uid; dbCreateProfile($profileData); // creating new profile return $profileData['UID']; }
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))); } }