Exemplo n.º 1
0
function dbDeleteNotification($NID)
{
    return dbRemoveEntry("notifications", 'NID', $NID);
}
Exemplo n.º 2
0
function profileForm_submit($form, $form_state)
{
    global $user;
    $params = drupal_get_query_parameters();
    if (!isset($params['UID'])) {
        $UID = $user->uid;
    } else {
        $UID = $params['UID'];
    }
    // getting the inputted info from the fields
    $fields = array("firstName", "lastName", "position", "phone", "grade", "gender", "FID", "type");
    $profileData = getFields($fields, $form_state['values']);
    $profileData = stripTags($profileData, '');
    $profileData['UID'] = $UID;
    $profileData['bio'] = stripTags(array($form_state['values']['bio']));
    // allow some tags in the bio only
    if (dbUserHasProfile($profileData['UID']) == false) {
        // if the user doesn't have a profile
        $result = dbCreateProfile($profileData);
        // creating new profile
        if ($result != false) {
            drupal_set_message("Your profile has been created!");
            // if it went through successfully
        } else {
            drupal_set_message("There was an error.");
            // if something "bad" occured during submission
        }
    } else {
        // if the user is simply editing existing profile
        dbUpdate("profiles", $profileData, "UID", $profileData['UID']);
        drupal_set_message("Profile has been updated!");
    }
    if (!empty($form_state['values']['secondaryEmail'])) {
        // user entered value
        if (dbGetSecondaryEmailForUser($profileData['UID']) == false) {
            // the user is adding a new secondary email
            dbAddEmailsToUser($profileData['UID'], array(trim($form_state['values']['secondaryEmail'])));
        } else {
            //  user is updating an old email
            dbUpdate('emailsVsUsers', array('email' => $form_state['values']['secondaryEmail']), "UID", $profileData['UID']);
        }
    } else {
        // user didn't enter value
        dbRemoveEntry('emailsVsUsers', 'UID', $profileData['UID']);
    }
    drupal_goto("viewUser", array('query' => array('UID' => $UID)));
}