]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - index.php
Merge branch 'v0.11' into stable
[github/shaarli/Shaarli.git] / index.php
index 957d8d9a4f428abbc0524b02f4e91bfd04e5b47e..3a5c35c480067caefe56e352b15fd110c6e20266 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,6 +1,12 @@
 <?php
 /**
+<<<<<<< HEAD
+ * Shaarli v0.8.7 - Shaare your links...
+ *
+ * The personal, minimalist, super-fast, database free, bookmarking service.
+=======
  * Shaarli - The personal, minimalist, super-fast, database free, bookmarking service.
+>>>>>>> v0.9.7
  *
  * Friendly fork by the Shaarli community:
  *  - https://github.com/shaarli/Shaarli
@@ -1126,22 +1132,24 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
 
         // lf_id should only be present if the link exists.
         $id = isset($_POST['lf_id']) ? intval(escape($_POST['lf_id'])) : $LINKSDB->getNextId();
+        $link['id'] = $id;
         // Linkdate is kept here to:
         //   - use the same permalink for notes as they're displayed when creating them
         //   - let users hack creation date of their posts
         //     See: https://shaarli.readthedocs.io/en/master/guides/various-hacks/#changing-the-timestamp-for-a-shaare
         $linkdate = escape($_POST['lf_linkdate']);
+        $link['created'] = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate);
         if (isset($LINKSDB[$id])) {
             // Edit
-            $created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate);
-            $updated = new DateTime();
-            $shortUrl = $LINKSDB[$id]['shorturl'];
+            $link['updated'] = new DateTime();
+            $link['shorturl'] = $LINKSDB[$id]['shorturl'];
+            $link['sticky'] = isset($LINKSDB[$id]['sticky']) ? $LINKSDB[$id]['sticky'] : false;
             $new = false;
         } else {
             // New link
-            $created = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $linkdate);
-            $updated = null;
-            $shortUrl = link_small_hash($created, $id);
+            $link['updated'] = null;
+            $link['shorturl'] = link_small_hash($link['created'], $id);
+            $link['sticky'] = false;
             $new = true;
         }
 
@@ -1157,17 +1165,13 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
         }
         $url = whitelist_protocols(trim($_POST['lf_url']), $conf->get('security.allowed_protocols'));
 
-        $link = array(
-            'id' => $id,
+        $link = array_merge($link, [
             'title' => trim($_POST['lf_title']),
             'url' => $url,
             'description' => $_POST['lf_description'],
             'private' => (isset($_POST['lf_private']) ? 1 : 0),
-            'created' => $created,
-            'updated' => $updated,
             'tags' => str_replace(',', ' ', $tags),
-            'shorturl' => $shortUrl,
-        );
+        ]);
 
         // If title is empty, use the URL as title.
         if ($link['title'] == '') {
@@ -1567,6 +1571,7 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
     if ($targetPage == Router::$PAGE_SAVE_PLUGINSADMIN) {
         try {
             if (isset($_POST['parameters_form'])) {
+                $pluginManager->executeHooks('save_plugin_parameters', $_POST);
                 unset($_POST['parameters_form']);
                 foreach ($_POST as $param => $value) {
                     $conf->set('plugins.'. $param, escape($value));