Beispiel #1
0
function switchTeam($TID, $teamName)
{
    setCurrentTeam($TID, $teamName);
    $message = "You are now operating under {$teamName}!";
    $message .= " Click <b><a href=\"?q=makeTeamDefault/{$TID}/\">here</a></b> to set the team as default.";
    drupal_set_message($message);
    drupal_goto('viewTeam', array('query' => array('TID' => $TID)));
}
function outreachPageHeader_submit($form, &$form_state)
{
    $fields = array('team');
    $newTID = getFields($fields, $form_state['values'])['team'];
    setCurrentTeam($newTID);
    $teamNumber = dbGetTeamNumber($newTID);
    drupal_set_message("Now operating under Team {$teamNumber}!");
    drupal_goto('outreach');
}
Beispiel #3
0
function teamSummary_submit($form, &$form_state)
{
    $fields = array('team');
    $newTID = getFields($fields, $form_state['values'])['team'];
    setCurrentTeam($newTID);
    $teamNumber = dbGetTeamNumber($newTID);
    drupal_set_message("Now operating under Team {$teamNumber}!");
    drupal_goto('teamDashboard');
}
Beispiel #4
0
function viewUserStats_submit($form, &$form_state)
{
    setCurrentTeam($form_state['values']['TID']);
    drupal_set_message('Team changed!');
    drupal_goto('myDashboard');
}
Beispiel #5
0
function teamForm_submit($form, $form_state)
{
    global $user;
    $params = drupal_get_query_parameters();
    $new = !isset($params['TID']);
    // determine if adding or editing
    $names = array('name', 'number', 'type', 'city', 'state', 'country', 'FID', 'rookieYear');
    $row = getFields($names, $form_state['values']);
    $row = stripTags($row, '');
    if ($row['rookieYear'] === '') {
        $row['rookieYear'] = null;
    }
    if ($new) {
        // team doesn't exist yet
        $row['UID'] = $user->uid;
        $TID = dbCreateTeam($row);
    } else {
        $result = dbUpdateTeam($params['TID'], $row);
        if ($result) {
            $TID = $params['TID'];
            if (!teamIsIneligible($TID)) {
                setCurrentTeam($params['TID'], $row['name']);
            }
        } else {
            drupal_set_message('Error in updating team', 'error');
            return;
        }
    }
    if ($TID != false) {
        if ($new) {
            // if team is submitted correctly
            drupal_set_message('Your team form has been submitted. The CROMA team will contact you when your team has been successfully created.');
            dbGiveUserRole($user->uid, $TID, 'teamOwner');
            dbAssignUserToTeam($user->uid, $TID);
            // send email
            $params = array('TID' => $TID, 'name' => $row['name'], 'number' => $row['number'], 'user' => $user->uid, 'userName' => dbGetUserName($user->uid));
            drupal_mail('teams', 'teamCreated', '*****@*****.**', variable_get('language_default'), $params, $from = NULL, $send = TRUE);
            drupal_goto('teamDashboard');
        } else {
            drupal_set_message('Your team has been updated!');
            if (!dbIsTeamApproved($TID)) {
                drupal_goto('manageUserTeams');
            } else {
                drupal_goto('viewTeam', array('query' => array('TID' => $params['TID'])));
            }
        }
    } else {
        // if something went wrong...
        drupal_set_message('Error creating team. Please try again.');
    }
}