/**
  * Gets existing student data from the database, creating record if necessary.
  */
 public static function getStudentData($pidm, $term)
 {
     $pidm = (int) $pidm;
     $term = (int) $term;
     $sql = sprintf('SELECT * FROM academic_excellence WHERE pidm = %d AND term = %d', $pidm, $term);
     $student = PSU::db('myplymouth')->GetRow($sql);
     if (count($student) == 0) {
         return AEStudent::createStudent($pidm, $term);
     }
     return $student;
 }
Example #2
0
/**
 * initializeSession
 *
 * Set up necessary session variables.
 */
function initializeSession()
{
    if (!isset($_SESSION['errors'])) {
        $_SESSION['errors'] = array();
    }
    if (!isset($_SESSION['messages'])) {
        $_SESSION['messages'] = array();
    }
    $_SESSION['student'] = array();
    $_SESSION['user_type'] = null;
    $_SESSION['editing'] = true;
    // first time through means we're editing
    $_SESSION['ae_init'] = true;
    $_SESSION['pidm'] = $GLOBALS['BannerIDM']->getIdentifier($_SESSION['username'], 'username', 'pidm');
    if (IDMObject::authZ('permission', 'academic_excellence_admin')) {
        $_SESSION['user_type'] = 'admin';
    } else {
        $gpa = $GLOBALS['BannerStudent']->getOverallGPA($_SESSION['pidm']);
        $_SESSION['gpa'] = $gpa['r_gpa'];
        unset($gpa);
        if ($_SESSION['username'] == 'ambackstrom') {
            $_SESSION['gpa'] = 3.5;
            // DEBUG: always let student through
        }
        // they're 'aestudent' only if their gpa qualifies
        if ($_SESSION['gpa'] < 3.5) {
            return;
        }
        $_SESSION['user_type'] = 'aestudent';
        $name = $GLOBALS['BannerStudent']->getName($_SESSION['pidm']);
        $_SESSION['student']['full_name'] = sprintf('%s %s %s', $name['r_first_name'], $name['r_mi'], $name['r_last_name']);
        $_SESSION['student']['first_name'] = $name['r_first_name'];
        $_SESSION['student']['middle_name'] = $name['r_mi'];
        $_SESSION['student']['last_name'] = $name['r_last_name'];
        unset($name);
        $student = AEStudent::getStudentData($_SESSION['pidm'], $GLOBALS['TERM']);
        $_SESSION['student'] = array_merge($_SESSION['student'], $student);
        // (confirmed != -1) means that they have already submitted the form in a previous session
        if ($student['confirmed'] > -1) {
            $_SESSION['editing'] = false;
        }
    }
}
    $value = str_replace('"', '', $value);
    $student[$key] = $value;
}
if ($student['ceremony_needs'] == $GLOBALS['SPECIAL_NEEDS_DEFAULT']) {
    $student['ceremony_needs'] = null;
}
// check for missing fields
$bad_fields = array();
foreach ($required_fields as $field => $long_desc) {
    if ($student[$field] == '') {
        array_push($bad_fields, $long_desc);
    }
}
// were there missing fields? (only check when they want the cert, otherwise we don't care)
if (count($bad_fields) > 0 && $student['confirmed_cert'] == 1) {
    $fields = implode(', ', $bad_fields);
    $error = sprintf('The following fields are required: %s.', $fields);
    $_SESSION['errors'][] = $error;
    // send them back to the input screen
    header('Location: ' . $GLOBALS['BASE_URL'] . '/');
    exit;
}
// update the table if there were no errors
$result = AEStudent::saveConfirmation($_SESSION['pidm'], $GLOBALS['TERM'], $student);
if ($result === false) {
    $_SESSION['errors'][] = 'Sorry, there was an error processing your input.';
    header('Location: ' . $GLOBALS['BASE_URL'] . '?error');
} else {
    $_SESSION['editing'] = false;
    header('Location: ' . $GLOBALS['BASE_URL']);
}
Example #4
0
<?php

/*
 * Simple script to set editing back to true and return to the main page.
 */
AEStudent::removeConfirmation($_SESSION['pidm'], $GLOBALS['TERM']);
$_SESSION['editing'] = true;
header('Location: ' . $GLOBALS['BASE_URL']);