Exemplo n.º 1
0
    $specialHrs = $groupInfo['hours'];
}
$insertString = "";
$curWeekUpdateString = "";
$nextWeekUpdateString = "";
$restUpdateString = "";
//Array to hold users being added (error-free)
$usersAddedArray = array();
//Array holding users + info to be added to permission table
$insertArray = array();
//Arrays to hold error users
$alreadyInGroupArray = array();
$notInMasterArray = array();
$badEmailUsers = array();
foreach ($fileLines as $user) {
    $netid = getNetId($user);
    if ($netid) {
        //$netid != false
        if (!userInGroup($db, $netid, $groupID)) {
            // user is NOT already in group, continue with addition
            if (userInMasterList($db, $netid)) {
                array_push($usersAddedArray, $netid);
                // add user to permissions table
                // specialHrs = 0 if the group has weekly hours
                $insertString .= "(?,?,?), ";
                array_push($insertArray, $netid, $groupID, $specialHrs);
                if (groupHasCurWeekHours($groupInfo)) {
                    // if group has weekly hours that are currently active,
                    // they should be immediately given to the user
                    $curWeekUpdateString .= "uID = ? OR ";
                }
 $badFormatUsers = [];
 $badClassUsers = [];
 $badEmailUsers = [];
 //Arrays to hold query values
 $insertMasterArray = array();
 $insertUserArray = array();
 //process each user
 foreach ($fileLines as $user) {
     $userData = explode(",", $user);
     // userData should have format <*****@*****.**>,<firstName>,<lastName>,<type>
     if (4 == sizeof($userData)) {
         // userData has expected number of elements
         if (checkClass($userData[3])) {
             // type is expected format; "Student" | "Faculty" | "Admin"
             // TODO: check length and format of elements
             $netid = getNetId($userData[0]);
             if ($netid) {
                 //$netid != false
                 // ('id', 'department')
                 $insertMasterString .= "(?, ?), ";
                 array_push($insertMasterArray, $netid, $department);
                 $curUserInfo = getCurUserInfo($db, $netid);
                 // check if user is already in User table. If they are, update their personal info if it's different
                 // if they are not in the User table, add them.
                 if (empty($curUserInfo)) {
                     //user not in User table, add them to user table
                     //('uID', 'firstName', 'lastName', 'class', 'curWeekHrs', 'nextWeekHrs', 'thirdWeekHrs', 'hasBookingDurationRestriction')
                     $insertUserString .= "(?, ?, ?, ?, ?, ?, ?, ?), ";
                     array_push($insertUserArray, $netid, $userData[1], $userData[2], $userData[3], $defaultHrs, $defaultHrs, $defaultHrs, 'Yes');
                     // get class, etc
                 } else {