public function showUserPopup($userID, $showAll = false) { $db = new DB(); if ($showAll) { $rows = $db->select2("id, firstName,lastName", "users", "", "userPriv, lastName"); } else { $rows = $db->select2("id, firstName,lastName", "users", "userPriv='S'", "lastName"); } echo '<div class="btn-group">' . "\n"; echo ' <select class="form-control" name="userPopup" id="userPopup">' . "\n"; if ($db->numRows == 0) { echo ""; } elseif ($db->numRows == 1) { echo '<option value="' . $rows["id"] . '">' . $rows["firstName"] . " " . $rows["lastName"] . "\n"; } else { foreach ($rows as $row) { if ($userID == $row["id"]) { echo '<option selected value="' . $row["id"] . '">' . $row["firstName"] . " " . $row["lastName"] . "\n"; } else { echo '<option value="' . $row["id"] . '">' . $row["firstName"] . " " . $row["lastName"] . "\n"; } } } echo ' </select>' . "\n"; echo '</div>' . "\n"; }
public function getAnswers($fromID = "", $toID = "") { $answers = array(); // Construct the where clause from supplied fromID and toID. $db = new DB(); if ($fromID != "") { $whereClause = "fromID = '{$fromID}'"; } else { $whereClause = ""; } if ($toID != "") { if ($whereClause != "") { $whereClause .= " and "; } $whereClause .= "toID = '{$toID}'"; } $rows = $db->select2("id", "answer", $whereClause); // Process the resulting answer. if ($db->numRows == 0) { return $answers; } elseif ($db->numRows == 1) { $answers[0] = $rows["id"]; } else { $i = 0; foreach ($rows as $row) { $answers[$i++] = $row["id"]; } } return $answers; }
public function modify() { $db = new DB(); $whereClause = "questionID=" . $this->questionID . " and fromID='" . $this->fromID . "' and toID='" . $this->toID . "'"; $results = $db->select2("id", "answer", $whereClause); if ($db->numRows == 0) { $this->insert(); } else { $this->id = $results["id"]; $this->update(); } }
public function showFormQuestions($formID, $whereTo = "#") { $db = new DB(); $rows = $db->select2("question.id, question.title", "formQuestions,form, question", "formID={$formID} and form.id=formID and question.id=questionID"); if ($db->numRows == 0) { echo "There are no questions on this form yet."; } elseif ($db->numRows == 1) { echo '<h2>Questions:</h2>'; echo '<a href="' . $whereTo . '?questionID=' . $rows["id"] . '" class="list-group-item form-control">' . $rows["title"] . "</a>\n"; } else { echo '<h2>Questions:</h2>'; foreach ($rows as $row) { echo '<a href="' . $whereTo . '?questionID=' . $row["id"] . '" class="list-group-item form-control">' . $row["title"] . "</a>\n"; } } echo "<br />\n"; }
public function getEndorsements() { $db = new DB(); $results = $db->select2("sum(endorsements.count) AS count", "((endorsements join students on endorsements.student_id = students.id) join technologies on technologies.id = endorsements.technology_id)", "endorsements.student_id = {$this->id}", "", ""); return $results[0]['count']; }
//get the user object from the session $userID = $_SESSION["userID"]; $uTool = new UserTools(); $user = $uTool->get($userID); $fromID = ""; $fromUser = null; // // See who is selected from the user popup menu. This is // who we want to see comments from. // if (isset($_POST['fromID'])) { $fromID = $_POST['fromID']; } else { // If no one is selected, select the first one in the menu. $db = new DB(); $rows = $db->select2("id", "users", "", "userPriv, lastName"); $fromID = $rows[0]["id"]; } $fromUser = $uTool->get($fromID); ?> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="User login." content=""> <meta name="Dr. Brown" content=""> <link rel="shortcut icon" href="images/favicon.png"> <title>Commentz From:</title>
public static function fetchAll($filterStr, $sortStr) { $filters = array("past" => "date < now()", "future" => "date IS NULL OR date > now()", "my" => "org_id = " . HttpSession::currentUser()->getOrganization()->id, "open" => "org_id IS NULL"); $where = isset($filters[$filterStr]) ? $filters[$filterStr] : $filters["future"]; $sorters = array("date" => "date DESC", "duration" => "duration DESC", "updated" => "updated DESC", "title" => "title asc"); $orderBy = isset($sorters[$sortStr]) ? $sorters[$sortStr] : $sorters["updated"]; $db = new DB(); $results = $db->select2("*", "sessions", $where, "", $orderBy); $sessions = array(); foreach ($results as $result) { array_push($sessions, new Session($result)); } return $sessions; }