You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.6 KiB
PHP

<?php
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
$newnote = true;
$note = new Note("", "", $_SESSION['uid'], null);
if (!empty($VARS['note'])) {
try {
$note = Note::loadNote($VARS['note']);
$newnote = false;
} catch (Exception $ex) {
// It's a new note I guess
$newnote = true;
}
}
// TODO: Check for note sharing
if ($note->getOwnerID() != $_SESSION['uid']) {
header("Location: app.php?msg=no_permission");
die();
}
if ($newnote && $SETTINGS['note_limit'] !== false && !(new User($_SESSION['uid']))->hasPermission($SETTINGS['unlimited_permission'])) {
$notecount = $database->count("notes", ['ownerid' => $_SESSION['uid']]);
if ($notecount >= $SETTINGS['note_limit']) {
header("Location: app.php?msg=quota_reached");
}
}
$note->saveNote();
?>
<style nonce="<?php echo $SECURE_NONCE; ?>">
.CodeMirror, #note_content, .cm-quote, .editor-preview-side {
background-color: #<?php echo $note->getColor(); ?>;
color: #<?php echo $note->getTextColor(); ?> !important;
caret-color: #<?php echo $note->getTextColor(); ?>;
}
.CodeMirror-cursor {
border-left: 1px solid #<?php echo $note->getTextColor(); ?>;
}
.editor-preview-side hr {
border-top: 1px solid #<?php echo $note->getTextColor(); ?>;
}
</style>
<form action="action.php" method="POST" id="noteform">
<textarea name="content" id="note_content" rows="10" class="form-control text-body"><?php echo $note->getText(); ?></textarea>
<input type="hidden" name="noteid" value="<?php echo $note->getID(); ?>" />
<input type="hidden" name="source" value="editnote" />
<input type="hidden" name="color" value="<?php echo $note->getColor(); ?>" />
<input type="hidden" name="action" value="savenote" />
<noscript>
<br />
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text"><?php $Strings->get("Note color"); ?></span>
</div>
<input class="form-control" type="color" name="color" value="#<?php echo $note->getColor(); ?>" />
</div>
<button type="submit" class="btn btn-success"><?php $Strings->get("Save"); ?></button>
<a href="./app.php?page=home" class="btn btn-default"><?php $Strings->get("Close"); ?></a>
<!-- Actually reload the page, otherwise Links gives an error -->
<input type="hidden" name="reload" value="1" />
</noscript>
</form>