Пример #1
0
function viewUserStats()
{
    global $user;
    $params = drupal_get_query_parameters();
    if (isset($params["UID"])) {
        $UID = $params["UID"];
    } else {
        $UID = $user->uid;
    }
    $currentTeam = getCurrentTeam();
    $TID = $currentTeam['TID'];
    $teamNumber = $currentTeam['number'];
    $numOfOutreachesForUser = dbGetNumOutreachForUser($UID);
    $markup = "<script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.js\"></script>";
    $markup .= '<script src="numberCounting.js"></script>';
    $form['script'] = array('#markup' => $markup);
    // create page header and table
    $form['mainHeader'] = array('#markup' => '<h1>My Dashboard</h1>');
    $form['table'] = array('#markup' => '<table><tr><td>');
    // displays users total stats
    $markup = '<table id="myTotalStats"><tr><td colspan="2" style="text-align:center">';
    $markup .= '<div class="help tooltip2">';
    $markup .= '<h2><b>My Total Stats</b></h2>';
    $markup .= '<span id="helptext"; class="helptext tooltiptext2">';
    $markup .= 'These are your total numbers of hours and outreaches.';
    $markup .= '</span></div>';
    $markup .= '</td></tr>';
    $markup .= '<tr><td style="text-align:center"><a href="?q=viewHours&UID=' . $UID . '"><b>HOURS</b></a></td>';
    $markup .= '<td style="text-align:center"><a href="?q=outreach"><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">' . dbGetUserHours($UID) . '</b></td>';
    $markup .= '<td style="text-align:center"><b class="countUp">' . $numOfOutreachesForUser;
    $markup .= '</b></td></tr></table></td>';
    $form['myStatsTable'] = array('#markup' => $markup);
    // if user has more than one team, displays stats for user on current team
    if (count(dbGetTeamsForUser($UID)) > 1) {
        // dropdown allows user to switch teams
        $form['TID'] = array('#prefix' => '<td><table id="myStatsOnTeamNumber"><tr><td id ="myStatsOnMultTeams1" style="text-align:right; padding:0px"><div class="help tooltip2"><h2><b>My Stats On</b></h2><span id="helptext"; class="helptext tooltiptext2">These are your total numbers of hours and outreaches for your currently active team.</span></div></td><td id="myStatsOnMultTeams2"> ', '#type' => 'select', '#attributes' => array('onChange' => 'document.getElementById("viewuserstats").submit();'), '#chosen' => true, '#options' => dbGetTeamsListForUser($UID), '#default_value' => $TID, '#suffix' => '</td></tr>');
        $markup = '<tr><td style="text-align:center"><a href="?q=userHoursForTeam&UID=' . $UID . '&TID=' . $TID . '"><b>HOURS</b></a></td>';
        $markup .= '<td style="text-align:center"><a href="?q=userEventsForTeam&UID=' . $UID . '&TID=' . $TID . '"><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">' . dbGetUserHoursForTeam($UID, $TID) . '</b></td>';
        $markup .= '<td style="text-align:center"><b class="countUp">' . dbGetNumOutreachesForUserForTeam($UID, $TID) . '</b></td></tr></table></td></tr></table>';
        $form['teamStatsTable'] = array('#markup' => $markup);
        $form['submit'] = array('#type' => 'submit', '#value' => 'Update', '#attributes' => array('style' => array('display: none;')));
    } else {
        // if user does not have more than one team, displays what team the user is on
        $markup = '<td><table id="myStatsOnTeamNumber"><tr><td colspan="2" style="text-align:center">';
        $markup .= '<div class="help tooltip2">';
        $markup .= '<h2>My Team</h2>';
        $markup .= '<span id="helptext"; class="helptext tooltiptext2">';
        $markup .= 'This is the team number and CROMA permission for your user.';
        $markup .= '</span></div>';
        $markup .= '</td></tr>';
        $markup .= '<tr style="font-size:48pt; font-family:"Open Sans", sans-serif;"><td style="text-align:center"><b>' . $currentTeam['number'] . '</b></td></tr>';
        $role = dbGetRoleForTeam($UID, $TID) == '' ? 'Team Member' : dbGetRoleForTeam($UID, $TID);
        $markup .= '<tr><td style="text-align:center"><b>CROMA Role: </b>' . $role . '</td></tr>';
        $markup .= '</table></td></tr></table>';
        $form['TID'] = array('#markup' => $markup);
    }
    return $form;
}
Пример #2
0
function deleteUserPage_submit($form, $form_state)
{
    global $user;
    $UID = $user->uid;
    $teams = dbGetTeamsForUser($UID);
    // getting teams that are associated with a user
    foreach ($teams as $team) {
        // looping through these teams
        dbKickUserFromTeam($UID, $team['TID']);
        // removing the user from these teams
        dbRemoveAllUserRoles($UID, $team['TID']);
        // ensuring the user doesn't have any role on the team
    }
    dbRemoveAllEmailsForUser($UID);
    dbDisableUser($UID);
    $params['feedback'] = stripTags($form_state['values']['misc'], '');
    // stripping any "illegal" HTML tags
    $params['userName'] = dbGetUserName($UID);
    // getting the user name
    drupal_mail('users', 'userdeleted', '*****@*****.**', variable_get('language_default'), $params, $from = null, $send = true);
    // sending the user a confirmation mail
    drupal_set_message("Your account has been deleted. We're sorry to see you go!");
    // message displayed and redirected to front page
    drupal_goto('<front>');
}
Пример #3
0
function publicOutreach($form, &$form_state)
{
    global $user;
    $UID = $user->uid;
    $TID = getCurrentTeam()['TID'];
    $outreaches = dbGetLockedOutreachForTeam($TID);
    // checking to make sure user has permission to change team outreach settings
    if (!hasPermissionForTeam('editAnyOutreach', $TID)) {
        drupal_set_message("You don't have permission to change outreach settings for this team.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    // checking to see if the user has a team assigned
    if (dbGetTeamsForUser($user->uid) == false) {
        drupal_set_message("You don't have a team assigned.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    // checking to see if the user is approved for the team
    if (!dbIsUserApprovedForTeam($UID, $TID)) {
        drupal_set_message("You aren't approved for this team.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    // checking to see if the team is active
    if (dbGetStatusForTeam($TID) == "0" || dbGetStatusForTeam($TID) == false) {
        drupal_set_message("This team isn't active/approved.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    $names = array();
    $data = array();
    // if team has locked outreaches
    if (!empty($outreaches)) {
        foreach ($outreaches as $outreach) {
            $names[$outreach['OID']] = $outreach['name'];
            if ($outreach['isPublic']) {
                $data[] = $outreach['OID'];
            }
        }
    }
    // begin form
    $form = array();
    $form['fields'] = array('#type' => 'fieldset', '#title' => t('Changing Visibilities For ' . dbGetTeamNumber($TID)));
    $new = false;
    // cancel changes button doesn't save anything and goes back to team outreach settings
    if (!$new) {
        $form['fields']['back'] = array('#prefix' => '<left>', '#limit_validation_errors' => array(), '#submit' => array('backToSettings'), '#type' => 'submit', '#value' => '⇦ Cancel Changes', '#attributes' => array('OnSubmit' => 'if(!confirm("Back?")){return false;}'), '#suffix' => '</left>');
    }
    // if the team has locked outreaches
    if (!empty($outreaches)) {
        $form['fields']['outreaches'] = array('#prefix' => '<table><tr><td>', '#type' => 'checkboxes', '#title' => t('<h5>Which outreaches would you like to make public?</h5>'), '#options' => $names, '#default_value' => $data, '#suffix' => '</td></tr><tr><td><br>Only showing outreaches which are "locked".</td></tr>', '#checkall' => true);
        $form['fields']['footer'] = array('#markup' => '</table>');
        $form['fields']['submit'] = array('#prefix' => '<table><tr><td colspan="3" style="text-align:right">', '#type' => 'submit', '#value' => t('Save'), '#suffix' => '</td></tr></table>');
    } else {
        // if the team does not have any locked outreaches
        $form['fields']['outreaches'] = array('#prefix' => '<table><tr><td colspan="3" style="text-align:left">', '#markup' => "Your team doesn't have any locked outreaches. All locked outreaches are displayed on this page. If you make a locked outreach public, it becomes visible on the outreach directory widget.<br>", '#suffix' => '</td></tr></table>');
    }
    return $form;
}
Пример #4
0
function mediaForm($form, &$form_state)
{
    global $user;
    $UID = $user->uid;
    $params = drupal_get_query_parameters();
    if (isset($params['MID'])) {
        $MID = $form_state['MID'] = $params['MID'];
    } else {
        if (isset($form_state['MID'])) {
            $MID = $form_state['MID'];
        } else {
            drupal_set_message('No media selected.', 'error');
            return;
        }
    }
    $media = dbGetMedia($MID);
    if (isset($media['OID'])) {
        $form_state['OID'] = $media['OID'];
    }
    $form['fields'] = array('#type' => 'fieldset', '#title' => t('Assign Media'));
    $form['fields']['back'] = array('#prefix' => '<left>', '#limit_validation_errors' => array(), '#submit' => array('backToMedia'), '#type' => 'submit', '#value' => '⇦ Cancel Changes', '#attributes' => array('OnSubmit' => 'if(!confirm("Back?")){return false;}'), '#suffix' => '</left>');
    $form['fields']['title'] = array('#prefix' => '<table id="table-fields"><tr><td>', '#type' => 'textfield', '#title' => t('Media Name'), '#suffix' => '</td>', '#default_value' => $media['title']);
    $form['fields']['picture'] = array('#prefix' => '<td>', '#type' => 'item', '#markup' => '<img src="' . generateURL($media['FID']) . '" style="max-width:200px; width:auto;  height:auto;">', '#suffix' => '</td></tr>');
    $form['fields']['description'] = array('#prefix' => '<tr><td>', '#type' => 'textarea', '#title' => t('Description'), '#suffix' => '</td></tr>', '#default_value' => $media['description']);
    $team = getCurrentTeam();
    $teams = dbGetTeamsForUser($UID);
    $form_state['teams'] = $teams;
    $TID = $team['TID'];
    $form_state['oldTID'] = $TID;
    if (count($teams) != 1) {
        $choices = array();
        foreach ($teams as $userTeam) {
            $choices[$userTeam['TID']] = $userTeam['number'];
        }
        $form['fields']['team'] = array('#prefix' => '<tr><td>', '#type' => 'select', '#title' => t('Team to be Associated With'), '#default_value' => $TID, '#options' => $choices, '#chosen' => true, '#suffix' => '</td></tr>', '#ajax' => array('callback' => 'modify', 'limit_validation_errors' => array(), 'wrapper' => 'div_OID_wrapper'));
    } else {
        $form['fields']['team'] = array('#markup' => '<tr><td></td></tr>');
    }
    $outreachList = dbGetOutreachListForTeam(getCurrentTeam()['TID']);
    $form_state['outreachList'] = $outreachList;
    if (empty($outreachList)) {
        drupal_set_message("You don't have any outreaches to assign this to.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
        return;
    }
    $form['fields']['OID-header'] = array('#markup' => '<tr><td>');
    $form['fields']['OID'] = array('#prefix' => '<div id="div_OID_wrapper">', '#type' => 'select', '#title' => t('Outreach Event to be Associated With'), '#default_value' => $media['OID'], '#validated' => true, '#options' => $form_state["outreachList"], '#chosen' => true, '#suffix' => '</div>');
    $form['fields']['OID-footer'] = array('#markup' => '</td></tr>');
    $form['fields']['remove'] = array('#prefix' => '<tr><td>', '#type' => 'submit', '#value' => t('Delete Picture'), '#limit_validation_errors' => array(), '#submit' => array("removeMediaFromForm"), '#attributes' => array('onclick' => 'if(!confirm("Are you sure you want to delete this file?")){return false;}'), '#suffix' => '</td>');
    $form['fields']['submit'] = array('#prefix' => '<td style="text-align:right">', '#type' => 'submit', '#value' => t('Submit'), '#suffix' => '</td></tr>');
    $form['tableFooter'] = array('#markup' => '</table>');
    return $form;
}
Пример #5
0
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;
}
Пример #6
0
function viewEventsForTeam()
{
    global $user;
    $params = drupal_get_query_parameters();
    if (dbGetTeamsForUser($user->uid) == NULL) {
        drupal_set_message("You don't have a team assigned.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
        return;
    }
    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);
    $markup = '<div style="width:50%;align-text:right;"><h2>Outreaches You Have <b>Signed Up</b> For</h2></div>';
    $markup .= '<table>';
    $markup .= '<tr>';
    $markup .= "<th>Name</th>";
    $markup .= "<th>Description</th>";
    $markup .= "<th>Hours</th>";
    $markup .= "</tr>";
    foreach ($outreaches as $outreach) {
        $markup .= "<tr>";
        $markup .= "<td>" . '<b><a href="?q=viewOutreach&OID=' . $outreach['OID'] . '">' . chopString($outreach["name"], 15) . '</a>' . "<b></td>";
        $markup .= "<td>" . chopString($outreach["description"], 15) . "</td>";
        $markup .= "<td>" . dbGetHoursForUserFromOutreach($UID, $outreach['OID']) . "</tr>";
        $markup .= "</tr>";
    }
    $markup .= "</table></div>";
    $retArray = array();
    $retArray['#markup'] = $markup;
    return $retArray;
}
Пример #7
0
function viewOwnedOutreaches()
{
    global $user;
    if (dbGetTeamsForUser($user->uid) == NULL) {
        drupal_set_message("You don't have a team assigned.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
        return;
    }
    $UID = $user->uid;
    $ownedOutreaches = dbGetOwnedOutreachForUser($UID);
    // get the owned outreaches for a user
    $markup = '<div align = "right"><a href="?q=outreachesSignedUpFor&UID=' . $UID . '"><button>View Outreaches You Have Signed Up For</button></a></div>';
    $markup .= '<div style="right" . width:30%;"><h2>Outreaches You <b>Own</b></h2>';
    // begin table
    $markup .= '<table>';
    $markup .= '<tr>';
    $markup .= "<th>Name</th>";
    $markup .= "<th>Description</th>";
    $markup .= "<th>Hours</th>";
    $markup .= "</tr>";
    foreach ($ownedOutreaches as $ownedOutreach) {
        $markup .= "<tr>";
        $markup .= "<td>" . '<b><a href="?q=viewOutreach&OID=' . $ownedOutreach['OID'] . '">' . chopString($ownedOutreach["name"], 15) . '</a>' . "<b></td>";
        $markup .= "<td>" . chopString($ownedOutreach["description"], 15) . "</td>";
        $markup .= "<td>" . dbGetHoursForUserFromOutreach($UID, $ownedOutreach['OID']) . "</tr>";
        $markup .= "</tr>";
    }
    $markup .= "</table></div>";
    $retArray = array();
    $retArray['#markup'] = $markup;
    return $retArray;
}
Пример #8
0
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');
    }
}
Пример #9
0
function dbApplyForTeam($application)
{
    if (in_array($application['TID'], dbGetTeamsForUser($application['UID']))) {
        printErrorMsg('You are already on this team!');
        return false;
    }
    if (in_array($application['TID'], dbGetTeamsAppliedFor($application['UID']))) {
        printErrorMsg('You have already applied for this team!');
        return false;
    }
    return dbGenericInsert($application, 'usersVsTeams');
}
Пример #10
0
function teamSummary($form, &$form_state)
{
    global $user;
    $UID = $user->uid;
    $team = getCurrentTeam();
    $teams = dbGetTeamsForUser($UID);
    $form = array();
    if (isset($params["UID"])) {
        $UID = $params["UID"];
    } else {
        $UID = $user->uid;
    }
    if (isset($params['TID'])) {
        $TID = $params['TID'];
        $team = dbGetTeam($TID);
        $teamNumber = $team['number'];
    } else {
        $team = getCurrentTeam();
        $TID = $team['TID'];
        $team = dbGetTeam($TID);
        $teamNumber = $team['number'];
    }
    // if team is not empty
    if (!empty($teams)) {
        $TID = $team['TID'];
        if (count($teams) != 1) {
            // if user has multiple teams then able to change team
            $multiple = true;
            $choices = array();
        } else {
            // if user has one team then display team number
            $multiple = false;
        }
        foreach ($teams as $userTeam) {
            $choices[$userTeam['TID']] = $userTeam['number'];
        }
        $markup = '<table id="teamPageSummary" style="margin:112px 0px 0px 0px; padding:0px"><tr style="text-align:center"><td ';
        if (!$multiple) {
            $markup .= 'colspan="2" style="text-align:center;';
        } else {
            $markup .= 'style="text-align:right;';
        }
        $markup .= ' width:50%; padding:0px"><h2>' . $team['type'] . ' ';
        $form['fields']['header'] = array('#markup' => $markup);
        if ($multiple) {
            $form['fields']['team'] = array('#prefix' => '</h2></td><td style="width:50%;padding:0px">', '#type' => 'select', '#default_value' => $TID, '#options' => $choices, '#chosen' => true, '#attributes' => array('onChange' => 'document.getElementById("teamsummary").submit();'), '#suffix' => '</td></tr>');
        } else {
            $form['fields']['team'] = array('#markup' => $team['number'] . '</h2></td></tr>');
        }
        if (!empty($team['FID'])) {
            $FID = $team['FID'];
            $file = file_load($FID);
            $uri = $file->uri;
            $variables = array('style_name' => 'profile', 'path' => $uri, 'width' => '150', 'height' => '150');
            $image = theme_image_style($variables);
            $form['fields']['FID'] = array('#prefix' => '<tr><td colspan="2" style="text-align:center">', '#type' => 'item', '#markup' => $image, '#suffix' => '</td></tr>');
        } else {
            // if team does not have a picture, then displays default pic
            $form['fields']['FID'] = array('#prefix' => '<tr><td colspan="2" style="text-align:center">', '#markup' => '<img src="/images/defaultPics/team.png" style="max-width:200px; width:auto; height:auto; padding: 15px 0px 15px 0px">', '#suffix' => '</td></tr>');
        }
        $form['fields']['markupOne'] = array('#markup' => '<tr><td style="text-align:left"><a href="?q=viewTeam&TID=' . $TID . '"><div class="help tooltip4"><button type="button">Team Info</button><span id="helptext"; class="helptext tooltiptext4">Click here to view/edit your team info or to enter old team hours.</span></div></a></td>');
        if (hasPermissionForTeam('manageOutreachTags', $TID)) {
            $form['fields']['markupTwo'] = array('#markup' => '<td colspan="2" style="text-align:right"><a href="?q=teamOutreachSettings"><div class="help tooltip3"><button type="button">Settings</button><span id="helptext"; class="helptext tooltiptext3">If you have permission, click here to manage your teams outreach tags and outreach visibilities.</span></div></a></td></tr></table>');
        } else {
            $form['fields']['markupTwo'] = array('#markup' => '<td colspan="2" style="text-align:right"><div class="help tooltip3"><button type="button" disabled>Settings</button><span id="helptext"; class="helptext tooltiptext3">If you have permission, click here to manage your teams outreach tags and outreach visibilities.</span></div></td></tr></table>');
        }
        if ($multiple) {
            $form['fields']['submit'] = array('#type' => 'submit', '#value' => 'Update', '#attributes' => array('style' => array('display: none;')));
        }
    }
    return $form;
}
Пример #11
0
function manageUserTeams()
{
    global $user;
    $UID = $user->uid;
    $markup = '<table><tr><td><h1>Manage My Teams</h1></td><td style="text-align:right">';
    $markup .= '<a href="?q=teamForm&destination=' . current_path() . '"><button>Create Team</button></a>';
    $markup .= '<a href="?q=applyForTeamForm&url=manageUserTeams"><button>Apply to Join Team</button></a></td></tr></table>';
    $currentTeams = dbGetTeamsForUser($UID);
    $pendingTeams = dbGetPendingTeams($UID);
    $unapprovedTeams = dbGetUnapprovedTeamsForUser($UID);
    foreach ($pendingTeams as &$pendingTeam) {
        $pendingTeam['isPending'] = true;
        $pendingTeam['name'] = "<i>{$pendingTeam['name']}</i>";
        $pendingTeam['number'] = "<i>{$pendingTeam['number']}</i>";
    }
    foreach ($unapprovedTeams as &$unapprovedTeam) {
        $unapprovedTeam['isUnapproved'] = true;
        $unapprovedTeam['name'] = "<i>{$unapprovedTeam['name']}</i>";
        $unapprovedTeam['number'] = "<i>{$unapprovedTeam['number']}</i>";
    }
    $teams = array_merge($currentTeams, $pendingTeams, $unapprovedTeams);
    if (empty($teams)) {
        $markup .= '<table class="infoTable">';
        $markup .= '<th></th><tr><td style="text-align:center">';
        $markup .= "You don't have any teams yet! Click the buttons above to create or join one.</td></tr></table>";
    } else {
        $markup .= '<table class="infoTable">';
        $markup .= '<th>Team Name</th>';
        $markup .= '<th>Team Number</th>';
        $markup .= '<th>CROMA Role</th>';
        $markup .= '<th></th>';
        foreach ($teams as $team) {
            if (isset($team['isUnapproved'])) {
                $role = "<i>Team awaiting approval</i>";
            } else {
                if (isset($team['isPending'])) {
                    $role = "<i>Application Pending</i>";
                    $isPending = true;
                } else {
                    // beautify the names of the roles
                    $role = dbGetRoleForTeam($UID, $team['TID']);
                    if (empty($role)) {
                        $role = "Member";
                    }
                    $isPending = false;
                }
            }
            $markup .= '<tr>';
            $markup .= '<td><a href="?q=viewTeam&TID=' . $team['TID'] . '">' . $team['name'] . '</a></td>';
            $markup .= '<td>' . $team['number'] . '</td>';
            $markup .= '<td>' . $role . '</td>';
            if ($role == 'Team Owner') {
                $markup .= '<td><a href="?q=teamForm&TID=' . $team['TID'] . '"><button><img class="editIcon" src="/images/icons/editWhite.png"></button></a>';
                $markup .= '<a href="?q=deleteTeamPage&TID=' . $team['TID'] . '"><button><img class="trashIcon" src="/images/icons/trashWhite.png"></button></a></td>';
            } else {
                if (isset($team['isPending'])) {
                    $markup .= '<td><a href="?q=rescindTeamApplication/' . $team['TID'] . '">';
                    $markup .= '<button>Withdraw Application</button></a>';
                } else {
                    if (isset($team['isUnapproved'])) {
                        $markup .= '<td><a href="?q=teamForm&TID=' . $team['TID'] . '"><button><img class="editIcon" src="/images/icons/editWhite.png"></button></a></td>';
                    } else {
                        $markup .= "<td><a href=\"?q=leaveTeam/{$team['TID']}\"><button>Leave Team</button></a></td>";
                    }
                }
            }
            $markup .= '</tr>';
        }
    }
    $markup .= '</table>';
    $array['#markup'] = $markup;
    return $array;
}
Пример #12
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;
}
Пример #13
0
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);
}
Пример #14
0
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;
}
Пример #15
0
function viewUser()
{
    global $user;
    $currentUID = $user->uid;
    $params = drupal_get_query_parameters();
    // checks that there is a user
    if (isset($params["UID"])) {
        $UID = $params["UID"];
    } else {
        drupal_set_message('No user specified.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    // checks that the user being viewed shares a team with the user currently viewing
    if (!($UID == $currentUID || isOnMyTeam($UID))) {
        drupal_set_message("You can't view this profile.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    $profile = dbGetUserProfile($UID);
    $canEdit = false;
    $sharedTeams = getSharedTeams($UID);
    if (!empty($sharedTeams)) {
        foreach ($sharedTeams as $TID) {
            if (hasPermissionForTeam('manageTeamMembers', $TID)) {
                $canEdit = true;
                break;
            }
        }
    }
    if ($user->uid == $UID) {
        $canEdit = true;
    }
    $markup = '';
    // create name header and table
    $markup .= '<div style="float:left; width:28%">';
    $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>';
    $markup .= $profile['firstName'] . ' ' . $profile['lastName'];
    $markup .= '</b></h2></div></td></tr></table>';
    $markup .= '<table id="photoAndEdit"><tr><td style="padding:0px;">';
    // if the profile belongs to the currently logged in user, the picture should be editable
    if ($canEdit) {
        $markup .= '<div align="right">';
        $markup .= '<a href= "?q=editThumbnail';
        $markup .= '&UID=' . $UID . '&FID=' . $profile['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;">';
    // if user has picture, display picture
    if (!empty($profile['FID'])) {
        $url = generateURL($profile['FID']);
        $markup .= '<div align="center"><img src="' . $url . '" style="max-width:150px; width:auto; height:auto; padding: 5px 0px 5px 0px">';
        // default picture if user does not have a picture
    } else {
        $markup .= '<div align="center"><img src="/images/defaultPics/user.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 user has permissions or owns the profile, edit info
    if ($canEdit) {
        $markup .= '<a href= "?q=profileForm';
        $markup .= '&UID=' . $UID . '">';
        $markup .= '<span title="Edit Profile"><button type="button"><img class="editIcon" src="/images/icons/editWhite.png"></button></a></span>';
    }
    // if the user wants to change their own password - no one else can access this feature on someone's profile
    if ($UID == $currentUID) {
        $markup .= '<a href="?q=user/' . $UID . '/edit"';
        $markup .= '<span title="Change Password"><button type="button"><img class="keyIcon" src="/images/icons/keyWhite.png"></button></a></span>';
    }
    // users are only allowed to delete their own profiles
    if ($UID == $currentUID) {
        $markup .= '<span title="Delete User"><a href="?q=deleteUser&UID=' . $UID . '"><button type="button"><img class="trashIcon" src="/images/icons/trashWhite.png"></button></a></span>';
    }
    $markup .= '</div>';
    // begin displaying info portion
    $markup .= '<div style="width:70%; float:right; padding-left:10px">';
    $markup .= '<table id="miniViewTeam" style="margin:16px 0px 0px 0px"><tr><td><b>Role: </b>' . ucfirst($profile['type']) . '</td>';
    $markup .= '<td><b>Position: </b> ' . strip_tags($profile['position']) . '</td>';
    if ($profile['grade'] == '0') {
        $markup .= '<tr><td><b>Grade: </b> N/A</td>';
    } else {
        $markup .= '<tr><td><b>Grade: </b> ' . $profile['grade'] . '</td>';
    }
    $markup .= '<td><b>Gender: </b> ' . $profile['gender'] . '</td></tr>';
    $email = dbGetUserPrimaryEmail($UID);
    $markup .= '<tr><td><b>Email: </b> <a href="mailto:' . $email . '" target="_blank">';
    $markup .= $email . '</a>';
    $secondaryEmail = dbGetSecondaryEmailForUser($UID);
    if ($secondaryEmail) {
        $markup .= "<br>(" . '<a href="mailto:' . $secondaryEmail . '" target="_blank">' . $secondaryEmail . '</a>' . ')';
    }
    $phoneNumber = dbFormatPhoneNumber($profile['phone']);
    $markup .= '</td><td><b>Phone: </b> ' . $phoneNumber . '</td></tr>';
    // displays teams the user is on
    $teamNumbers = '';
    $first = true;
    // used to put commas in the right places
    $teams = dbGetTeamsForUser($UID);
    foreach ($teams as $team) {
        if ($first) {
            $teamNumbers = '<a href="?q=viewTeam&TID=' . $team['TID'] . '">' . $team['number'] . '</a>';
            $first = false;
        } else {
            $teamNumbers = $teamNumbers . ', <a href="?q=viewTeam&TID=' . $team['TID'] . '">' . $team['number'] . '</a>';
        }
    }
    if (count($teams) > 1) {
        $teamLabel = 'Teams';
    } else {
        $teamLabel = 'Team';
    }
    if ($UID == $currentUID) {
        $markup .= '<tr><td><a href="?q=manageUserTeams"><b>' . $teamLabel . ':</b></a> ' . $teamNumbers . '</td>';
    } else {
        $markup .= '<tr><td><b>' . $teamLabel . ':</b> ' . $teamNumbers . '</td>';
    }
    // displays user hours
    $numberOfHours = dbGetUserHours($UID);
    if ($numberOfHours != 0) {
        $markup .= "<td><a href=\"?q=viewHours&UID={$UID}\"><b>Number of Hours:</b></a> {$numberOfHours}</td>";
    } else {
        $markup .= "<td><b>Number of Hours:</b> No Hours!</td>";
    }
    // displays user bio
    $markup .= '</table><table id="miniViewTeam" style="margin:16px 0px 0px 0px"><tr><td><b>Bio: </b>';
    $markup .= wordwrap($profile['bio'], 92, "<br />\n") . '</td></tr>';
    $markup .= '</table></div>';
    return array("#markup" => $markup);
}
Пример #16
0
function searchFormSidebar($form, &$form_state)
{
    global $user;
    $params = drupal_get_query_parameters();
    $form_state['TID'] = getCurrentTeam()['TID'];
    if (isset($_SESSION['showAdvanced'])) {
        $form_state['showAdvanced'] = $_SESSION['showAdvanced'];
    } else {
        $form_state['showAdvanced'] = $_SESSION['showAdvanced'] = true;
    }
    // where the current instance of the form is located (e.g. allTeamOutreach)
    $form['fields']['source'] = array('#type' => 'hidden', '#value' => isset($params['source']) ? $params['source'] : '');
    $form['fields']['markupOne'] = array('#markup' => '<div id="searchFormOnSidebar" style="padding:24px 0px 0px 0px"><h2>Search All Outreach</h2>');
    $form['fields']['nameHeader'] = array('#markup' => '<table><tr><td style="padding:0px 5px 0px 0px"><b>Name:</b></td><td style="padding:0px">');
    $form['fields']['name'] = array('#type' => 'textfield', '#default_value' => fillFromSession('name', array()));
    $form['fields']['nameFooter'] = array('#markup' => '</td></tr></table>');
    $form['fields']['statusHeader'] = array();
    $form['fields']['status'] = array('#type' => 'checkboxes', '#prefix' => '<table><tr><td style="vertical-align:top">', '#title' => '<b>Status:</b>', '#options' => array('isIdea' => 'Idea', 'isOutreach' => 'Outreach', 'doingWriteUp' => 'Write-Up', 'locked' => 'Locked'), '#default_value' => fillFromSession('status', array()), '#suffix' => '</td>');
    $teams = dbGetTeamsForUser($user->uid);
    // if user is on multiple teams, allow him to select teams for searching
    if (!empty($teams)) {
        $teamOptions = array();
        foreach ($teams as $team) {
            $teamOptions[$team['TID']] = $team['number'];
        }
        $defaultTeam = array(getCurrentTeam()['TID']);
        $form['fields']['teams'] = array('#prefix' => '<td style="vertical-align:top">', '#type' => 'checkboxes', '#title' => '<b>Team:</b>', '#options' => $teamOptions, '#default_value' => fillFromSession('teams', $defaultTeam), '#suffix' => '</td></tr></table>');
    }
    $form['fields']['typeBttn'] = array('#type' => 'submit', '#submit' => array('toggleShowTypeSection'), '#value' => 'Type', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'showTypeSection_callback', 'wrapper' => 'type-div'));
    $form['fields']['type'] = array('#prefix' => '<div id="type-div">', '#suffix' => '</div>');
    // merge various data from all the teams of the given user
    $userTIDs = dbGetTIDsforUser($user->uid);
    $tags = array();
    $allUsers = array();
    foreach ($userTIDs as $TID) {
        $teamTags = dbGetOutreachTagsForTeam($TID);
        $users = dbGetUsersListFromTeam($TID);
        if (!empty($teamTags)) {
            $tags = array_replace($tags, $teamTags);
        }
        if (!empty($users)) {
            $allUsers = array_replace($users, $allUsers);
        }
    }
    // toggle display of the "Type" section
    if (isset($_SESSION['showTypeSection']) && $_SESSION['showTypeSection']) {
        if (!empty($tags)) {
            $form['fields']['type']['tags'] = array('#prefix' => '<tr><td colspan="3" style="text-align:center">', '#type' => 'select', '#title' => t('Tags:'), '#attributes' => array('style' => 'width:200px'), '#chosen' => true, '#multiple' => true, '#options' => $tags, '#default_value' => fillFromSession('tags', array()), '#suffix' => '</td>');
        }
        $form['fields']['type']['cancelled'] = array('#type' => 'checkbox', '#title' => t("Cancelled"), '#default_value' => fillFromSession('cancelled'));
    }
    $form['fields']['peopleBttn'] = array('#type' => 'submit', '#submit' => array('toggleShowPeopleSection'), '#value' => 'People', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'showPeopleSection_callback', 'wrapper' => 'people-div'));
    $form['fields']['people'] = array('#prefix' => '<div id="people-div">', '#suffix' => '</div>');
    if (isset($_SESSION['showPeopleSection']) && $_SESSION['showPeopleSection']) {
        $form['fields']['people']['ownerLabel'] = array('#prefix' => '<table style="margin:0px"><tr><td style="padding:0px">', '#markup' => '<b>Owner:</b>', '#suffix' => '</td>');
        $form['fields']['people']['owner'] = array('#prefix' => '<td style="padding:0px">', '#type' => 'select', '#options' => $allUsers, '#default_value' => fillFromSession('owner'), '#attributes' => array('style' => 'width:200px'), '#chosen' => true, '#multiple' => true, '#suffix' => '</td></tr></table>');
        $form['fields']['people']['signedUpLabel'] = array('#prefix' => '<table style="margin:0px"><tr><td style="padding:0px">', '#markup' => '<b>Signed Up:</b>', '#suffix' => '</td>');
        $form['fields']['people']['signedUp'] = array('#prefix' => '<td style="padding:0px">', '#type' => 'select', '#options' => $allUsers, '#default_value' => fillFromSession('signedUp'), '#attributes' => array('style' => 'width:200px'), '#chosen' => true, '#multiple' => true, '#suffix' => '</td></tr></table>');
        $form['fields']['people']['co_organizationLabel'] = array('#prefix' => '<table style="margin:0px"><tr><td style="padding:0px">', '#markup' => '<b>Organization:</b>', '#suffix' => '</td>');
        $form['fields']['people']['co_organization'] = array('#prefix' => '<td style="padding:0px">', '#type' => 'textfield', '#default_value' => fillFromSession('co_organization'), '#size' => 20, '#suffix' => '</td></tr></table>');
    }
    $form['fields']['locationBttn'] = array('#type' => 'submit', '#submit' => array('toggleShowLocationSection'), '#value' => 'Location', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'showLocationSection_callback', 'wrapper' => 'location-div'));
    $form['fields']['location'] = array('#prefix' => '<div id="location-div">', '#suffix' => '</div>');
    if (isset($_SESSION['showLocationSection']) && $_SESSION['showLocationSection']) {
        $form['fields']['location']['cityLabel'] = array('#prefix' => '<table style="margin:0px"><tr><td style="padding:0px">', '#markup' => '<b>City:</b>', '#suffix' => '</td>');
        $form['fields']['location']['city'] = array('#prefix' => '<td style="padding:0px">', '#type' => 'textfield', '#size' => 25, '#default_value' => fillFromSession('city'), '#suffix' => '</td></tr></table>');
        $form['fields']['location']['stateLabel'] = array('#prefix' => '<table style="margin:0px"><tr><td style="padding:0px">', '#markup' => '<b>State:</b>', '#suffix' => '</td>');
        $form['fields']['location']['state'] = array('#prefix' => '<td style="padding:0px">', '#type' => 'select', '#options' => states_list(), '#default_value' => fillFromSession('state'), '#chosen' => true, '#suffix' => '</td></tr></table>');
        $form['fields']['location']['countryLabel'] = array('#prefix' => '<table style="margin:0px"><tr><td style="padding:0px">', '#markup' => '<b>Country:</b>', '#suffix' => '</td>');
        $form['fields']['location']['country'] = array('#prefix' => '<td style="padding:0px">', '#type' => 'select', '#options' => countries_list(), '#default_value' => fillFromSession('country'), '#attributes' => array('width' => '200px'), '#chosen' => true, '#suffix' => '</td></tr></table>');
    }
    // if user would like to see advanced fields, show them
    //  if (isset($form_state['showAdvanced']) && $form_state['showAdvanced']){
    //  if (isset($_SESSION['showAdvanced']) && $_SESSION['showAdvanced']){
    $form['fields']['timeBttn'] = array('#type' => 'submit', '#submit' => array('toggleShowTimeSection'), '#value' => 'Time', '#limit_validation_errors' => array(), '#ajax' => array('callback' => 'showTimeSection_callback', 'wrapper' => 'time-div'));
    $form['fields']['time'] = array('#prefix' => '<div id="time-div">', '#suffix' => '</div>');
    if (isset($_SESSION['showTimeSection']) && $_SESSION['showTimeSection']) {
        $form['fields']['time']['timeConstraints'] = array('#markup' => '<table style="table-layout:fixed"><tr></tr>');
        $form['fields']['time']['within5Years'] = array('#prefix' => '<tr style="white-space:nowrap"><td style="padding:0px;display:inline-block">Within 5 Years</td><td style="padding:5px;display:inline-block">', '#type' => 'checkbox', '#default_value' => fillFromSession('within5Years'), '#suffix' => '</td></tr>');
        $form['fields']['time']['dateSelection3'] = array('#markup' => '<tr style="white-space:nowrap"><td style="padding:5px; display:inline-block">Within</td><td style="padding:5px; display:inline-block">');
        // search outreaches within some time of specified date
        $distanceOptions = array('1 day' => '1 day', '1 week' => '1 week', '1 month' => '1 month', '1 year' => '1 year');
        $form['fields']['time']['dateDistance'] = array('#type' => 'select', '#options' => $distanceOptions, '#default_value' => fillFromSession('dateDistance'), '#chosen' => true);
        $form['fields']['time']['dateSelection4'] = array('#markup' => '</td><td style="padding:5px; display:inline-block">of</td><td style="padding:5px;display:inline-block; width:100px">');
        // specify date of outreach for use with dateDistance
        $form['fields']['time']['date'] = array('#type' => 'date_popup', '#date_format' => SHORT_TIME_FORMAT, '#date_label_position' => 'within', '#date_increment' => 1, '#date_year_range' => '-20:+20', '#datepicker_options' => array(), '#default_value' => isset($_SESSION['searchParams']['date']['center']) ? $_SESSION['searchParams']['date']['center'] : '');
        $form['fields']['time']['dateSelection5'] = array('#markup' => '</td></tr><tr style="white-space:nowrap"><td style="padding:0px; display:inline-block">Events In Year</td><td style="display:inline-block">');
        $years = array('select' => '-Select-');
        for ($i = date("Y"); $i >= 1992; $i--) {
            $years[(string) $i] = $i;
        }
        $form['fields']['time']['year'] = array('#type' => 'select', '#options' => $years, '#chosen' => true, '#default_value' => fillFromSession('year'));
        $form['fields']['time']['dateSelection6'] = array('#markup' => '</td></tr></table>');
    }
    $form['fields']['submit'] = array('#type' => 'submit', '#value' => 'Search');
    return $form;
}
Пример #17
0
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;
}
Пример #18
0
function viewMedia()
{
    global $user;
    if (dbGetTeamsForUser($user->uid) == false) {
        drupal_set_message("You don't have a team assigned.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    $params = drupal_get_query_parameters();
    if (!isset($params['OID'])) {
        drupal_set_message('No outreach selected.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    $OID = $params['OID'];
    $markup = '';
    $outreachName = dbGetOutreachName($OID);
    // create header, table
    $markup .= "<table><tr><td><h1>Media for \"{$outreachName}\" </h1></td>";
    $markup .= '<td style="text-align:right">';
    // upload media button
    $markup .= "<a href=\"?q=uploadMedia&OID={$OID}\"><button>Upload Media</button></a></td></tr></table>";
    $media = dbGetMediaForOutreach($OID);
    // create table
    $markup .= '<table class="infoTable"><tr><th>Image</th><th>Name</th><th><Info</th><th>Uploaded By</th><th></th><th></th>';
    // if media for outreach is not empty
    if (!empty($media)) {
        // displays all media for the outreach
        foreach ($media as $m) {
            $url = generateURL($m['FID']);
            $MID = $m['MID'];
            $UIDofMID = dbGetUserForMedia($MID);
            $profile = dbGetUserProfile($UIDofMID);
            $markup .= '<tr><td><a href=' . $url . '><img src="' . $url . '" width="150px" height="150px"></a></td>';
            $markup .= '<td>' . $m['title'] . '</td>';
            $markup .= '<td>' . wordwrap(chopString($m['description'], 30), 15, "<br>\n", TRUE) . '</td>';
            $markup .= "<td>" . $profile['firstName'] . ' ' . $profile['lastName'] . "</td>";
            $markup .= "<td><a href=\"?q=mediaForm&MID={$MID}&OID={$OID}\"><button><img class=\"editIcon\" src=\"/images/icons/editThumbnailWhite.png\"></button></a></td>";
            // allow user to delete media if he/she was the one to upload it
            if (isMyMedia($MID)) {
                $markup .= "<td><a href=\"?q=removeMedia/{$MID}\"><button><img class=\"trashIcon\" src=\"/images/icons/trashWhite.png\"></button></a></td>";
            } else {
                $markup .= "<td></td>";
            }
        }
        $markup .= '</tr></table>';
    } else {
        // if there is no media assigned to the outreach
        $markup .= "<tr>";
        $markup .= '<td style="text-align:center" colspan="10"><em>[None]</em></td>';
        $markup .= "</tr>";
    }
    $markup .= "</table>";
    return array('#markup' => $markup);
}