summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2017-12-10 18:36:53 +0100
committermsquare <msquare@notrademark.de>2017-12-10 18:36:53 +0100
commitaae8c77ed1a7b0d323f1d32c71b5fd12ff15d4bf (patch)
tree0500fe31fece134cde58751648cacbb42513ea81 /includes
parentdbf6e64a2cc0d83322d249da4844b5cf3b85bf60 (diff)
fix #212: Duplicate entry for Room name
Diffstat (limited to 'includes')
-rw-r--r--includes/pages/admin_import.php21
1 files changed, 14 insertions, 7 deletions
diff --git a/includes/pages/admin_import.php b/includes/pages/admin_import.php
index b59f2b17..ccc62b9b 100644
--- a/includes/pages/admin_import.php
+++ b/includes/pages/admin_import.php
@@ -310,26 +310,33 @@ function prepare_rooms($file)
$data = read_xml($file);
// Load rooms from db for compare with input
- $rooms = DB::select('SELECT `Name`, `RID` FROM `Room` WHERE `from_frab`=TRUE');
+ $rooms = Rooms();
+ // Contains rooms from db with from_frab==true
$rooms_db = [];
+ // Contains all rooms from db
+ $rooms_db_all = [];
+ // Contains all rooms from db and frab
$rooms_import = [];
foreach ($rooms as $room) {
- $rooms_db[] = $room['Name'];
+ if($room['from_frab']) {
+ $rooms_db[] = $room['Name'];
+ }
+ $rooms_db_all[] = $room['Name'];
$rooms_import[$room['Name']] = $room['RID'];
}
$events = $data->vcalendar->vevent;
- $rooms_pb = [];
+ $rooms_frab = [];
foreach ($events as $event) {
- $rooms_pb[] = (string)$event->location;
+ $rooms_frab[] = (string)$event->location;
if (!isset($rooms_import[trim($event->location)])) {
$rooms_import[trim($event->location)] = trim($event->location);
}
}
- $rooms_pb = array_unique($rooms_pb);
+ $rooms_frab = array_unique($rooms_frab);
- $rooms_new = array_diff($rooms_pb, $rooms_db);
- $rooms_deleted = array_diff($rooms_db, $rooms_pb);
+ $rooms_new = array_diff($rooms_frab, $rooms_db_all);
+ $rooms_deleted = array_diff($rooms_db, $rooms_frab);
return [
$rooms_new,