Ejemplo n.º 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;
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
0
function switchTeamTab()
{
    global $user;
    $currentTeam = getCurrentTeam();
    $TID = $currentTeam['TID'];
    $markup = '<br><div style="color:white;"><a href="?q=switchTeam"><button id="switchTeamBttn"><span title="Click this button to switch the team you are operating under">';
    $markup .= dbGetTeamNumber($TID);
    $markup .= '</span></button></a></div>';
    return array('#markup' => $markup);
}
Ejemplo n.º 4
0
function hoursAwaitingApproval()
{
    $currentTeam = getCurrentTeam();
    if ($currentTeam == false) {
        drupal_set_message("You don't have a team assigned.", 'error');
        return;
    }
    $TID = $currentTeam['TID'];
    $teamNumber = $currentTeam['number'];
    // create header
    $markup = '';
    $markup .= '<h2>Hours Awaiting Approval</h2>';
    $markup .= '<table class="infoTable"><tr>';
    $markup .= '<th colspan="2">Outreach</th>';
    $markup .= '<th colspan="2">User</th>';
    $markup .= '<th colspan="2">Hours</th>';
    $markup .= '<th colspan="2"></th>';
    $markup .= "</tr>";
    $filterParams = array('TID' => $TID, 'isApproved' => false);
    $hours = dbGetHours($filterParams);
    // if the team has unapproved hours
    if (!empty($hours)) {
        foreach ($hours as $hour) {
            $OID = $hour['OID'];
            $outreach = dbGetOutreach($OID);
            $UID = $hour["UID"];
            $numHours = $hour['numberOfHours'];
            $HID = $hour['HID'];
            $markup .= "<tr>";
            $markup .= '<td colspan="2">' . '<a href="?q=viewOutreach&OID=' . $outreach['OID'] . '">' . chopString($outreach["name"], 20) . '</a>' . '</td>';
            $markup .= '<td colspan="2">' . dbGetUserName($UID) . ' </td>';
            $markup .= '<td colspan="2"><a href="?q=logHours&HID=' . $HID . '">' . $numHours . '</a></td>';
            // approve or reject buttons
            if (canApproveHours($HID)) {
                $markup .= "<td colspan=\"2\"><a href=\"?q=approveHours/{$hour['HID']}\"><button>Approve</button></a>";
                $markup .= "<a href=\"?q=deleteHours/{$HID}\">";
                $markup .= '<button><img class="trashIcon" src="/images/icons/trashWhite.png"></button></a></td>';
            } else {
                $markup .= '<td></td><td></td>';
            }
            $markup .= "</tr>";
        }
    } else {
        // display none if the team has no hours waiting approval
        $markup .= "<tr>";
        $markup .= '<td style="text-align:center" colspan="8"><em>[None]</em></td>';
        $markup .= "</tr>";
    }
    $markup .= "</table>";
    $retArray = array();
    $retArray['#markup'] = $markup;
    return $retArray;
}
Ejemplo n.º 5
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;
}
Ejemplo n.º 6
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;
}
Ejemplo n.º 7
0
function viewUsersAwaitingApproval()
{
    global $user;
    $params = drupal_get_query_parameters();
    if (isset($params['TID'])) {
        $TID = $params['TID'];
        $teamNumber = dbGetTeamNumber($TID);
    } else {
        $team = getCurrentTeam();
        $TID = $team['TID'];
        $teamNumber = $team['number'];
    }
    if (teamIsIneligible($TID)) {
        drupal_set_message('Your team does not have permission to access this page.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    $markup = '<table><tr><td colspan="3">';
    $markup .= "<h1>Users Awaiting Approval for {$teamNumber}</h1></td>";
    $markup .= '<td colspan="3" style="text-align:right">';
    $markup .= '<a href= "?q=showUsersForTeam">';
    $markup .= '<button type="button">View All Users</button></a></td></tr><table>';
    $markup .= '<table class="infoTable"><th>Name</th><th>Email</th><th>Message</th><th></th></tr>';
    $users = dbGetUsersAwaitingApproval($TID);
    if (!empty($users)) {
        // loop through users, displaying approve and reject buttons for each
        foreach ($users as $person) {
            $markup .= "<tr><td>{$person['firstName']} {$person['lastName']}</td>";
            $markup .= '<td>' . $person['userEmail'] . '</td>';
            $markup .= '<td>' . $person['userMessage'] . '</td>';
            $markup .= '<td><a href="?q=approveUser/' . "{$person['UID']}/{$TID}" . '">';
            $markup .= '<button>Approve</button></a>';
            $markup .= '<a href="?q=rejectUser/' . "{$person['UID']}/{$TID}" . '">';
            $markup .= '<button>Reject</button></a></td></tr>';
        }
    } else {
        $markup .= "<tr>";
        $markup .= '<td style="text-align:center" colspan="10"><em>[None]</em></td>';
        $markup .= "</tr>";
    }
    $markup .= '</table>';
    return array('#markup' => $markup);
}
Ejemplo n.º 8
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;
}
Ejemplo n.º 9
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;
}
Ejemplo n.º 10
0
function widgetGenerator()
{
    $markup = '';
    $teamNumber = getCurrentTeam()['number'];
    $markup .= '<table><tr><td colspan="2" style="width:50%"><div class="help tooltip2"><h2>Create Widgets</h2><span id="helptext"; class="helptext tooltiptext2">Widgets provide information that teams can display on their own webpages.</span></div></td><td style="text-align:right">';
    // allow users to navigate to page to manage outreach visibilities (for outreach directory widget)
    $markup .= '<a href= "?q=outreachVisibilities">';
    $markup .= '<div class="help tooltip1"><button type="button">Outreach Visibilities</button><span id="helptext"; class="helptext tooltiptext1">Click here to manage your teams public and private outreaches.</span></div></a></td></tr></table>';
    $markup .= '<table><tr><th colspan="4"></th></tr><tr><td><h2>1</h2></td>';
    // show 'static statistics' widget; this is the image generated to have the correct numbers on it
    $markup .= '<td colspan="2"><table><tr><td colspan="3"><h4><b>Static Statistics</b></h4>This is the quick and simple way of displaying up-to-date data on your teams outreach. Just display the image at the URL below, and we will dynamically generate it to show your latest statistics.</td></tr>';
    $markup .= '<tr><td><b>Preview:</b><br><img src="http://croma.chapresearch.com' . PORT;
    $markup .= '/basicStatsImage.php?teamNumber=' . $teamNumber . '"></td>';
    $markup .= "<td><b>Your Custom HTML:</b><br>&lt;img src=\"http://croma.chapresearch.com" . PORT;
    $markup .= "/basicStatsImage.php?teamNumber={$teamNumber}\"&gt;</td></tr></table></td>";
    $markup .= '</tr><tr style="border-top:1pt solid black;"><td><h2>2</h2></td>';
    // show 'fancy statistics' widget; this is the version that uses an iframe to having scrolling numbers
    $markup .= "<td colspan=\"2\"><table><tr><td colspan=\"3\"><h4><b>Fancy Statistics Widget</b></h4>Just paste in the HTML below, and your statistics will count up automatically. However, note that for a small percentage of users this widget may not work out of the box (depending on website configurations). The \"basic\" back-up option is above in case you don't feel like fiddling with it.</td></tr>";
    $markup .= '<tr><td style="width:400px"><b>Preview:</b><br><iframe style="overflow:hidden; border:none; width:400px; height:200px" scrolling="no" ';
    $markup .= 'src="http://croma.chapresearch.com' . PORT . '/fancyScrollingStats.html?teamNumber=' . $teamNumber . '"></iframe></td>';
    $markup .= "<td><b>Your Custom HTML:</b><br>&lt;iframe style=\"overflow:hidden; border:none; width: 400px; height: 200px\" scrolling=\"no\" src=\"http://croma.chapresearch.com" . PORT . "/fancyScrollingStats.html?teamNumber={$teamNumber}\"&gt;</iframe\\></td></tr></table></td>";
    $markup .= '</tr></table>';
    return array('#markup' => $markup);
}
Ejemplo n.º 11
0
function writeUpsAwaitingApproval()
{
    $currentTeam = getCurrentTeam();
    if ($currentTeam == false) {
        drupal_set_message("You don't have a team assigned.", 'error');
        return;
    }
    $TID = $currentTeam['TID'];
    $teamNumber = $currentTeam['number'];
    // create header
    $markup = '<h2>Write-Ups Awaiting Approval</h2>';
    $markup .= '<table class="infoTable"><tr><th colspan="3">Name</th>';
    $markup .= '<th colspan="2">Log Date</th>';
    $markup .= '<th colspan="2">Owner</th>';
    $markup .= '<th></th>';
    $markup .= "</tr>";
    // "true" indicates to only get write-ups that have been submitted
    $outreaches = dbGetWriteUpsForTeam($TID, true);
    // if the team has write-ups
    if (!empty($outreaches)) {
        $count = 0;
        foreach ($outreaches as $outreach) {
            $count++;
            $TID = $outreach['TID'];
            $team = dbGetTeam($outreach['TID']);
            $rawDate = $outreach['logDate'];
            $rawDate = dbDateSQL2PHP($rawDate);
            $logDate = date(TIME_FORMAT, $rawDate);
            $OID = $outreach['OID'];
            $owner = dbGetOutreachOwner($OID);
            $markup .= "<tr>";
            $markup .= '<td colspan="3">' . '<a href="?q=viewOutreach&OID=' . $outreach['OID'] . '">' . chopString($outreach["name"], 20) . '</a>' . '</td>';
            $markup .= '<td colspan="2">' . $logDate . '</td>';
            $markup .= '<td colspan="2">' . dbGetUserName($owner) . ' </td>';
            // button to view the write up
            if (hasPermissionForTeam('approveIdeas', $TID)) {
                $markup .= '<td><a href="?q=writeupform&approving&OID=' . $OID . '"><button>View</button></a></td>';
            } else {
                $markup .= '<td></td>';
            }
            $markup .= "</tr>";
        }
        // if the team doesn't have any write-ups
    } else {
        $markup .= "<tr>";
        $markup .= '<td style="text-align:center" colspan="8"><em>[None]</em></td>';
        $markup .= "</tr>";
    }
    $markup .= "</table>";
    $retArray = array();
    $retArray['#markup'] = $markup;
    return $retArray;
}
Ejemplo n.º 12
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;
}
Ejemplo n.º 13
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;
}
Ejemplo n.º 14
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;
}
Ejemplo n.º 15
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;
}
Ejemplo n.º 16
0
function reject($form, $form_state)
{
    global $user;
    $params = drupal_get_query_parameters();
    $TID = getCurrentTeam()['TID'];
    $OID = $params["OID"];
    $outreachData = dbGetOutreach($OID);
    $writeUpUpdate['status'] = "doingWriteUp";
    $writeUpUpdate['writeUpUID'] = null;
    $writeUpUpdate['isWriteUpSubmitted'] = 0;
    $result = dbUpdateOutreach($OID, $writeUpUpdate);
    $notification = array();
    $userName = dbGetUserName($user->uid);
    $outName = dbGetOutreachName($OID);
    $notification['dateCreated'] = dbDatePHP2SQL(time());
    $notification['dateTargeted'] = dbDatePHP2SQL(time());
    $notification['message'] = "{$userName} has rejected a write up for {$outName}.";
    $notification['bttnTitle'] = 'Redo Write Up';
    $notification['bttnLink'] = '?q=viewOutreach&OID=' . $OID;
    $notification['TID'] = $TID;
    $notification['UID'] = $outreachData['writeUpUID'];
    dbAddNotification($notification);
    drupal_set_message("Write Up Rejected.");
    drupal_goto('viewOutreach', array('query' => array('OID' => $OID)));
}
Ejemplo n.º 17
0
function viewOutreachEvent()
{
    global $user;
    $UID = $user->uid;
    $params = drupal_get_query_parameters();
    if (isset($params['OID']) && $params['OID'] > 0) {
        $OID = $params['OID'];
        $outreach = dbGetOutreach($OID);
        if ($outreach == false) {
            drupal_set_message('Invalid outreach event. Click <a href="?q=teamDashboard">here</a> to navigate back to events in Team Dashboard.', 'error');
            return;
        }
        $TID = $outreach['TID'];
        if (!isMyTeam($TID)) {
            drupal_set_message('You do not have permission to access this page.', 'error');
            return;
        }
        // if the outreach status is outreach and the event is over, then turn the status to write up
        if ($outreach['status'] == "isOutreach") {
            outreachToWriteUp($OID);
        }
        // determine if the user can physically sign up
        $canSignUp = !dbIsOutreachOver($OID) && ($outreach['status'] == 'isOutreach' || $outreach['status'] == 'doingWriteUp');
        $markup = '';
        $markup .= '<div style="float:left; width:38%">';
        $markup .= '<table style="margin:0px 0px 10px 0px;"><tr>';
        $markup .= '<td style="padding:0px 14px 10px 14px;"><div align="left"><h2 style="margin:0px 0px 7px 0px;"><b>';
        // display outreach name
        $markup .= "{$outreach['name']}";
        $markup .= '</b></h2></div></td></tr>';
        $markup .= '<tr><td>';
        $markup .= showOutreachStatusIcon($outreach['status']);
        // displays the icon for a public outreach
        $markup .= $outreach['isPublic'] ? '<span title="Public"><img class="eventPrivacyIcon" src="/images/icons/publicBlue.png"></span>' : '<span title="Private"><img class="eventPrivacyIcon" src="/images/icons/privateBlue.png"></span>';
        // displays the icon for a cancelled outreach
        $markup .= $outreach['cancelled'] ? '<span title="Event Cancelled"><img class="eventCancelledIcon" src="/images/icons/cancelledRed.png"' : '';
        $markup .= '</td></tr></table>';
        $markup .= '<table id="photoAndEdit"><tr><td style="padding:0px;">';
        // cannot edit photo if user doesn't have the correct permissions
        if (!isMyOutreach($OID) && !hasPermissionForTeam('editAnyOutreach', getCurrentTeam()['TID'])) {
            $markup .= '<div align="right">';
            $markup .= '<span title="Edit Photo"><button type="button" disabled><img class="editIcon" src="/images/icons/editThumbnailWhite.png"></button></span>';
            $markup .= '</div>';
        } else {
            // edit photo if user has permissions
            $markup .= '<div align="right">';
            $markup .= '<a href= "?q=editThumbnail';
            $markup .= '&OID=' . $OID . '&FID=' . $outreach['FID'] . '">';
            $markup .= '<span title="Edit Photo"><button type="button"><img class="editIcon" src="/images/icons/editThumbnailWhite.png"></button></a></span>';
            $markup .= '</div>';
        }
        $markup .= '</td></tr><tr><td style="padding:0px;">';
        // default picture for outreach
        if (!empty($outreach['FID'])) {
            $FID = dbGetOutreachThumbnail($OID);
            $url = generateURL($FID);
            $markup .= '<div align="center"><img src="' . $url . '" style="max-width:150px; width:auto; height:auto; padding: 5px 0px 5px 0px">';
        } else {
            $markup .= '<div align="center"><img src="/images/defaultPics/team.png" style="max-width:200px; width:auto; height:auto; padding: 15px 0px 15px 0px">';
        }
        $markup .= '</div></td></tr></table></div>';
        $markup .= '<div align="right">';
        // if the status is write-up, then allow a user to submit a write up
        if ($outreach['status'] == 'doingWriteUp' && !$outreach['isWriteUpSubmitted']) {
            $markup .= '<a href="?q=writeupform&OID=' . $outreach['OID'] . '"><button>Write Up</button></a>';
        } else {
            if ($outreach['isWriteUpSubmitted'] && hasPermissionForTeam('approveIdeas', $TID) && $outreach['status'] == 'doingWriteUp') {
                $markup .= '<a href="?q=writeupform&OID=' . $outreach['OID'] . '&approving"><button>Approve Write Up</button></a>';
            }
        }
        // if the status is idea, then allow a user with permissions to approve or reject the idea
        if ($outreach['status'] == 'isIdea' && hasPermissionForTeam('approveIdeas', $TID)) {
            $markup .= '<a href="?q=approveIdea/' . $outreach['OID'] . '/' . $TID . '"><button>Approve</button></a>';
            $markup .= '<a href="?q=rejectIdea/' . $outreach['OID'] . '/' . $TID . '"><button>Reject</button></a>';
        }
        // notifications button
        if (!isMyOutreach($OID) && !hasPermissionForTeam('editAnyOutreach', getCurrentTeam()['TID'])) {
            $markup .= '<button type="button" disabled>Notifications</button>';
        } else {
            $markup .= '<a href="?q=manageNotifications&OID=' . $outreach['OID'] . '"><button>Notifications</button></a>';
        }
        // manage sign-ups button
        if (!dbIsOutreachCancelled($OID)) {
            if (dbIsUserSignedUp($UID, $OID)) {
                if (dbIsOutreachOver($OID)) {
                    $markup .= '<a href="?q=signUp&OID=' . $OID . '"><div class="help tooltip4"><button type="button" disabled>Edit Sign Up</button><span id="helptext"; class="helptext tooltiptext4">You cannot edit your sign up for this event because it is already over.</span></div></a>';
                } else {
                    $markup .= '<a href="?q=signUp&OID=' . $OID . '"><div class="help tooltip4"><button type="button">Edit Sign Up</button><span id="helptext"; class="helptext tooltiptext4">Click here to edit your sign up for this event.</span></div></a>';
                }
            } else {
                if (dbIsOutreachOver($OID) || $outreach['status'] == 'isIdea') {
                    $markup .= '<a href="?q=signUp&OID=' . $OID . '"><div class="help tooltip4"><button type="button" disabled>Sign Up</button><span id="helptext"; class="helptext tooltiptext4">You cannot sign up for this event because it is already over.</span></div></a>';
                } else {
                    $markup .= '<a href="?q=signUp&OID=' . $OID . '"><div class="help tooltip4"><button type="button">Sign Up</button><span id="helptext"; class="helptext tooltiptext4">Click here to sign up for this event.</span></div></a>';
                }
            }
        } else {
            $markup .= '<a href="?q=signUp&OID=' . $OID . '"><div class="help tooltip4"><button type="button" disabled>Sign Up</button><span id="helptext"; class="helptext tooltiptext4">You cannot sign up for this event because it is cancelled.</span></div></a>';
        }
        // hours button
        if (!dbIsOutreachCancelled($OID)) {
            $markup .= '<a href= "?q=viewHours';
            $markup .= '&OID=' . $OID . '">';
            $markup .= '<button type="button" ';
            $markup .= $outreach['status'] == 'isIdea' ? ' disabled' : '';
            $markup .= '>Hours</button></a>';
        } else {
            // if outreach is cancelled
            $markup .= '<button type="button" disabled';
            $markup .= $outreach['status'] == 'isIdea' ? ' disabled' : '';
            $markup .= '>Hours</button>';
        }
        // view media button
        $markup .= '<a href="?q=viewMedia';
        $markup .= '&OID=' . $OID . '">';
        $markup .= '<button type="button"';
        $markup .= $outreach['status'] == 'isIdea' ? ' disabled' : '';
        $markup .= '>Media</button></a>';
        // edit outreach button
        if (!isMyOutreach($OID) && !hasPermissionForTeam('editAnyOutreach', getCurrentTeam()['TID'])) {
            $markup .= '<button type="button" disabled><img class="editIcon" src="/images/icons/editWhite.png"></button>';
        } else {
            $markup .= '<a href= "?q=outreachForm';
            $markup .= '&OID=' . $OID . '">';
            $markup .= '<button type="button"><img class="editIcon" src="/images/icons/editWhite.png"></button></a>';
        }
        $markup .= '</div>';
        $markup .= '<div style="width:60%; float:right; padding-left:10px">';
        $hasPointOfContact = false;
        if (!(empty($outreach['co_organization']) && empty($outreach['co_firstName']) && empty($outreach['co_email']) && empty($outreach['co_phoneNumber']))) {
            $hasPointOfContact = true;
        }
        // account for cases where no info is present
        if ($outreach['description'] == null) {
            $outreach['description'] = '[none]';
        }
        if ($outreach['type'] == null || $outreach['type'] == '') {
            $outreach['type'] = '[none]';
        }
        if ($outreach['status'] == null) {
            $outreach['status'] = '[none]';
        }
        if ($outreach['co_organization'] == null) {
            $outreach['co_organization'] = '[none]';
        }
        if ($outreach['co_position'] == null) {
            $outreach['co_position'] = '[none]';
        }
        if ($outreach['co_firstName'] == null) {
            $outreach['co_firstName'] = '[none]';
        }
        if ($outreach['co_email'] == null) {
            $outreach['co_email'] = '[none]';
        }
        if ($outreach['co_phoneNumber'] == null) {
            $outreach['co_phoneNumber'] = '[none]';
        }
        if ($outreach['city'] == null) {
            $outreach['city'] = '[none]';
        }
        if ($outreach['state'] == null) {
            $outreach['state'] = '[none]';
        }
        if ($outreach['address'] == null) {
            $outreach['address'] = '[none]';
        }
        if ($outreach['country'] == null) {
            $outreach['country'] = '[none]';
        }
        if ($outreach['totalAttendance'] == null) {
            $outreach['totalAttendance'] = 0;
        }
        if ($outreach['testimonial'] == null) {
            $outreach['testimonial'] = '[none]';
        }
        $team = dbGetTeam($outreach['TID']);
        // begin displaying info body
        $markup .= '<table id="miniViewTeam" style="margin:16px 0px 0px 0px"><tr><td><h3><b><u>General<u></b></h3></td></tr>';
        $owner = dbGetOutreachOwner($OID);
        $markup .= "<tr><td colspan='3'><b>Owner: </b>" . dbGetUserName($owner) . "</a></td>";
        $markup .= "<td colspan='3'><b>Team: </b>{$team['number']}</td></tr>";
        $markup .= '<tr><td colspan="3"><b>Tags: </b>';
        $tags = dbGetTagsForOutreach($OID);
        if (!empty($tags)) {
            dpm($tags);
            $first = true;
            $length = count($tags);
            $i = 1;
            foreach ($tags as $OTID => $tagName) {
                $markup .= '<a href="?q=outreach&tag=' . $OTID . '">' . $tagName . '</a>';
                if ($i < $length) {
                    $markup .= ', ';
                }
                $i++;
            }
            // if there aren't any tags
        } else {
            $markup .= '[none]';
        }
        $markup .= '</td></tr>';
        $times = dbGetTimesForOutreach($OID);
        // display time if the outreach status isn't an idea
        if ($outreach['status'] != 'isIdea') {
            if (!empty($times)) {
                foreach ($times as $time) {
                    $startTime = date(TIME_FORMAT, dbDateSQL2PHP($time['startTime']));
                    $endTime = date(TIME_FORMAT, dbDateSQL2PHP($time['endTime']));
                    $markup .= '<tr><td colspan="3"><b>Start Date: </b>' . $startTime . '</td>';
                    $markup .= '<td colspan="3"><b>End Date: </b>' . $endTime . '</td></tr>';
                }
            }
        }
        $markup .= '<tr><td colspan="5" style="word-break:break-word"><b>Description: </b>';
        $markup .= wordwrap($outreach['description'], 70, "<br />\n");
        $markup .= '</td></tr>';
        // if the outreach has contact information
        if ($hasPointOfContact) {
            $markup .= '<tr><td><h3><b><u>Contact Info<u></b></h3></td></tr>';
            $markup .= '<tr><td colspan="3"><b>Host Organization: </b>';
            $markup .= strip_tags($outreach['co_organization'], ALLOWED_TAGS) . '</td>';
            $markup .= '<td colspan="3"><b>Contact Name: </b>';
            $markup .= strip_tags($outreach['co_firstName'] . ' ' . $outreach['co_lastName'], ALLOWED_TAGS) . '</td></tr>';
            $markup .= '<tr><td colspan="3"><b>Contact Email: </b>' . strip_tags($outreach['co_email'], ALLOWED_TAGS) . '</td>';
            $phoneNumber = dbFormatPhoneNumber($outreach['co_phoneNumber']);
            $markup .= '<td colspan="3"><b>Contact Number: </b>' . $phoneNumber . '</td></tr>';
            $markup .= '<tr><td colspan="6"><b>Address: </b>' . strip_tags($outreach['address'], ALLOWED_TAGS) . ', ' . strip_tags($outreach['city'], ALLOWED_TAGS) . ', ' . strip_tags($outreach['state'], ALLOWED_TAGS) . '</td></tr>';
            $markup .= '</tr>';
        } else {
            $markup .= '<tr><td><h3><b><u>Contact Info<u></b></h3></td></tr>';
            $markup .= '<tr><td colspan="6"><b>Address: </b>' . strip_tags($outreach['address'], ALLOWED_TAGS) . ', ' . strip_tags($outreach['city'], ALLOWED_TAGS) . ', ' . strip_tags($outreach['state'], ALLOWED_TAGS) . '</td></tr>';
            $markup .= '</tr>';
        }
        $markup .= '<tr><td><h3><b><u>Statistics<u></b></h3></td></tr>';
        $markup .= '<tr>';
        if ($outreach['status'] != 'isIdea') {
            $numPpl = dbGetNumPplSignedUpForEvent($OID);
            $markup .= '<td colspan="3"><b>';
            // only show the link if people are signed up
            if ($numPpl != 0) {
                $markup .= '<a href="?q=outreachList&OID=' . $OID . '"target="_blank">';
            }
            $markup .= 'People Signed Up: </b>';
            // end the link
            if ($numPpl != 0) {
                $markup .= '</a>';
            }
            $markup .= $numPpl . '</td>';
            // view total hours for the outreach
            $markup .= '<td colspan="3"><b>Total Hours: </b><a href="?q=viewHours&OID=' . $OID . '">' . dbGetHoursForOutreach($OID) . '</a></td></tr>';
            //if the outreach status is idea
        } else {
            $markup .= '<td colspan="3">';
            $markup .= '<b>People Signed Up: </b>';
            $markup .= 'None';
            $markup .= '</td></tr>';
        }
        $markup .= '</table></div>';
        // if the outreach has an approved write-up
        if ($outreach['isWriteUpApproved'] && $outreach['status'] == 'locked') {
            $writeUp = empty($outreach["writeUp"]) ? '[None]' : $outreach["writeUp"];
            $totalAttendance = empty($outreach["totalAttendance"]) ? '[Not Filled Out]' : $outreach["totalAttendance"];
            $testimonial = empty($outreach["testimonial"]) ? '[None]' : $outreach["testimonial"];
            $markup .= '<div style="float:left; width:38%;"><table id="miniViewTeam" style="margin:16px 0px 0px 0px"><tr><td><h3><b><u>Write Up<u></b></h3></td>';
            $markup .= '<td><a href="?q=writeupform&OID=' . $outreach['OID'] . '&approved"><button> View</button></a></td></tr>';
            $markup .= '<tr><td><b>Write Up:</b></td></tr>';
            $markup .= '<tr><td>' . $writeUp . '</td></tr>';
            $markup .= '<tr><td><b>Total Attendance:</b></td></tr>';
            $markup .= '<tr><td>' . $totalAttendance . '</td></tr>';
            $markup .= '<tr><td><b>Testimonials/Comments:</b></td></tr>';
            $markup .= '<tr><td>' . $testimonial . '</td></tr>';
            $markup .= '</table></div>';
        }
        $retArray = array();
        $retArray['#markup'] = $markup;
        return $retArray;
    } else {
        drupal_set_message('Invalid outreach event. Click <a href="?q=teamDashboard">here</a> to navigate back to events in Team Dashboard.', 'error');
    }
}
Ejemplo n.º 18
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;
}
Ejemplo n.º 19
0
function signUp_submit($form, $form_state)
{
    global $user;
    $UID = $user->uid;
    $params = drupal_get_query_parameters();
    $OID = $params['OID'];
    $new = $form_state['new'];
    $fields = array("times");
    $fieldsData = getFields($fields, $form_state['values']);
    $types = $fieldsData['times'];
    $types = array_values($types);
    if ($new) {
        // if the user is signing up for the first time
        foreach ($types as $type) {
            if ($type !== 0) {
                dbAssignUserToOutreach($UID, $OID, $type);
                // assigning user to outreach and the various time(s) they signed up for
            }
        }
        $msgToUser = "******";
    }
    if (!$new) {
        // user is updating the time(s)
        $previous = dbGetUserSignUpType($UID, $OID);
        $deleted = array_diff($previous, $types);
        $added = array_diff($types, $previous);
        foreach ($deleted as $delete) {
            if (!empty($delete)) {
                dbRemoveCommitmentFromOutreach($UID, $OID, $delete);
                // removing the times the user "unchecked"
            }
        }
        foreach ($added as $add) {
            // adding the times the user "checked"
            if (!empty($add)) {
                dbAssignUserToOutreach($UID, $OID, $add);
            }
        }
        $msgToUser = "******";
    }
    // sending a notification to the appropriate user(s)
    $notification = array();
    $userName = dbGetUserName($UID);
    $outName = dbGetOutreachName($OID);
    $team = getCurrentTeam();
    $TID = $team['TID'];
    $notification['dateTargeted'] = $notification['dateCreated'] = dbDatePHP2SQL(time());
    $notification['message'] = "{$userName} has just signed up for your outreach: {$outName}!";
    $notification['TID'] = $TID;
    notifyOwnerOfOutreach($OID, $notification);
    $outreachEventLink = '<a href="?q=viewOutreach&OID=' . $OID . '">' . dbGetOutreachName($OID) . '</a>';
    drupal_set_message("{$msgToUser} {$outreachEventLink}!");
    drupal_goto('viewOutreach', array('query' => array('OID' => $OID)));
}
Ejemplo n.º 20
0
function viewOutreach()
{
    global $user;
    $UID = $user->uid;
    $params = drupal_get_query_parameters();
    $markup = "<script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.js\"></script>";
    $markup .= '<script src="numberCounting.js"></script>';
    $markup .= '<h1>Outreach</h1><br>';
    // if doing a custom search
    if (isset($params['query']) && $params['query'] == 'search') {
        $sql = generateSearchSQL($_SESSION['searchParams'], $_SESSION['proxyFields']);
        $outreaches = dbSearchOutreach($sql, $_SESSION['proxyFields']);
        $header = '<h2>Custom Search Results (';
        $header .= empty($outreaches) ? '0' : count($outreaches);
        $header .= ' matches)</h2>';
    } else {
        if (isset($params['tag'])) {
            $_SESSION['searchParams'] = array('tags' => array($params['tag']));
            $_SESSION['proxyFields'] = array();
            $sql = generateSearchSQL($_SESSION['searchParams'], $_SESSION['proxyFields']);
            $outreaches = dbSearchOutreach($sql, $_SESSION['proxyFields']);
            $header = '<h2>Outreaches Tagged "' . dbGetTagName($params['tag']) . '"</h2>';
        } else {
            if (isset($params['owned'])) {
                $outreaches = dbGetOwnedOutreachForUser($UID);
                $header = '<h2>Outreaches I Own</h2>';
            } else {
                if (isset($params['signedUp'])) {
                    $outreaches = dbGetOutreachForUser($UID);
                    $header = '<h2>Outreaches I Am Signed Up For</h2>';
                } else {
                    if (isset($params['allTeamOutreach'])) {
                        $TID = getCurrentTeam()['TID'];
                        $_SESSION['searchParams'] = array('TID' => array('value' => $TID, 'matchType' => 'exact'));
                        $_SESSION['proxyFields'] = array(':TID' => $TID);
                        $sql = generateSearchSQL($_SESSION['searchParams'], $_SESSION['proxyFields']);
                        $outreaches = dbSearchOutreach($sql, $_SESSION['proxyFields']);
                        $teamName = dbGetTeamName($TID);
                        $header = "<h2>All Outreach for {$teamName}</h2>";
                    } else {
                        $_SESSION['searchParams'] = array();
                        $_SESSION['proxyFields'] = array();
                        $header = "<h2>No Search Selected</h2>";
                    }
                }
            }
        }
    }
    if (isset($_SESSION['searchParams']['teams']) && count($_SESSION['searchParams']['teams']) > 1) {
        $multipleTeamsInResult = true;
    } else {
        $multipleTeamsInResult = false;
    }
    $markup .= $header;
    // set $outreaches to an array rather than false (so that later functions don't have errors)
    if (empty($outreaches)) {
        $outreaches = array();
    }
    $totalFilterOutreaches = count($outreaches);
    $totalFilterHours = 0;
    foreach ($outreaches as &$outreach) {
        $outreach['hours'] = dbGetHoursForOutreach($outreach['OID']);
        $totalFilterHours += $outreach['hours'];
    }
    unset($outreach);
    $sortParam = isset($params["sort"]) ? $params['sort'] : 'name';
    $isAscending = isset($params['isAscending']) ? true : false;
    orderByValue($outreaches, $sortParam, $isAscending);
    // custom function (see helperFunctions.inc)
    $markup .= '<table style="margin:0px">';
    $markup .= '<tr><td style="padding:0px; text-align:left"><b>Outreaches with Current Filters: </b><span class="countUp">' . $totalFilterOutreaches . '</span></td>';
    $markup .= '<td style="padding:0px; text-align:right" align="right"><b>Hours with Current Filters: </b><span class="countUp">' . $totalFilterHours . '</span></td></tr>';
    $markup .= '<tr><td style="padding:0px" align="left">Sort By: ';
    // remove special params (since they should not be added every time)
    unset($params['isAscending']);
    unset($params['sort']);
    $markup .= sortHeader($sortParam, $params, $isAscending, 'Name', 'name', 'outreach') . ' | ';
    $markup .= sortHeader($sortParam, $params, $isAscending, 'Status', 'status', 'outreach') . ' | ';
    $markup .= sortHeader($sortParam, $params, $isAscending, 'Hours', 'hours', 'outreach') . ' | ';
    $markup .= sortHeader($sortParam, $params, $isAscending, 'Event Date', 'eventDate', 'outreach');
    $markup .= '</td><td style="padding:0px; text-align:right">';
    if (!isset($params['owned'])) {
        $markup .= '<a href="?q=outreach&owned"><div class="help tooltip4"><button>Owned</button><span id="helptext"; class="helptext tooltiptext4">Click here to sort by outreach you own.</span></div></a>';
    } else {
        $markup .= '<a href="?q=outreach&allTeamOutreach"><button>All Team Outreach</button></a>';
    }
    if (!isset($params['signedUp'])) {
        $markup .= '<a href="?q=outreach&signedUp"><div class="help tooltip3"><button>Signed Up</button><span id="helptext"; class="helptext tooltiptext3">Click here to sort by outreach you are signed up for.</span></div></a>';
    } else {
        $markup .= '<a href="?q=outreach&allTeamOutreach"><button>All Team Outreach</button></a>';
    }
    $markup .= '</td></tr></table>';
    $markup .= '<table class="infoTable" style="margin:0px"><tr><th colspan="2">Status</th>';
    if ($multipleTeamsInResult) {
        $markup .= '<th colspan="2">Team</th>';
    }
    $markup .= '<th colspan="4">Name</th>';
    $markup .= '<th colspan="2">Hours</th>';
    $markup .= '<th colspan="2">Event Date</th>';
    if (empty($outreaches)) {
        $markup .= '<tr><td colspan="11">No outreach found! Click <a href="?q=outreachForm">here</a> to create new outreach!</td></tr></table>';
        return array('#markup' => $markup);
    }
    foreach ($outreaches as $outreach) {
        $OID = $outreach['OID'];
        $hours = dbGetHoursForOutreach($OID);
        $status;
        switch ($outreach['status']) {
            case 'isOutreach':
                $status = '<span title="Outreach Event"><img class="eventIndicatorIcon" src="/images/icons/outreachBlue.png"></span>';
                break;
            case 'isIdea':
                $status = '<span title="Idea"><img class="eventIndicatorIcon" src="/images/icons/ideaBlue.png"></span>';
                break;
            case 'doingWriteUp':
                $status = '<span title="Write Up"><img class="eventIndicatorIcon" src="/images/icons/writeUpBlue.png"></span>
';
                break;
            case 'locked':
                $status = '<span title="Locked Event"><img class="eventIndicatorIcon" src="/images/icons/lockedBlue.png"></span>';
                break;
            default:
                drupal_set_message('Invalid outreach data.');
                break;
        }
        $markup .= '<tr><td colspan="2" style="padding: 0px 0px 0px 14px;">';
        $markup .= showOutreachStatusIcon($outreach['status']) . '</td>';
        if ($multipleTeamsInResult) {
            $markup .= '<td colspan="2"><a href="?q=viewTeam&TID=' . $outreach['TID'] . '">' . dbGetTeamNumber($outreach['TID']) . '</a></td>';
        }
        $markup .= '<td colspan="4"><a href="?q=viewOutreach&OID=' . $OID . '">' . chopString($outreach['name'], 15) . '</a></td>';
        $markup .= '<td colspan="2">' . $hours . '</td>';
        if (dbGetEarliestTimeForOutreach($OID) != false) {
            $markup .= '<td colspan="2">' . date(TIME_FORMAT, dbDateSQL2PHP(dbGetEarliestTimeForOutreach($OID))) . '</td>';
        } else {
            $markup .= '<td colspan="2">[none]</td>';
        }
    }
    $markup .= '</table>';
    return array('#markup' => $markup);
}
Ejemplo n.º 21
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;
}
Ejemplo n.º 22
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);
}
Ejemplo n.º 23
0
function viewUserUpcomingEvents()
{
    global $user;
    $UID = $user->uid;
    $currentTeam = getCurrentTeam();
    $TID = $currentTeam['TID'];
    $teamNumber = $currentTeam['number'];
    $markup = '<div class="help tooltip2">';
    $markup .= '<h2>My Upcoming Events</h2>';
    $markup .= '<span id="helptext"; class="helptext tooltiptext2">';
    $markup .= 'These are your upcoming events that you own or have signed up for.';
    $markup .= '</span></div>';
    $markup .= '<table class="infoTable"><tr><th colspan="3">Name</th>';
    $markup .= '<th colspan="2">Event Date</th>';
    if (dbUserMoreThan1Team($UID)) {
        // if the user has more than one team
        $markup .= '<th>Team</th>';
    } else {
        $markup .= '<th></th>';
    }
    $markup .= '<th></th>';
    $markup .= "</tr>";
    $orderParams = 'upcoming';
    $outreaches = dbGetOutreachForUser($user->uid, $orderParams, NUM_UPCOMING_OUTREACHES_SHOWN);
    // if the user has upcoming outreaches
    if (!empty($outreaches)) {
        foreach ($outreaches as $outreach) {
            $OID = $outreach['OID'];
            $TID = $outreach['TID'];
            $team = dbGetTeam($outreach['TID']);
            $eventDate = date(TIME_FORMAT, strtotime(dbGetEarliestTimeForOutreach($OID)));
            // display outreach information
            $markup .= "<tr>";
            $markup .= '<td colspan="3">' . '<a href="?q=viewOutreach&OID=' . $OID . '">' . chopString($outreach["name"], 20) . '</a>' . "</td>";
            $markup .= '<td colspan="2">' . $eventDate . "</td>";
            $markup .= "<td>{$team['number']}</td>";
            $markup .= '<td><a href="?q=signUp&OID=' . $OID . '">';
            $markup .= '<button type="button">Edit Sign Up</button></a></td>';
            $markup .= "</tr>";
        }
    } else {
        // if the user does not have any upcoming events
        $markup .= "<tr>";
        $markup .= '<td style="text-align:center" colspan="7"><em>[None]</em></td>';
        $markup .= "</tr>";
    }
    $markup .= "</table>";
    $retArray = array();
    $retArray['#markup'] = $markup;
    return $retArray;
}