Jelajahi Sumber

feat: make the email button optional. Issue #1031
::by sergio giraldo
@ 20230909T2226CEST, gpg signed

Sergio Giraldo 2 tahun lalu
induk
melakukan
c665385ff6
5 mengubah file dengan 26 tambahan dan 2 penghapusan
  1. 8 2
      cfg/conf.sample.php
  2. 1 0
      lib/Configuration.php
  3. 1 0
      lib/Controller.php
  4. 11 0
      tpl/bootstrap.php
  5. 5 0
      tpl/page.php

+ 8 - 2
cfg/conf.sample.php

@@ -1,4 +1,5 @@
-;<?php http_response_code(403); /*
+;<?php http_response_code(403); 
+/*
 ; config file for PrivateBin
 ;
 ; An explanation of each setting can be find online at https://github.com/PrivateBin/PrivateBin/wiki/Configuration.
@@ -65,6 +66,10 @@ languageselection = false
 ; It works both when a new paste is created and when you view a paste.
 ; qrcode = true
 
+; (optional) Let users send an email sharing the paste URL with one click.
+; It works both when a new paste is created and when you view a paste.
+; email = true
+
 ; (optional) IP based icons are a weak mechanism to detect if a comment was from
 ; a different user when the same username was used in a comment. It might get
 ; used to get the IP of a comment poster if the server salt is leaked and a
@@ -258,4 +263,5 @@ dir = PATH "data"
 ; (optional) the "signature" (access key) issued by YOURLS for the using account
 ; signature = ""
 ; (optional) the URL of the YOURLS API, called to shorten a PrivateBin URL
-; apiurl = "https://yourls.example.com/yourls-api.php"
+; apiurl = "https://yourls.example.com/yourls-api.php"
+*/

+ 1 - 0
lib/Configuration.php

@@ -53,6 +53,7 @@ class Configuration
             'languagedefault'          => '',
             'urlshortener'             => '',
             'qrcode'                   => true,
+            'email'                    => true,
             'icon'                     => 'identicon',
             'cspheader'                => 'default-src \'none\'; base-uri \'self\'; form-action \'none\'; manifest-src \'self\'; connect-src * blob:; script-src \'self\' \'unsafe-eval\'; style-src \'self\'; font-src \'self\'; frame-ancestors \'none\'; img-src \'self\' data: blob:; media-src blob:; object-src blob:; sandbox allow-same-origin allow-scripts allow-forms allow-popups allow-modals allow-downloads',
             'zerobincompatibility'     => false,

+ 1 - 0
lib/Controller.php

@@ -411,6 +411,7 @@ class Controller
         $page->assign('EXPIREDEFAULT', $this->_conf->getKey('default', 'expire'));
         $page->assign('URLSHORTENER', $this->_conf->getKey('urlshortener'));
         $page->assign('QRCODE', $this->_conf->getKey('qrcode'));
+        $page->assign('EMAIL', $this->_conf->getKey('email'));
         $page->assign('HTTPWARNING', $this->_conf->getKey('httpwarning'));
         $page->assign('HTTPSLINK', 'https://' . $this->_request->getHost() . $this->_request->getRequestUri());
         $page->assign('COMPRESSION', $this->_conf->getKey('compression'));

+ 11 - 0
tpl/bootstrap.php

@@ -144,6 +144,7 @@ if ($QRCODE) :
 		</div>
 <?php
 endif;
+if ($EMAIL) :
 ?>
 		<div id="emailconfirmmodal" tabindex="-1" class="modal fade" aria-labelledby="emailconfirmmodalTitle" role="dialog" aria-hidden="true">
 			<div class="modal-dialog" role="document">
@@ -167,6 +168,9 @@ endif;
 				</div>
 			</div>
 		</div>
+<?php
+endif;
+?>
 		<nav class="navbar navbar-<?php echo $isDark ? 'inverse' : 'default'; ?> navbar-<?php echo $isCpct ? 'fixed' : 'static'; ?>-top"><?php
 if ($isCpct) :
 ?><div class="container"><?php
@@ -216,10 +220,17 @@ endif;
 						<button id="downloadtextbutton" type="button" class="hidden btn btn-<?php echo $isDark ? 'warning' : 'default'; ?> navbar-btn">
 							<span class="glyphicon glyphicon glyphicon-download-alt" aria-hidden="true"></span> <?php echo I18n::_('Save paste'), PHP_EOL; ?>
 						</button>
+<?php
+if ($EMAIL) :
+?>
+
 						<button id="emaillink" type="button" class="hidden btn btn-<?php echo $isDark ? 'warning' : 'default'; ?> navbar-btn">
 							<span class="glyphicon glyphicon-envelope" aria-hidden="true"></span> <?php echo I18n::_('Email'), PHP_EOL; ?>
 						</button>
 <?php
+endif;
+?>
+<?php
 if ($QRCODE) :
 ?>
 						<button id="qrcodelink" type="button" data-toggle="modal" data-target="#qrcodemodal" class="hidden btn btn-<?php echo $isDark ? 'warning' : 'default'; ?> navbar-btn">

+ 5 - 0
tpl/page.php

@@ -129,8 +129,13 @@ endif;
 					<button id="clonebutton" class="hidden"><img src="img/icon_clone.png" width="15" height="17" alt="" /><?php echo I18n::_('Clone'); ?></button>
 					<button id="rawtextbutton" class="hidden"><img src="img/icon_raw.png" width="15" height="15" alt="" /><?php echo I18n::_('Raw text'); ?></button>
 					<button id="downloadtextbutton" class="hidden"><?php echo I18n::_('Save paste'), PHP_EOL; ?></button>
+<?php
+if ($EMAIL):
+?>
+
 					<button id="emaillink" class="hidden"><img src="img/icon_email.png" width="15" height="15" alt="" /><?php echo I18n::_('Email'); ?></button>
 <?php
+endif;
 if ($QRCODE):
 ?>
 					<button id="qrcodelink" class="hidden"><img src="img/icon_qr.png" width="15" height="15" alt="" /><?php echo I18n::_('QR code'); ?></button>