Page 1 of 2

How do I let new users to automatically subscribe to the fee

Posted: 25 Jun 2013, 21:21
by msilvya
I just set up my tt-rss site and I've set ENABLE_REGISTRATION to true in config.php. But when new users register, they are subscribed to the default Tiny Tiny RSS: Forum and Tiny Tiny RSS: New Release feeds by default and not the RSS feeds that I have created as an administrator.

I was just wondering if there's a setting/way that would allow newly registered users to be automatically subscribed to the Feeds that I have set up as an administrator of my tt-rss site?

And thank you for making tt-rss. Now nobody can tell me again to move my feeds. Take that Google! :evil:

Re: How do I let new users to automatically subscribe to the

Posted: 25 Jun 2013, 21:34
by fox
There's no setting for that, you'll have to hack the code.

Re: How do I let new users to automatically subscribe to the

Posted: 25 Jun 2013, 21:40
by msilvya
Thanks for the quick reply.

I noticed /include/functions.php has the following lines:

Code: Select all

function initialize_user($uid) {

      db_query("insert into ttrss_feeds (owner_uid,title,feed_url)
         values ('$uid', 'Tiny Tiny RSS: New Releases',
         'http://tt-rss.org/releases.rss')");

      db_query("insert into ttrss_feeds (owner_uid,title,feed_url)
         values ('$uid', 'Tiny Tiny RSS: Forum',
            'http://tt-rss.org/forum/rss.php')");
   }


while ttrss_schema_mysql.sql has the following SQL insert queries.

Code: Select all

insert into ttrss_feeds (owner_uid, title, feed_url) values
   (1, 'Tiny Tiny RSS: New Releases', 'http://tt-rss.org/releases.rss');

insert into ttrss_feeds (owner_uid, title, feed_url) values
   (1, 'Tiny Tiny RSS: Forum', 'http://tt-rss.org/forum/rss.php');



Do I need to modify these?

Re: How do I let new users to automatically subscribe to the

Posted: 25 Jun 2013, 21:53
by fox
You only need to modify initialize_user(), schema stuff is for your default admin user only.

Re: How do I let new users to automatically subscribe to the

Posted: 25 Jun 2013, 22:08
by msilvya
Thanks again for replying, fox.
So, in functions.php I need change the initialize_user function and add feeds like the following?

Code: Select all

function initialize_user($uid) {

      db_query("insert into ttrss_feeds (owner_uid,title,feed_url)
         values ('$uid', '[b]My favorite feed 1[/b]',
         'http://tt-rss.org/Myfavoritefeed1.rss')");

      db_query("insert into ttrss_feeds (owner_uid,title,feed_url)
         values ('$uid', '[b]My favorite feed 2[/b]',
            'http://tt-rss.org/Myfavoritefeed2')");
   
      db_query("insert into ttrss_feeds (owner_uid,title,feed_url)
         values ('$uid', '[b]My favorite feed 3[/b]',
            'http://tt-rss.org/Myfavoritefeed3')");
   }

... and so on?

Re: How do I let new users to automatically subscribe to the

Posted: 25 Jun 2013, 22:13
by fox
Yes, don't use bbcode in SQL though.

Re: How do I let new users to automatically subscribe to the

Posted: 25 Jun 2013, 22:28
by msilvya
fox wrote:Yes, don't use bbcode in SQL though.

True. I used the BBCode in my previous comment to bold the codes but the editor here displayed it as a BBCode. :oops:

Anyway, I modified the function initialize_user($uid) as follows and registered as a new user, but again only the Tiny Tiny RSS: Forum and Tiny Tiny RSS: Releases are showing up and not the new feed. Any idea where I could be going wrong?

Code: Select all

function initialize_user($uid) {

      db_query("insert into ttrss_feeds (owner_uid,title,feed_url)
         values ('$uid', 'Tiny Tiny RSS: New Releases',
         'http://tt-rss.org/releases.rss')");

      db_query("insert into ttrss_feeds (owner_uid,title,feed_url)
         values ('$uid', 'Tiny Tiny RSS: Forum',
            'http://tt-rss.org/forum/rss.php')");
   
      db_query("insert into ttrss_feeds (owner_uid,title,feed_url)
         values ('$uid', 'My favorite feed 3',
            'http://MyFavoriteSite.org/Myfavoritefeed3')");
   }

Re: How do I let new users to automatically subscribe to the

Posted: 25 Jun 2013, 22:40
by fox
Look for SQL errors in the log. This should be the place where those feeds are entered, so I dunno what could be wrong.

Re: How do I let new users to automatically subscribe to the

Posted: 25 Jun 2013, 23:05
by msilvya
fox wrote:Look for SQL errors in the log. This should be the place where those feeds are entered, so I dunno what could be wrong.

I'm going to kick myself in the butt. I thought I was working on the remote functions.php file while the changes I had made was on a local file. :oops:

It works perfect - Thanks a lot for your help, fox!

Re: How do I let new users to automatically subscribe to the

Posted: 26 Jun 2013, 00:02
by AngryChris
Are you using an opcode cache like APC? And if you are using APC, do you have apc.stat=0 set in its configuration? If you do, then you may need to either clear your cache or bounce your webserver (if apc.stat is turned off, files are only cached the first time they are accessed, not when they change).

EDIT: Ignore this post. :P

Re: How do I let new users to automatically subscribe to the

Posted: 03 Jul 2013, 16:47
by msilvya
Digging this thread again as I'm stuck with assigning the default feeds to a set of categories.

What I mean is: Currently when a user signs up, all the default feeds are assigned to a category called Uncategorised - As I posted above, I have been able to achieve this.

BUT going beyond what I have achieved, Is there a way to assign the default set of feeds to a particular category with the categories also automatically created besides the feeds? For example, Category 1 and Category 2 are automatically created while Feeds 1, 2, 3, 4 are automatically assigned to the Category 1 and Category 2 the way I want it.

So, when a user registers to my ttrss site, the user sees the following set of default feeds I have created.

Category 1
Feed 1
Feed 2
..
Feed n

Category 2
Feed 3
Feed 4
..
Feed n

and so on?

Re: How do I let new users to automatically subscribe to the

Posted: 04 Jul 2013, 00:25
by sleeper_service
msilvya wrote:Digging this thread again as I'm stuck with assigning the default feeds to a set of categories.

What I mean is: Currently when a user signs up, all the default feeds are assigned to a category called Uncategorised - As I posted above, I have been able to achieve this.

BUT going beyond what I have achieved, Is there a way to assign the default set of feeds to a particular category with the categories also automatically created besides the feeds? For example, Category 1 and Category 2 are automatically created while Feeds 1, 2, 3, 4 are automatically assigned to the Category 1 and Category 2 the way I want it.

So, when a user registers to my ttrss site, the user sees the following set of default feeds I have created.

Category 1
Feed 1
Feed 2
..
Feed n

Category 2
Feed 3
Feed 4
..
Feed n

and so on?


check the table layout, there's a column for what category the feed's in. assign as needed. (I could go into more detail, but then I'd have to look up table and column names, and I'm not feeling that energetic at the moment, so I figure you can do it *grin*)

Re: How do I let new users to automatically subscribe to the

Posted: 04 Jul 2013, 01:06
by AngryChris
I'd start with looking at the add_feed_category() function in functions.php:

Code: Select all

        function add_feed_category($feed_cat, $parent_cat_id = false) {

                if (!$feed_cat) return false;

                db_query("BEGIN");

                if ($parent_cat_id) {
                        $parent_qpart = "parent_cat = '$parent_cat_id'";
                        $parent_insert = "'$parent_cat_id'";
                } else {
                        $parent_qpart = "parent_cat IS NULL";
                        $parent_insert = "NULL";
                }

                $feed_cat = mb_substr($feed_cat, 0, 250);

                $result = db_query(
                        "SELECT id FROM ttrss_feed_categories
                        WHERE $parent_qpart AND title = '$feed_cat' AND owner_uid = ".$_SESSION["uid"]);

                if (db_num_rows($result) == 0) {

                        $result = db_query(
                                "INSERT INTO ttrss_feed_categories (owner_uid,title,parent_cat)
                                VALUES ('".$_SESSION["uid"]."', '$feed_cat', $parent_insert)");

                        db_query("COMMIT");

                        return true;
                }

                return false;
        }

It looks like the relevant portion that would be safe to run for a brand new user is:

Code: Select all

                        $result = db_query(
                                "INSERT INTO ttrss_feed_categories (owner_uid,title,parent_cat)
                                VALUES ('".$_SESSION["uid"]."', '$feed_cat', $parent_insert)");

Incorporate this into your add user changes. It looks like by default, parent_cat is null.

Re: How do I let new users to automatically subscribe to the

Posted: 04 Jul 2013, 13:44
by msilvya
AngryChris wrote:It looks like the relevant portion that would be safe to run for a brand new user is:

Code: Select all

                        $result = db_query(
                                "INSERT INTO ttrss_feed_categories (owner_uid,title,parent_cat)
                                VALUES ('".$_SESSION["uid"]."', '$feed_cat', $parent_insert)");

Incorporate this into your add user changes. It looks like by default, parent_cat is null.

Thanks for replying Chris.

Does this mean that I add the following to function initialize_user($uid) {

Code: Select all

db_query("INSERT INTO ttrss_feed_categories (owner_uid,title,parent_cat)
VALUES ('$uid', 'some category', '1');


Sorry, I'm no programmer but trying my best to get this to work. :oops:

Re: How do I let new users to automatically subscribe to the

Posted: 04 Jul 2013, 13:48
by msilvya
sleeper_service wrote:check the table layout, there's a column for what category the feed's in. assign as needed. (I could go into more detail, but then I'd have to look up table and column names, and I'm not feeling that energetic at the moment, so I figure you can do it *grin*)


Thanks for replying sleeper. Can you please be energetic? I really need this done :D

Here's the table layout for Browse ttrss_feed_categories

id owner_uid title collapsed order_id parent_cat view_settings

While ttrss_feeds has the following layout.

id owner_uid title cat_id feed_url icon_url update_interval purge_interval last_updated last_error favicon_avg_color site_url auth_login auth_pass parent_feed private rtl_content hidden include_in_digest cache_images hide_images cache_content auth_pass_encrypted last_viewed last_update_started always_display_enclosures update_method order_id mark_unread_on_update update_on_checksum_change strip_images view_settings pubsub_state favicon_last_checked