[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [websites/paste-kde-org] app: Wishlist #162: Expiration for guests and users
From: Sayak Banerjee <sayakb () kde ! org>
Date: 2014-11-01 22:48:46
Message-ID: E1XkhTS-0000Ov-3b () scm ! kde ! org
[Download RAW message or body]
Git commit 19f97e95699149a7285b9cc3e620ca830194a0e0 by Sayak Banerjee.
Committed on 01/11/2014 at 21:46.
Pushed by sayakb into branch 'master'.
Wishlist #162: Expiration for guests and users
M +1 -1 app/config/default.php
M +1 -1 app/config/expire.php
M +3 -2 app/lang/en/admin.php
M +31 -0 app/models/Paste.php
http://commits.kde.org/websites/paste-kde-org/19f97e95699149a7285b9cc3e620ca830194a0e0
diff --git a/app/config/default.php b/app/config/default.php
index bf2d087..5484a11 100755
--- a/app/config/default.php
+++ b/app/config/default.php
@@ -30,7 +30,7 @@ return array(
'guestPosts' => '1',
'pasteSearch' => '1',
'comments' => '1',
- 'noExpire' => '1',
+ 'noExpire' => 'all',
'csrf' => '1',
'statsTTL' => '-6 months',
'statsDisplay' => '-1 month',
diff --git a/app/config/expire.php b/app/config/expire.php
index 6019dcb..d5beb01 100755
--- a/app/config/expire.php
+++ b/app/config/expire.php
@@ -26,6 +26,6 @@ return array(
'31536000' => array('expire_1year', TRUE),
- '0' => array('expire_forever', Site::config('general')->noExpire OR \
Auth::roles()->admin), + '0' => array('expire_forever', Paste::noExpire()),
);
diff --git a/app/lang/en/admin.php b/app/lang/en/admin.php
index 829ab39..97b577f 100755
--- a/app/lang/en/admin.php
+++ b/app/lang/en/admin.php
@@ -91,8 +91,9 @@ return array(
"expire_forever" => "Keep forever",
"expiration" => "Expiration",
"expiration_exp" => "This setting determines the maximum age for pastes \
created on this site.",
- "pastes_expire" => "Users must set a finite expiration time",
- "pastes_donot_expire" => "Users can create pastes that do not expire",
+ "noexpire_none" => "Everyone must set a finite expiration time",
+ "noexpire_user" => "Registered users can create pastes that do not expire",
+ "noexpire_all" => "Every one can create pastes that do not expire",
"ip_tracking" => "IP tracking",
"ip_tracking_exp" => "Set this option to trust proxy headers if your site is \
behind a proxy ".
"intermediary (such as a load balancer) to get the \
actual client IP address.",
diff --git a/app/models/Paste.php b/app/models/Paste.php
index 531ff5d..8cb7b07 100755
--- a/app/models/Paste.php
+++ b/app/models/Paste.php
@@ -293,6 +293,37 @@ class Paste extends Eloquent {
}
/**
+ * Check if the paste cannot expire
+ *
+ * @static
+ * @return bool
+ */
+ public static function noExpire()
+ {
+ $noExpire = FALSE;
+
+ // Admins can always create permanent pastes
+ if (Auth::roles()->admin)
+ {
+ $noExpire = TRUE;
+ }
+
+ // Check if only registered users can create permanent pastes
+ if (Site::config('general')->noExpire == 'user' AND Auth::roles()->user)
+ {
+ $noExpire = TRUE;
+ }
+
+ // Check if everyone can create permanent pastes
+ if (Site::config('general')->noExpire == 'all')
+ {
+ $noExpire = TRUE;
+ }
+
+ return $noExpire;
+ }
+
+ /**
* Fetches available expiration times for a paste
*
* @static
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic