]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
shaarli/Shaarli#34: Make update check optional 120/head
authorArthurHoaro <arthur@hoa.ro>
Fri, 20 Feb 2015 21:28:10 +0000 (22:28 +0100)
committerArthurHoaro <arthur@hoa.ro>
Fri, 20 Feb 2015 21:49:41 +0000 (22:49 +0100)
  * Add a check box at installation (checked by default)
  * Add a check box in configuration page

index.php
tpl/configure.html
tpl/install.html

index dfebdcad312c58dedaebf0ee893499fd050d5e26..9d4ce15619b4562dc85004062c055151701d392c 100644 (file)
--- a/index.php
+++ b/index.php
@@ -178,6 +178,7 @@ function checkphpversion()
 function checkUpdate()
 {
     if (!isLoggedIn()) return ''; // Do not check versions for visitors.
+    if (empty($GLOBALS['config']['ENABLE_UPDATECHECK'])) return ''; // Do not check if the user doesn't want to.
 
     // Get latest version number at most once a day.
     if (!is_file($GLOBALS['config']['UPDATECHECK_FILENAME']) || (filemtime($GLOBALS['config']['UPDATECHECK_FILENAME'])<time()-($GLOBALS['config']['UPDATECHECK_INTERVAL'])))
@@ -1462,6 +1463,7 @@ function renderPage()
             $GLOBALS['disablejquery']=!empty($_POST['disablejquery']);
             $GLOBALS['privateLinkByDefault']=!empty($_POST['privateLinkByDefault']);
             $GLOBALS['config']['ENABLE_RSS_PERMALINKS']= !empty($_POST['enableRssPermalinks']);
+            $GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']);
             writeConfig();
             echo '<script>alert("Configuration was saved.");document.location=\'?do=tools\';</script>';
             exit;
@@ -2191,6 +2193,7 @@ function install()
         $GLOBALS['salt'] = sha1(uniqid('',true).'_'.mt_rand()); // Salt renders rainbow-tables attacks useless.
         $GLOBALS['hash'] = sha1($_POST['setpassword'].$GLOBALS['login'].$GLOBALS['salt']);
         $GLOBALS['title'] = (empty($_POST['title']) ? 'Shared links on '.htmlspecialchars(indexUrl()) : $_POST['title'] );
+        $GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']);
         writeConfig();
         echo '<script>alert("Shaarli is now configured. Please enter your login/password and start shaaring your links!");document.location=\'?do=login\';</script>';
         exit;
@@ -2359,6 +2362,7 @@ function writeConfig()
     $config .= '$GLOBALS[\'disablejquery\']='.var_export($GLOBALS['disablejquery'],true).'; ';
     $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 .= ' ?>';
     if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0)
     {
index c096018b3aaf55fda1f82db7254cbd43dd51fe02..887be327321e1ef9b728c7b94ae3d8c3bb80fa5c 100644 (file)
                <td>
                        <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>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>
         </tr>
          <tr><td></td><td class="right"><input type="submit" name="Save" value="Save config" class="bigbutton"></td></tr>
        </table>
index df42bf6d0fbe5187782364d04121d8272588bc4d..88eb540e1f18b8fc5d61056e2579e695f14cc15e 100644 (file)
@@ -3,17 +3,20 @@
 <head>{include="includes"}{$timezone_js}</head>
 <body onload="document.installform.setlogin.focus();">
 <div id="install">
-<h1>Shaarli</h1>       
-It looks like it's the first time you run Shaarli. Please configure it:<br>
-<form method="POST" action="#" name="installform" id="installform">
-<table>
-<tr><td><b>Login:</b></td><td><input type="text" name="setlogin" size="30"></td></tr>
-<tr><td><b>Password:</b></td><td><input type="password" name="setpassword" size="30"></td></tr>
-{$timezone_html}
-<tr><td><b>Page title:</b></td><td><input type="text" name="title" size="30"></td></tr>
-<tr><td colspan="2"><input type="submit" name="Save" value="Save config" class="bigbutton"></td></tr>
-</table>
-</form>
+    <h1>Shaarli</h1>
+    It looks like it's the first time you run Shaarli. Please configure it:<br>
+    <form method="POST" action="#" name="installform" id="installform">
+        <table>
+            <tr><td><b>Login:</b></td><td><input type="text" name="setlogin" size="30"></td></tr>
+            <tr><td><b>Password:</b></td><td><input type="password" name="setpassword" size="30"></td></tr>
+            {$timezone_html}
+            <tr><td><b>Page title:</b></td><td><input type="text" name="title" size="30"></td></tr>
+            <tr><td valign="top"><b>Update:</b></td><td>
+                <input type="checkbox" name="updateCheck" id="updateCheck" checked="checked"><label for="updateCheck">&nbsp;Notify me when a new release is ready</label></td>
+            </tr>
+            <tr><td colspan="2"><input type="submit" name="Save" value="Save config" class="bigbutton"></td></tr>
+        </table>
+    </form>
 </div>
 {include="page.footer"}
 </body>