aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Models/UserDAO.php22
-rw-r--r--app/SQL/install.sql.mysql.php9
-rw-r--r--app/SQL/install.sql.pgsql.php13
-rw-r--r--app/SQL/install.sql.sqlite.php10
-rw-r--r--app/install.php25
-rw-r--r--config.default.php10
6 files changed, 56 insertions, 33 deletions
diff --git a/app/Models/UserDAO.php b/app/Models/UserDAO.php
index e9d3a7329..0cf163bae 100644
--- a/app/Models/UserDAO.php
+++ b/app/Models/UserDAO.php
@@ -30,19 +30,17 @@ class FreshRSS_UserDAO extends Minz_ModelPdo {
}
}
if ($ok && $insertDefaultFeeds) {
- if (defined('SQL_INSERT_FEEDS')) { //E.g. MySQL
- $sql = sprintf(SQL_INSERT_FEEDS, $bd_prefix_user);
+ $default_feeds = FreshRSS_Context::$system_conf->default_feeds;
+ foreach ($default_feeds as $feed) {
+ $sql = sprintf(SQL_INSERT_FEED, $bd_prefix_user);
$stm = $userPDO->bd->prepare($sql);
- $ok &= $stm && $stm->execute();
- } else { //E.g. SQLite
- global $SQL_INSERT_FEEDS;
- if (is_array($SQL_INSERT_FEEDS)) {
- foreach ($SQL_INSERT_FEEDS as $instruction) {
- $sql = sprintf($instruction, $bd_prefix_user);
- $stm = $userPDO->bd->prepare($sql);
- $ok &= ($stm && $stm->execute());
- }
- }
+ $parameters = array(
+ ':url' => $feed['url'],
+ ':name' => $feed['name'],
+ ':website' => $feed['website'],
+ ':description' => $feed['description'],
+ );
+ $ok &= ($stm && $stm->execute($parameters));
}
}
} catch (Exception $e) {
diff --git a/app/SQL/install.sql.mysql.php b/app/SQL/install.sql.mysql.php
index b3353ac95..0f396f701 100644
--- a/app/SQL/install.sql.mysql.php
+++ b/app/SQL/install.sql.mysql.php
@@ -109,10 +109,11 @@ CREATE TABLE IF NOT EXISTS `%1$sentrytag` ( -- v1.12
ENGINE = INNODB;
');
-define('SQL_INSERT_FEEDS', '
-INSERT IGNORE INTO `%1$sfeed` (url, category, name, website, description, ttl) VALUES("https://freshrss.org/feeds/all.atom.xml", 1, "FreshRSS.org", "https://freshrss.org/", "FreshRSS, a free, self-hostable aggregator…", 86400);
-INSERT IGNORE INTO `%1$sfeed` (url, category, name, website, description, ttl) VALUES("https://github.com/FreshRSS/FreshRSS/releases.atom", 1, "FreshRSS @ GitHub", "https://github.com/FreshRSS/FreshRSS/", "FreshRSS releases @ GitHub", 86400);
-');
+define(
+ 'SQL_INSERT_FEED',
+ 'INSERT IGNORE INTO `%1$sfeed` (url, category, name, website, description, ttl)
+ VALUES(:url, 1, :name, :website, :description, 86400);'
+);
define('SQL_DROP_TABLES', 'DROP TABLE IF EXISTS `%1$sentrytag`, `%1$stag`, `%1$sentrytmp`, `%1$sentry`, `%1$sfeed`, `%1$scategory`');
diff --git a/app/SQL/install.sql.pgsql.php b/app/SQL/install.sql.pgsql.php
index e68e6f3be..ef08ca940 100644
--- a/app/SQL/install.sql.pgsql.php
+++ b/app/SQL/install.sql.pgsql.php
@@ -99,14 +99,11 @@ $SQL_CREATE_TABLE_TAGS = array(
'CREATE INDEX "%1$sentrytag_id_entry_index" ON "%1$sentrytag" ("id_entry");',
);
-global $SQL_INSERT_FEEDS;
-$SQL_INSERT_FEEDS = array(
-'INSERT INTO "%1$sfeed" (url, category, name, website, description, ttl)
- SELECT \'https://freshrss.org/feeds/all.atom.xml\', 1, \'FreshRSS.org\', \'https://freshrss.org/\', \'FreshRSS, a free, self-hostable aggregator…\', 86400
- WHERE NOT EXISTS (SELECT id FROM "%1$sfeed" WHERE url = \'https://freshrss.org/feeds/all.atom.xml\');',
-'INSERT INTO "%1$sfeed" (url, category, name, website, description, ttl)
- SELECT \'https://github.com/FreshRSS/FreshRSS/releases.atom\', 1, \'FreshRSS @ GitHub\', \'https://github.com/FreshRSS/FreshRSS/\', \'FreshRSS releases @ GitHub\', 86400
- WHERE NOT EXISTS (SELECT id FROM "%1$sfeed" WHERE url = \'https://github.com/FreshRSS/FreshRSS/releases.atom\');',
+define(
+ 'SQL_INSERT_FEED',
+ 'INSERT INTO "%1$sfeed" (url, category, name, website, description, ttl)
+ SELECT :url::VARCHAR, 1, :name, :website, :description, 86400
+ WHERE NOT EXISTS (SELECT id FROM "%1$sfeed" WHERE url = :url);'
);
define('SQL_DROP_TABLES', 'DROP TABLE IF EXISTS "%1$sentrytag", "%1$stag", "%1$sentrytmp", "%1$sentry", "%1$sfeed", "%1$scategory"');
diff --git a/app/SQL/install.sql.sqlite.php b/app/SQL/install.sql.sqlite.php
index 1dd5f2647..d1dbfc192 100644
--- a/app/SQL/install.sql.sqlite.php
+++ b/app/SQL/install.sql.sqlite.php
@@ -99,12 +99,10 @@ $SQL_CREATE_TABLE_TAGS = array(
'CREATE INDEX entrytag_id_entry_index ON `entrytag` (`id_entry`);',
);
-global $SQL_INSERT_FEEDS;
-$SQL_INSERT_FEEDS = array(
-'INSERT OR IGNORE INTO `feed` (url, category, name, website, description, ttl)
- VALUES ("https://freshrss.org/feeds/all.atom.xml", 1, "FreshRSS.org", "https://freshrss.org/", "FreshRSS, a free, self-hostable aggregator…", 86400);',
-'INSERT OR IGNORE INTO `feed` (url, category, name, website, description, ttl)
- VALUES ("https://github.com/FreshRSS/FreshRSS/releases.atom", 1, "FreshRSS releases", "https://github.com/FreshRSS/FreshRSS/", "FreshRSS releases @ GitHub", 86400);',
+define(
+ 'SQL_INSERT_FEED',
+ 'INSERT OR IGNORE INTO `feed` (url, category, name, website, description, ttl)
+ VALUES(:url, 1, :name, :website, :description, 86400);'
);
define('SQL_DROP_TABLES', 'DROP TABLE IF EXISTS `entrytag`, `tag`, `entrytmp`, `entry`, `feed`, `category`');
diff --git a/app/install.php b/app/install.php
index a4d1d0af9..a92394d2a 100644
--- a/app/install.php
+++ b/app/install.php
@@ -346,13 +346,13 @@ function checkDbUser(&$dbOptions) {
try {
$c = new PDO($str, $dbOptions['user'], $dbOptions['password'], $driver_options);
if (defined('SQL_CREATE_TABLES')) {
- $sql = sprintf(SQL_CREATE_TABLES . SQL_CREATE_TABLE_ENTRYTMP . SQL_CREATE_TABLE_TAGS . SQL_INSERT_FEEDS,
+ $sql = sprintf(SQL_CREATE_TABLES . SQL_CREATE_TABLE_ENTRYTMP . SQL_CREATE_TABLE_TAGS,
$dbOptions['prefix_user'], _t('gen.short.default_category'));
$stm = $c->prepare($sql);
$ok = $stm && $stm->execute();
} else {
- global $SQL_CREATE_TABLES, $SQL_CREATE_TABLE_ENTRYTMP, $SQL_CREATE_TABLE_TAGS, $SQL_INSERT_FEEDS;
- $instructions = array_merge($SQL_CREATE_TABLES, $SQL_CREATE_TABLE_ENTRYTMP, $SQL_CREATE_TABLE_TAGS, $SQL_INSERT_FEEDS);
+ global $SQL_CREATE_TABLES, $SQL_CREATE_TABLE_ENTRYTMP, $SQL_CREATE_TABLE_TAGS;
+ $instructions = array_merge($SQL_CREATE_TABLES, $SQL_CREATE_TABLE_ENTRYTMP, $SQL_CREATE_TABLE_TAGS);
$ok = !empty($instructions);
foreach ($instructions as $instruction) {
$sql = sprintf($instruction, $dbOptions['prefix_user'], _t('gen.short.default_category'));
@@ -360,6 +360,25 @@ function checkDbUser(&$dbOptions) {
$ok &= $stm && $stm->execute();
}
}
+
+ Minz_Configuration::register(
+ 'system',
+ join_path(DATA_PATH, 'config.php'),
+ join_path(FRESHRSS_PATH, 'config.default.php')
+ );
+ $system_conf = Minz_Configuration::get('system');
+ $default_feeds = $system_conf->default_feeds;
+ foreach ($default_feeds as $feed) {
+ $sql = sprintf(SQL_INSERT_FEED, $dbOptions['prefix_user']);
+ $stm = $c->prepare($sql);
+ $parameters = array(
+ ':url' => $feed['url'],
+ ':name' => $feed['name'],
+ ':website' => $feed['website'],
+ ':description' => $feed['description'],
+ );
+ $ok &= ($stm && $stm->execute($parameters));
+ }
} catch (PDOException $e) {
$ok = false;
$dbOptions['error'] = $e->getMessage();
diff --git a/config.default.php b/config.default.php
index 9d74940c1..a38a9372a 100644
--- a/config.default.php
+++ b/config.default.php
@@ -151,6 +151,16 @@ return array(
),
+ # Configure the default feeds to which users will automatically be subscribed.
+ 'default_feeds' => array(
+ array(
+ 'url' => 'https://github.com/FreshRSS/FreshRSS/releases.atom',
+ 'name' => 'FreshRSS releases',
+ 'website' => 'https://github.com/FreshRSS/FreshRSS/',
+ 'description' => 'FreshRSS releases @ GitHub',
+ ),
+ ),
+
# Configuration to send emails. Be aware that PHP < 5.5 are not supported.
# These options are basically a mapping of the PHPMailer class attributes
# from the PHPMailer library.