예제 #1
0
function outreachSettingsHeader()
{
    $team = getCurrentTeam();
    $TID = $team['TID'];
    // if the team does not have permission to access team outreach settings
    if (teamIsIneligible($TID)) {
        drupal_set_message('Your team does not have permission to access this page.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    // create header with team number
    $markup = "<h1>Team {$team['number']} Outreach Settings</h1>";
    return $markup;
}
예제 #2
0
function usersSearch($form, &$form_state)
{
    global $user;
    if (isset($params['TID'])) {
        $TID = $params['TID'];
        $team = dbGetTeam($TID);
    } else {
        $team = getCurrentTeam();
        $TID = $team['TID'];
    }
    if (teamIsIneligible($TID)) {
        drupal_set_message('Your team does not have permission to access this page.', 'error');
        drupal_goto('myDashboard');
    }
    $form = array();
    // displays what a user can search
    $form['fields']['nameContains'] = array('#type' => 'textfield', '#placeholder' => 'Name or Email');
    // submit button
    $form['fields']['submit'] = array('#prefix' => '<div align="left" style="float:left">', '#type' => 'submit', '#value' => t('Search'), '#suffix' => '</div>');
    // button to view all team members on current team
    $form['fields']['button'] = array('#markup' => '<div align="right" style="float:right"><a href="?q=showUsersForTeam"><button type="button">View All Team Members</button></a></div>');
    return $form;
}
예제 #3
0
function viewUsersForTeam($form, &$form_state)
{
    global $user;
    $params = drupal_get_query_parameters();
    if (isset($params['TID'])) {
        $TID = $params['TID'];
    } else {
        $TID = getCurrentTeam()['TID'];
    }
    if (teamIsIneligible($TID) || !isMyTeam($TID)) {
        drupal_set_message('You do not have permission to access that page.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    $form_state['TID'] = $TID;
    $canManageTeamMembers = hasPermissionForTeam('manageTeamMembers', $TID);
    $canManageTeamOwners = hasPermissionForTeam('manageTeamOwners', $TID);
    $markup = '<table><tr><td colspan="3">';
    if (isset($params['query'])) {
        $persons = dbSearchUsersFromTeam($TID, $params['query']);
    } else {
        $type = isset($params['type']) ? $params['type'] : '';
        // filter by type (student vs mentor vs alumni)
        $persons = dbGetUsersFromTeam($TID, $type);
    }
    if (empty($persons)) {
        drupal_set_message('No users found.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    } else {
        if (isset($params['query'])) {
            $markup .= '<h1>Search Results (' . count($persons) . ' matches)</h1></td>';
        } else {
            $markup .= '<h1>' . count($persons) . ' users on Team ' . dbGetTeamNumber($TID) . '</h1></td>';
        }
    }
    // create page header, table, and pending users/view all button
    $markup .= '<td colspan="3" style="text-align:right">';
    if ($canManageTeamMembers) {
        if (!empty(dbGetUsersAwaitingApproval($TID))) {
            $markup .= '<a href="?q=viewUsersToBeApproved&TID=' . $TID;
            $markup .= '"><button type="button">View Pending Users</button></a>';
        } else {
            $markup .= '<button type="button" disabled>No Pending Users</button>';
        }
        $markup .= '<a href="?q=addTeamMember&TID=' . $TID;
        $markup .= '&destination=' . current_path();
        $markup .= '"><button type="button">Add User</button></a>';
    }
    if (isset($params['type'])) {
        $markup .= '<a href="?q=showUsersForTeam&TID=' . $TID;
        $markup .= '"><button type="button">View All</button></a>';
    }
    $markup .= '</td></tr></table>';
    // sets up the table to display name, role, and grade of every user on the certain team
    $markup .= '<table class="infoTable"><th>Name</th>';
    $markup .= '<th>Email</td></th>';
    $markup .= '<th>Team Role</td></th>';
    $markup .= '<th>CROMA Role</th>';
    // if user is an admin, they see a new column where they can change the role of other team members
    if ($canManageTeamMembers) {
        $markup .= '<th>Admin Functions</th>';
    } else {
        $markup .= '<th></th>';
    }
    $form['tableHeader'] = array('#markup' => $markup);
    $i = 0;
    foreach ($persons as $person) {
        $form_state["UID-{$i}"] = $person['UID'];
        $markup = '<tr><td><a href="?q=viewUser&UID=' . $person["UID"] . ' ">';
        // hyperlinks the name so every name is linked to its user profile
        $markup .= $person["firstName"] . " " . $person["lastName"] . '</a></td>';
        $form["name-{$i}"] = array('#markup' => $markup);
        $email = dbGetUserPrimaryEmail($person['UID']);
        $markup = "<td><a href=\"mailto:{$email}\" target=\"_top\">{$email}</a></td>";
        $form["email-{$i}"] = array('#markup' => $markup);
        $markup = '<td>' . ucfirst(dbGetUserProfile($person['UID'])['type']) . '</td>';
        $form["isStudent-{$i}"] = array('#markup' => $markup);
        $RID = dbGetRIDForTeam($person['UID'], $TID);
        $teamOwnerRID = dbGetRID('teamOwner');
        $personIsTeamOwner = $RID == $teamOwnerRID;
        // allow current user to change roles (but not change the role of the team owner)
        if ($canManageTeamMembers && !$personIsTeamOwner) {
            // if the person in question doesn't have a role
            if (!$RID) {
                $RID = 0;
            }
            $roles = dbGetAllRoles();
            $roles[0] = 'Team Member';
            // if current user can't create team owners
            if (!$canManageTeamOwners) {
                unset($roles[$teamOwnerRID]);
            }
            // make sure the roles are still in order
            ksort($roles);
            $form["RID-{$i}"] = array('#prefix' => '<td class="roleSelector">', '#type' => 'select', '#default_value' => $RID, '#options' => $roles, '#suffix' => '</td>', '#ajax' => array('event' => 'change', 'callback' => 'callback', 'wrapper' => 'confirm-div', 'method' => 'replace'));
        } else {
            // if the current user can't change the role
            if ($RID == 0) {
                $role = 'Member';
            } else {
                $role = dbGetRoleName($RID);
            }
            $form["role-{$i}"] = array('#prefix' => '<td>', '#markup' => $role, '#suffix' => '</td>');
        }
        // if the person in question is the current user
        if ($person['UID'] == $user->uid) {
            // if the person is the team owner -- transfer ownership
            if ($personIsTeamOwner) {
                $markup = "<td><a href=\"?q=transferTeamOwnership&TID={$TID}\">";
                $markup .= "<button type=\"button\">Transfer Ownership</button></a></td>";
            } else {
                // allow user to leave team
                $markup = "<td><a href=\"?q=leaveTeam/{$TID}\">";
                $markup .= "<button type=\"button\">Leave Team</button></a></td>";
            }
            // if the current user can remove users
        } else {
            if ($canManageTeamMembers && !$personIsTeamOwner) {
                $markup = "<td><a href=\"?q=kickUserFromTeam/{$person['UID']}/{$TID}\">";
                $markup .= "<button type=\"button\" onclick=\"if(!confirm('Are you sure you want to remove this user from your team?')){return false;}\">Kick User</button></a></td>";
            } else {
                // or just some random person
                $markup = '<td></td>';
            }
        }
        $form["adminFunctions-{$i}"] = array('#markup' => $markup);
        $form["rowFooter-{$i}"] = array('#markup' => '</tr>');
        $i++;
    }
    // end of foreach
    $form_state['numUsers'] = $i;
    $form['tableFooter'] = array('#markup' => '</table>');
    if ($canManageTeamMembers) {
        $form['buttons'] = array('#prefix' => '<div id="confirm-div" style="visibility:hidden">', '#suffix' => '</div>');
        $form['buttons']['confirm'] = array('#type' => 'submit', '#value' => 'Confirm');
    }
    return $form;
}
예제 #4
0
function tagManager($form, &$form_state)
{
    $team = getCurrentTeam();
    $form_state['TID'] = $TID = $team['TID'];
    if (teamIsIneligible($TID)) {
        drupal_set_message('Your team does not have permission to access this page.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    $currentURL = getCurrentURL();
    // if browser didn't end up here by coming from the current page
    if ($currentURL != getAjaxURL() && (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != $currentURL)) {
        switchTagEditMode(false);
        // be sure to start with just viewing the tags
        if (!empty(drupal_get_query_parameters())) {
            // clear any other drupal_query_parameters
            drupal_goto(parseURLAlias($_SERVER['QUERY_STRING']));
        }
    }
    $markup = "<h1>Team {$team['number']} Outreach Settings</h1>";
    $editMode = checkTagEditMode();
    // create the wrapper-div used by AJAX
    $form['tags'] = array('#prefix' => '<div id="tags-div">', '#suffix' => '</div>');
    $tableHeader = '<table><tr><td><div class="help tooltip2"><h2>Outreach Tags</h2><span id="helptext"; class="helptext tooltiptext2">Outreach Tags are used to tag similar outreaches.</span></div></td><td><div align="right">';
    $form['tags']['tableHeader'] = array('#markup' => $tableHeader);
    // only show edit button if in "view mode" and the user has proper permissions
    if (!$editMode && hasPermissionForTeam('manageOutreachTags', $TID)) {
        $form['tags']['buttons'] = array('#type' => 'image_button', '#src' => '/images/icons/editWhite.png', '#attributes' => array('class' => array('editIcon')), '#limit_validation_errors' => array(), '#submit' => array('switchTagEditMode'));
    }
    // finish off the title and buttons table, then start the table for the tags themselves
    $tableHeader2 = '</div></td></tr></table>';
    $tableHeader2 .= '<table class="infoTable"><tr><th>Tag Name</th>';
    if (!$editMode) {
        $tableHeader2 .= '<th style="text-align:center">Matched Outreaches</th>';
    } else {
        $tableHeader2 .= '<th></th><th></th>';
    }
    $form['tags']['tableHeader2'] = array('#markup' => $tableHeader2);
    $tags = dbGetOutreachTagsForTeam($TID);
    if (!$editMode) {
        // if in "view" mode (aka not acting as a form)
        $tableContents = '';
        $tableContents .= '</tr>';
        if (!empty($tags)) {
            foreach ($tags as $OTID => $tagName) {
                // display the name
                $tableContents .= '<tr><td>' . $tagName . '</td>';
                // show the number of matching outreaches (which can be clicked on to search the outreach form by tags)
                $numMatched = dbGetOutreachMatchingTags(array($tagName), $TID, true);
                // "true" indicates only a count is returned
                $tableContents .= "<td style=\"text-align:center\"><a href=\"?q=outreach&tag={$OTID}\">{$numMatched}</a></td></tr>";
            }
        } else {
            $tableContents = '<tr><td colspan="2" style="text-align:center"><em>[None]</em></td></tr>';
        }
        $form['tags']['tableContents'] = array('#markup' => $tableContents);
    } else {
        // -------------------------------- in "edit" mode
        $i = 0;
        if (!empty($tags)) {
            foreach ($tags as $OTID => $tagName) {
                $i++;
                $form['tags']["tagName-{$i}"] = array('#prefix' => '<tr><td colspan="2">', '#type' => 'textfield', '#maxlength' => 50, '#default_value' => $tagName, '#suffix' => '</td>');
                $numMatching = dbGetOutreachMatchingTags(array(dbGetTagName($OTID)), $TID, true);
                $confirmBoxJS = '';
                if ($numMatching > 0) {
                    $confirmBoxJS = "if(!confirm('This tag matches {$numMatching} outreach(es). Are you sure you want to delete it?')){return false;}";
                }
                $form['tags']["deleteBttn-{$i}"] = array('#prefix' => "<td><a href=\"?q=deleteTag/{$OTID}/{$TID}\">", '#markup' => "<button onclick=\"{$confirmBoxJS}\" type=\"button\"><img src=\"/images/icons/trashWhite.png\" class=\"trashIcon\"></button>", '#suffix' => '</a></td></tr>');
                $form_state["OTID-{$i}"] = $OTID;
            }
            // end of foreach
        }
        // end of if
        $form_state['numTags'] = $i;
        // initialize the 'numNewRows' variable
        if (empty($form_state['numNewRows'])) {
            $form_state['numNewRows'] = 1;
        }
        $x;
        // PHP is weird and makes you declare a variable before the loop
        // create the empty row for creating new tags
        for ($x = 1; $x <= $form_state['numNewRows']; $x++) {
            // have to be sure to not overwrite anything
            // create row to allow entry of a new tag
            $form['tags']["newTagName-{$x}"] = array('#prefix' => '<tr><td>', '#type' => 'textfield', '#maxlength' => 50, '#suffix' => '</td>');
            // if this is the last row (and not the only row), add a "-" button
            if ($form_state['numNewRows'] > 1 && $x == $form_state['numNewRows']) {
                $form['tags']["newRemoveBttn-{$x}"] = array('#prefix' => '<td>', '#type' => 'submit', '#submit' => array('removeTagRow'), '#value' => '-', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'modifyTagRows_callback', 'wrapper' => 'tags-div'), '#suffix' => '</td>');
            } else {
                // add a placeholder instead of the "-" button
                $form['tags']["removeBttnPlaceHolder-{$x}"] = array('#markup' => '<td></td>');
            }
            // if this is the last row, add a "+" button
            if ($x == $form_state['numNewRows']) {
                $form['tags']["newAddBttn-{$x}"] = array('#prefix' => '<td>', '#type' => 'submit', '#submit' => array('addTagRow'), '#value' => '+', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'modifyTagRows_callback', 'wrapper' => 'tags-div'), '#suffix' => '</td>');
            } else {
                // add a placeholder instead of the "+" button
                $form['tags']["addBttnPlaceHolder-{$x}"] = array('#markup' => '<td></td>');
            }
            $for['tags']["rowFooter-{$x}"] = array('#markup' => '</tr>');
        }
        // end of for loop
    }
    // end of else (aka edit mode code)
    $form['tags']['tableFooter'] = array('#markup' => '</table>');
    // allow the user to cancel and return to the previous page
    // (note that the URL for cancel has a random extra parameter to ensure the mode is changed to view)
    if ($editMode) {
        $form['cancel'] = array('#prefix' => '<table><tr><td style="text-align:left">', '#markup' => '<a href="?q=teamOutreachSettings&notEdit"><button type="button">Cancel</button></a>', '#suffix' => '</td>');
        $form['submit'] = array('#prefix' => '<td style="text-align:right">', '#type' => 'submit', '#value' => 'Confirm', '#suffix' => '</td></tr></table>');
    }
    return $form;
}
예제 #5
0
function viewTeamStatistics()
{
    global $user;
    $params = drupal_get_query_parameters();
    $UID = $user->uid;
    if (isset($params['TID'])) {
        $TID = $params['TID'];
        $team = dbGetTeam($TID);
        $teamNumber = $team['number'];
    } else {
        $currentTeam = getCurrentTeam();
        $TID = $currentTeam['TID'];
        $teamNumber = $currentTeam['number'];
    }
    // checks if team has permission to acces page
    if (teamIsIneligible($TID)) {
        drupal_set_message('Your team does not have permission to access this page.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    $markup = "<script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.js\"></script>";
    $markup .= '<script src="numberCounting.js"></script>';
    // create table and header
    $markup .= '<table id="teamStats"><tr><td colspan="2" style="text-align:center">';
    $markup .= '<div class="help tooltip1">';
    $markup .= '<h2><b>Team Stats</b></h2>';
    $markup .= '<span id="helptext"; class="helptext tooltiptext1">';
    $markup .= 'These are the total numbers of hours and outreaches your team has inputted into CROMA.';
    $markup .= '</span></div>';
    $markup .= '</td></tr>';
    // links to all team outreach page
    $markup .= '<tr><td style="text-align:center"><a href="?q=outreach&allTeamOutreach"><b>HOURS</b></a></td>';
    $markup .= '<td style="text-align:center"><a href="?q=outreach&allTeamOutreach"><b>OUTREACHES</b></a></td></tr>';
    $markup .= '<tr style="font-size:48pt; font-family: "Open Sans", sans-serif;"><td style="text-align:center"><b class="countUp">' . dbGetHoursForTeam($TID) . '</a></b></td>';
    $markup .= '<td style="text-align:center"><b class="countUp">' . dbGetNumOutreachForTeam($TID);
    $markup .= '</b></td></tr></table>';
    return array('#markup' => $markup);
}
예제 #6
0
function outreachForm($form, &$form_state)
{
    global $user;
    $UID = $user->uid;
    $params = drupal_get_query_parameters();
    $currentTeam = getCurrentTeam();
    $TID = $currentTeam['TID'];
    $form_state['TID'] = $TID;
    $new = $form_state['new'] = true;
    if (teamIsIneligible($TID)) {
        drupal_set_message('Your team does not have permission to access this page.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    if (isset($params["OID"])) {
        $form_state['OID'] = $params['OID'];
        $new = $form_state['new'] = false;
        $outreach = dbGetOutreach($params["OID"]);
        $times = dbGetTimesForOutreach($params["OID"]);
        // set to display all times
        $form_state['numRows'] = count($times);
        // record how many were there before (in case user deletes one)
        $form_state['initialNumTimes'] = count($times);
        $TID = $outreach['TID'];
        $form_state['TID'] = $TID;
    }
    $form = array();
    // if the user is editing an old outreach
    if (!$new) {
        // menu hook to duplicate outreach
        $confirmBoxJS = "if(!confirm('Are you sure you want to duplicate this outreach? Any changes you made just now will NOT be saved.')){return false;}";
        $form['duplicate'] = array('#prefix' => "<div style=\"text-align:right\"><a href=\"?q=duplicateOutreach/{$form_state['OID']}/{$TID}\">", '#markup' => "<button onclick=\"{$confirmBoxJS}\" type=\"button\">Duplicate</button>", '#suffix' => '</a>');
    }
    if (!$new) {
        // menu hook to cancel the outreach
        if ($outreach["cancelled"]) {
            $confirmBoxJS = "if(!confirm('Are you sure you want to uncancel this outreach for the team?')){return false;}";
            $form['cancel'] = array('#prefix' => "<a href=\"?q=cancelOutreach/{$form_state['OID']}/{$TID}\">", '#markup' => "<button onclick=\"{$confirmBoxJS}\" type=\"button\">Uncancel Outreach</button>", '#suffix' => '</a></div>');
        } else {
            $confirmBoxJS = "if(!confirm('Are you sure you want to cancel this outreach for the team? This will remove the outreach from current team use.')){return false;}";
            $form['cancel'] = array('#prefix' => "<a href=\"?q=cancelOutreach/{$form_state['OID']}/{$TID}\">", '#markup' => "<button onclick=\"{$confirmBoxJS}\" type=\"button\">Cancel From Team Use</button>", '#suffix' => '</a></div>');
        }
    }
    $teamNumb = dbGetTeamNumber($TID);
    // form title
    $form['fields'] = array('#type' => 'fieldset', '#title' => t('Add Outreach: Team ' . '<b>' . $teamNumb . '</b>'));
    // if editing an outreach, then allow a user to cancel changes
    if (!$new) {
        $form['fields']['back'] = array('#prefix' => '<left>', '#limit_validation_errors' => array(), '#submit' => array('backToEvent'), '#type' => 'submit', '#value' => '⇦ Cancel Changes', '#attributes' => array('OnSubmit' => 'if(!confirm("Back?")){return false;}'), '#suffix' => '</left>');
    }
    $form['fields']['markupOne'] = array('#markup' => '<table>');
    // displays the name of the outreach editing
    $form['fields']['name'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'textfield', '#title' => t('Outreach Name:'), '#default_value' => $new ? '' : $outreach['name'], '#placeholder' => 'Name of the event', '#attributes' => array('onsubmit' => 'return false'), '#suffix' => '</td>');
    $tags = dbGetOutreachTagsForTeam($TID);
    // notifies a user to create outreach tags if the team doesn't have any
    if (empty($tags)) {
        if (hasPermissionForTeam('manageOutreachTags', $TID)) {
            $msg = 'Click <a href="?q=teamOutreachSettings"><b>here</b></a> to change your settings.';
        } else {
            $msg = 'Please have a team admin or owner set up tags for your team.';
        }
        drupal_set_message('To give the outreach a tag, you need to set up the tag options for your team! ' . $msg, 'error');
        $form['fields']['tags'] = array('#prefix' => '<td colspan="3" style="text-align:center">', '#markup' => 'Tags:<br><em>You have no available tags.</em>', '#suffix' => '</td></tr>');
    } else {
        // allows a user to add tags to the outreach
        if (!$new) {
            // get only OTID's to satisfy select field
            $oldTags = dbGetTagsForOutreach($form_state['OID'], true);
        }
        $form['fields']['tags'] = array('#prefix' => '<td colspan="3" style="text-align:center">', '#type' => 'select', '#id' => 'tags_field', '#title' => t('Tags:'), '#options' => $tags, '#default_value' => $new ? '' : $oldTags, '#chosen' => true, '#multiple' => true, '#suffix' => '</td></tr>');
    }
    // allows a user to change the status of the outreach if they have permission
    if (hasPermissionForTeam('manageOutreachTags', $TID)) {
        $form['fields']['status'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#default_value' => $new ? 'Select' : $outreach['status'], '#options' => array('isIdea' => 'Idea', 'isOutreach' => 'Outreach', 'doingWriteUp' => 'Write-Up', 'locked' => 'Locked'), '#title' => t('Status:'), '#chosen' => true, '#suffix' => '</td>');
        // if the user doesn't have permission, then the status of isIdea displays idea
    } else {
        if (!$new && $outreach['status'] == 'isIdea') {
            $form['fields']['status'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#title' => t('Status:'), '#options' => array('isIdea' => 'Idea'), '#default_value' => 'isIdea', '#disabled' => true, '#suffix' => '</td>');
            // if the user doesn't have permission, then the status of isOutreach displays outreach
        } else {
            if (!$new && $outreach['status'] == 'isOutreach') {
                $form['fields']['status'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#title' => t('Status:'), '#options' => array('isOutreach' => 'Outreach'), '#default_value' => 'isOutreach', '#disabled' => true, '#suffix' => '</td>');
                // if the user doesn't have permission, then the status of doingWriteUp displays write-up
            } else {
                if (!$new && $outreach['status'] == 'doingWriteUp') {
                    $form['fields']['status'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#title' => t('Status:'), '#options' => array('doingWriteUp' => 'Write-Up'), '#default_value' => 'doingWriteUp', '#disabled' => true, '#suffix' => '</td>');
                    // if the user doesn't have permission, then the status of locked displays locked
                } else {
                    if (!$new && $outreach['status'] == 'locked') {
                        $form['fields']['status'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#title' => t('Status:'), '#options' => array('locked' => 'Locked'), '#default_value' => 'locked', '#disabled' => true, '#suffix' => '</td>');
                        // if the user doesn't have permission, then the events created can only have a status of idea
                    } else {
                        $form['fields']['status'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#default_value' => $new ? 'Select' : $outreach['status'], '#options' => array('isIdea' => 'Idea'), '#title' => t('Status:'), '#chosen' => true, '#suffix' => '</td>');
                    }
                }
            }
        }
    }
    // allows a user to go to team outreach settings
    $form['fields']['manageTagsBttn'] = array('#prefix' => '<td colspan ="3" style="text-align:center">', '#markup' => '<a href="?q=teamOutreachSettings" target="_blank"><button type="button">Manage Tags</button></a>', '#suffix' => '</td></tr>');
    $form['fields']['description'] = array('#prefix' => '<tr><td colspan="6" style="text-align:center">', '#type' => 'textarea', '#title' => t('Description:'), '#default_value' => $new ? '' : $outreach['description'], '#placeholder' => 'Maximum of 500 characters', '#suffix' => '</td></tr>', '#maxlength_js' => 'TRUE', '#maxlength' => '500');
    $form['fields']['address'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'textfield', '#title' => t('Address:'), '#default_value' => $new ? '' : $outreach['address'], '#suffix' => '</td>');
    $team = dbGetTeam($TID);
    // default value from the team form
    $form['fields']['city'] = array('#prefix' => '<td colspan="1" style="text-align:center">', '#type' => 'textfield', '#title' => t('City:'), '#default_value' => $new ? $team['city'] : $outreach['city'], '#suffix' => '</td></tr>');
    $form['fields']['state'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#title' => t('State:'), '#options' => states_list(), '#default_value' => $new ? $team['state'] : $outreach['state'], '#chosen' => true, '#suffix' => '</td>');
    $form['fields']['country'] = array('#prefix' => '<td colspan="3" style="text-align:center">', '#type' => 'select', '#title' => t('Country:'), '#options' => countries_list(), '#default_value' => $new ? $team['country'] : $outreach['country'], '#chosen' => true, '#suffix' => '</td></tr>');
    $form['fields']['co_firstName'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'textfield', '#title' => t("Host Contact's First Name:"), '#default_value' => $new ? '' : $outreach['co_firstName'], '#placeholder' => 'Contact for this outreach', '#suffix' => '</td>');
    $form['fields']['co_lastName'] = array('#prefix' => '<td colspan="3" style="text-align:center">', '#type' => 'textfield', '#title' => t("Host Contact's Last Name:"), '#default_value' => $new ? '' : $outreach['co_lastName'], '#suffix' => '</tr>');
    $form['fields']['co_phoneNumber'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'textfield', '#title' => t("Host Contact's Phone Number:"), '#default_value' => $new ? '' : $outreach['co_phoneNumber'], '#placeholder' => 'Format: XXXXXXXXXX', '#suffix' => '</td>');
    $form['fields']['co_email'] = array('#prefix' => '<td colspan="3" style="text-align:center">', '#type' => 'textfield', '#title' => t("Host Contact's Email:"), '#default_value' => $new ? '' : $outreach['co_email'], '#placeholder' => 'Email of outreach contact', '#suffix' => '</td></tr>');
    $form['fields']['co_organization'] = array('#prefix' => '<tr><td colspan="6" style="text-align:center">', '#type' => 'textfield', '#title' => t("Host Organization:"), '#default_value' => $new ? '' : $outreach['co_organization'], '#placeholder' => 'Group participating with for this outreach', '#suffix' => '</td></tr>');
    // allows a user to add dates to an outreach
    if (empty($form_state['numRows'])) {
        $form_state['numRows'] = 1;
    }
    $form['fields']['datesHeader'] = array('#markup' => '<tr><td colspan="6">');
    $form['fields']['dates']['header'] = array('#markup' => '<div id="dates-div"><table>');
    $date = date(DEFAULT_TIME_FORMAT, strtotime('today noon'));
    for ($i = 0; $i < $form_state['numRows']; $i++) {
        $form['fields']['dates']["openFieldOfStart-{$i}"] = array('#markup' => '<tr><td colspan="2" align="left" style="text-align:left">');
        if (!empty($times)) {
            $startTime = date(DEFAULT_TIME_FORMAT, dbDateSQL2PHP($times[$i]['startTime']));
        }
        $form['fields']['dates']["startTime-{$i}"] = array('#type' => 'date_popup', '#title' => t('Start Date:'), '#default_value' => !isset($startTime) ? $date : $startTime, '#date_format' => TIME_FORMAT, '#date_label_position' => 'within', '#date_increment' => 1, '#date_year_range' => '-20:+20', '#datepicker_options' => array(), '#states' => array('invisible' => array(':input[name="status"]' => array('value' => 'isIdea'))));
        if (!$new) {
            $form_state['fields']['dates']["TOID-{$i}"] = $times[$i]['TOID'];
        }
        $form['fields']['dates']["closeFieldOfStart-{$i}"] = array('#markup' => '</td>');
        $form['fields']['dates']["openFieldOfEnd-{$i}"] = array('#markup' => '<td colspan="2" align="right" style="text-align:left">');
        if (!empty($times)) {
            $endTime = date(DEFAULT_TIME_FORMAT, dbDateSQL2PHP($times[$i]['endTime']));
        }
        $form['fields']['dates']["endTime-{$i}"] = array('#type' => 'date_popup', '#title' => t('End Date:'), '#default_value' => !isset($endTime) ? $date : $endTime, '#date_format' => TIME_FORMAT, '#date_label_position' => 'within', '#date_increment' => 1, '#date_year_range' => '-20:+20', '#datepicker_options' => array(), '#states' => array('invisible' => array(':input[name="status"]' => array('value' => 'isIdea'))));
        $form['fields']['dates']["closeFieldOfEnd-{$i}"] = array('#markup' => '</td>');
        if ($i == $form_state['numRows'] - 1) {
            $form['fields']['dates']["addRowButton-{$i}"] = array('#prefix' => '<td colspan="1" style="text-align:center">', '#type' => 'submit', '#submit' => array('addDateRow'), '#value' => '+', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'modifyDateRows_callback', 'wrapper' => 'dates-div'), '#states' => array('invisible' => array(':input[name="status"]' => array('value' => 'isIdea'))), '#suffix' => '</td>');
        }
        if ($i == $form_state['numRows'] - 1) {
            $form['fields']['dates']["removeRowButton-{$i}"] = array('#prefix' => '<td colspan="1" style="text-align:center">', '#type' => 'submit', '#submit' => array('removeDateRow'), '#value' => '-', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'modifyDateRows_callback', 'wrapper' => 'dates-div'), '#states' => array('invisible' => array(':input[name="status"]' => array('value' => 'isIdea'))), '#suffix' => '</td>');
        }
        $form['fields']['dates']["rowFooter-{$i}"] = array('#markup' => '</tr>');
    }
    // end of for loop
    $form['fields']['dates']["divFooter-{$i}"] = array('#markup' => '</table></div></td>');
    // allows the user to change the outreach visibility if the status is locked
    if (!$new && $outreach["status"] == "locked") {
        $isPublicOptions = array(0 => t('Private'), 1 => t('Public'));
        $form['fields']['isPublic'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'radios', '#title' => t('Set Event Visibility'), '#options' => $isPublicOptions, '#default_value' => $new ? '1' : $outreach['isPublic'], '#suffix' => '</td></tr>');
    }
    $form['fields']['submit'] = array('#prefix' => '<tr><td colspan="6" style="text-align:right">', '#type' => 'submit', '#value' => t('Save'), '#sorted' => false, '#suffix' => '</td></tr>');
    $form['fields']['finalFooter'] = array('#markup' => '</table>');
    if (!$new && !(hasPermissionForTeam('editAnyOutreach', $TID) || isMyOutreach($params['OID']))) {
        drupal_set_message("You don't have permission to edit this outreach.", 'error');
        drupal_goto('viewOutreach', array('query' => array('OID' => $params['OID'])));
    }
    if (dbGetTeamsForUser($user->uid) == NULL) {
        drupal_set_message("You don't have a team assigned.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    if (!dbIsUserApprovedForTeam($UID, $TID)) {
        drupal_set_message("You aren't approved for this team.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    if (dbGetStatusForTeam($TID) == "0" || dbGetStatusForTeam($TID) == FALSE) {
        drupal_set_message("This team isn't active/approved.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    return $form;
}
예제 #7
0
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.');
    }
}
예제 #8
0
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');
    }
}
예제 #9
-1
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)));
    }
}