Add(_('Delete prohibited, invalid security token!'));
$action = ACT_VIEW;
break;
}
unset($_SESSION['token']);
// get information for redirect
$sth = $pdo->prepare("SELECT notetype, refid FROM note WHERE noteid=?");
$sth->execute([$id]);
$note = $sth->fetch(PDO::FETCH_OBJ);
if ($note->notetype == 'task') {
$backlink = 'task.php';
} else {
$backlink = 'maintenance.php';
}
$backlink .= '?f=view&id='. $note->refid;
// now really delete
$sth = $pdo->prepare("DELETE FROM note WHERE noteid=?");
$sth->execute([$id]);
header_location($backlink);
break;
default:
$g_error->Add(sprintf(_("Unknown function '%s'!"), $submit));
$valid = FALSE;
}
// ========== ACTIONS END =====================================================
require 'header.php';
// ========== PAGE CONTENT ====================================================
if ($action == ACT_DEFAULT):
// ========== VARIANT: default behavior =======================================
echo '
', $pagetitle, "
\n";
$sql = "SELECT n.noteid, n.notetype, n.refid,"
. " IF(CHAR_LENGTH(n.annotation) > 60, CONCAT(LEFT(n.annotation, 60), '…'), n.annotation) AS annotation "
. "FROM note AS n JOIN task AS t ON (n.notetype='task' AND n.refid=t.taskid AND t.vid=:vid) "
. "UNION "
. "SELECT n.noteid, n.notetype, n.refid,"
. " IF(CHAR_LENGTH(n.annotation) > 60, CONCAT(LEFT(n.annotation, 60), '…'), n.annotation) AS annotation "
. "FROM note AS n JOIN maintenance AS m ON (n.notetype='maint' AND n.refid=m.maintid AND m.vid=:vid) "
. "ORDER BY noteid";
$sth = $pdo->prepare($sql);
$sth->execute([':vid' => $user->vid]);
$res = $sth->fetchAll();
?>