diff --git a/cfg/conf.ini b/cfg/conf.ini index cf6f9290..28476fb7 100644 --- a/cfg/conf.ini +++ b/cfg/conf.ini @@ -53,6 +53,10 @@ languageselection = false ; make sure the value exists in [expire_options] default = "1week" +; optionally the "clone" button can be disabled on expiring pastes +; note that this only hides the button, copy & paste is still possible +; clone = false + [expire_options] ; Set each one of these to the number of seconds in the expiration period, ; or 0 if it should never expire diff --git a/lib/configuration.php b/lib/configuration.php index 4bb151a9..11e062bc 100644 --- a/lib/configuration.php +++ b/lib/configuration.php @@ -46,6 +46,7 @@ class configuration ), 'expire' => array( 'default' => '1week', + 'clone' => true, ), 'expire_options' => array( '5min' => 300, diff --git a/lib/zerobin.php b/lib/zerobin.php index edda4b64..f94bc495 100644 --- a/lib/zerobin.php +++ b/lib/zerobin.php @@ -47,6 +47,14 @@ class zerobin */ private $_data = ''; + /** + * does the paste expire + * + * @access private + * @var bool + */ + private $_doesExpire = false; + /** * formatter * @@ -354,7 +362,9 @@ class zerobin $paste = $this->_model->getPaste($dataid); if ($paste->exists()) { - $this->_data = json_encode($paste->get()); + $data = $paste->get(); + $this->_doesExpire = property_exists($data, 'meta') && property_exists($data->meta, 'expire_date'); + $this->_data = json_encode($data); } else { @@ -434,6 +444,7 @@ class zerobin $page->assign('LANGUAGES', i18n::getLanguageLabels(i18n::getAvailableLanguages())); $page->assign('EXPIRE', $expire); $page->assign('EXPIREDEFAULT', $this->_conf->getKey('default', 'expire')); + $page->assign('EXPIRECLONE', !$this->_doesExpire || ($this->_doesExpire && $this->_conf->getKey('clone', 'expire'))); $page->draw($this->_conf->getKey('template')); } diff --git a/tpl/bootstrap-compact.html b/tpl/bootstrap-compact.html index df1580ef..662d5387 100644 --- a/tpl/bootstrap-compact.html +++ b/tpl/bootstrap-compact.html @@ -41,10 +41,10 @@
  • + {if="$EXPIRECLONE"} + {/if} diff --git a/tpl/bootstrap-page.html b/tpl/bootstrap-page.html index ab8e1c32..69e3531d 100644 --- a/tpl/bootstrap-page.html +++ b/tpl/bootstrap-page.html @@ -40,10 +40,10 @@
  • + {if="$EXPIRECLONE"} + {/if} diff --git a/tpl/bootstrap.html b/tpl/bootstrap.html index a3a82ecd..57fbb455 100644 --- a/tpl/bootstrap.html +++ b/tpl/bootstrap.html @@ -40,10 +40,10 @@
  • + {if="$EXPIRECLONE"} + {/if} diff --git a/tpl/page.html b/tpl/page.html index 8071dd25..7bd7ab2e 100644 --- a/tpl/page.html +++ b/tpl/page.html @@ -43,8 +43,8 @@
    - - + {if="$EXPIRECLONE"} + {/if}