aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorfeula <mr.pikzen@gmail.com>2015-04-09 18:13:11 +0200
committerfeula <mr.pikzen@gmail.com>2015-04-09 18:13:11 +0200
commit8fa1ebd6059050566bd685c23d88ff4f60a20c55 (patch)
treefedae5abeecd56ffea307529844fe617ffb86a2e
parent8438a2e5d0cb90a869d67516c6e6cf756f77a588 (diff)
downloadShaarli-8fa1ebd6059050566bd685c23d88ff4f60a20c55.tar.gz
Shaarli-8fa1ebd6059050566bd685c23d88ff4f60a20c55.tar.zst
Shaarli-8fa1ebd6059050566bd685c23d88ff4f60a20c55.zip
Allow disabling all public links, fixes #188
-rw-r--r--index.php7
-rw-r--r--tpl/configure.html7
2 files changed, 14 insertions, 0 deletions
diff --git a/index.php b/index.php
index 3192029a..0f39cdc2 100644
--- a/index.php
+++ b/index.php
@@ -34,6 +34,7 @@ $GLOBALS['config']['UPDATECHECK_INTERVAL'] = 86400 ; // Updates check frequency
34 // Note: You must have publisher.php in the same directory as Shaarli index.php 34 // Note: You must have publisher.php in the same directory as Shaarli index.php
35$GLOBALS['config']['ARCHIVE_ORG'] = false; // For each link, add a link to an archived version on archive.org 35$GLOBALS['config']['ARCHIVE_ORG'] = false; // For each link, add a link to an archived version on archive.org
36$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. 36$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.
37$GLOBALS['config']['DISABLE_PUBLIC_LINKS'] = false;
37// ----------------------------------------------------------------------------------------------- 38// -----------------------------------------------------------------------------------------------
38// You should not touch below (or at your own risks!) 39// You should not touch below (or at your own risks!)
39// Optional config file. 40// Optional config file.
@@ -1458,6 +1459,7 @@ function renderPage()
1458 $GLOBALS['privateLinkByDefault']=!empty($_POST['privateLinkByDefault']); 1459 $GLOBALS['privateLinkByDefault']=!empty($_POST['privateLinkByDefault']);
1459 $GLOBALS['config']['ENABLE_RSS_PERMALINKS']= !empty($_POST['enableRssPermalinks']); 1460 $GLOBALS['config']['ENABLE_RSS_PERMALINKS']= !empty($_POST['enableRssPermalinks']);
1460 $GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']); 1461 $GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']);
1462 $GLOBALS['config']['DISABLE_PUBLIC_LINKS'] = !empty($_POST['disablePublicLinks']);
1461 writeConfig(); 1463 writeConfig();
1462 echo '<script>alert("Configuration was saved.");document.location=\'?do=tools\';</script>'; 1464 echo '<script>alert("Configuration was saved.");document.location=\'?do=tools\';</script>';
1463 exit; 1465 exit;
@@ -1899,9 +1901,13 @@ function buildLinkList($PAGE,$LINKSDB)
1899 } 1901 }
1900 $search_type='permalink'; 1902 $search_type='permalink';
1901 } 1903 }
1904 // We chose to disable all private links and the user isn't logged in, do not return any link.
1905 else if ($GLOBALS['config']['DISABLE_PUBLIC_LINKS'] && !isLoggedIn())
1906 $linksToDisplay = array();
1902 else 1907 else
1903 $linksToDisplay = $LINKSDB; // Otherwise, display without filtering. 1908 $linksToDisplay = $LINKSDB; // Otherwise, display without filtering.
1904 1909
1910
1905 // Option: Show only private links 1911 // Option: Show only private links
1906 if (!empty($_SESSION['privateonly'])) 1912 if (!empty($_SESSION['privateonly']))
1907 { 1913 {
@@ -2328,6 +2334,7 @@ function writeConfig()
2328 $config .= '$GLOBALS[\'privateLinkByDefault\']='.var_export($GLOBALS['privateLinkByDefault'],true).'; '; 2334 $config .= '$GLOBALS[\'privateLinkByDefault\']='.var_export($GLOBALS['privateLinkByDefault'],true).'; ';
2329 $config .= '$GLOBALS[\'config\'][\'ENABLE_RSS_PERMALINKS\']='.var_export($GLOBALS['config']['ENABLE_RSS_PERMALINKS'], true).'; '; 2335 $config .= '$GLOBALS[\'config\'][\'ENABLE_RSS_PERMALINKS\']='.var_export($GLOBALS['config']['ENABLE_RSS_PERMALINKS'], true).'; ';
2330 $config .= '$GLOBALS[\'config\'][\'ENABLE_UPDATECHECK\']='.var_export($GLOBALS['config']['ENABLE_UPDATECHECK'], true).'; '; 2336 $config .= '$GLOBALS[\'config\'][\'ENABLE_UPDATECHECK\']='.var_export($GLOBALS['config']['ENABLE_UPDATECHECK'], true).'; ';
2337 $config .= '$GLOBALS[\'config\'][\'DISABLE_PUBLIC_LINKS\']='.var_export($GLOBALS['config']['DISABLE_PUBLIC_LINKS'], true).'; ';
2331 $config .= ' ?>'; 2338 $config .= ' ?>';
2332 if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0) 2339 if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0)
2333 { 2340 {
diff --git a/tpl/configure.html b/tpl/configure.html
index 373d0690..01f846cc 100644
--- a/tpl/configure.html
+++ b/tpl/configure.html
@@ -27,6 +27,13 @@
27 <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> 27 <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>
28 </td> 28 </td>
29 </tr> 29 </tr>
30 <tr>
31 <td valign="top"><b>Disable public links</b></td>
32 <td>
33 <input type="checkbox" name="disablePublicLinks" id="disablePublicLinks" {if="!empty($GLOBALS['config']['DISABLE_PUBLIC_LINKS'])"}checked{/if}/><label for="disablePublicLinks">&nbsp;
34 Do not show any links if the user is not logged in.</label>
35 </td>
36 </tr>
30 <tr><td valign="top"><b>Update:</b></td><td> 37 <tr><td valign="top"><b>Update:</b></td><td>
31 <input type="checkbox" name="updateCheck" id="updateCheck" {if="!empty($GLOBALS['config']['ENABLE_UPDATECHECK'])"}checked{/if}/> 38 <input type="checkbox" name="updateCheck" id="updateCheck" {if="!empty($GLOBALS['config']['ENABLE_UPDATECHECK'])"}checked{/if}/>
32 <label for="updateCheck">&nbsp;Notify me when a new release is ready</label></td> 39 <label for="updateCheck">&nbsp;Notify me when a new release is ready</label></td>