Пример #1
0
 /**
  * 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;
 }
Пример #2
0
    $admin = $env['admin']['username'];
    $result = Postmortem::add_history($event, $admin, $action);
    echo json_encode($result);
});
$app->post('/events/:id/tags', function ($id) use($app) {
    header("Content-Type: application/json");
    $tags = $app->request->post('tags');
    $tags = explode(",", $tags);
    $tags = array_map('trim', $tags);
    $tags = array_map('strtolower', $tags);
    $res = Postmortem::save_tags_for_event($id, $tags);
    if ($res["status"] == Postmortem::ERROR) {
        $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"]);
Пример #3
0
 $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";