예제 #1
0
파일: Postmortem.php 프로젝트: nlsun/morgue
 /**
  * Get an event from the database
  *
  * @param $event_id - id of the event to get
  * @param $conn - PDO connection object, will be newly instantiated when
  *                null (default: null)
  *
  * @returns an event map including an "id" field on success or a map of the
  * form ( "id" => null, "error" => "an error message" ) on failure
  */
 static function get_event($event_id, $conn = null)
 {
     $conn = $conn ?: Persistence::get_database_object();
     if (is_null($conn)) {
         return array("id" => null, "error" => "Couldn't get connection object.");
     }
     $event = Persistence::get_postmortem($event_id, $conn);
     if (is_null($event["id"])) {
         return $event;
     }
     $tags = Postmortem::get_tags_for_event($event_id, $conn);
     if ($tags["status"] != Persistence::OK) {
         $conn = null;
         return array("id" => null, "error" => "error fetching data");
     } else {
         $event["tags"] = $tags["values"];
         $event["history"] = self::get_history($event["id"]);
         $conn = null;
         return $event;
     }
 }
예제 #2
0
파일: routes.php 프로젝트: lursu/morgue
 $content = "anniversary/views/anniversary-mail";
 $show_sidebar = false;
 $page_title = "Today in Post Mortem History";
 $today = date("Y-m-d", time());
 $get_date = trim($app->request->get('date'));
 if ($get_date) {
     $get_date = date("Y-m-d", strtotime($get_date));
     $today = $get_date;
 }
 $conn = Persistence::get_database_object();
 $pm_ids = Anniversary::get_ids($today, $conn);
 $human_readable_date = date("F jS", strtotime($today));
 $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'];
     }
 }