Ejemplo n.º 1
0
function notificationForm_submit($form, $form_state)
{
    global $user;
    $params = drupal_get_query_parameters();
    $OID = $params['OID'];
    // generate the notification
    $notification = getFields(array('dateTargeted', 'message'), $form_state['values']);
    $notification = stripTags($notification);
    // allow some tags
    $notification['dateTargeted'] = dbDatePHP2SQL(strtotime($notification['dateTargeted']));
    $notification['bttnTitle'] = 'View Outreach';
    $notification['bttnLink'] = '?q=viewOutreach&OID=' . $OID;
    $notification['OID'] = $OID;
    $notification['TID'] = dbGetTeamForOutreach($OID);
    $notification['dateCreated'] = dbDatePHP2SQL(time());
    foreach ($form_state['values']['UID'] as $UID) {
        if ($UID != null) {
            $notification['UID'] = $UID;
            $result = dbAddNotification($notification);
        }
    }
    if ($result) {
        drupal_set_message('Notification added!');
        drupal_goto('manageNotifications', array('query' => array('OID' => $OID)));
    } else {
        drupal_set_message('There was an error.', 'error');
    }
}
Ejemplo n.º 2
0
function populateTestData()
{
    dbCreateTeam(array("name" => "Team Appreciate", "number" => "2468", "type" => "FRC", "city" => "1000 Westbank Austin TX 78746", "state" => "Texas", "country" => "United States", "isActive" => true));
    dbCreateTeam(array("name" => "The Poofs", "number" => "254", "isActive" => true));
    dbCreateTeam(array("name" => "RobotTots", "number" => "118", "isActive" => true));
    dbCreateTeam(array("name" => "Katies Team", "number" => "3310", "isActive" => true));
    dbCreateProfile(array("firstName" => "Philip", "lastName" => "Liu", "bio" => "Philip Liu is a sophomore at Westlake High School. He has been highly involved with STEM programs since a young age and has developed many skills such as leadership, communication, and perseverance. In Chap Research, Philip is currently working on two different projects. The first is an all hardware project called the Chap Measuring Press (CMP) while the second is the Chap Research Outreach Management Application (CROMA). He is a member of FRC 2468 Team Appreciate and works in many sub-systems. In addition to working with the robot design, CAD, and manufacturing, he manages the documentation and portfolio for the outreach team. With all these generous opportunities, he uses his knowledge (so far) to mentor FTC teams. Outside of robotics and school, Philip practices TaeKwonDo (a soon-to-be instructor), dances, and plays football, basketball, and fantasy with his friends. In order to balance his time with a laughing and happy manner, his favorite quote is 'where there is a will, there is a way.'", "position" => "CROMA Admin", "phone" => "512-925-2241", "grade" => "10", "gender" => "Male"));
    dbCreateProfile(array("firstName" => "Parker", "lastName" => "Bergen"));
    dbCreateProfile(array("firstName" => "Rachel", "lastName" => "Gardner"));
    dbCreateProfile(array("firstName" => "Lewis", "lastName" => "Jones"));
    dbAssignUserToTeam("2", "1");
    dbAssignUserToTeam("1", "1");
    dbAssignUserToTeam("3", "1");
    dbApproveUser("1", "1");
    dbApproveUser("3", "2");
    dbApproveUser("2", "1");
    dbCreateOutreach(array("name" => "CROMA Prep", "status" => "isOutreach", "logDate" => date("Y-m-d H:i:s", time()), "TID" => "1", "address" => "my house", "description" => "An event"));
    dbCreateOutreach(array("name" => "SXSW", "status" => "isOutreach", "logDate" => time(), "address" => "my house", "description" => "An event"));
    dbCreateOutreach(array("name" => "Barnes and Nobles", "status" => "isOutreach", "logDate" => time(), "address" => "my house", "description" => "An event", "TID" => "1"));
    dbCreateOutreach(array("name" => "CROMA Prep", "status" => "isOutreach", "TID" => "1"));
    dbCreateOutreach(array("name" => "NI Week", "status" => "isIdea", "TID" => "1"));
    dbCreateOutreach(array("name" => "Robot Fair", "description" => "Promoting STEM education to the community", "type" => "Ripple Effect", "status" => "isIdea"));
    dbApproveEvent("1");
    dbAssignUserToOutreach("1", "1");
    dbAssignUserToOutreach("1", "2");
    dbAssignUserToOutreach("1", "3");
    dbAssignUserToOutreach("1", "4");
    dbAssignUserToOutreach("2", "2");
    dbLogHours(array("UID" => "1", "OID" => "1", "numberOfHours" => "12", "type" => "Pre"));
    dbLogHours(array("UID" => "2", "OID" => "1", "numberOfHours" => "15", "type" => "Post"));
    dbAddMedia(array("OID" => null, "title" => "test", "UID" => "1", "description" => "fbsjdfjsdg", "dateEntered" => time(), "link" => "https://pbs.twimg.com/profile_images/447374371917922304/P4BzupWu.jpeg"));
    dbAddMedia(array("OID" => null, "UID" => "1", "description" => "YO HOMEDAWG", "dateEntered" => time(), "link" => "http://croma.chapresearch.com/sites/default/files/CROMA%20Logo%20v1_0.png"));
    dbAddMedia(array("OID" => "1", "UID" => "1", "description" => "Ni Hao", "dateEntered" => time(), "link" => "http://chapresearch.com/wp-content/uploads/2015/08/William-e1439428977920.jpg"));
    dbAddMedia(array("OID" => "2", "description" => "Philip likes Chap Research"));
    dbAddMedia(array("OID" => null, "UID" => "1", "title" => "FUNNY"));
    dbAddEmails("1", array("*****@*****.**"));
    dbAddEmails("1", array("*****@*****.**"));
    dbAddEmails("2", array("*****@*****.**"));
    dbAddEmails("2", array("*****@*****.**"));
    dbAddTimesToOutreach(array("OID" => "1", "startTime" => "5/25/15", "endTime" => "5/26/15"));
    dbAddTimesToOutreach(array("OID" => "2", "startTime" => "1/25/15", "endTime" => "3/26/15"));
    dbAddTimesToOutreach(array("OID" => "2", "startTime" => "9/2/15", "endTime" => "11/12/15"));
    dbAddTimesToOutreach(array("OID" => "4", "startTime" => "1/3/15", "endTime" => "3/28/15"));
    dbAddNotification(array("TID" => "1", "UID" => "1", "date" => "11/10/15", "title" => "Dell Family Day", "message" => "This event will take place on Saturday, November 28th, at the J.W. Marriott hotel in Downtown Austin. We need all Robowranglers to attend."));
    dbAddNotification(array("TID" => "4", "UID" => "1", "date" => "15/4/15", "title" => "Barnes and Noble", "message" => "This event will take place on Saturday, November 7th at the Barnes and Noble in the Hill Country Galleria. See Roger Newton for details."));
    dbAddNotification(array("TID" => "3", "UID" => "1", "date" => "12/1/15", "title" => "Freescale Marathon", "message" => "Informal event... Show up on December 31st to wish the runners at the finish line a Happy New Year!"));
}
Ejemplo n.º 3
0
function approveTeam($TID)
{
    $params = drupal_get_query_parameters();
    dbApproveTeam($TID);
    $UID = dbGetOwnerForTeam($TID);
    $teamName = dbGetTeamName($TID);
    drupal_mail('adminFunctions', 'teamApproved', dbGetUserPrimaryEmail($UID), variable_get('language_default'), $params = array('teamName' => $teamName, 'fullName' => dbGetUserName($UID)), $from = NULL, $send = TRUE);
    drupal_set_message('The team has been approved and the team owner has been notified!');
    $notification = array('UID' => $UID, 'TID' => $TID, 'dateCreated' => dbDatePHP2SQL(time()), 'dateTargeted' => dbDatePHP2SQL(time()));
    $notification['message'] = "Your team, team \"{$teamName}\" has just been approved!";
    $notification['bttnTitle'] = 'View';
    $notification['bttnLink'] = "?q=viewTeam&TID={$TID}";
    dbAddNotification($notification);
    if (isset($params['show'])) {
        drupal_goto('adminPage', array('query' => array($params['show'])));
    } else {
        drupal_goto('adminPage');
    }
}
function rejectIdea($OID)
{
    $outreach = dbGetOutreach($OID);
    $outreachName = dbGetOutreachName($OID);
    if (dbRejectIdea($OID)) {
        $UID = $outreach['UID'];
        $TID = $outreach['TID'];
        // notification to user that their outreach has been rejected
        $notification = array('UID' => $UID, 'TID' => $TID, 'message' => "{$outreachName} has been rejected.", 'dateCreated' => dbDatePHP2SQL(time()), 'dateTargeted' => dbDatePHP2SQL(time()));
        dbAddNotification($notification);
        drupal_set_message("{$outreachName} has been rejected");
    } else {
        drupal_set_message("An error has occurred.", 'error');
    }
    if (isset($_SERVER['HTTP_REFERER'])) {
        drupal_goto($_SERVER['HTTP_REFERER']);
    } else {
        drupal_goto('myDashboard');
    }
}
Ejemplo n.º 5
0
function addTeamMember_submit($form, $form_state)
{
    $UID = dbSearchUserByEmail($form_state['values']['primaryEmail']);
    $teamName = dbGetTeamName($form_state['TID']);
    // if the user doesn't exist yet
    if ($UID == false) {
        // programmatically creates a Drupal user and sends an email to set-up account
        $UID = createNewUser($form_state);
    } else {
        $params['fullName'] = dbGetUserName($UID);
        $params['teamName'] = $teamName;
        drupal_mail('teams', 'approvedForTeam', $form_state['values']['primaryEmail'], NULL, $params, '*****@*****.**');
    }
    $notification = array('UID' => $UID, 'TID' => $form_state['TID'], 'dateCreated' => dbDatePHP2SQL(time()), 'dateTargeted' => dbDatePHP2SQL(time()));
    $notification['message'] = 'You have just been added to ' . $teamName . '!';
    $notification['bttnTitle'] = 'View Team';
    $notification['bttnLink'] = "?q=viewTeam&TID={$form_state['TID']}";
    dbAddNotification($notification);
    dbAssignUserToTeam($UID, $form_state['TID']);
    $userName = dbGetUserName($UID);
    drupal_set_message("{$userName} has been invited to your team!");
}
Ejemplo n.º 6
0
function viewUsersForTeam_submit($form, $form_state)
{
    $TID = $form_state['TID'];
    $roleChanged = false;
    for ($i = 0; $i < $form_state['numUsers']; $i++) {
        if (!isset($form_state['values']["RID-{$i}"])) {
            continue;
        }
        $UID = $form_state["UID-{$i}"];
        $newRID = $form_state['values']["RID-{$i}"];
        $oldRID = $form["RID-{$i}"]['#default_value'];
        // check if the RID changed
        if ($newRID != $oldRID) {
            // adding new role
            if ($oldRID == 0) {
                dbGiveUserRID($UID, $TID, $newRID);
            } else {
                if ($newRID != 0) {
                    $result = dbUpdateUserRole($UID, $TID, $newRID);
                } else {
                    dbRemoveAllUserRoles($UID, $TID);
                }
            }
            $userName = dbGetUserName($UID);
            drupal_set_message("{$userName}'s role has been updated.");
            $roleChanged = true;
            $notification = array('UID' => $UID, 'TID' => $TID, 'dateCreated' => date(DEFAULT_TIME_FORMAT, time()), 'dateTargeted' => date(DEFAULT_TIME_FORMAT, time()));
            // check if the user no longer has a role
            if (dbGetRoleName($newRID) == false) {
                $notification['message'] = "You are no longer a " . strtolower(dbGetRoleName($oldRID));
            } else {
                $notification['message'] = 'You are now a ' . strtolower(dbGetRoleName($newRID));
            }
            $notification['message'] .= ' on team ' . dbGetTeamName($TID) . '.';
            dbAddNotification($notification);
        }
    }
    if (!$roleChanged) {
        drupal_set_message('No changes were made. An issue occured.', 'error');
    }
}
Ejemplo n.º 7
0
function leaveTeam($TID)
{
    global $user;
    dbKickUserFromTeam($user->uid, $TID);
    dbRemoveAllUserRoles($user->uid, $TID);
    dbRemoveUserFromFutureTeamOutreach($user->uid, $TID);
    clearCurrentTeam();
    $notification = array();
    $notification['dateCreated'] = dbDatePHP2SQL(time());
    $notification['dateTargeted'] = dbDatePHP2SQL(time());
    $userName = dbGetUserName($user->uid);
    $teamName = dbGetTeamName($TID);
    $notification['message'] = "{$userName} has left team {$teamName}.";
    $notification['bttnTitle'] = "View";
    $notification['bttnLink'] = "?q=viewUser&UID={$user->uid}";
    $notification['TID'] = $TID;
    notifyUsersByRole($notification, 'teamAdmin');
    // notify team owner
    $notification['UID'] = dbGetTeam($TID)['UID'];
    dbAddNotification($notification);
    drupal_set_message("You have successfully left {$teamName}.");
    if (isset($_SERVER['HTTP_REFERER'])) {
        drupal_goto($_SERVER['HTTP_REFERER']);
    } else {
        drupal_goto('manageUserTeams');
    }
}
Ejemplo n.º 8
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.º 9
-1
function rejectUser($UID, $TID)
{
    if (teamIsIneligible($TID)) {
        drupal_set_message('Your team does not have permission to access this page.', 'error');
        drupal_goto($_SERVER['HTTP_REFERER']);
    }
    // currently delete the user's application to the team
    dbRejectUser($UID, $TID);
    $notification = array('UID' => $UID, 'TID' => $TID, 'dateCreated' => dbDatePHP2SQL(time()), 'dateTargeted' => dbDatePHP2SQL(time()));
    $notification['message'] = 'You have been rejected from ' . dbGetTeamName($TID) . '.';
    $notification['bttnTitle'] = 'Reapply';
    $notification['bttnLink'] = "?q=applyForTeamForm";
    dbAddNotification($notification);
    module_load_include('inc', 'mimemail');
    drupal_mail('teams', 'rejectedFromTeam', dbGetUserPrimaryEmail($UID), variable_get('language_default'), $params = array('teamName' => dbGetTeamName($TID), 'fullName' => dbGetUserName($UID)), $from = NULL, $send = TRUE);
    drupal_set_message("User has been rejected from your team.");
    if (isset($_SERVER['HTTP_REFERER'])) {
        drupal_goto($_SERVER['HTTP_REFERER']);
    } else {
        drupal_goto('viewUsersToBeApproved', array('query' => array('TID' => $TID)));
    }
}