Merge pull request #1333 from ArthurHoaro/hotfix/sticky-update
Persist sticky status on bookmark update
This commit is contained in:
commit
d7dead5644
1 changed files with 10 additions and 14 deletions
24
index.php
24
index.php
|
@ -1126,22 +1126,24 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
|
||||||
|
|
||||||
// lf_id should only be present if the link exists.
|
// lf_id should only be present if the link exists.
|
||||||
$id = isset($_POST['lf_id']) ? intval(escape($_POST['lf_id'])) : $LINKSDB->getNextId();
|
$id = isset($_POST['lf_id']) ? intval(escape($_POST['lf_id'])) : $LINKSDB->getNextId();
|
||||||
|
$link['id'] = $id;
|
||||||
// Linkdate is kept here to:
|
// Linkdate is kept here to:
|
||||||
// - use the same permalink for notes as they're displayed when creating them
|
// - use the same permalink for notes as they're displayed when creating them
|
||||||
// - let users hack creation date of their posts
|
// - let users hack creation date of their posts
|
||||||
// See: https://shaarli.readthedocs.io/en/master/guides/various-hacks/#changing-the-timestamp-for-a-shaare
|
// See: https://shaarli.readthedocs.io/en/master/guides/various-hacks/#changing-the-timestamp-for-a-shaare
|
||||||
$linkdate = escape($_POST['lf_linkdate']);
|
$linkdate = escape($_POST['lf_linkdate']);
|
||||||
|
$link['created'] = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate);
|
||||||
if (isset($LINKSDB[$id])) {
|
if (isset($LINKSDB[$id])) {
|
||||||
// Edit
|
// Edit
|
||||||
$created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate);
|
$link['updated'] = new DateTime();
|
||||||
$updated = new DateTime();
|
$link['shorturl'] = $LINKSDB[$id]['shorturl'];
|
||||||
$shortUrl = $LINKSDB[$id]['shorturl'];
|
$link['sticky'] = isset($LINKSDB[$id]['sticky']) ? $LINKSDB[$id]['sticky'] : false;
|
||||||
$new = false;
|
$new = false;
|
||||||
} else {
|
} else {
|
||||||
// New link
|
// New link
|
||||||
$created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate);
|
$link['updated'] = null;
|
||||||
$updated = null;
|
$link['shorturl'] = link_small_hash($link['created'], $id);
|
||||||
$shortUrl = link_small_hash($created, $id);
|
$link['sticky'] = false;
|
||||||
$new = true;
|
$new = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1157,17 +1159,13 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
|
||||||
}
|
}
|
||||||
$url = whitelist_protocols(trim($_POST['lf_url']), $conf->get('security.allowed_protocols'));
|
$url = whitelist_protocols(trim($_POST['lf_url']), $conf->get('security.allowed_protocols'));
|
||||||
|
|
||||||
$link = array(
|
$link = array_merge($link, [
|
||||||
'id' => $id,
|
|
||||||
'title' => trim($_POST['lf_title']),
|
'title' => trim($_POST['lf_title']),
|
||||||
'url' => $url,
|
'url' => $url,
|
||||||
'description' => $_POST['lf_description'],
|
'description' => $_POST['lf_description'],
|
||||||
'private' => (isset($_POST['lf_private']) ? 1 : 0),
|
'private' => (isset($_POST['lf_private']) ? 1 : 0),
|
||||||
'created' => $created,
|
|
||||||
'updated' => $updated,
|
|
||||||
'tags' => str_replace(',', ' ', $tags),
|
'tags' => str_replace(',', ' ', $tags),
|
||||||
'shorturl' => $shortUrl,
|
]);
|
||||||
);
|
|
||||||
|
|
||||||
// If title is empty, use the URL as title.
|
// If title is empty, use the URL as title.
|
||||||
if ($link['title'] == '') {
|
if ($link['title'] == '') {
|
||||||
|
@ -1181,8 +1179,6 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
|
||||||
$link['thumbnail'] = $thumbnailer->get($url);
|
$link['thumbnail'] = $thumbnailer->get($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
$link['sticky'] = isset($link['sticky']) ? $link['sticky'] : false;
|
|
||||||
|
|
||||||
$pluginManager->executeHooks('save_link', $link);
|
$pluginManager->executeHooks('save_link', $link);
|
||||||
|
|
||||||
$LINKSDB[$id] = $link;
|
$LINKSDB[$id] = $link;
|
||||||
|
|
Loading…
Reference in a new issue