<?php require_once '../lib/header_ajax.php'; require_once '../lib/lib_ne.php'; try { switch ($_POST['act']) { case 'newAnnotation': $tagset_id = get_current_tagset(); if (empty($_POST['paragraph'])) { throw new Exception(); } $id = start_ne_annotation($_POST['paragraph'], $tagset_id); $result['id'] = $id; break; case 'finishAnnotation': if (empty($_POST['paragraph'])) { throw new Exception(); } finish_ne_annotation($_POST['paragraph']); break; case 'newEntity': if (empty($_POST['paragraph']) or empty($_POST['tokens']) or empty($_POST['types'])) { throw new Exception(); } list($par_id, $token_ids, $tags) = array($_POST['paragraph'], $_POST['tokens'], $_POST['types']); $id = add_ne_entity($par_id, $token_ids, $tags); $result['id'] = $id; break; case 'deleteEntity': if (empty($_POST['entity'])) { throw new Exception();
function finish_book_moderation($book_id, $tagset_id) { check_permission(PERM_NE_MODER); // create absent annotations $res = sql_pe("\n SELECT par_id FROM paragraphs\n LEFT JOIN ne_paragraphs USING (par_id)\n WHERE book_id = ?\n AND tagset_id = ?\n GROUP BY par_id\n HAVING COUNT(annot_id) = 0\n ", array($book_id, $tagset_id)); sql_begin(); foreach ($res as $r) { start_ne_annotation($r['par_id'], $tagset_id, true); } set_ne_book_status($book_id, $tagset_id, NE_STATUS_FINISHED); sql_commit(); }