Skip to content

Commit

Permalink
Fixed overwrite bug
Browse files Browse the repository at this point in the history
Events from BC event calendar would overwrite events with the same name
and time as org sync events.
  • Loading branch information
evanotero committed Aug 24, 2016
1 parent c1801d3 commit e30e467
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions includes/fetcheventcalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,24 @@
}

// Query to see if event already exits in database
$query1 = "select NAME from events where NAME = '$name' AND STARTDATE = '$date'";
$query1 = "select NAME from events where NAME = '$name' AND STARTDATE = '$date' AND U_ID = 2";
$result1 = perform_query( $dbc, $query1);

$query2 = "select NAME from events where LINK = '$eventlink' AND STARTDATE = '$date'";
$query2 = "select NAME from events where LINK = '$eventlink' AND STARTDATE = '$date' AND U_ID = 2";
$result2 = perform_query( $dbc, $query2);

if (mysqli_fetch_array($result1, MYSQLI_ASSOC)) {
// Event already exists with this name and date
$query = "UPDATE events
SET ORGANIZER = '$group', LOCATION = '$location', DESCRIPTION = '$description',
MEDIAURL = '$mediaurl', LINK = '$eventlink', HIDDENINFO = '$fulltitle'
WHERE NAME = '$name' AND STARTDATE = '$date';";
WHERE NAME = '$name' AND STARTDATE = '$date' AND U_ID = 2;";
} elseif (mysqli_fetch_array($result2, MYSQLI_ASSOC)) {
// Event already exists with this link
$query = "UPDATE events
SET NAME = '$name', ORGANIZER = '$group', LOCATION = '$location',
DESCRIPTION = '$description', MEDIAURL = '$mediaurl', HIDDENINFO = '$fulltitle'
WHERE LINK = '$eventlink' AND STARTDATE = '$date';";
WHERE LINK = '$eventlink' AND STARTDATE = '$date' AND U_ID = 2;";
} else {
// Insert Event into DB
$query = "INSERT INTO events (
Expand Down
4 changes: 2 additions & 2 deletions includes/fetchorgsync.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@
// Do NOT add events from Academic Calendar (BC event calendar contains this information)
if (strcmp($group, "Academic") != 0 && strcmp($group, "OCH") != 0) {
// Query to see if event already exits in database
$query = "select NAME from events where LINK = '$eventlink'";
$query = "select NAME from events where LINK = '$eventlink' AND U_ID = 1";

$result = perform_query( $dbc, $query);
if (mysqli_fetch_array($result, MYSQLI_ASSOC)) {
// Event already exists with this link
$query = "UPDATE events
SET NAME = '$name', ORGANIZER = '$group', LOCATION = '$location',
DESCRIPTION = '$description', MEDIAURL = '$mediaurl', STARTDATE = '$startdate',
ENDDATE = '$enddate' WHERE LINK = '$eventlink';";
ENDDATE = '$enddate' WHERE LINK = '$eventlink' AND U_ID = 1;";
} else {
// Insert Event into DB
$query = "INSERT INTO events (
Expand Down

0 comments on commit e30e467

Please sign in to comment.