function getDetails($email, $name) { $query = "SELECT `User ID` FROM `TUSERS` WHERE `Email` = '{$email}'"; try { return db_select_single_exception($query, $name); } catch (Exception $ex) { $msg = "Incorrect username/password, please try again."; returnToPageError($msg, $email); } }
include_once $include_path . '/public_html/classes/AllClasses.php'; include_once $include_path . '/public_html/includes/htmlCore.php'; sec_session_start(); $resultArray = checkUserLoginStatus(filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING)); if ($resultArray[0]) { $loggedInUser = $_SESSION['user']; $fullName = $loggedInUser->getFirstName() . ' ' . $loggedInUser->getSurname(); $loggedInUserId = $loggedInUser->getUserId(); } else { header($resultArray[1]); exit; } $userid = filter_input(INPUT_GET, 'userid', FILTER_SANITIZE_STRING); $query = "SELECT `Role` FROM TUSERS WHERE `User ID` = {$userid}"; try { $role = db_select_single_exception($query, 'Role'); } catch (Exception $ex) { header("Location: ../portalhome.php"); exit; } if ($role == 'STUDENT') { $user = Student::createStudentFromId($userid); $prefName = $user->getPrefferedName(); $dob = $user->getDateOfBirth(); $hideStaff = 'style="display:none;"'; $hideStudents = ''; } else { $user = Teacher::createTeacherFromId($userid); $title = $user->getTitle(); $initials = $user->getInitials(); $classroom = $user->getClassroom();
$query = "SELECT G.`Group ID` ID, G.Name Name " . "FROM TUSERGROUPS U JOIN TGROUPS G ON U.`Group ID` = G.`Group ID` " . "WHERE `User ID` = {$staffId} AND G.`Type ID` = 3 AND U.`Archived` <> 1 ORDER BY G.Name;"; try { $sets = db_select_exception($query); if ($setId == 0 && count($sets) > 0) { $setId = $sets[0]['ID']; } $message = filter_input(INPUT_GET, 'msg', FILTER_SANITIZE_STRING); $type = filter_input(INPUT_GET, 'err', FILTER_SANITIZE_STRING); } catch (Exception $ex) { errorLog($ex->getMessage()); $success = FALSE; $message = "There was an error loading the markbook."; $type = "ERROR"; } try { $set = db_select_single_exception("SELECT Name FROM TGROUPS WHERE `Group ID` = {$setId};", "Name"); } catch (Exception $ex) { $set = ""; } $postData = array("set" => $setId, "staff" => $staffId, "type" => "MARKBOOKFORSETANDTEACHER", "userid" => $userid, "userval" => $userval); $resp = sendCURLRequest("/requests/getMarkbook.php", $postData); $respArray = json_decode($resp[1], TRUE); if ($respArray["success"]) { $success = isset($success) ? $success : TRUE; $students = $respArray["students"]; $worksheets = $respArray["worksheets"]; $results = $respArray["results"]; $blankCols = max([10 - count($results), 0]); $noStudents = count($students) == 0; } else { $success = FALSE;
function updateTag($string, $nberror) { $array = explode(':', $string); $qid = $array[0]; $tagid = $array[1]; $type = $array[2]; if ($type == 'NEW') { //Add a brand new tag //Check if the tag is actually new or not, if not then just add the question try { try { $query1 = "SELECT `Tag ID` FROM TTAGS WHERE `Name` = '{$tagid}'"; $newtagid = db_select_single_exception($query1, "Tag ID"); } catch (Exception $ex) { if ($ex->getCode() === 199) { $now = date("Y-m-d H:i:s", time()); $query = "INSERT INTO `TTAGS`(`Name`, `Date Added`) VALUES ('{$tagid}','{$now}');"; $resultArray = db_insert_query_exception($query); $newtagid = $resultArray[1]; } else { $nberror[] = "There was a problem adding the tag '{$tagid}'."; return $nberror; } } $query = "INSERT INTO `TQUESTIONTAGS` (`Tag ID`, `Stored Question ID`) VALUES ({$newtagid}, {$qid});"; db_query_exception($query); } catch (Exception $ex) { $nberror[] = "There was a problem adding the tag '{$tagid}'."; return $nberror; } } else { if ($type == 'ADD') { //Add a new tag for the question $query = "INSERT INTO `TQUESTIONTAGS` (`Tag ID`, `Stored Question ID`) VALUES ({$tagid}, {$qid});"; try { db_query_exception($query); } catch (Exception $ex) { $nberror[] = "There was a problem adding a tag for an unknown question."; return $nberror; } } else { if ($type == 'DELETE') { //Delete a tag $query = "DELETE FROM `TQUESTIONTAGS` WHERE `Tag ID` = {$tagid} AND `Stored Question ID` = {$qid}"; try { db_query_exception($query); } catch (Exception $ex) { $nberror[] = "There was a problem deleting a tag."; return $nberror; } } else { $nberror[] = "There was a problem saving a tag."; return $nberror; } } } return $nberror; }