/** * description: Returns an array with the given user's info, except for the password * * @param username: The user to retrieve the info of * @return array: The user's info in an array */ public function getUserInfo($username) { $id = parent::getUserID($username); $resourceid = $this->_dbConnection->selectFromTable("RoboUsers", "UserID", $id); $arrInfo = $this->_dbConnection->formatQuery($resourceid); unset($arrInfo[0]["UserPassword"]); // removes the user's password from the array of info for security, because it will not be needed when calling this method return $arrInfo[0]; }
/** * combines all other methods under one hood. returns true on success and if the username is taken message on failure. */ public function register($username, $password, $phonenumber, $type = null) { $code = md5(mt_rand()); $username = parent::sanitize($username); $password = parent::sanitize($password); $phonenumber = parent::sanitize($phonenumber); $result = $this->inputNewUser($username, $password, $phonenumber, $code, $type); // inputs a new user if username is not taken if ($result) { //$this->inputEmail($username); // this method becomes useful if everyone uses a school email, because then the method can just concatenate the school's domain to the end of the username. $this->activateNewUser($username, $code); return true; // success in inputting user } else { return false; // username already taken } }
/** * combines all other methods under one hood. returns true on success and the username is taken message on failure. */ public function register($username, $password, $phonenumber) { $code = md5(mt_rand()); $username = parent::sanitize($username); $password = parent::sanitize($password); $phonenumber = parent::sanitize($phonenumber); $result = $this->inputNewUser($username, $password, $phonenumber, $code); // result stores false or text string 'true' depending on the outcome of the input method if ($result) { //print 'result is TRUE'; $this->inputEmail($username); $this->emailNewUser($username, $code); return true; // success in inputting user } else { return false; // username already taken } }
echo "<p>Please specify a valid username.</p>"; } } ?> </table> <br /> <h2>Email List</h2> <table class="clearfix"> <form method="post" name="form5" action=""> <fieldset> <input name="emails" type="submit" class="getdate" value="Get Emails" /> </fieldset> </form> <?php if (isset($_POST['emails'])) { $api = new roboSISAPI(); $arr_emails = $api->getAllEmails(); $arr_emails = json_decode($arr_emails); $numemails = count($arr_emails); echo "<p>There are {$numemails} emails currently in the database.</p>"; for ($i = 0; $i < $numemails; $i++) { $cl = ""; //if ($i % 2 == 0) // allows table to alternate colors //{ // $cl = "r1"; //} //else //{ // $cl = "r2"; //} echo "<tr class=\"" . $cl . "\"><td>" . $arr_emails[$i] . ",</td></tr>";
<?php echo "<div id=\"nav\">\n\t\t\t\t<div id=\"navbar\">\n\t\t\t\t\t<ul>\n\t\t\t\t\t\t<li><a href=\"dashboard.php\">Home</a></li>\n\t\t\t\t\t\t<li><a href=\"profilepage.php\">My Profile</a></li>\n\t\t\t\t\t\t<li><a href=\"viewmyforms.php\">Purchase Orders</a></li>"; $username = $_SESSION['robo']; $api = new roboSISAPI(); if ($api->isAdmin($username)) { echo '<li><a href="billOfMaterials.php">Bill Of Materials</a></li>'; echo '<li><a href="admin_dashboard.php">Admin</a></li>'; } echo "</ul>\n\t\t\t\t</div>\n\t\t\t\t<div id=\"login_status\">\n\t\t\t\t\t<p>Logged in as: "; echo $_SESSION['robo']; // echos the username echo "</p>\n\t\t\t\t\t<form method=\"post\" name=\"form\" action=\"\">\n\t\t\t\t\t<fieldset>\n\t\t\t\t\t\t<input name=\"logout\" type=\"submit\" class=\"logout\" value=\"Logout\" />\n\t\t\t\t\t</fieldset>\n\t\t\t\t\t</form>\n\t\t\t\t</div> <!-- end of login_status -->\n\t\t\t</div>\n\t\t\t<h1>The Harker School - Robotics Team 1072</h1>";
<div id="dashboardWindow" class="clearfix"> <?php include "navbar.php"; ?> <div id="dashboard-checkin" class="clearfix"> <div id="forms" class="clearfix"> <h2>Purchase Order Forms - View All Forms</h2> <ul> <li><a href="submitform.php">Submit a Form</a></li> <li><a href="viewmyforms.php">View My Forms</a></li> <li class="form-selected">View All Forms</li> <?php $username = $_SESSION['robo']; $api = new roboSISAPI(); if ($api->isAdmin($username)) { echo '<li><a href="adminviewpending.php">Admin Pending</a></li>'; } if ($api->isMentor($username)) { echo '<li><a href="mentorviewpending.php">Mentor Pending</a></li>'; } ?> </ul> </div> <div id="selectdate-form"> <form method="post" name="form4" action="" style="float:right"> <fieldset> <p> Search:
public function __construct() { parent::__construct(); }
$possibilities = array('../controllers' . DIRECTORY_SEPARATOR . $className . '.php', '../back_end' . DIRECTORY_SEPARATOR . $className . '.php', '../views' . DIRECTORY_SEPARATOR . $className . '.php', $className . '.php'); foreach ($possibilities as $file) { if (file_exists($file)) { require_once $file; return true; } } return false; }); if (is_null($_GET['id'])) { header('Location: viewmyforms.php'); // if there is no order to view, redirects to viewmyforms page exit; } $username = $_SESSION['robo']; $api = new roboSISAPI(); if (!$api->isMentor($username)) { header('Location: index.php'); exit; } $controller = new financeController(); $orderID = $_GET['id']; if ($controller->isMentorApproved($orderID)) { header("Location: mentorviewpending.php"); } if (isset($_POST['approve'])) { $comment = $_POST['comment']; $controller->setMentorApproval($orderID, true, $comment); header("Location: mentorviewpending.php"); } if (isset($_POST['reject'])) {
<form method="post" name="form2" action=""> <fieldset> <input name="checkin" type="submit" class="checkin" value="Check-In" /> </fieldset> </form> </div> <h2>Recent Check-Ins</h2> <p class="clearfix"> <ul> <?php function __autoload($class) { require_once $class . '.php'; } $username = $_SESSION['robo']; $api = new roboSISAPI(); if (isset($_POST['checkin'])) { $api->inputCheckIn($username); } //echo 'here'; $result = $api->getCheckIns($username); //echo $result; $table = json_decode($result); for ($i = 0; $i < count($table); $i++) { echo "<li>" . $table[$i] . "</li>"; //echo "<br />"; } ?> </ul> </p> </div>
/** * Sets a user's type as "Admin" * * @param username: The username to give admin access to * @return void */ public function setAdmin($username) { $id = parent::getUserID($username); $arrVals = array("UserType" => "Admin"); $this->_dbConnection->updateTable("RoboUsers", "RoboUsers", "UserID", $id, "UserID", $arrVals, "UserID = {$id}"); }
<?php // autoloader code // loads classes as needed, eliminates the need for a long list of includes at the top spl_autoload_register(function ($className) { $possibilities = array('../controllers' . DIRECTORY_SEPARATOR . $className . '.php', '../back_end' . DIRECTORY_SEPARATOR . $className . '.php', '../views' . DIRECTORY_SEPARATOR . $className . '.php', $className . '.php'); foreach ($possibilities as $file) { if (file_exists($file)) { require_once $file; return true; } } return false; }); $api = new roboSISAPI(); //print_r($api->getCheckIns("12rohits"); //$jk = 1399924; //$di = 1; //$api->inputCheckIn($jk,"12rohits"); //print_r($api->getUserID("12rohits")); //$api->getAllEmails(); //$api->getUserType("12rohits"); $api->getMentorsEmail();
<?php // autoloader code // loads classes as needed, eliminates the need for a long list of includes at the top spl_autoload_register(function ($className) { $possibilities = array('../controllers' . DIRECTORY_SEPARATOR . $className . '.php', '../back_end' . DIRECTORY_SEPARATOR . $className . '.php', '../views' . DIRECTORY_SEPARATOR . $className . '.php', $className . '.php'); foreach ($possibilities as $file) { if (file_exists($file)) { require_once $file; return true; } } return false; }); $api = new roboSISAPI(); //print_r($api->getCheckIns("12rohits"); //$jk = 1399924; //$di = 1; //$api->inputCheckIn($jk,"12rohits"); //print_r($api->getUserID("12rohits")); //$api->getAllEmails(); //$api->getUserType("12rohits"); $api->getUsersCheckedInForDate(20111005);
/** * description: Emails the mentor when an order is Pending Mentor Approval. * * @param orderID: The ID of the order which the notification is about. * @param vendorname: The name of the vendor of the given order. * @param submittinguser: The user who submitted the order. * @return boolean: true if mail was sent successfuly, false otherwise. */ public function notifyMentorOfPending($orderID, $vendorname, $submittinguser) { $to = parent::getMentorsEmail(); $subject = "Robotics PO System: OrderID #{$orderID} is awaiting your approval"; $message = "Hello, \n\nThe purchase order with OrderID #{$orderID} and vendor \"{$vendorname}\" has been submitted by {$submittinguser} for your approval. You can approve or reject the order at {$this->_serverURL}/views/mentorvieworder.php?id={$orderID}. \n\n - The Robotics 1072 Web Team"; $header = "From: harker1072@gmail.com"; //print_r($to); //print_r($subject); //print_r($message); //print_r($header); $result = mail($to, $subject, $message, $header); // returns true on delivery return $result; }