aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Configuration.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-05-13 21:03:32 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-05-13 21:03:32 +0200
commita86a51cca69b7256d3a8dcf1c68447b6d5abe917 (patch)
treeb461e144d54656fb3c2c95aee96d6303cf6fa12c /app/Models/Configuration.php
parent88fa624a02d0346c2eb9173b1e9a02fc38b56d50 (diff)
parente763cd407a57e4829c2b6ffbddb164e5676670d7 (diff)
Merge branch 'dev' into 320-template
Diffstat (limited to 'app/Models/Configuration.php')
-rw-r--r--app/Models/Configuration.php77
1 files changed, 44 insertions, 33 deletions
diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php
index 2b719c370..8d3e69a1c 100644
--- a/app/Models/Configuration.php
+++ b/app/Models/Configuration.php
@@ -10,13 +10,15 @@ class FreshRSS_Configuration {
'mail_login' => '',
'token' => '',
'passwordHash' => '', //CRYPT_BLOWFISH
+ 'apiPasswordHash' => '', //CRYPT_BLOWFISH
'posts_per_page' => 20,
'view_mode' => 'normal',
- 'default_view' => 'not_read',
+ 'default_view' => FreshRSS_Entry::STATE_NOT_READ,
'auto_load_more' => true,
'display_posts' => false,
'onread_jump_next' => true,
'lazyload' => true,
+ 'sticky_post' => true,
'sort_order' => 'DESC',
'anon_access' => false,
'mark_when' => array(
@@ -37,6 +39,7 @@ class FreshRSS_Configuration {
'collapse_entry' => 'c',
'load_more' => 'm',
'auto_share' => 's',
+ 'focus_search' => 'a',
),
'topline_read' => true,
'topline_favorite' => true,
@@ -48,16 +51,7 @@ class FreshRSS_Configuration {
'bottomline_tags' => true,
'bottomline_date' => true,
'bottomline_link' => true,
- 'sharing' => array(
- 'shaarli' => '',
- 'wallabag' => '',
- 'diaspora' => '',
- 'twitter' => true,
- 'g+' => true,
- 'facebook' => true,
- 'email' => true,
- 'print' => true,
- ),
+ 'sharing' => array(),
);
private $available_languages = array(
@@ -65,8 +59,10 @@ class FreshRSS_Configuration {
'fr' => 'Français',
);
- public function __construct ($user) {
- $this->filename = DATA_PATH . '/' . $user . '_user.php';
+ private $shares;
+
+ public function __construct($user) {
+ $this->filename = DATA_PATH . DIRECTORY_SEPARATOR . $user . '_user.php';
$data = @include($this->filename);
if (!is_array($data)) {
@@ -80,10 +76,20 @@ class FreshRSS_Configuration {
}
}
$this->data['user'] = $user;
+
+ $this->shares = DATA_PATH . DIRECTORY_SEPARATOR . 'shares.php';
+
+ $shares = @include($this->shares);
+ if (!is_array($shares)) {
+ throw new Minz_PermissionDeniedException($this->shares);
+ }
+
+ $this->data['shares'] = $shares;
}
public function save() {
@rename($this->filename, $this->filename . '.bak.php');
+ unset($this->data['shares']); // Remove shares because it is not intended to be stored in user configuration
if (file_put_contents($this->filename, "<?php\n return " . var_export($this->data, true) . ';', LOCK_EX) === false) {
throw new Minz_PermissionDeniedException($this->filename);
}
@@ -104,16 +110,6 @@ class FreshRSS_Configuration {
}
}
- public function sharing($key = false) {
- if ($key === false) {
- return $this->data['sharing'];
- }
- if (isset($this->data['sharing'][$key])) {
- return $this->data['sharing'][$key];
- }
- return false;
- }
-
public function availableLanguages() {
return $this->available_languages;
}
@@ -136,7 +132,7 @@ class FreshRSS_Configuration {
}
}
public function _default_view ($value) {
- $this->data['default_view'] = $value === 'all' ? 'all' : 'not_read';
+ $this->data['default_view'] = $value === FreshRSS_Entry::STATE_ALL ? FreshRSS_Entry::STATE_ALL : FreshRSS_Entry::STATE_NOT_READ;
}
public function _display_posts ($value) {
$this->data['display_posts'] = ((bool)$value) && $value !== 'no';
@@ -147,6 +143,9 @@ class FreshRSS_Configuration {
public function _lazyload ($value) {
$this->data['lazyload'] = ((bool)$value) && $value !== 'no';
}
+ public function _sticky_post($value) {
+ $this->data['sticky_post'] = ((bool)$value) && $value !== 'no';
+ }
public function _sort_order ($value) {
$this->data['sort_order'] = $value === 'ASC' ? 'ASC' : 'DESC';
}
@@ -168,6 +167,9 @@ class FreshRSS_Configuration {
public function _passwordHash ($value) {
$this->data['passwordHash'] = ctype_graph($value) && (strlen($value) >= 60) ? $value : '';
}
+ public function _apiPasswordHash ($value) {
+ $this->data['apiPasswordHash'] = ctype_graph($value) && (strlen($value) >= 60) ? $value : '';
+ }
public function _mail_login ($value) {
$value = filter_var($value, FILTER_VALIDATE_EMAIL);
if ($value) {
@@ -187,24 +189,33 @@ class FreshRSS_Configuration {
}
}
public function _sharing ($values) {
- $are_url = array ('shaarli', 'wallabag', 'diaspora');
- foreach ($values as $key => $value) {
- if (in_array($key, $are_url)) {
+ $this->data['sharing'] = array();
+ foreach ($values as $value) {
+ if (!is_array($value)) {
+ continue;
+ }
+
+ // Verify URL and add default value when needed
+ if (isset($value['url'])) {
$is_url = (
- filter_var ($value, FILTER_VALIDATE_URL) ||
+ filter_var ($value['url'], FILTER_VALIDATE_URL) ||
(version_compare(PHP_VERSION, '5.3.3', '<') &&
(strpos($value, '-') > 0) &&
($value === filter_var($value, FILTER_SANITIZE_URL)))
); //PHP bug #51192
-
if (!$is_url) {
- $value = '';
+ continue;
}
- } elseif (!is_bool($value)) {
- $value = true;
+ } else {
+ $value['url'] = null;
+ }
+
+ // Add a default name
+ if (empty($value['name'])) {
+ $value['name'] = $value['type'];
}
- $this->data['sharing'][$key] = $value;
+ $this->data['sharing'][] = $value;
}
}
public function _theme($value) {