Add download button to notes

master
Skylar Ittner 6 years ago
parent bc86fd0aa6
commit 91636b15d2

@ -57,4 +57,15 @@ switch ($VARS['action']) {
}
$note->deleteNote();
returnToSender("note_deleted");
case "downloadnote":
if (empty($VARS['noteid'])) {
die($Strings->get("invalid parameters", false));
}
$note = Note::loadNote($VARS['noteid']);
if (!$note->hasReadAccess(new User($_SESSION['uid']))) {
die($Strings->get("invalid parameters", false));
}
header("Content-Type: text/markdown; charset=UTF-8");
header("Content-disposition: attachment; filename=\"" . $note->getCleanTitle() . "_" . $note->getModified() . ".md\"");
echo $note->getText();
}

@ -4,5 +4,6 @@
"Note": "Note",
"Edit": "Edit",
"Delete": "Delete",
"Download": "Download",
"Note deleted": "Note deleted"
}

@ -42,6 +42,9 @@ foreach ($notes as $note) {
<a href="./app.php?page=editnote&note=<?php echo $note->getID(); ?>" class="text-body mr-2">
<i class="fas fa-edit"></i> <?php $Strings->get('Edit'); ?>
</a>
<a href="./action.php?action=downloadnote&noteid=<?php echo $note->getID(); ?>" class="text-body mr-2">
<i class="fas fa-download"></i> <?php $Strings->get('Download'); ?>
</a>
<a href="./action.php?action=deletenote&noteid=<?php echo $note->getID(); ?>" class="text-body text-danger">
<i class="fas fa-trash"></i> <?php $Strings->get('Delete'); ?>
</a>

Loading…
Cancel
Save