function manageNotifications()
{
    $params = drupal_get_query_parameters();
    if (isset($params['OID'])) {
        $OID = $params['OID'];
        $outreachName = dbGetOutreachName($OID);
        // create page header, table, and add notification button
        $markup = '';
        $markup .= '<table>';
        $markup .= "<tr><td><h1>Manage Notifications for \"{$outreachName}\" </h1>";
        $markup .= '</td><td style="text-align:right">';
        $markup .= '<a href="?q=notificationForm&OID=' . $OID . '"><button>Add Notification</button></a></td></tr></table>';
        $markup .= '<table class="infoTable"><tr><th colspan="3">Target Users</th><th colspan="3">Notification Message</th><th colspan="2">Date To Be Sent</th><th colspan="2"></th></tr>';
        $notifications = dbGetNotificationsForOutreach($OID);
        // if outreach already has notifications
        if (!empty($notifications)) {
            foreach ($notifications as $notification) {
                $markup .= '<tr>';
                $markup .= '<td colspan="3">' . dbGetUserName($notification['UID']) . '</td>';
                $markup .= '<td colspan="3">' . $notification['message'] . '</td>';
                $date = dbDateSQL2PHP($notification['dateTargeted']);
                $markup .= '<td colspan="2">' . date(TIME_FORMAT, $date) . '</td>';
                $markup .= '<td colspan="2"><a href="?q=deleteNotification/' . $notification['NID'];
                $markup .= "/{$OID}\"><button>Delete</button></a></td>";
                $markup .= '</td>';
            }
            $markup .= '</table>';
        } else {
            // if outreach does not have notifications
            $markup .= "<tr>";
            $markup .= '<td style="text-align:center" colspan="10"><em>[None]</em></td>';
            $markup .= "</tr>";
        }
        $markup .= "</table>";
        return array('#markup' => $markup);
    } else {
        // returns message if OID is not correct
        drupal_set_message('No outreach selected.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
}
Example #2
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);
}
Example #3
0
function viewUserOutreach()
{
    global $user;
    $UID = $user->uid;
    $userName = dbGetUserName($UID);
    $params = drupal_get_query_parameters();
    $currentYear = date("Y");
    $totalFilterHours = 0;
    $markup = "<h1>All Outreach for {$userName}</h1>";
    if (isset($params["cancelled"])) {
        $outreaches = dbGetCancelledOutreach($TID);
    } else {
        if (isset($params['query']) && $params['query'] == 'search') {
            $outreaches = dbSearchOutreach($_SESSION['searchSQL'], $_SESSION['proxyFields']);
        } else {
            $outreaches = dbGetOutreachesForTeam($TID);
            if (isset($params['status']) && $params['status'] != 'all') {
                $proxyFields = array();
                $outreaches = dbSearchOutreach(generateSearchSQL(array('status' => array($params['status'])), $proxyFields), $proxyFields);
            }
        }
    }
    foreach ($outreaches as &$outreach) {
        $outreach['hours'] = dbGetHoursForOutreach($outreach['OID']);
        $totalFilterHours += $outreach['hours'];
    }
    unset($outreach);
    $markup .= '<div style="float:left"><h4>Hours With Current Filters: ' . $totalFilterHours . '</h4></div><br><br>';
    $sortParam = isset($params["sort"]) ? $params['sort'] : 'name';
    $statusParam = isset($params["status"]) ? $params['status'] : 'all';
    orderByValue($outreaches, $sortParam, true);
    // custom function (see helperFunctions.inc)
    $markup .= '<div align="left" style="float: left">Sort By: ';
    switch ($sortParam) {
        case 'name':
            $markup .= '<b>Name</b><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=status">Status</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=hours">Hours</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=logDate">Log Date</a><br>';
            break;
        case 'status':
            $markup .= '<a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=name">Name</a><b> | </b><b>Status | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=hours">Hours</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=logDate">Log Date</a><br>';
            break;
        case 'hours':
            $markup .= '<a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=name">Name</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=status">Status</a><b> | </b><b>Hours | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=logDate">Log Date</a><br>';
            break;
        case 'logDate':
            $markup .= '<a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=name">Name</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=status">Status</a><b> | </b><a href="?q=allTeamOutreach&status=' . $statusParam . '&sort=hours">Hours</a><b> | </b><b>Log Date</b><br>';
            break;
    }
    $markup .= 'Include Status: ';
    switch ($statusParam) {
        case 'isIdea':
            $markup .= '<a href="?q=allTeamOutreach&sort=' . $sortParam . '">All</a><b> | </b><b>Idea | </b><a href="?q=allTeamOutreach&status=isOutreach&sort=' . $sortParam . '">Outreach</a><b> | </b><a href="?q=allTeamOutreach&status=doingWriteUp&sort=' . $sortParam . '">Write Up</a><br>';
            break;
        case 'isOutreach':
            $markup .= '<a href="?q=allTeamOutreach&sort=' . $sortParam . '">All</a><b> | </b><a href="?q=allTeamOutreach&status=isIdea&sort=' . $sortParam . '">Idea</a><b> | </b><b>Outreach | </b><a href="?q=allTeamOutreach&status=doingWriteUp&sort=' . $sortParam . '">Write Up</a><br>';
            break;
        case 'doingWriteUp':
            $markup .= '<a href="?q=allTeamOutreach&sort=' . $sortParam . '">All</a><b> | </b><a href="?q=allTeamOutreach&status=isIdea&sort=' . $sortParam . '">Idea</a><b> | </b><a href="?q=allTeamOutreach&status=isOutreach&sort=' . $sortParam . '">Outreach</a><b> | </b><b>Write Up</b><br>';
            break;
        default:
            $markup .= '<b>All</b><b> | </b><a href="?q=allTeamOutreach&status=isIdea&sort=' . $sortParam . '">Idea</a><b> | </b><a href="?q=allTeamOutreach&status=isOutreach&sort=' . $sortParam . '">Outreach</a><b> | </b><a href="?q=allTeamOutreach&status=doingWriteUp&sort=' . $sortParam . '">Write Up</a><br>';
    }
    $markup .= '</div>';
    orderByValue($outreaches, $sortParam, true);
    // custom function (see helperFunctions.inc)
    // Begin Displaying Outreach Events
    $markup .= '<div align="right" style="float:right"><a href="?q=searchForm"><button>Search</button></a>';
    if (!isset($params["cancelled"])) {
        $markup .= '<a href="?q=allTeamOutreach&cancelled"><button>Cancelled</button></a>';
    } else {
        $markup .= '<a href="?q=allTeamOutreach"><button>All Outreaches</button></a>';
    }
    $markup .= '<a href="?q=viewOutreachSettings"><button';
    $markup .= dbGetRIDForTeam($user->uid, $TID) > 0 ? '' : ' disabled';
    $markup .= '>Outreach Settings</button></a>';
    $markup .= '</div><br>';
    $markup .= '<table><tr><th>Name</th>';
    $markup .= '<th>Description</th>';
    $markup .= '<th>Status</th>';
    $markup .= '<th>Hours</th>';
    $markup .= '<th>Log Date</th>';
    foreach ($outreaches as $outreach) {
        $hours = dbGetHoursForOutreach($outreach['OID']);
        $status;
        switch ($outreach['status']) {
            case 'isOutreach':
                $status = 'Outreach';
                break;
            case 'isIdea':
                $status = 'Idea';
                break;
            case 'doingWriteUp':
                $status = 'Write-Up';
                break;
            default:
                $status = '[none]';
                break;
        }
        $markup .= "<tr><td><a href='?q=viewOutreach&OID={$outreach['OID']}'>{$outreach['name']}</a></td>";
        if (isset($outreach['description'])) {
            $markup .= "<td>" . chopString($outreach['description'], 50) . "</td>";
        } else {
            $markup .= '<td>[none]</td>';
        }
        $markup .= "<td>{$status}</td>";
        $markup .= "<td>{$hours}</td>";
        $eventDate = date(TIME_FORMAT, dbDateSQL2PHP($outreach['logDate']));
        $markup .= "<td>{$eventDate}</td></tr>";
    }
    $markup .= '</table>';
    return array('#markup' => $markup);
}
Example #4
0
function dbIsOutreachOver($OID)
{
    $sql = "SELECT MAX(endTime) FROM timesVsOutreach ";
    $sql .= "WHERE OID = :OID;";
    $proxyFields = array(":OID" => $OID);
    $result = db_query($sql, $proxyFields)->fetchAll(PDO::FETCH_ASSOC);
    if ($result[0]['MAX(endTime)'] != null) {
        return dbDateSQL2PHP($result[0]['MAX(endTime)']) < time();
    }
    return false;
}
Example #5
0
function recentTeamOutreach()
{
    global $user;
    $UID = $user->uid;
    $params = drupal_get_query_parameters();
    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'];
    }
    // checks to see if team can access page
    if (teamIsIneligible($TID)) {
        drupal_set_message('Your team does not have permission to access this page.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    // create header
    $markup = '<h1>Team Dashboard</h1><br>';
    $markup .= '<h2>' . $team['number'] . ' Outreach</h2>';
    $searchParams['teams'] = array($TID);
    $markup .= '<div align="left" style="float: left">Sort By: ';
    if (isset($params['sortByDate'])) {
        $outreaches = dbGetOutreachesForTeam($TID, 'upcoming', NUM_RECENT_OUTREACHES_SHOWN);
        $markup .= '<a href="?q=teamDashboard">Recently Added</a><b> | Upcoming Events</b></div>';
    } else {
        $outreaches = dbGetOutreachesForTeam($TID, 'logDate', NUM_RECENT_OUTREACHES_SHOWN);
        $markup .= '<b>Recently Added | </b><a href="?q=teamDashboard&sortByDate">Upcoming Events</a></div>';
    }
    $markup .= '<div align="right" style="float:right">';
    // moderator page button
    if (!teamIsIneligible($TID) && hasPermissionForTeam('manageOutreachTags', $TID)) {
        $markup .= '<a href="?q=teamModeratorPage">';
        $markup .= '<div class="help tooltip4">';
        $markup .= '<button>Moderators</button>';
        $markup .= '<span id="helptext"; class="helptext tooltiptext4">';
        $markup .= 'Click here to view ideas, write-ups, and hours awaiting approval.';
        $markup .= '</span></div></a>';
    } else {
        $markup .= '';
    }
    // all team outreach button
    $markup .= '<a href="?q=outreach&allTeamOutreach"><div class="help tooltip3"><button>All Team Outreach</button><span id="helptext"; class="helptext tooltiptext3">Click here to view all of your teams outreach.</span></div></a></div>';
    // create table
    $markup .= '<table class="infoTable"><tr><th>Name</th><th>Event Date</th><th>Owner</th><th></th></tr>';
    foreach ($outreaches as $outreach) {
        $OID = $outreach['OID'];
        $markup .= '<tr><td><a href="?q=viewOutreach&OID=' . $OID . '"</a>';
        $markup .= chopString($outreach["name"], 20) . '</td>';
        // displays event date
        if (dbGetEarliestTimeForOutreach($OID) != false) {
            $markup .= '<td>' . date(TIME_FORMAT, dbDateSQL2PHP(dbGetEarliestTimeForOutreach($OID))) . '</td>';
        } else {
            $markup .= '<td>[none]</td>';
        }
        $owner = dbGetOutreachOwner($OID);
        // displays outreach owner
        if ($owner != false) {
            $markup .= '<td><a href="?q=viewUser&UID=' . $owner . '">' . dbGetUserName($owner) . '</a></td>';
        } else {
            $markup .= '<td>[none]</td>';
            // insert placeholder if no outreach owner
        }
        $markup .= '<td>';
        // sign up for outreach button
        $signUp = dbIsUserSignedUp($UID, $OID);
        if (dbIsUserSignedUp($UID, $OID)) {
            if (dbIsOutreachOver($OID)) {
                $markup .= '<a href="?q=signUp&OID=' . $OID . '"><button type="button" disabled>Edit Sign Up</button></a>';
            } else {
                $markup .= '<a href="?q=signUp&OID=' . $OID . '"><button type="button">Edit Sign Up</button></div></a>';
            }
        } else {
            if (dbIsOutreachOver($OID)) {
                $markup .= '<a href="?q=signUp&OID=' . $OID . '"><button type="button" disabled>Sign Up</button></div></a>';
            } else {
                $markup .= '<a href="?q=signUp&OID=' . $OID . '"><button type="button">Sign Up</button></div></a>';
            }
        }
        $markup .= '</td></tr>';
    }
    // if no outreaches for team
    if (empty($outreaches)) {
        $markup .= '<tr><td colspan="10">No outreach found! Click <a href="?q=outreachForm">here</a> to create new outreach!</td></tr></table>';
        return array('#markup' => $markup);
    }
    $markup .= '</table>';
    return array('#markup' => $markup);
}
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;
}
Example #7
0
function viewAllNotifications()
{
    global $user;
    $UID = $user->uid;
    // create page header, table, and dismiss all notifications button
    $timezone = $user->timezone;
    $notifications = dbGetNotificationsForUser($user->uid);
    $markup = '<table><tr><td style="text-align:left"><h1><b>View All Notifications</b></h1></td>';
    $markup .= '<td style="text-align:right"><a href="?q=dismissAllNotifications"><button>';
    $markup .= 'Dismiss All</button></a></td></tr></table>';
    // if user has no notifications
    if (empty($notifications)) {
        $markup .= '<table class="infoTable"><th></th><tr><td style="text-align:center" colspan="10"><em>No New Notifications!</em></td></tr></table>';
        $_SESSION['notificationNIDsShown'] = array();
    } else {
        // if user has notifications
        $markup .= '<table class="infoTable"><tr><th>Associated Picture</th><th>Notification Content</th><th></th></tr>';
        foreach ($notifications as $notification) {
            // used to prevent lack of page refresh issues
            $_SESSION['notificationNIDsShown'][] = $notification['NID'];
            $rawDate = $notification['dateTargeted'];
            $rawDate = dbDateSQL2PHP($rawDate);
            $date = date(TIME_FORMAT, $rawDate);
            $markup .= "<tr><td>";
            // generates picture for notification
            if (!empty($notification['FID'])) {
                $FID = $notification['FID'];
                $file = file_load($FID);
                $uri = $file->uri;
                $variables = array('style_name' => 'all_notifications', 'path' => $uri, 'width' => '150', 'height' => '150');
                $image = theme_image_style($variables);
                $markup .= $image;
            }
            $markup .= '</td><td style="width:50% . "text-align:center">';
            $markup .= '<br><b>' . $date . "</b><br>";
            $markup .= '<i>' . $notification['message'] . "</i><br><br></td>";
            $markup .= '<td>';
            // buttons for viewing or dismissing a notification
            if ($notification['bttnLink'] != null && $notification['bttnTitle'] != null) {
                $markup .= "<a href=\"{$notification['bttnLink']}\">";
                $markup .= '<button type="button">' . $notification['bttnTitle'] . '</button>';
            }
            $markup .= '<a href="?q=dismissNotification/' . $notification['NID'] . '&allnote">';
            $markup .= '<button type="button"><img class="trashIcon" src="/images/icons/trashWhite.png"></button></a>' . '&nbsp' . '&nbsp';
            $markup .= '</td></tr>';
        }
        $markup .= '</td></tr></table>';
    }
    $retArray = array();
    $retArray['#markup'] = $markup;
    return $retArray;
}
Example #8
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;
}
Example #9
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');
    }
}
Example #10
0
function viewPastUserMedia()
{
    global $user;
    $UID = $user->uid;
    // checks to see if the user has a team
    if (dbGetTeamsForUser($user->uid) == false) {
        drupal_set_message("You don't have a team assigned.", 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    // processes the mail messages sent to pics@chapresearch.com
    getIncomingMedia();
    $medias = dbGetPastMediaForUser($UID);
    // create header
    $markup = '<h1>Media</h1><br><div class="help tooltip2"><h2>Assigned Media</h2>';
    $markup .= '<span id="helptext"; class="helptext tooltiptext2">';
    $markup .= 'This is past media that you have already assigned to outreach.';
    $markup .= '</span></div>';
    // create table
    $markup .= '<table class="infoTable"><tr><th>Media</th><th>Info</th><th colspan="2">Outreach</th></tr>';
    // if user has not assigned media before
    if (empty($medias)) {
        $markup .= '<tr><td colspan="4">No past media!</td></tr></table>';
        return array('#markup' => $markup);
    }
    // displays previously assigned media
    foreach ($medias as $media) {
        $FID = $media['FID'];
        $file = file_load($FID);
        $uri = $file->uri;
        $url = generateURL($FID);
        $variables = array('style_name' => 'preview', 'path' => $uri, 'width' => '200', 'height' => '200');
        $image = theme_image_style($variables);
        $rawDate = dbDateSQL2PHP($media['dateEntered']);
        $date = date(SHORT_TIME_FORMAT, $rawDate);
        $title = empty($media['title']) ? '[no title]' : $media['title'];
        $description = wordwrap(chopString($media['description'], 50), 25, "<br>\n", true);
        $markup .= '<tr><td style = "vertical-align: middle;"><a href="' . $url . '">' . $image . '</a></td>';
        $markup .= '<td style = "vertical-align: middle;"><a href="?q=viewMedia&OID=' . $media['OID'] . '"><b>' . $title . '</b></a>
<br>' . $date . '<br>' . $description . '</td>';
        $markup .= '<td style = "vertical-align: middle;">';
        if (!empty($name = dbGetOutreachName($media['OID']))) {
            $markup .= '<a href="?q=viewOutreach&OID=' . $media['OID'] . '">' . $name . '</a>';
        } else {
            $markup .= '[none]';
        }
        $markup .= '</td>';
        // delete past media
        $markup .= '<td style ="vertical-align: middle;"><a href="?q=removeMedia/' . $media["MID"] . '"><button type="button"><img class="trashIcon" src="/images/icons/trashWhite.png"></button></a></td>';
        $markup .= '</tr>';
    }
    $markup .= '</table>';
    return array('#markup' => $markup);
}
function dbGetOrderCustomer($OID)
{
    $hadError = false;
    $con = dbConnect();
    if ($con == null) {
        return null;
    }
    $sql = "SELECT customers.*\n           FROM orders,customers\n           WHERE orders.OID = {$OID} AND customers.CID = orders.CID";
    $result = mysqli_query($con, $sql);
    if (!$result) {
        dbErrorMsg("Error during sql query in dbGetOrderCustomer" . mysqli_error($con));
        $hadError = true;
    } else {
        // only get one row
        $row = mysqli_fetch_assoc($result);
        $row["MetDate"] = dbDateSQL2PHP($row["MetDate"]);
        mysqli_free_result($result);
    }
    dbClose($con);
    if ($hadError) {
        return null;
    } else {
        return $row;
    }
}
Example #12
0
function viewOutreachIdeas()
{
    global $user;
    if (dbGetTeamsForUser($user->uid) == NULL) {
        drupal_set_message("You don't have a team assigned.", 'error');
        $TID = 0;
    }
    if (isset($params["UID"])) {
        $UID = $params["UID"];
    } else {
        $UID = $user->uid;
    }
    $currentTeam = getCurrentTeam();
    $TID = $currentTeam['TID'];
    $teamNumber = $currentTeam['number'];
    if (isset($params['OID']) && $params['OID'] > 0) {
        $OID = $params['OID'];
        $outreach = dbGetOutreach($OID);
    }
    // if the user has more than one team
    if (count(dbGetTeamsForUser($UID)) > 1) {
        $markup = '<div class="help tooltip2">';
        $markup .= '<h2>My Outreach Ideas</h2>';
        $markup .= '<span id="helptext"; class="helptext tooltiptext2">';
        $markup .= 'These are your ideas that have not yet been approved to become outreaches.';
        $markup .= '</span></div>';
        // allows a user to see the outreach ideas of the team currently being used
        $outreaches = dbGetOutreachIdeas($user->uid, PREVIEW_NUMBER);
        // begin table
        $markup .= '<table class="infoTable"><tr><th colspan="3">Name</th>';
        $markup .= '<th colspan="3">Log Date</th>';
        $markup .= '<th colspan="2">Team</th>';
        $markup .= '<th colspan="2"></th>';
        $markup .= "</tr>";
        // of the user has outreach ideas
        if (!empty($outreaches)) {
            foreach ($outreaches as $outreach) {
                $TID = $outreach['TID'];
                $team = dbGetTeam($outreach['TID']);
                $rawDate = $outreach['logDate'];
                $rawDate = dbDateSQL2PHP($rawDate);
                $logDate = date(TIME_FORMAT, $rawDate);
                $markup .= "<tr>";
                $markup .= '<td colspan="3">' . '<a href="?q=viewOutreach&OID=' . $outreach['OID'] . '">' . chopString($outreach["name"], 20) . '</a>' . "</td>";
                $markup .= '<td colspan="3">' . $logDate . "</td>";
                $markup .= "<td colspan='2'>{$team['number']}</td>";
                // approve and reject idea buttons if the user has permission
                if (hasPermissionForTeam('approveIdeas', $TID)) {
                    $markup .= "<td colspan=\"2\"><a href=\"?q=approveIdea/{$outreach['OID']}/{$TID}\"><button>Approve</button></a>";
                    $markup .= "<a href=\"?q=rejectIdea/{$outreach['OID']}/{$TID}\"><button>Reject</button></a></td>";
                } else {
                    $markup .= '<td></td><td></td>';
                }
                $markup .= "</tr>";
            }
        } else {
            // display none if the user doesnt have any outreaches
            $markup .= "<tr>";
            $markup .= '<td style="text-align:center" colspan="10"><em>[None]</em></td>';
            $markup .= "</tr>";
        }
        $markup .= "</table>";
    } else {
        // if the user only has one team
        $markup = '<div class="help tooltip2">';
        $markup .= '<h2>My Outreach Ideas</h2>';
        $markup .= '<span id="helptext"; class="helptext tooltiptext2">';
        $markup .= 'These are your ideas that have not yet been approved to become outreaches.';
        $markup .= '</span></div>';
        // allows a user to see the outreach ideas of the team currently being used
        $outreaches = dbGetOutreachIdeas($user->uid, PREVIEW_NUMBER);
        $markup .= '<table class="infoTable"><tr><th>Name</th>';
        $markup .= "<th>Log Date</th>";
        $markup .= "<th></th>";
        $markup .= "<th></th>";
        $markup .= "</tr>";
        // if the user has outreach ideas
        if (!empty($outreaches)) {
            foreach ($outreaches as $outreach) {
                $TID = $outreach['TID'];
                $rawDate = $outreach['logDate'];
                $rawDate = dbDateSQL2PHP($rawDate);
                $logDate = date(TIME_FORMAT, $rawDate);
                $markup .= "<tr>";
                $markup .= "<td>" . '<a href="?q=viewOutreach&OID=' . $outreach['OID'] . '">' . chopString($outreach["name"], 20) . '</a>' . "</td>";
                $markup .= "<td>" . $logDate . "</td>";
                if (hasPermissionForTeam('approveIdeas', $TID)) {
                    $markup .= "<td><a href=\"?q=approveIdea/{$outreach['OID']}/{$TID}\"><button>Approve</button></a></td>";
                    $markup .= "<td><a href=\"?q=rejectIdea/{$outreach['OID']}/{$TID}\"><button>Reject</button></a></td>";
                } else {
                    $markup .= '<td></td><td></td>';
                }
                $markup .= "</tr>";
            }
        } else {
            // display none if the user doesn't have any outreach ideas
            $markup .= "<tr>";
            $markup .= '<td style="text-align:center" colspan="10"><em>[None]</em></td>';
            $markup .= "</tr>";
        }
        $markup .= "</table>";
    }
    $retArray = array();
    $retArray['#markup'] = $markup;
    return $retArray;
}