function CurrEvents() { // returns all events you are apart of except for groups global $conn; date_default_timezone_set("America/New_York"); $eventmax = date('Y-m-d H:i:s', strtotime("+5 days")); // add an hour to the event for the end time $sql = "SELECT events.eventName,events.startTime FROM events WHERE events.userID = " . $_COOKIE['userID'] . " AND events.startTime <= '{$eventmax}' AND events.groupID IS NULL ORDER BY events.startTime LIMIT 20 "; // returns only the events that are from todays date to +5 days. $results = $conn->query($sql); if ($results->num_rows > 0) { // checks to make sure there are events, if 0 there are none and echos that out. foreach ($results as $val) { echo "<li class=\"currentgroup owngroup\"><p>" . $val['eventName'] . "</p> Starting: " . fetchDate($val['startTime']) . "</li>"; // if it finds any then it returns them. } } }
function displaygroupinfo($groupID, $eventbool, $passfail, $members, $events) { global $locationName; global $locationState; global $locationCity; global $conn; global $userID; $isfounder = false; if ($passfail == true) { // part of the group/public group //--- SECTION:VIEWABLE TO ALL USERS ---- $classname = "SELECT class.courseTitle FROM class INNER JOIN study_groups ON class.courseID = study_groups.courseID WHERE study_groups.groupID = {$groupID}"; // Select the courseTitle $course = $conn->query($classname); foreach ($course as $name) { echo "<h2 id='course'>" . $name['courseTitle'] . "</h2>"; //Course Title that the group is studing } echo "<section id='memberlist'><h4> Member List: </h4><ul>"; // MEMBERS LIST! for ($i = 0; $i < count($members); $i++) { // prints out all members of this group $sql = "SELECT fname,lname FROM users WHERE userID = " . $members[$i]; // select the fname and lname $membernamnes = $conn->query($sql); foreach ($membernamnes as $names) { // go through all values echo "<li>" . $names['fname'] . " " . $names['lname'] . "</li>"; // PRINT! } } echo "</ul></section>"; //--- END SECTION ---- if ($eventbool == true) { //--- SECTION:VIEWABLE TO ONLY MEMBERS OF THE GROUP ---- $locationID; foreach ($events as $vent) { $locationID = $vent['locationID']; } $locationsql = "SELECT locationName,locationCity,locationState FROM locations where locationID = {$locationID}"; // get the location $location = $conn->query($locationsql); foreach ($location as $local) { // print the location $locationName = $local['locationName']; echo "<section class='inline' id='location'>Where: " . $local['locationName'] . "</section>"; } $meetingTime = "SELECT * FROM study_groups WHERE groupID = {$groupID}"; $meetingTimeResult = $conn->query("{$meetingTime}"); $time = $meetingTimeResult->fetch_assoc(); echo "<p id='meetingtime'>When: " . fetchDate($time['meetingTime']) . "</p>"; if ($time['founderID'] == $userID) { // if the userID in cookies is the same as the founder id $isfounder = true; } $jsonfile = $time['json']; $json = file_get_contents($jsonfile); $jsondata = json_decode($json, true); echo "<strong>Useful Links:</strong><ul>"; // display the useful links to the users foreach ($jsondata as $links) { foreach ($links as $anchor) { echo "<li><a class=\"grouplinks\" target='_blank' href=\"" . $anchor['link'] . "\">" . $anchor['title'] . "</a></li>"; } } echo "</ul>"; if ($isfounder) { // STUFF FOR THE FOUNDER ONLY echo "<h5 class='settingshead'>Add a link</h5>"; echo "<form id=\"add\" action=\"group.php?id={$groupID}\" method=\"POST\">Name: <input id='txtpadname' type=\"text\" name=\"title\" ><button class='btn btn-default btnright' type=\"submit\">Add</button><br>"; // form to add useful links echo "Link: <input id='txtpadlink' type=\"text\" name=\"link\"><input type=\"hidden\" name=\"jsonf\" value=\"{$jsonfile}.\"></form>"; echo "<h5 class='settingshead'>Add a member</h5>"; echo "<form method='POST' action='group.php?id={$groupID}'>"; //For for the founder to add a member echo "<input type='text' name='email' value='Member Email'>"; echo "<input class='btn btn-default btnright' type='submit' name='addemail' value='Add Member'>"; echo "<h5 class='settingshead'>Leave Group</h5>"; echo "<form method='POST' action='group.php?id={$groupID}'>"; //Form to delete the group. echo "<input class='btn btn-default btnright' type='submit' name='removegroup' value='Delete Group'>"; } else { // STUFF FOR EVERYONE ELSE echo "<h5 class='settingshead'>Leave Group</h5>"; echo "<form method='POST' action='group.php?id={$groupID}'>"; // Creates a form that users can use to join the group is public - ONLY shows to users at a public group in which they are not members of and signed in echo "<input class='btn btn-default btnright' type='submit' name='removeself' value='Remove Me'>"; } //--- END SECTION ---- } else { //--- SECTION:VIEWABLE TO ALL USERS SIGNED IN---- if ($userID == 0) { echo "<h5 class='settingshead'> Join this Group </h5>"; echo "<form method='POST' action='login.php'>"; // Creates a form that when submited will redirect to the login page because the user is not signed in. echo "<input class='btn btn-default' type='submit' name='submit' value='Join'>"; } else { echo "<h5 class='settingshead'> Join this Group </h5>"; echo "<form method='POST' action='group.php?id={$groupID}'>"; // Creates a form that users can use to join the group is public - ONLY shows to users at a public group in which they are not members of. echo "<input class='btn btn-default' type='submit' name='submit' value='Join'>"; } //--- END SECTION ---- } } else { // group private and not apart of the group echo "Sorry, you are not apart of this group and this group is private"; } }