Example #1
0
function thumbnailForm_submit($form, $form_state)
{
    $params = drupal_get_query_parameters();
    // getting the inputted info from the fields
    $fields = array("FID");
    $picData = getFields($fields, $form_state['values']);
    $picData = stripTags($picData, '');
    $oldFID = isset($form_state['oldFID']) ? $form_state['oldFID'] : 0;
    if (isset($params["UID"])) {
        // if updating user's profile picture
        $UID = $params["UID"];
        replacePicture($picData['FID'], $oldFID, 'Users');
        dbUpdate("profiles", $picData, "UID", $UID);
        drupal_goto("viewUser", array('query' => array('UID' => $UID)));
    } else {
        if (isset($params["OID"])) {
            // if editing outreach thumbnail
            $OID = $params["OID"];
            replacePicture($picData['FID'], $oldFID, 'Outreach');
            dbUpdateOutreach($OID, $picData);
            drupal_goto("viewOutreach", array('query' => array('OID' => $OID)));
        } else {
            if (isset($params["TID"])) {
                // if editing team thumbnail
                $TID = $params["TID"];
                replacePicture($picData['FID'], $oldFID, 'Teams');
                dbUpdateTeam($TID, $picData);
                drupal_goto("viewTeam", array('query' => array('TID' => $TID)));
            } else {
                drupal_goto("myDashboard");
            }
        }
    }
}
function transferTeamOwnershipForm_submit($form, $form_state)
{
    global $user;
    // update the team and the new owner's role
    $newOwnerUID = $form_state['values']['newOwner'];
    $TID = $form_state['TID'];
    dbUpdateTeam($TID, array('UID' => $newOwnerUID));
    dbUpdateUserRole($newOwnerUID, $TID, dbGetRID('teamOwner'));
    dbUpdateUserRole($user->uid, $TID, dbGetRID('teamAdmin'));
    // set a message to notify the old owner on-screen
    $newOwnerName = dbGetUserName($newOwnerUID);
    $teamName = dbGetTeamName($TID);
    drupal_set_message("{$newOwnerName} is now the owner of {$teamName}!");
    // notify new owner through CROMA
    $notification = array('UID' => $newOwnerUID, 'TID' => $TID, 'dateTargeted' => dbDatePHP2SQL(time()), 'dateCreated' => dbDatePHP2SQL(time()));
    $notification['message'] = "You are now the owner of {$teamName}!";
    $notification['bttnTitle'] = 'View';
    $notification['bttnLink'] = "?q=viewTeam&TID=" . $TID;
    dbAddNotification($notification);
    // notify new owner through email
    $oldOwnerName = dbGetUserName($user->uid);
    $oldOwnerEmail = $user->mail;
    drupal_mail('teams', 'becameOwner', dbGetUserPrimaryEmail($newOwnerUID), variable_get('language_default'), $params = array('teamName' => $teamName, 'newOwnerName' => $newOwnerName, 'oldOwnerName' => $oldOwnerName, 'oldOwnerEmail' => $oldOwnerEmail, 'TID' => $TID), $from = NULL, $send = TRUE);
    drupal_goto('showUsersForTeam', array('query' => array('TID' => $TID)));
}
Example #3
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.');
    }
}