if (!$error) { $app->response->status(201); echo json_encode($facilitator); } else { $app->response->status(400); echo $error; return; } }); $app->get("/calendar/facilitators/request/:id", function ($id) use($app) { $config = Configuration::get_configuration('calendar'); if (!$config["facilitator"]) { return; } $conn = Persistence::get_database_object(); $event = Postmortem::get_event($id, $conn); $user = MorgueAuth::get_auth_data(); $userHtml = Contact::get_html_for_user($user['username']); $domain = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; $to = implode(", ", $config["facilitators_email"]); $to .= ', ' . Contact::get_email_for_user($user['username']); $from = "Morgue <*****@*****.**>"; $subject = "Facilitator needed [PM-{$id}]"; $message = ' <html> <head> <title>Facilitator Needed for PM-' . $id . '</title> </head> <body style="font-family: \'Helvetica Neue\', Helvetica,Arial, sans-serif;"> <h3>' . $userHtml . ' has requested a facilitator for this event :</h3> <a href="' . $domain . '/events/' . $id . '" style="text-decoration:none;"><h3>' . $event["title"] . '</h3></a>
$app->response->status(400); } else { $app->response->status(201); $tags = Postmortem::get_tags_for_event($id); if ($tags["status"] == Postmortem::ERROR) { $app->response->status(404); return; } else { $output = json_encode($tags["values"]); echo str_replace("\\/", "/", $output); } } }); $app->delete('/events/:event_id/tags/:tag_id', function ($event_id, $tag_id) use($app) { header("Content-Type: application/json"); $res = Postmortem::delete_tag($tag_id, $event_id); if ($res["status"] == Postmortem::ERROR) { $app->response->status(500); echo json_encode($res["error"]); } else { $app->response->status(204); } }); $app->get('/ping', function () use($app) { header("Content-Type: application/json"); echo json_encode(array('status' => 'ok')); }); // Handle custom static assets. // Javascript first then CSS. $app->get('/features/:feature/js/:path', function ($feature, $path) use($app) { // read the file if it exists. Then serve it back.
$pms = array(); if ($pm_ids['status'] === 0) { foreach ($pm_ids['values'] as $k => $v) { $pm = Persistence::get_postmortem($v['id'], $conn); $pms[] = $pm; } } else { $message = $pm_ids['error']; $content = "error"; include 'views/page.php'; return; } if (count($pms)) { // get the tags for each PM we found so we can display them foreach ($pms as $k => $pm) { $tags = Postmortem::get_tags_for_event($pm['id'], null); $pms[$k]['tags'] = $tags['values']; } } if (count($pms)) { ob_start(); include $content . ".php"; $out = ob_get_contents(); ob_end_clean(); print $out; $to = $config['mailto']; $subject = "{$subject}"; $message = $out; $headers = "From: {$config['mailfrom']}\r\n"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
/** * delete tags belonging to a certain event to the database * * @param $event_id - numeric ID of the event to delete for * @param $conn - a PDO connection object * * @returns ( "status" => self::OK ) on success * or ( "status" => self::ERROR, "error" => "an error message" ) on failure */ static function delete_tags_for_event($event_id, $conn = null) { $res = Postmortem::get_tags_for_event($event_id); if ($res == Persistence::ERROR) { return $res; } $tags = $res['values']; foreach ($tags as $tag) { $res = Postmortem::delete_tag($tag['id'], $event_id, $conn); if ($res['status'] == Persistence::ERROR) { break; } } return $res; }
<?php $app->get('/events/:id/why_surprised', function ($id) use($app) { $event = Postmortem::get_event($id); if (is_null($event["id"])) { $app->response->status(404); return; } header("Content-Type: application/json"); echo json_encode(array("why_surprised" => $event["why_surprised"])); });
<div class="control-group"> <label class="control-label severity_levels" id="event-severity">Severity: </label> <div class="controls controls-row"> <select id="severity-select" name="severity" class="input editable" title=" <?php $config = Configuration::get_configuration(); if (isset($config['severity']) && isset($config['severity']['tooltip_title'])) { echo $config['severity']['tooltip_title']; } else { echo "Severity Levels"; } ?> " disabled> <?php $severity_levels = Postmortem::get_severity_levels(); foreach ($severity_levels as $level => $desc) { $sev_level = $level + 1; echo '<option value="' . $sev_level . '" description="' . $desc . '"'; if ($sev_level == $severity) { echo 'selected="true"'; } echo '>' . $sev_level . '. ' . $desc . '</option>'; } ?> </select> </div> </div> </div> <!-- Calculated Controls -->
<!-- Postmortem History --> <div class="row-fluid"> <legend style="margin-bottom:0px; border-bottom:none;">Postmortem History</legend> <table class="table"> <tbody> <?php foreach ($event["history"] as $i => $h) { echo "<tr><td>" . Postmortem::humanize_history($h) . "</td></tr>"; } ?> </tbody> </table> </div> <div class="row-fluid"><br/></div>
<?php /** * Routes for report */ $app->get('/report', function () use($app) { $content = "report/views/report"; $page_title = "report"; $show_sidebar = false; $days_back = 30; $start_date = time() - $days_back * 86400; $end_date = time(); $results = Postmortem::get_events_by_date($start_date, $end_date); if ($results['status'] == Postmortem::OK) { $events = $results['values']; uasort($events, 'cmp'); } else { $content = 'error'; $message = $results['error']; include "views/page.php"; return; } include "views/page.php"; });
<?php $app->get('/history/:event_id/:history_id', function ($event_id, $history_id) use($app) { $event = Postmortem::get_event($event_id); $history = Postmortem::get_history_event($history_id); $timezone = getUserTimezone(); $tz = new DateTimeZone($timezone); $edited = new DateTime(); $edited->setTimestamp($history['create_date']); $edited->setTimezone($tz); $edited = $edited->format('m/d/Y G:ia'); $edited = " @ " . $edited; $content = "history/views/diff"; $show_sidebar = false; $page_title = "Event History"; include "views/page.php"; });