session_start();
if (!session_is_registered("LLC"))
{
// if session check fails, invoke error handler
header("Location: /login/loginform.php");
exit();
}
$user = $_SESSION['UNAME'];
include_once("../../includes/llcrewards/dbhelperfunctions.php");
include_once("../../includes/llcrewards/uihelperfunctions.php");
$err = "";
$action = "";
$searchusername = "";
$searchid = "";
$studentid = "";
$lastname = "";
$firstname = "";
$gender = "";
$email = "";
$username = "";
$password = "";
$membersince = date("m-d-Y");
$status = "";
$avatar = "";
$welcomedate = "";
$enablefields = true;
$numPassports = 0;
$readonlyFlag = ""; //is set to readonly if editing an existing record.
$action = isset($_GET["a"]) ? $_GET["a"] : ''; //new-1, edit-2
$searchusername = isset($_GET["u"]) ? $_GET["u"] : ''; //if u=blank then behave as new profile
$searchid = isset($_GET["si"]) ? $_GET["si"] : ''; //search student id
$err = isset($_GET["e"]) ? $_GET["e"] : ''; //error code
$dupUsername = isset($_GET["eu"]) ? $_GET["eu"] : ''; //error code
$dupStudentid = isset($_GET["ei"]) ? $_GET["ei"] : ''; //error code
//just incase no search params are provided
if (($searchusername == "") and ($searchid == ""))
{
$action = "1";
}
else
{
//if username or studentid provided, then it is a look up and edit
//if ($action == "2") //edit or search
$participantList = getParticipantsByIDUsername($searchusername, $searchid);
if (sizeof($participantList) == 0)
{
$action = "1"; //user not found, display nothing
$err = "1";
}
else
{
$participant = reset($participantList); //get the first (and only) element
$recordid = trim($participant['id']);
$studentid = trim($participant['studentid']);
$lastname = trim($participant['lastname']);
$firstname = trim($participant['firstname']);
$gender = trim($participant['gender']);
$email = trim($participant['email']);
$username = trim($participant['username']);
$password = trim($participant['password']);
$membersince = trim($participant['membersince']);
$status = trim($participant['status']);
$avatar = trim($participant['avatar']);
$welcomedate = trim($participant['welcomedate']);
$enableFields = false;
$passportArray = getPassportListByUsername($username);
$action = "2"; //since the info will be displayed for editing
$readonlyFlag = "readonly";
}
}
switch ($err)
{
case "0":
$errmsg= "Changes saved";
break;
case "1":
$errmsg= "Username and/or Student ID not found.";
break;
case "2":
$errmsg= "Error saving changes.";
break;
case "3":
$errmsg= "Duplicate found. ".$dupUsername." ".$dupStudentid." already exists.";
break;
case "4":
$errmsg= "Error occurred while deleting passport. Try again.";
break;
default:
$errmsg= "Asterisked (*) fields are required. Save new profiles before adding languages.";
}
$passportTerm="";
$passportYear="";
$passportLinks="";
if (sizeof($passportArray) > 0)
{
$lastTerm = "";
$lastYear = "";
foreach ($passportArray as $passport)
{
$passportTerm = $passport['term'];
$passportYear = $passport['year'];
$passportLang = $passport['language'];
if ((($lastTerm == "") and ($lastyear == "")) or
(($lastTerm == $passportTerm) and ($lastYear == $passportYear)))
{
$lastTerm = $passportTerm;
$lastYear = $passportYear;
$passportLinks = "/llc/llcrewards/passport.php?l=".$passportLang."&u=".$username."&t=".$passportTerm."&y=".$passportYear."
".$passportLinks;
}
elseif (($passportTerm <> $lastTerm) or ($passportYear <> $lastyear))
{
break 1;
}
}
reset($passportArray);
}
?>