summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2011-07-13 14:29:40 +0200
committerPhilip Häusler <msquare@notrademark.de>2011-07-13 14:29:40 +0200
commiteeff48ad97b42f16b80a5fb17553a409b94592c8 (patch)
tree6cb965b4b7c1993a3c699832a5d22c35b61cfb9f
parenta476beafe310aa8b291996c06d876e31975deb7d (diff)
#4 import shift names
-rw-r--r--includes/pages/admin_import.php16
-rw-r--r--includes/sys_template.php6
-rw-r--r--public/index.php4
-rw-r--r--templates/admin_import_check.html9
4 files changed, 29 insertions, 6 deletions
diff --git a/includes/pages/admin_import.php b/includes/pages/admin_import.php
index a789dd3d..f8afb409 100644
--- a/includes/pages/admin_import.php
+++ b/includes/pages/admin_import.php
@@ -117,9 +117,9 @@ function admin_import() {
'link' => page_link_to('admin_import'),
'rooms_new' => count($rooms_new) == 0 ? "<tr><td>None</td></tr>" : table_body($rooms_new),
'rooms_deleted' => count($rooms_deleted) == 0 ? "<tr><td>None</td></tr>" : table_body($rooms_deleted),
- 'events_new' => count($events_new) == 0 ? "<tr><td>None</td><td></td><td></td><td></td></tr>" : table_body(shifts_printable($events_new)),
- 'events_updated' => count($events_updated) == 0 ? "<tr><td>None</td><td></td><td></td><td></td></tr>" : table_body(shifts_printable($events_updated)),
- 'events_deleted' => count($events_deleted) == 0 ? "<tr><td>None</td><td></td><td></td><td></td></tr>" : table_body(shifts_printable($events_deleted))
+ 'events_new' => count($events_new) == 0 ? "<tr><td>None</td><td></td><td></td><td></td><td></td></tr>" : table_body(shifts_printable($events_new)),
+ 'events_updated' => count($events_updated) == 0 ? "<tr><td>None</td><td></td><td></td><td></td><td></td></tr>" : table_body(shifts_printable($events_updated)),
+ 'events_deleted' => count($events_deleted) == 0 ? "<tr><td>None</td><td></td><td></td><td></td><td></td></tr>" : table_body(shifts_printable($events_deleted))
));
break;
@@ -137,10 +137,12 @@ function admin_import() {
list ($events_new, $events_updated, $events_deleted) = prepare_events($import_file);
foreach ($events_new as $event)
- sql_query("INSERT INTO `Shifts` SET `start`=" . sql_escape($event['start']) . ", `end`=" . sql_escape($event['end']) . ", `RID`=" . sql_escape($event['RID']) . ", `PSID`=" . sql_escape($event['PSID']) . ", `URL`='" . sql_escape($event['URL']) . "'");
+ sql_query("INSERT INTO `Shifts` SET `name`='" .
+ sql_escape($event['name']) . "', `start`=" . sql_escape($event['start']) . ", `end`=" . sql_escape($event['end']) . ", `RID`=" . sql_escape($event['RID']) . ", `PSID`=" . sql_escape($event['PSID']) . ", `URL`='" . sql_escape($event['URL']) . "'");
foreach ($events_updated as $event)
- sql_query("UPDATE `Shifts` SET `start`=" . sql_escape($event['start']) . ", `end`=" . sql_escape($event['end']) . ", `RID`=" . sql_escape($event['RID']) . ", `PSID`=" . sql_escape($event['PSID']) . ", `URL`='" . sql_escape($event['URL']) . "' WHERE `PSID`=" . sql_escape($event['PSID']) . " LIMIT 1");
+ sql_query("UPDATE `Shifts` SET `name`='" .
+ sql_escape($event['name']) . "', `start`=" . sql_escape($event['start']) . ", `end`=" . sql_escape($event['end']) . ", `RID`=" . sql_escape($event['RID']) . ", `PSID`=" . sql_escape($event['PSID']) . ", `URL`='" . sql_escape($event['URL']) . "' WHERE `PSID`=" . sql_escape($event['PSID']) . " LIMIT 1");
foreach ($events_deleted as $event)
sql_query("DELETE FROM `Shifts` WHERE `PSID`=" .
@@ -205,6 +207,7 @@ function prepare_events($file) {
'start' => DateTime :: createFromFormat("Ymd\THis", $event->dtstart)->getTimestamp(),
'end' => DateTime :: createFromFormat("Ymd\THis", $event->dtend)->getTimestamp(),
'RID' => $rooms_import[trim($event->location)],
+ 'name' => trim($event->summary),
'URL' => trim($event->url),
'PSID' => $event_id
);
@@ -222,7 +225,7 @@ function prepare_events($file) {
$shifts_new[] = $shift;
else {
$tmp = $shifts_db[$shift['PSID']];
- if ($shift['start'] != $tmp['start'] || $shift['end'] != $tmp['end'] || $shift['RID'] != $tmp['RID'] || $shift['URL'] != $tmp['URL'])
+ if ($shift['name'] != $tmp['name'] || $shift['start'] != $tmp['start'] || $shift['end'] != $tmp['end'] || $shift['RID'] != $tmp['RID'] || $shift['URL'] != $tmp['URL'])
$shifts_updated[] = $shift;
}
@@ -256,6 +259,7 @@ function shifts_printable($shifts) {
$shifts_printable[] = array (
'day' => date("l, Y-m-d", $shift['start']),
'start' => date("H:i", $shift['start']),
+ 'name' => shorten($shift['name']),
'end' => date("H:i", $shift['end']),
'room' => $rooms[$shift['RID']]
);
diff --git a/includes/sys_template.php b/includes/sys_template.php
index 06d5ef72..922010fd 100644
--- a/includes/sys_template.php
+++ b/includes/sys_template.php
@@ -15,6 +15,12 @@ function template_render($file, $data) {
}
}
+function shorten($str) {
+ if (strlen($str) < 50)
+ return $str;
+ return substr($str, 0, 47) . '...';
+}
+
function table_body($array) {
$html = "";
foreach ($array as $line) {
diff --git a/public/index.php b/public/index.php
index 83443879..f4fac853 100644
--- a/public/index.php
+++ b/public/index.php
@@ -48,6 +48,10 @@ if (in_array($p, $privileges)) {
require_once ('includes/pages/user_news.php');
$content = user_meetings();
}
+ elseif ($p == "user_shifts") {
+ require_once ('includes/pages/user_shifts.php');
+ $content = user_shifts();
+ }
elseif ($p == "user_messages") {
$content = user_messages();
}
diff --git a/templates/admin_import_check.html b/templates/admin_import_check.html
index 291ad9df..788ea58e 100644
--- a/templates/admin_import_check.html
+++ b/templates/admin_import_check.html
@@ -40,6 +40,9 @@
End
</th>
<th>
+ Name
+ </th>
+ <th>
Room
</th>
</tr>
@@ -62,6 +65,9 @@
End
</th>
<th>
+ Name
+ </th>
+ <th>
Room
</th>
</tr>
@@ -84,6 +90,9 @@
End
</th>
<th>
+ Name
+ </th>
+ <th>
Room
</th>
</tr>