]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Allow disabling all public links, fixes #188 197/head
authorfeula <mr.pikzen@gmail.com>
Thu, 9 Apr 2015 16:13:11 +0000 (18:13 +0200)
committerfeula <mr.pikzen@gmail.com>
Thu, 9 Apr 2015 16:13:11 +0000 (18:13 +0200)
index.php
tpl/configure.html

index 3192029a82158becf5d386200939697494caaa87..0f39cdc2ef79345600843194e605a65d075cecf6 100644 (file)
--- a/index.php
+++ b/index.php
@@ -34,6 +34,7 @@ $GLOBALS['config']['UPDATECHECK_INTERVAL'] = 86400 ; // Updates check frequency
                                           // Note: You must have publisher.php in the same directory as Shaarli index.php
 $GLOBALS['config']['ARCHIVE_ORG'] = false; // For each link, add a link to an archived version on archive.org
 $GLOBALS['config']['ENABLE_RSS_PERMALINKS'] = true;  // Enable RSS permalinks by default. This corresponds to the default behavior of shaarli before this was added as an option.
+$GLOBALS['config']['DISABLE_PUBLIC_LINKS'] = false;
 // -----------------------------------------------------------------------------------------------
 // You should not touch below (or at your own risks!)
 // Optional config file.
@@ -1458,6 +1459,7 @@ function renderPage()
             $GLOBALS['privateLinkByDefault']=!empty($_POST['privateLinkByDefault']);
             $GLOBALS['config']['ENABLE_RSS_PERMALINKS']= !empty($_POST['enableRssPermalinks']);
             $GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']);
+            $GLOBALS['config']['DISABLE_PUBLIC_LINKS'] = !empty($_POST['disablePublicLinks']);
             writeConfig();
             echo '<script>alert("Configuration was saved.");document.location=\'?do=tools\';</script>';
             exit;
@@ -1899,9 +1901,13 @@ function buildLinkList($PAGE,$LINKSDB)
         }
         $search_type='permalink';
     }
+    // We chose to disable all private links and the user isn't logged in, do not return any link.
+    else if ($GLOBALS['config']['DISABLE_PUBLIC_LINKS'] && !isLoggedIn())
+        $linksToDisplay = array();
     else
         $linksToDisplay = $LINKSDB;  // Otherwise, display without filtering.
 
+
     // Option: Show only private links
     if (!empty($_SESSION['privateonly']))
     {
@@ -2328,6 +2334,7 @@ function writeConfig()
     $config .= '$GLOBALS[\'privateLinkByDefault\']='.var_export($GLOBALS['privateLinkByDefault'],true).'; ';
     $config .= '$GLOBALS[\'config\'][\'ENABLE_RSS_PERMALINKS\']='.var_export($GLOBALS['config']['ENABLE_RSS_PERMALINKS'], true).'; ';
     $config .= '$GLOBALS[\'config\'][\'ENABLE_UPDATECHECK\']='.var_export($GLOBALS['config']['ENABLE_UPDATECHECK'], true).'; ';
+    $config .= '$GLOBALS[\'config\'][\'DISABLE_PUBLIC_LINKS\']='.var_export($GLOBALS['config']['DISABLE_PUBLIC_LINKS'], true).'; ';
     $config .= ' ?>';
     if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0)
     {
index 373d0690fc14dc773db2e4e5f3bcbf2c4e9bca46..01f846cc11b34c8eee9416b1514abd8df434fbe6 100644 (file)
                        <input type="checkbox" name="enableRssPermalinks" id="enableRssPermalinks" {if="!empty($GLOBALS['config']['ENABLE_RSS_PERMALINKS'])"}checked{/if}/><label for="enableRssPermalinks">&nbsp;Switches the RSS feed URLs between full URLs and shortlinks. Enabling it will show a permalink in the description, and the feed item will be linked to the absolute URL. Disabling it swaps this behaviour around (permalink in title and link in description). RSS Permalinks are currently <b>{if="$GLOBALS['config']['ENABLE_RSS_PERMALINKS']"}enabled{else}disabled{/if}</b></label>
                </td>
         </tr>
+        <tr>
+            <td valign="top"><b>Disable public links</b></td>
+            <td>
+                <input type="checkbox" name="disablePublicLinks" id="disablePublicLinks" {if="!empty($GLOBALS['config']['DISABLE_PUBLIC_LINKS'])"}checked{/if}/><label for="disablePublicLinks">&nbsp;
+                Do not show any links if the user is not logged in.</label>
+            </td>
+        </tr>
         <tr><td valign="top"><b>Update:</b></td><td>
             <input type="checkbox" name="updateCheck" id="updateCheck" {if="!empty($GLOBALS['config']['ENABLE_UPDATECHECK'])"}checked{/if}/>
             <label for="updateCheck">&nbsp;Notify me when a new release is ready</label></td>